Skip to content

refactor(l1,l2): extract duplicate witness generation logic to helper#5905

Open
Itodo-S wants to merge 6 commits intolambdaclass:mainfrom
Itodo-S:refactor/deduplicate-witness-generation
Open

refactor(l1,l2): extract duplicate witness generation logic to helper#5905
Itodo-S wants to merge 6 commits intolambdaclass:mainfrom
Itodo-S:refactor/deduplicate-witness-generation

Conversation

@Itodo-S
Copy link

@Itodo-S Itodo-S commented Jan 19, 2026

Motivation

Both functions shared a significant amount of identical code for reconstructing partial tries and fetching block headers. This refactor reduces maintenance burden and improves code readability.

Description

Extracted the duplicated witness generation logic from [generate_witness_for_blocks_with_fee_configs] and [generate_witness_from_account_updates] into a new helper function [construct_execution_witness]

Changes

  • Created [construct_execution_witness] helper function in [crates/blockchain/blockchain.rs]
  • Updated [generate_witness_for_blocks_with_fee_configs] and [generate_witness_from_account_updates] to use the helper.

Verification

  • Ran cargo test -p ethrex-blockchain to ensure no regressions were introduced.
  • All tests passed.

Closes #5708

@Itodo-S Itodo-S requested a review from a team as a code owner January 19, 2026 13:22
@Itodo-S Itodo-S requested a review from azteca1998 February 8, 2026 18:24
)
}

#[allow(clippy::too_many_arguments)]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 8 parameters is a lot. If more get added in the future, consider bundling some of these into a WitnessContext struct (e.g., first_block_header, last_block_header, witness_first_block_number, initial_state_root). Not necessary for this PR.

Copy link
Author

Choose a reason for hiding this comment

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

That's a great observation. noted

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.

3 participants