Skip to content

refactor(ethexe/processor): split run module into submodules#5266

Closed
playX18 wants to merge 1 commit intomasterfrom
ap-split-run-module
Closed

refactor(ethexe/processor): split run module into submodules#5266
playX18 wants to merge 1 commit intomasterfrom
ap-split-run-module

Conversation

@playX18
Copy link
Copy Markdown
Member

@playX18 playX18 commented Mar 30, 2026

Resolves #5120

  • Split ethexe/processor/src/handling/run.rs into separate module
  • Create run/ directory with logical components:
    • mod.rs: Main execution loop, RunContext trait, CommonRunContext
    • chunks_splitting.rs: Chunk partitioning algorithm and data structures
    • chunk_execution_spawn.rs: Thread pool spawning and parallel execution
    • chunk_execution_processing.rs: Journal collection and processing

@gear-tech/dev

- Split ethexe/processor/src/handling/run.rs (1006 lines) into separate module
- Create run/ directory with logical components:
  - mod.rs: Main execution loop, RunContext trait, CommonRunContext
  - chunks_splitting.rs: Chunk partitioning algorithm and data structures
  - chunk_execution_spawn.rs: Thread pool spawning and parallel execution
  - chunk_execution_processing.rs: Journal collection and processing
- Update overlaid.rs imports to use re-exported types
- All 18 tests pass, no functional changes

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@playX18 playX18 requested review from breathx and grishasobol March 30, 2026 03:20
@playX18 playX18 self-assigned this Mar 30, 2026
@playX18 playX18 added A0-pleasereview PR is ready to be reviewed by the team D8-ethexe ethexe-related PR labels Mar 30, 2026
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Mar 30, 2026

@playX18 playX18 closed this Mar 30, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the processor's execution logic by decomposing a large module into smaller, focused submodules. This change improves code organization and readability by separating concerns related to chunk partitioning, parallel execution, and journal processing.

Highlights

  • Refactoring: Split the monolithic ethexe/processor/src/handling/run.rs file into a dedicated run/ directory with submodules for better maintainability.
  • Modularization: Introduced chunks_splitting.rs, chunk_execution_spawn.rs, and chunk_execution_processing.rs to encapsulate specific logical components of the execution loop.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the chunk execution logic by extracting submodules from ethexe/processor/src/handling/run/mod.rs into dedicated files: chunk_execution_processing.rs, chunk_execution_spawn.rs, and chunks_splitting.rs. The review feedback recommends using a more idiomatic functional approach with fold in collect_chunk_journals to avoid external mutability. Additionally, a suggestion was made to simplify a redundant module path for ExecutionChunks to improve code consistency.

Comment on lines +51 to +71
let mut max_gas_spent_in_chunk = 0u64;

let chunk_journals = chunk_outputs
.into_iter()
.map(
|(program_id, new_state_hash, program_journals, gas_spent)| {
// Handle state updates that occurred during journal processing within the runtime (allocations, pages).
// This should happen before processing the journal notes because `send_dispatch` from another program can modify the state.
ctx.inner_mut().transitions.modify(program_id, |state, _| {
state.hash = new_state_hash;
});

max_gas_spent_in_chunk = max_gas_spent_in_chunk.max(gas_spent);

(program_id, program_journals)
},
)
.collect();

(chunk_journals, max_gas_spent_in_chunk)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation uses map with side effects to update max_gas_spent_in_chunk and then collects the results. A more idiomatic and functional approach would be to use fold. This would eliminate the need for an external mutable variable and make the data transformation more self-contained and clearer.

    chunk_outputs
        .into_iter()
        .fold((Vec::new(), 0u64), |(mut journals, max_gas), (program_id, new_state_hash, program_journals, gas_spent)| {
            // Handle state updates that occurred during journal processing within the runtime (allocations, pages).
            // This should happen before processing the journal notes because `send_dispatch` from another program can modify the state.
            ctx.inner_mut().transitions.modify(program_id, |state, _| {
                state.hash = new_state_hash;
            });

            journals.push((program_id, program_journals));

            (journals, max_gas.max(gas_spent))
        })

fn handle_chunk_data(
&self,
execution_chunks: &mut ExecutionChunks,
execution_chunks: &mut chunks_splitting::ExecutionChunks,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with how ActorStateHashWithQueueSize is used in the next line, and to leverage the use statement on line 111, it's better to refer to ExecutionChunks directly without the module path. This improves readability and consistency within the module.

Suggested change
execution_chunks: &mut chunks_splitting::ExecutionChunks,
execution_chunks: &mut ExecutionChunks,

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

Labels

A0-pleasereview PR is ready to be reviewed by the team D8-ethexe ethexe-related PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ethexe: processor run split to several files and move to separate module

1 participant