CosmWasm / wasmd

Basic cosmos-sdk app with web assembly smart contracts
Other
368 stars 402 forks source link

Question: can the `BlockGasMeter` be used for absolute tx position? #1950

Open joshklop opened 2 months ago

joshklop commented 2 months ago

The amount of consumed block gas is used here to uniquely identify the position of a transaction in a block.

Is it possible that a transaction could consume zero gas, leading to a collision (that tx and the tx that follows will have the same "absolute index")?

chipshort commented 1 month ago

In theory that is possible, but a zero gas transaction is inherently problematic, since it can be used for spamming and potentially a DoS, so transactions shouldn't be zero gas in the first place. Also, this is just used for metadata on the contract history, so it's not critical if this were to happen.

chipshort commented 1 month ago

Looks like a better method to get a transaction index was introduced at some point. Let's use this as an opportunity to explore switching the contract history over to that too.