Skip to content

Conversation

@purusang
Copy link
Contributor

@purusang purusang commented Nov 5, 2025

Description

It is a work heavily based on strata-proofimpl-evm-ee-stf/src/executor.rs::process_block() and used tons of help from Claude understanding the traits, process_block() function, evm data types, .... and to generate code.
Thanks!

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor
  • New or updated tests
  • Dependency Update

Notes to Reviewers

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added (where necessary) tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.
  • I have disclosed my use of AI
    in the body of this PR.

Related Issues

STR-1781

@purusang purusang requested review from MdTeach and delbonis November 5, 2025 16:40
@purusang purusang force-pushed the STR-1781-impl-evm-ee branch 2 times, most recently from ce3a83a to 3d10b00 Compare November 5, 2025 16:48
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Commit: 8057953

SP1 Execution Results

program cycles success
EVM EE STF 1,303,832
CL STF 211,071
Checkpoint 2,242

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 72.83825% with 267 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.78%. Comparing base (e2c9878) to head (fdf7d37).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/evm-ee/src/codec_shims.rs 56.20% 67 Missing ⚠️
crates/evm-ee/src/execution.rs 58.38% 62 Missing ⚠️
crates/evm-ee/src/types/partial_state.rs 54.88% 60 Missing ⚠️
crates/evm-ee/src/types/witness_db.rs 39.08% 53 Missing ⚠️
crates/evm-ee/src/types/block.rs 42.85% 8 Missing ⚠️
crates/evm-ee/src/types/write_batch.rs 85.71% 6 Missing ⚠️
crates/evm-ee/src/types/block_body.rs 92.98% 4 Missing ⚠️
crates/evm-ee/src/types/tests.rs 97.77% 3 Missing ⚠️
crates/reth/evm/src/utils.rs 90.32% 3 Missing ⚠️
crates/evm-ee/src/utils.rs 99.23% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1127      +/-   ##
==========================================
- Coverage   76.03%   75.78%   -0.26%     
==========================================
  Files         530      544      +14     
  Lines       44666    45682    +1016     
==========================================
+ Hits        33962    34619     +657     
- Misses      10704    11063     +359     
Flag Coverage Δ
functional 50.53% <75.75%> (-0.66%) ⬇️
unit 56.52% <71.51%> (+0.37%) ⬆️

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

Files with missing lines Coverage Δ
...rates/ee-acct-runtime/src/chain_segment_builder.rs 93.02% <ø> (ø)
crates/evm-ee/src/types/header.rs 100.00% <100.00%> (ø)
crates/proof-impl/evm-ee-stf/src/executor.rs 92.40% <100.00%> (-0.37%) ⬇️
crates/reth/node/src/payload_builder.rs 77.01% <100.00%> (-11.56%) ⬇️
crates/simple-ee/src/execution.rs 98.94% <100.00%> (+0.01%) ⬆️
crates/evm-ee/src/utils.rs 99.23% <99.23%> (ø)
crates/evm-ee/src/types/tests.rs 97.77% <97.77%> (ø)
crates/reth/evm/src/utils.rs 85.00% <90.32%> (-3.89%) ⬇️
crates/evm-ee/src/types/block_body.rs 92.98% <92.98%> (ø)
crates/evm-ee/src/types/write_batch.rs 85.71% <85.71%> (ø)
... and 5 more

... and 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@delbonis delbonis left a comment

Choose a reason for hiding this comment

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

There's a lot of work that's being done to manipulate the state in places that aren't quite ideal for it, should find ways to improve this.

@purusang purusang self-assigned this Nov 6, 2025
@purusang purusang force-pushed the STR-1781-impl-evm-ee branch 2 times, most recently from 7ebeb7e to b492ad0 Compare November 12, 2025 15:22
Copy link
Contributor

@delbonis delbonis left a comment

Choose a reason for hiding this comment

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

Better, I have some organizational questions though.

@purusang purusang force-pushed the STR-1781-impl-evm-ee branch from b492ad0 to 55b55bc Compare November 13, 2025 15:11
@purusang purusang marked this pull request as ready for review November 13, 2025 16:23
@purusang purusang requested review from a team as code owners November 13, 2025 16:23
@purusang purusang force-pushed the STR-1781-impl-evm-ee branch from 5e812df to 7e80db7 Compare November 24, 2025 19:16
delbonis
delbonis previously approved these changes Nov 25, 2025
Copy link
Contributor

@delbonis delbonis left a comment

Choose a reason for hiding this comment

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

not sure if that review comment is relevant right now or if we can defer it

make a note of it in any case

Implement ExecutionEnvironment trait for EVM block execution using
RSP's sparse state and Reth's execution engine.

Core components:
- EvmPartialState: Wraps EthereumState with witness data (bytecodes, ancestor_headers)
- EvmWriteBatch: Wraps HashedPostState for state diffs
- EvmBlock types: Header, Body, and complete Block with TransactionSigned
- EvmExecutionEnvironment: Full ExecutionEnvironment trait implementation

Trait methods:
- execute_block_body: Execute block and compute state changes
- complete_header: Combine intrinsics with computed commitments
- verify_outputs_against_header: Validate state root and logs bloom
- merge_write_into_state: Apply HashedPostState to EthereumState

Refs: STR-1781
Add test_with_witness_params that validates full execution flow:
- Loads real witness data from reference implementation
- Tests execute_block_body with actual block data
- Validates complete_header and verify_outputs_against_header

Refs: STR-1781
- Add utility functions (build_and_recover_block, accumulate_logs_bloom, etc.)
- Update module structure to expose utils module
- Implement Codec for EvmHeader, EvmBlockBody, EvmBlock, EvmPartialState, EvmWriteBatch
- Add encoding helpers (encode_rlp_with_length, encode_bytes_with_length) for consistency
- Reorganize types into module with comprehensive test suite
…sion

- Move EVM config creation to constructor for cleaner code structure
- Extract witness database preparation into EvmPartialState for better encapsulation
- Implement conversion logic for withdrawal intents to bridge messages
- Updated types
- Updated codec impl to work with this change
- refactored header chain validation logic
- other minor nits
- ChainSpec: use Arc::clone instead of dereferencing (2x per block)
- EthEvmConfig: pass by reference instead of cloning
- Headers: use seal_ref_slow() to avoid cloning N+1 headers
- BundleState/receipts/requests: take ownership instead of cloning (3x per block)
- Block construction: remove redundant header clone
- Move accumulate_logs_bloom to alpen-reth-evm
- Simplify compute_hashed_post_state
- Refactor withdrawal intent message conversion
- Use .clone() style instead of Arc::clone
- Move use statement to top of file in check_header_matches_body
- Use impl_type_flat_struct macro for EvmBlock codec
- Rename withdrawal_intents to extract_withdrawal_intents
- Add panic documentation to extract_withdrawal_intents
- Serialize pre-computed hashes for headers and bytecodes to avoid rehashing inside zkVM
- Add lazy hash caching in WitnessDB for addresses and storage keys
- Implement custom DatabaseRef for WitnessDB with zero-copy references

TODO: remove bincode serialization for EthereumState
Remove `complete_header` from `ExecutionEnvironment` and move to new
`BlockAssembler` trait. Proof path only verifies blocks, doesn't build
them. Block assembly still needed for test infrastructure.

- Remove `complete_header` from `ExecutionEnvironment` trait
- Add `BlockAssembler` trait for block assembly operations
- Implement for EVM and Simple execution environments
- Validate deposits from BlockInputs against block withdrawals field
- Add conversion helpers for SubjectId to Address and satoshis to gwei
…lementations

- Remove bincode dependency, replace with rlp crate
- Implement deterministic encoding for EthereumState using RLP and sorted iteration
- Implement deterministic encoding for HashedPostState with sorted HashMap entries
- Add custom codec functions in codec_shims module for external types
@purusang purusang force-pushed the STR-1781-impl-evm-ee branch from 6bdd7b9 to 00a9395 Compare November 26, 2025 04:49
Comment on lines 53 to 61
// Encode withdrawal intent data: descriptor bytes + txid
let mut msg_data = Vec::new();
msg_data.extend_from_slice(&intent.destination.to_bytes());
msg_data.extend_from_slice(&intent.withdrawal_txid.0);

let bridge_gateway_account = AccountId::from(BRIDGE_GATEWAY_ACCOUNT);

// Create message to bridge gateway with withdrawal amount and intent data
let payload = MsgPayload::new(BitcoinAmount::from_sat(intent.amt), msg_data);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use this message data to construct the message.

}
}

impl Codec for EvmPartialState {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably should have fuzzing/proptesting on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@delbonis I have created a ticket for it to unblock other tasks as proptesting it with EthereumState became a bit complicated.

@sapinb sapinb mentioned this pull request Nov 28, 2025
14 tasks
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.

6 participants