Remediations for EIP-1283 reentrancy bug

For reference, there is a new proposal coming from @AlexeyAkhunov which I’m now promoting which is something in between option 5 and 3.

Already proposed here as number 6.

I admit I might have missed some responses in this thread, but critic found for 3/5 like options are:

I don’t believe the 4% gas cost increase in worst case matches with “seriously”.

I can try to add information how much gas in advance you need to provide in transaction to the spreadsheet. But so far “much more” is not very precise figure.


Also, would be nice to put #6 and #7 in the top comment.

What I meant by ‘seriously decreasing the impact’ is that the final gas cost is less important for scaling here than the gas limit of a transaction. If I want to execute 100 SSTOREs out of which 99 are just updating the single storage address I will need at least 21000 + 100 * 5000 gas now (gas limit of 521000), with the EIP 1283 it was meant to be 21000 + 5000 + 99 * 200 (gas limit of 45800). With the 2300 + 2100 refund the gas limit required would be 21000 + 5000 + 99 * 2300 (253700). Maybe we can test the transaction gas limit against the gas used - refund?

We cannot because this test is done before the transaction is executed.

I meant testing the remaining gas in the transaction - transaction limit vs currently used gas.

So if we are executing and having 100k gas used and 70k refund then even if tx gas limit is 51k it would still allow to continue execution.

That would be quite excessive change (considering the scope of this EIP) with a lot of security considerations needed.

See EIP-2200: Structured Definitions for Net Gas Metering by sorpaas · Pull Request #2200 · ethereum/EIPs · GitHub

If the 2300 gas is to guard against reentrancy following a transfer, then 1600 will also suffice as the underlying CALL will cost at least 700.

So in actual fact, we could do 21000 + 5000 + 99 * 1600 = 184400, which is at least better than 253700