Closed intoverflow closed 11 months ago
This PR is based on https://github.com/risc0/zeth/tree/rkhalil/op-derive. It might make more sense to submit this branch as a PR into that branch, then submit that branch as a PR into main. Let me know what you think.
We should also absolutely add an e2e test similar to block_cli_ethereum
for the derivation data now in the repo
We should also absolutely add an e2e test similar to
block_cli_ethereum
for the derivation data now in the repo
done
This PR builds on prior work by @Wollac and @hashcashier. It introduces a new tool:
op-derive
. This tool has two inputs:block_no
, an L2 block number (used as the initial "safe head")blocks
, a block count (indicating how many blocks should be derived)The tool begins by reading the system transaction from the initial safe head. This allows the tool to determine which L1 block it should begin reading from.
It then applies the L1 -> L2 derivation process for the specified sequence of L2 blocks (
block_no + 1
,block_no + 2
, ...,block_no + blocks
).Along the way, the tool verifies that each of the derived L2 blocks have the expected block number, parent block, and list of transactions.
This complements Zeth's existing
op-block
tool, which can prove that a given list of transactions generates a given block.Direct links:
The derive logic is defined in the library; the host and guest both use this same function. The function fetches data using the
BatcherDb
trait. In the guest, we use an in-memory implementation; on the host, we use an implementation that fetches data using RPC, and which also saves this data to an in-memory implementation that can be later passed to the guest ("preflight data fetching").Sample output
Starting from op block 110800000, we derive 10 blocks:
Semantically, this output means: if L2 block 110800000 and L1 block 18341377 both have the correct hash, then L2 block 110800001 with the indicated hash has the correct block number, parent block, and list of transactions.
Additionally, if L2 block 110800001 has the correct hash, then L2 block 110800002 with the indicated hash has the correct block number, parent block, and list of transactions.
(And so on, inductively.)
Testing
Tested with by deriving 10,000 blocks starting from 110800000: