DA0-DA0 / polytone

An account on every blockchain for every smart contract.
42 stars 5 forks source link

Investigate cause of nondeterminism in gas usage #23

Open 0xekez opened 1 year ago

0xekez commented 1 year ago

To reproduce, change ACK_GAS_NEEDED to a low number in contracts/voice/ibc.rs, then run the test suite a couple times noticing that the gas_used error message has a different value on each failure. You can verify in the just simtest output that the contract hashes are the same.

This is relevant because we hand tune the ACK_GAS_NEEDED parameter. If gas_used is non-deterministic, can someone induce this non-determinism to move gas usage in a particular direction? We need to be sure that an attacker can't control this non-determinism and cause ACKs not to be returned.

0xekez commented 1 year ago

second paragraph of this discusses how gas is selected. experiment: check if gas usage non-determinism changes if the hardware changes.

0xekez commented 1 year ago

part of this work is to make wiki page describing updates to gas usage by x/gov and how to handle them.

Art3miX commented 1 year ago

check if gas usage non-determinism changes if the hardware changes.

Maybe create a test that just return average gas consumption over 100 msgs or so, and we can test it on different devices and return the results here

Art3miX commented 1 year ago

@0xekez out of gas in location: WritePerByte; gasWanted: 3000000, gasUsed: 3000250: out of gas

Can you test it on your end and make sure its passing on my branch for you? (just simtest)

Edit: Only happened once, without playing with any gas values.