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

Implement EXECUTE precompile #3865

Draft
wants to merge 30 commits into
base: master
Choose a base branch
from
Draft

Implement EXECUTE precompile #3865

wants to merge 30 commits into from

Conversation

acolytec3
Copy link
Contributor

@acolytec3 acolytec3 commented Feb 6, 2025

This is a proof-of-concept implementation of the simplest form of the EXECUTE precompile proposal, using transaction re-execution for verification of the L2 state transition.

The current design expects a trace as an SSZ encoded object that contains a set of transactions (formatted as eth_call transactions) and a witness taking the form of a binary merkle tree execution witness modeled largely on the Verkle Execution Witness but with simple merkle proofs instead of a Verkle proof.

As a short cut until proper blob referencing is implemented, the trace is stored as a simple bytestring in the EVM and referenced by the sha256 hash of the trace in its bytes serialized form.

Additional potential todos

  • Add support for multiple "state"/"VM" options as suggested by some in the original research thread. For our purposes this would be allowing the precompile caller to specify which state they want via providing a contract address that could be used by the precompile to determine which execution path to follow
  • Make the trace be fully stored in blobspace that is then accessed by the evm via either locating the blob in the local transaction pool or else even potentially retrieved from the CL

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.70%. Comparing base (d3e8e33) to head (87e399a).

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 76.95% <ø> (ø)
blockchain 83.81% <ø> (ø)
client ?
common 91.59% <100.00%> (+0.01%) ⬆️
devp2p 76.45% <ø> (ø)
evm ?
genesis 99.84% <ø> (ø)
mpt 61.02% <ø> (-0.21%) ⬇️
rlp 69.70% <ø> (ø)
statemanager 67.21% <ø> (ø)
tx 81.54% <ø> (ø)
util 79.36% <ø> (ø)
vm ?
wallet 84.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

for (const stem of accessedSuffixes.keys()) {
tree.root(parentStateRoot)
// Generate proofs for each stem from prestate root
const proof = await tree.createBinaryProof(hexToBytes(stem))
Copy link
Contributor

@g11tech g11tech Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do multiproof instead of per stem proof? (may be later i guess)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yes. We just don't have multiproofs implemented for binary trees yet. This is as rudimentary as it gets.

const BinaryTreeExecutionWitness = ssz.container({
stateDiff: ssz.list(1024, StateDiff), // List of state diffs
parentStateRoot: ssz.bytevector(32), // Parent state root as hex
proof: ssz.list(256, ProofEntry), // List of proof entries with stems and proof data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming these are super low test limits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, completely arbitrary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants