ethstorage / es-node

Golang implementation of the EthStorage node.
Other
1.15k stars 77 forks source link

Mining error: execution reverted: StorageContract: diff not match #304

Closed qzhodl closed 17 hours ago

qzhodl commented 3 months ago

System information

Build date: Jul 3 2024 System version: e.g. amd64/linux Golang version: e.g. go1.21 Commit hash : 053b1b0e6cd152f874b3eb07e474c94943c402ab

Expected behaviour

Mining success

Actual behaviour

4981720001105_ pic

Steps to reproduce the behaviour

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

syntrust commented 2 months ago

The same issue is discovered with the contract on L2: https://github.com/ethstorage/es-node/issues/314

A possible cause is that another submission updated the difficulty/lastMinedTime in the contract after the current node retrieved mining info, but before its mining tx is executed.

syntrust commented 1 month ago

Fixed in https://github.com/ethstorage/es-node/pull/315

ping-ke commented 1 week ago

Integration tests still fail with this error (diff not match).

 https://github.com/ethstorage/es-node/actions/runs/11200265994/job/31133678610.
 https://github.com/ethstorage/es-node/actions/runs/11158402497/job/31014607228

1728352874009 log: es-node-it.log image

syntrust commented 1 week ago

As commented above, this error could happen when the difficulty has been changed after a mining task starts and before it is submitted. The following logs are picked up from the attachment in which all the events happened within 1 minute, demonstrating that the difficulty of shard 0 has changed from 1,834,471 to 1,891,798 while the miner prepares its transaction: notice that "Generate zk proof done" takes 78.249 seconds.

t=2024-10-07T08:09:19+0000 lvl=info msg="Mining info retrieved"                 shard=0 lastMineTime=1,728,288,360 difficulty=1,834,471 proofsSubmitted=6
...
t=2024-10-07T08:09:44+0000 lvl=info msg="Mining info retrieved"                 shard=0 lastMineTime=1,728,288,396 difficulty=1,891,798 proofsSubmitted=7
...
t=2024-10-07T08:09:51+0000 lvl=info msg="Generate zk proof done"                sampleIdx="[1632 2819]" timeUsed(s)=78.249
t=2024-10-07T08:09:51+0000 lvl=info msg="Got storage proof"                     shard=0 block=6,831,012 kvIdx="[5891 6129]"   sampleIdxsInKv="[1632 2819]"
...
t=2024-10-07T08:09:51+0000 lvl=eror msg="Estimate gas failed"                   error="execution reverted: StorageContract: diff not match"

It is an edge case that happens only when the mining transactions are submitted too frequently on the same shard. For example, there are 7 attempts to submit mining tx in less than half a minute from 08:09:28 to 08:09:51 according to the log.

syntrust commented 17 hours ago

Resolved as https://github.com/ethstorage/storage-contracts-v1/pull/113 lower the frequency of mining txs.