hyperledger / besu

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu
https://www.hyperledger.org/projects/besu
Apache License 2.0
1.47k stars 799 forks source link

Extend Tracing for zk EVMs #7301

Open daniellehrner opened 1 month ago

daniellehrner commented 1 month ago

Description

Currently the tracing does not provide all the necessary information necessary to create zk-proofs for the transaction executing. Specifically the following two cases are currently not covered by tracing:

Open questions:

OlivierBBB commented 1 month ago

Which data should be provided by the tracer. Is the MessageFrame enough?

We will need

Note. The world state may be available through messageFrame.getWorldUpdater() though I'm not really clear on whether the updater only contains the relevant (currently valid) state deltas associated with the current state of the execution or if it contains the whole (currently valid) updated state.

WRT the hooks

We've implemented a rollbackDefer mechanism that allows us to schedule actions now for later execution (and modifying the relevant trace section). What we haven't done is to connect it to a Besu hook so far. Ideally I would like to request some time from someone on the Besu team to go over the existing hooks. In particular any hook that activates at context "re-entry" such as traceContextReEntry to see if that hook already fulfils the requirements (all changes that may be rolled back were already rolled back.) And similarly for hooks triggering just before exiting a context (traceContextExit).

I'll add a quote from issue #816

The TraceRollback hook should be triggered on rollbacks at the precise point in time when Besu finishes the rollback (in particular of the state (balances, nonces, storage ...) and accrued state variables such as address/storage warmth ...) and before any potential new opcode is acted upon in the parent context. For the root context, Besu hook should be triggered also at transaction end in case it exits with status code 0, similarly: when all rollbacks were acted upon, though before gas/value reimbursement to the sender/recipient and coinbase reward. These "transaction finalization" actions are a separate thing and this hook should appear before them.