-
Notifications
You must be signed in to change notification settings - Fork 410
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
Reduce gas when using governance proposals to store wasm #761
Comments
I need to dive deeper but at a first look it seems stored compressed with the proposal: CLI: https://github.com/CosmWasm/wasmd/blob/master/x/wasm/client/cli/gov_tx.go#L29 then we validate only the length on the compressed data: |
I can confirm that the contract is stored compressed in the proposal we use the following to verify the contract checksum
However this still takes huge amount of gas to submit a proposal and even after it causes issues for voters, taking almost 1M gas to submit a vote see example. Not really sure if there could be a different way to submit proposals for storing code like would it be possible to submit the hash to governance for approval? and the contract can be uploaded with the regular store command. Not really familiar with the process of verifying and storing contracts but some wallets doesn't even let the user change the gas param (like Keplr Mobile) |
Thanks for that check. I took a brief look at the x/gov module and I don't see how we can somehow store the wasm outside of the contract using the normal submit proposal process. If someone else wants to dig into the cosmos-sdk and look for some hooks where we can split this in the normal gov process, please do provide that info. The ProposalContent interface doesn't give so much power as far as I can see. The only idea I can think of is a 2 step proposal:
|
I looked into this there is a The 2 steps would be nice but maybe adding a store deposit that is released when the proposal ends to prevent contracts from being uploaded and never removed. I also had the idea of submitting the hash only in the proposal assuming a contract build can be reproduced byte to byte, and then the contract can be uploaded with the regular store transaction where it would check if the hash has been previously approved. |
I make a proposal how we can handle this with a minor refactor here: #785 (comment) Happy for feedback |
wasm contracts tend to be 200-300kb which is large and expensive.
In order to reduce gas, we already zip the wasm on
wasmd tx wasm store
in order to reduce the tx size by 3x. We never write the wasm to the iavl tree, but to disk directly, where it is handled by Rust code later.However, I do not believe we perform these optimisations on
wasmd tx gov submit-proposal wasm-store
. We should check.Also, even if we reduce the tx size, I am almost certain that when we create the proposal, we store the unzipped wasm. Once we validate the syntax (in memory), we can continue to store the original zip data in the proposal (in the IAVL tree) and unzip it when processing a passed proposal before sending it to the Rust library.
Context: when testing this on osmosis, I got surprisingly high gas costs for creating this proposal and for depositing on it (which read and wrote the proposal)
The text was updated successfully, but these errors were encountered: