-
Notifications
You must be signed in to change notification settings - Fork 586
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
Add check that wasm contract only modifies code hash in migrateContract API #5037
Add check that wasm contract only modifies code hash in migrateContract API #5037
Conversation
…wasm-contract-only-modifies-code-hash-in-migratecontract-api
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.
Nice work, @chatton. I left a few comments after a first pass.
@@ -242,6 +249,65 @@ func (suite *TypesTestSuite) TestWasmSudo() { | |||
}, | |||
types.ErrWasmInvalidResponseData, | |||
}, | |||
{ | |||
"failure: invalid clientstate type", |
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.
Should we add similar tests in TestWasmMigrate
(except for the one that changes the code hash)?
…wasm-contract-only-modifies-code-hash-in-migratecontract-api
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.
Excellent, just left some additional tidy up comments.
LGTM! 🚀
…wasm-contract-only-modifies-code-hash-in-migratecontract-api
…wasm-contract-only-modifies-code-hash-in-migratecontract-api
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.
pushed a bit to add these checks to instantiate too, lgtm
…wasm-contract-only-modifies-code-hash-in-migratecontract-api
…wasm-contract-only-modifies-code-hash-in-migratecontract-api
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.
ACK updates
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.
Excellent work! I just left one comment re-raising one suggestion that @DimitrisJim had that I think makes sense. Happy to do it a follow-up PR.
// codehash should only be able to be modified during migration. | ||
if !bytes.Equal(codeHash, newClientState.CodeHash) { | ||
return result, errorsmod.Wrapf(ErrWasmInvalidContractModification, "expected code hash %s, got %s", hex.EncodeToString(codeHash), hex.EncodeToString(newClientState.CodeHash)) | ||
} |
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.
@DimitrisJim suggested to do this check also in wasmMigrate
and then it could be included in validatePostExecutionClientState
, just to make sure the the contract is not doing something we don't expect, even though we set the code hash in 08-wasm after calling wasmMigrate
.
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.
Yea, didn't push this now. I do agree would be nice to do but without real consequence. Open to pushing this afterwards.
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.
just one nit!
I am going to merge this now and tag later today beta.0. |
Description
closes: #5011
This PR adds checks that verify
Note: a lot of tests needed to be updated as we were using dummy bytes as clientState (which is no longer valid). These tests were updated to use valid
ClientState
bytes.Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.