-
Notifications
You must be signed in to change notification settings - Fork 411
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
Enable larger wasm bytecode upload for gov proposals #1095
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1095 +/- ##
==========================================
+ Coverage 59.79% 59.82% +0.02%
==========================================
Files 54 54
Lines 7273 7273
==========================================
+ Hits 4349 4351 +2
+ Misses 2612 2611 -1
+ Partials 312 311 -1
|
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.
Very nice!
One minor issue and some feedback on the max value for gov content would be great.
) | ||
|
||
func validateWasmCode(s []byte) error { | ||
func validateWasmCode(s []byte, maxSize int) 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.
good adoption of function!
x/wasm/types/validation.go
Outdated
@@ -13,14 +13,17 @@ var ( | |||
|
|||
// MaxWasmSize is the largest a compiled contract code can be when storing code on chain | |||
MaxWasmSize = 800 * 1024 // extension point for chains to customize via compile flag. | |||
|
|||
// MaxProposalWasmSize is the largest a gov proposal compiled contract code can be when storing code on chain | |||
MaxProposalWasmSize = 4 * 1024 * 1024 // extension point for chains to customize via compile flag. |
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.
Good to have this as a variable, too. I am not fully convinced that 4mb is a good value, given the spam case. 2mb feels a bit more conservative but it is also a random value
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.
gov proposals charge like 3x gas for the proposal size (than just raw tx size), but yes it is written to state
It is easy to get 1.5MB contracts, maybe 2.5MB or 3MB if you want to be a bit conservative but still allow more complexity (like a js interpreter)
Also, we could just charge extra gas for every byte above the base (800kb) level up to this hard cap, but that might be too confusing/complex
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 chains can override, we just need a reasonable default. I am fine with 3MB. Feel 2MB is a bit tight (I got a demo contract I could only trim to 1.8MB and could easily grow a bit if I added any features)
x/wasm/types/genesis.go
Outdated
@@ -47,7 +47,7 @@ func (c Code) ValidateBasic() error { | |||
if err := c.CodeInfo.ValidateBasic(); err != nil { | |||
return sdkerrors.Wrap(err, "code info") | |||
} | |||
if err := validateWasmCode(c.CodeBytes); err != nil { | |||
if err := validateWasmCode(c.CodeBytes, MaxWasmSize); err != nil { |
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 needs to be raised or an import fails for gov contracts
if err := validateWasmCode(c.CodeBytes, MaxWasmSize); err != nil { | |
if err := validateWasmCode(c.CodeBytes, MaxProposalWasmSize); err != nil { |
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.
👍 thanks for the updates 🏄
69ce1ac
to
af91fdb
Compare
Great. Thank you for this! |
* Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB
…proposal message (#1072) * Provide source, builder and codehash information in store code proposal message * Make linter happy * Update x/wasm/simulation/proposals.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * Update x/wasm/client/cli/gov_tx.go * Update x/wasm/client/cli/gov_tx.go * Bump github.com/cosmos/gogoproto from 1.4.2 to 1.4.3 Bumps [github.com/cosmos/gogoproto](https://github.com/cosmos/gogoproto) from 1.4.2 to 1.4.3. - [Release notes](https://github.com/cosmos/gogoproto/releases) - [Changelog](https://github.com/cosmos/gogoproto/blob/main/CHANGELOG.md) - [Commits](cosmos/gogoproto@v1.4.2...v1.4.3) --- updated-dependencies: - dependency-name: github.com/cosmos/gogoproto dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Update authz grant examples * Enable larger wasm bytecode upload for gov proposals (#1095) * Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB * Bump SDK to v0.45.11 * Fix license head * Fix README header * Bump version go to 1.19 (#1044) * bump go 1.19 * add change log * correct change log * Provide source, builder and codehash information in store code proposal message * Implement source, builder, code_info for StoreAndInstantiateProposal * Apply review recommendations * Make linter happy * Fix tests * Formatting only Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Giancarlos Salas <giansalex@gmail.com> Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> Co-authored-by: GNaD13 <89174180+GNaD13@users.noreply.github.com>
* Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB
…proposal message (CosmWasm#1072) * Provide source, builder and codehash information in store code proposal message * Make linter happy * Update x/wasm/simulation/proposals.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * Update x/wasm/client/cli/gov_tx.go * Update x/wasm/client/cli/gov_tx.go * Bump github.com/cosmos/gogoproto from 1.4.2 to 1.4.3 Bumps [github.com/cosmos/gogoproto](https://github.com/cosmos/gogoproto) from 1.4.2 to 1.4.3. - [Release notes](https://github.com/cosmos/gogoproto/releases) - [Changelog](https://github.com/cosmos/gogoproto/blob/main/CHANGELOG.md) - [Commits](cosmos/gogoproto@v1.4.2...v1.4.3) --- updated-dependencies: - dependency-name: github.com/cosmos/gogoproto dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Update authz grant examples * Enable larger wasm bytecode upload for gov proposals (CosmWasm#1095) * Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB * Bump SDK to v0.45.11 * Fix license head * Fix README header * Bump version go to 1.19 (CosmWasm#1044) * bump go 1.19 * add change log * correct change log * Provide source, builder and codehash information in store code proposal message * Implement source, builder, code_info for StoreAndInstantiateProposal * Apply review recommendations * Make linter happy * Fix tests * Formatting only Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Giancarlos Salas <giansalex@gmail.com> Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> Co-authored-by: GNaD13 <89174180+GNaD13@users.noreply.github.com>
* Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB
…proposal message (CosmWasm#1072) * Provide source, builder and codehash information in store code proposal message * Make linter happy * Update x/wasm/simulation/proposals.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * Update x/wasm/client/cli/gov_tx.go * Update x/wasm/client/cli/gov_tx.go * Bump github.com/cosmos/gogoproto from 1.4.2 to 1.4.3 Bumps [github.com/cosmos/gogoproto](https://github.com/cosmos/gogoproto) from 1.4.2 to 1.4.3. - [Release notes](https://github.com/cosmos/gogoproto/releases) - [Changelog](https://github.com/cosmos/gogoproto/blob/main/CHANGELOG.md) - [Commits](cosmos/gogoproto@v1.4.2...v1.4.3) --- updated-dependencies: - dependency-name: github.com/cosmos/gogoproto dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Update authz grant examples * Enable larger wasm bytecode upload for gov proposals (CosmWasm#1095) * Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB * Bump SDK to v0.45.11 * Fix license head * Fix README header * Bump version go to 1.19 (CosmWasm#1044) * bump go 1.19 * add change log * correct change log * Provide source, builder and codehash information in store code proposal message * Implement source, builder, code_info for StoreAndInstantiateProposal * Apply review recommendations * Make linter happy * Fix tests * Formatting only Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Giancarlos Salas <giansalex@gmail.com> Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> Co-authored-by: GNaD13 <89174180+GNaD13@users.noreply.github.com>
* Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB
…proposal message (CosmWasm#1072) * Provide source, builder and codehash information in store code proposal message * Make linter happy * Update x/wasm/simulation/proposals.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * Update x/wasm/client/cli/gov_tx.go * Update x/wasm/client/cli/gov_tx.go * Bump github.com/cosmos/gogoproto from 1.4.2 to 1.4.3 Bumps [github.com/cosmos/gogoproto](https://github.com/cosmos/gogoproto) from 1.4.2 to 1.4.3. - [Release notes](https://github.com/cosmos/gogoproto/releases) - [Changelog](https://github.com/cosmos/gogoproto/blob/main/CHANGELOG.md) - [Commits](cosmos/gogoproto@v1.4.2...v1.4.3) --- updated-dependencies: - dependency-name: github.com/cosmos/gogoproto dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Update authz grant examples * Enable larger wasm bytecode upload for gov proposals (CosmWasm#1095) * Enable larger wasm bytecode upload for gov proposals * Set max proposal wasm code size to 3MB * Bump SDK to v0.45.11 * Fix license head * Fix README header * Bump version go to 1.19 (CosmWasm#1044) * bump go 1.19 * add change log * correct change log * Provide source, builder and codehash information in store code proposal message * Implement source, builder, code_info for StoreAndInstantiateProposal * Apply review recommendations * Make linter happy * Fix tests * Formatting only Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Giancarlos Salas <giansalex@gmail.com> Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> Co-authored-by: GNaD13 <89174180+GNaD13@users.noreply.github.com>
Resolves #1038