Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] transactions trie witness generation after 4844 and OP stack support #34

Merged
merged 2 commits into from
Mar 18, 2024

Conversation

jonathanpwang
Copy link
Contributor

No ZK circuit code was changed.

To generate witness transaction MPT proofs, we reconstruct the transactions trie of a block from the raw transactions returns by a JSON-RPC call for a block. To construct the trie, we must compute the RLP encoding of each raw transaction. Previously, we used ethers_core to do this. However ethers_core has not been updated after EIP 4844 (Dencun) for the new Type 3 Blob Transaction.

The longer term plan is to switch to using alloy_rpc_types. However there is currently no RLP implementation for transaction and receipts in alloy (they are in reth-primitives, but the types are incompatible). Therefore short term it is simpler to continue using ethers_core but patch the implementations as we do here.

  • We have also added RLP support for OP stack deposit transactions and receipts.
  • Moved some of the trie code from axiom-query to axiom-eth to remove redundancy.

References:

* fix: transaction trie needs tx rlp to support 4844

No ZK circuit code was changed.

To generate witness transaction MPT proofs, we reconstruct the
transactions trie of a block from the raw transactions returns by a
JSON-RPC call for a block. To construct the trie, we must compute the
RLP encoding of each raw transaction. Previously, we used `ethers_core`
to do this. However `ethers_core` has not been updated after EIP 4844
(Dencun) for the new Type 3 Blob Transaction.

At first I tried to use `reth`'s transaction RLP encoding logic. However
`reth` uses an internal type to represent transactions. Since we get
transactions from RPC calls, we need an adapter from the RPC type. This
latter type is provided in `alloy_rpc_types`, but in writing the
converter from RPC type to reth primitive type, I ran into issues that
many structs were defined in parallel in the two crates, and also there
was inconsistency in the use of `ruint` primitives. I decided it was
easier just to keep `ethers_core` types for now and add custom
implementations of RLP for the new transaction type.

Also added RLP support for OP stack deposit transactions.

Moved some of the trie code from `axiom-query` to `axiom-eth` to remove
redundancy.

References:
- https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4844.md
- https://github.com/paradigmxyz/reth/blob/28f3a2e2d9525bf2f6373e755e2d6dc0c2f97821/crates/primitives/src/transaction/mod.rs#L128
- https://github.com/alloy-rs/alloy/blob/d5967abdbae58dd84acc4c1ee31345108d42d041/crates/rpc-types/src/eth/transaction/mod.rs

* feat: switch to `ethers` v2.0.14 so `OtherField` and "optimism" are
compatible

* chore: storageProof key is now U256 instead of H256

* chore: add rpc tests
@jonathanpwang jonathanpwang merged commit 9dda66d into main Mar 18, 2024
2 checks passed
@jonathanpwang jonathanpwang deleted the fix/tx_trie_4844_and_op branch March 18, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant