Out of gas - 'gasWanted 25000000, gasUsed: 35609914'
xBalbinus opened this issue · 5 comments
ION Dao is seeking to deploy their contracts to testnet and mainnet but are encountering issues with the gas limits.
Replicate by (I created a test-proposal file that emulates current inputs already in the original repo):
git clone https://github.com/xBalbinus/ion-dao-contracts
beaker wasm build
beaker wasm proposal store-code --proposal proposal.yaml --signer-account test1 --network testnet ion_dao --gas 25000000uosmo --gas-limit 25000000
We are already using the optimizer here.
Do we know of any other quick contract gas optimization techniques, or if I need to delve in to try to manually minimize gas (the gas to deploy is quite a bit over the testnet / mainnet limit though, which is difficult)?
Is there any way to raise the hard cap of 25000000?
When trying to reproduce do you get this?
beaker wasm build
output:
Optimizing wasm...
Error: No such file or directory (os error 2)
I created #85 for this issue for now.
@xBalbinus I think this is an M1 related issue, could you please commit the artifacts
folder so that I can test.
Thanks!
Ok I was able to replicate now:
Error: deliver_tx failed: TxResult { code: Err(11), data: None, log: Log("out of gas in location: WritePerByte; gasWanted: 25000000, gasUsed: 35610007: out of gas"), info: Info(""), gas_wanted: Gas(25000000), gas_used: Gas(35610007), events: [Event { type_str: "coin_spent", attributes: [Tag { key: Key("spender"), value: Value("osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks") }, Tag { key: Key("amount"), value: Value("25000000uosmo") }] }, Event { type_str: "coin_received", attributes: [Tag { key: Key("receiver"), value: Value("osmo17xpfvakm2amg962yls6f84z3kell8c5lczssa0") }, Tag { key: Key("amount"), value: Value("25000000uosmo") }] }, Event { type_str: "transfer", attributes: [Tag { key: Key("recipient"), value: Value("osmo17xpfvakm2amg962yls6f84z3kell8c5lczssa0") }, Tag { key: Key("sender"), value: Value("osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks") }, Tag { key: Key("amount"), value: Value("25000000uosmo") }] }, Event { type_str: "message", attributes: [Tag { key: Key("sender"), value: Value("osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks") }] }, Event { type_str: "tx", attributes: [Tag { key: Key("fee"), value: Value("25000000uosmo") }] }, Event { type_str: "tx", attributes: [Tag { key: Key("acc_seq"), value: Value("osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks/192") }] }, Event { type_str: "tx", attributes: [Tag { key: Key("signature"), value: Value("9sx35FnMHeOYX5/x3IAMC0h8mTNYkPQGNrR3p8bIKSVbPirGzxj7OfNE/hlXjdBv1O3RS5tbcuCPy/8pTurebg==") }] }], codespace: Codespace("sdk") }
I modified the testnet node gas requirement, something we need to document and probably update in mainnet nodes as well.
Steps
- Login to our testnet node server
- nano ~/.osmosisd/config/app.toml
- change settings from:
max-gas-wanted-per-tx = "25000000"
tomax-gas-wanted-per-tx = "50000000"
- restart service
systemctl restart osmosisd.service
Try again
beaker wasm proposal store-code --proposal proposal.yaml --signer-account test1 --network testnet ion_dao --gas 30000000uosmo --gas-limit 50000000
❌ ERROR:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: response error
Caused by:
Internal error: timed out waiting for tx to be included in a block (code: -32603)
Location:
/Users/web/.cargo/registry/src/github.com-1ecc6299db9ec823/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9
Caused by:
0: response error
1: Internal error: timed out waiting for tx to be included in a block (code: -32603)
Location:
/Users/web/.cargo/registry/src/github.com-1ecc6299db9ec823/cosmrs-0.7.1/src/tx/raw.rs:34:12', /Users/web/.cargo/registry/src/github.com-1ecc6299db9ec823/beaker-0.0.7/src/support/cosmos.rs:246:77
if I run it again it will then give a different error message:
❌ ERROR:
Error: check_tx failed: TxResult { code: Err(32), data: None, log: Log("account sequence mismatch, expected 196, got 195: incorrect account sequence"), info: Info(""), gas_wanted: Gas(50000000), gas_used: Gas(4727780), events: [], codespace: Codespace("sdk") }
I tried again with the CLI and it worked:
osmosisd tx wasm store artifacts/ion_dao.wasm --from test --gas-prices 0.1uosmo --gas auto --gas-adjustment 1.3 -y --output json -b block
RIP this was what I was worried about in #53
What is this contract size for reference?
And yeah we are likely going to have to bump mainnet max gas per tx limits for this. Thankfully its just a mempool config, so we can ask one validator to change theirs and submit to their mempool.
ION_DAO.WASM 553Kb
Yes you called it. The context you provided in our call a few weeks ago was very useful.
Hoe do you calculate gas settings vs message size?