-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Protocol Upgrades #948
Conversation
@adshmh Could you help review this PR? |
aab0217
to
4291b3e
Compare
@0xBigBoss Before I dive into reviewing this PR, I noticed its still a draft and wanted to ask:
My goal is to avoid spending time reviewing documentation and code that will have major changes. |
Hey @Olshansk the part i am currently in the middle of is investigating the best place to perform the upgrades and writing the upgrade module. Nothing definitive yet for that. Not sure exactly this upgrade module would do now since any database migrations would have to be thought through carefully.
edit I think it'll be best to update the e2e tests in this PR after your statesync pr has been merged. |
4291b3e
to
c843e47
Compare
Adds servicer pk to validator1 docker compose deployment
7b337ed
to
6d1105c
Compare
6d1105c
to
2cd8bd8
Compare
Could I get a review on this? @adshmh @Olshansk so far the cli, rpc, consensus, utility and persistence modules have all been updated to include sending upgrade messages. Not all of the e2e tests will pass due to the error handling and not saving invalid transactions yet. Some things that I think we should track in #882 or a new issue:
|
@0xBigBoss Sorry for the delay. On my list for this week. Could you merge with main & resolve conflicts in the meantime? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Adding unit testing to utility unit of work is a key task IMO.
// DISCUSS(#310): define UX for return values - should we return the raw response or a parsed/human readable response? For now, I am simply printing to stdout | ||
|
||
if resp.StatusCode() != 200 { | ||
return fmt.Errorf("HTTP status code: %d\n", resp.StatusCode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything else in the response we can print? A single status code, e.g. 404 for a bad request, does not help the user understand why a request failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to my immediate knowledge. I haven't extensively reviewed our rpc error handling nor our openapi spec. In any case, this should be a new opened in a new issue with your requirements here https://github.com/pokt-network/pocket/blob/main/rpc/v1/openapi.yaml#L1
@@ -1,17 +1,8 @@ | |||
ARG GOLANG_IMAGE_VERSION=golang:1.20-alpine3.16 | |||
ARG GOLANG_IMAGE_VERSION=golang:1.20-bookworm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not against this change, but using a bare-minimum image like alpine and adding what we need to it is highly preferable to using a (potentially) bloated image that happens to have the packages we need preinstalled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh ur an infra guy too? yeah i made this change to have parity with the localnet since both were using debian. Alpine is great for prod, a bit tough on people in development.
In any case, what is ur action here and let's move it to a new issue as to not slow down protocol work.
build/Dockerfile.localdev
Outdated
@@ -25,3 +23,5 @@ RUN go install github.com/go-delve/delve/cmd/dlv@latest | |||
# Needed to make `go install dlv` and `dlv debug` work... | |||
RUN apk update && apk add --no-cache gcc musl-dev | |||
RUN go get github.com/go-delve/delve/cmd/dlv@latest | |||
|
|||
COPY . . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand the reason for this change. It is copying the same location, i.e. current directory. The previous commands should not change the current directory's contents AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step is redundant and unfortunately has cost a lot of us a lot of CPU time. The docker compose file from which this is referenced mounts the same directory as a volume into the container.
func (p *PostgresContext) SetUpgrade(signer, version string, height int64) error { | ||
ctx, tx := p.getCtxAndTx() | ||
_, err := tx.Exec(ctx, ` | ||
INSERT INTO upgrades(signer, version, height, created) VALUES ($1, $2, $3, $4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the importance of any upgrade rows, does it makes sense to verify if such a row already exists and return an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I included that in the schema,
pocket/persistence/types/gov.go
Lines 40 to 52 in 08d55bc
CREATE TABLE IF NOT EXISTS upgrades | |
( | |
signer text NOT NULL, | |
version varchar(10) NOT NULL, | |
height bigint NOT NULL UNIQUE, | |
created bigint NOT NULL UNIQUE, | |
PRIMARY KEY (version) | |
); | |
COMMENT ON TABLE upgrades IS 'stores the upgrade history of the network'; | |
COMMENT ON COLUMN upgrades.signer IS 'the address of the signer of the upgrade'; | |
COMMENT ON COLUMN upgrades.version IS 'the semver 2.0 version of the upgrade'; | |
COMMENT ON COLUMN upgrades.height IS 'the activation height of the upgrade'; | |
COMMENT ON COLUMN upgrades.created IS 'the height the upgrade was created'; |
|
||
// Preliminary filter to determine which functions we're interested in trying to call | ||
if !isModifierRe.MatchString(methodName) { | ||
continue | ||
} | ||
|
||
// IMPROVE: This is a hack to prevent the SetUpgrade function from being called more than once | ||
if methodName == "SetUpgrade" && count > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If SetUpgrade
returns an error if called twice with the same arguments (as suggested in the above comment), this would not be needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please review the purpose of this test
pocket/persistence/test/state_test.go
Lines 109 to 112 in 580dbfb
// This unit test generates random transactions and creates random state changes, but checks | |
// that replaying them will result in the same state hash, guaranteeing the integrity of the | |
// state hash. |
It's not intended to validate the inputs or crash.
@0xBigBoss Just a heads up that we're having an internal sprint to have the entire core team to focus on a specific aspect of Pocket v1, but will follow up afterwards. Will leave the review up as is for a couple of weeks. |
Description
This PR aims to implement #882. It includes so far cli, rpc, and persistence related changes. It is still incomplete according to #882.
This goal of this PR is give the ACL owner the ability to upgrade the protocol.
I am using this script so far to run the commands and develop locally, https://gist.github.com/0xBigBoss/d1a576d857f77dbe42292daa7a32bb2e.
Summary generated by Reviewpad on 09 Aug 23 15:48 UTC
This pull request introduces various changes across multiple files:
The file "validator.feature" has a change related to the scenario "User Wants Help Using The Validator Command". The command "Validator help" has been changed to "the user runs the command with no error "Validator help"".
In the file "persistence/trees/trees_test.go", the constant
treesHash1
has been updated.The diff in the file "Dockerfile.localdev" includes changes related to package installation and file copying.
The file "rpc/utils.go" has modifications related to handling the
MessageUpgrade
messageType and calculating the message fee.A new test case has been added in the file "e2e/steps_gov_test.go" to verify the behavior of importing and retrieving an ACL owner key.
The file "account.go" has error handling and logging enhancements in the
getAccountAmount
function.The file "benchmark_state_test.go" introduces changes related to benchmarking and modifying the persistence context in unit tests.
The file "openapi.yaml" includes changes in schema definitions and a TODO task for a future task.
The diff in the file "handlers.go" includes changes to the
PostV1ClientBroadcastTxSync
function, specifically returning a response with the transaction hash.The diff in the file "txmessage_error.go" includes changes related to error codes and error functions.
The diff in the file "defaults.go" includes changes in variable values related to upgrading a message fee.
The diff in the file "Dockerfile.localdev" includes changes related to package installation and file copying.
The diff in the file "message_upgrade_test.go" adds unit tests for the
MessageUpgrade
struct.The file "transaction.go" in the
utility/unit_of_work
directory includes changes in error handling and logging.In the file "e2e/README.md", there is a change in a scenario command.
The file "upgrades.go" introduces new constants and an update function.
The diff in the file "handlers.go" includes changes related to returning a transaction hash as part of the response.
The file "transaction_errors.go" includes changes related to constants, error functions, and updates to the package imports.
The file "defaults.go" includes changes in variables related to upgrading government parameters.
The changes in the file "Dockerfile.localdev" include updates to package installations and a code removal.
The diff in the file "message_upgrade_test.go" includes changes related to importing packages, added functions, and versions.
The file "upgrade.proto" introduces a new protobuf message called "Upgrade".
The file "block.go" indicates potential locations for pausing and state migrations.
Please review these changes and let me know if you need further assistance.
Issue
Fixes #882
Type of change
Please mark the relevant option(s):
List of changes
Testing
make develop_test
; if any code changes were mademake test_e2e
on k8s LocalNet; if any code changes were madee2e-devnet-test
passes tests on DevNet; if any code was changedRequired Checklist
godoc
format comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)