scroll-tech / go-ethereum

Scroll's fork of the official Go implementation of the Ethereum protocol
GNU Lesser General Public License v3.0
470 stars 271 forks source link

fix(traces): deletion proof apply wrong storage value from structLogger #838

Closed noel2004 closed 2 months ago

noel2004 commented 2 months ago

While tracing a tx, the deletion proof module would pick all updated storage slots from the UpdatedStorages of structLogger. The map being returned is expected to contain all the slots and its FINAL value. If the final value is 0, module consider it is an deletion and add a addtion trace for building the deletion proof.

However, the UpdatedStorages only record the value from SLOAD/SSTORE op and in the case of revert, the recorded value is unmatch with the final value. This PR make the final value directly from statedb instead of the record, so it fix the issue.

This fixing can be safely being picked into older version for patching.

Has test the new l2trace generated for block 6689419 and there is no panic any more

lispc commented 2 months ago

I think GetState will read value From in-memory cache? Never disk io?

noel2004 commented 2 months ago

I think GetState will read value From in-memory cache? Never disk io?

Yes. And that is just what we need (the final value). Also accessing in-memory cache has much less cost.