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

chore(engine): simplify StateRootTask creation and hook management #13213

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

fgimenez
Copy link
Member

@fgimenez fgimenez commented Dec 7, 2024

Towards #12639

Moves StateRootTask's message channel and hook closure creation inside the type, making it easier to manage externally.

Before:

let (state_root_tx, state_root_rx) = std::sync::mpsc::channel();
let state_root_config = StateRootConfig { consistent_view, input: Arc::new(input) };
let state_root_task =
            StateRootTask::new(state_root_config, state_root_tx.clone(), state_root_rx);
let state_root_handle = state_root_task.spawn();
let state_hook_sender = StateHookSender::new(state_root_tx);
let state_hook = move |state: &EvmState| {
    let _ = state_hook_sender.send(StateRootMessage::StateUpdate(state.clone()));
};
let output = self.metrics.executor.execute_metered(
   executor,
   (&block, U256::MAX).into(),
   Box::new(state_hook),
)?;

After:

let state_root_config = StateRootConfig { consistent_view, input: Arc::new(input) };
let state_root_task =StateRootTask::new(state_root_config);
let state_hook = state_root_task.state_hook();
let state_root_handle = state_root_task.spawn();
let output = self.metrics.executor.execute_metered(
   executor,
   (&block, U256::MAX).into(),
   Box::new(state_hook),
)?;

@fgimenez fgimenez requested review from shekhirin and removed request for Rjected, mattsse and rkrasiuk December 7, 2024 16:54
@fgimenez fgimenez added C-enhancement New feature or request A-blockchain-tree Related to sidechains, reorgs and pending blocks labels Dec 7, 2024
@mattsse mattsse added this pull request to the merge queue Dec 9, 2024
Merged via the queue into main with commit f7a3476 Dec 9, 2024
42 checks passed
@mattsse mattsse deleted the fgimenez/srt-simplify-constructor-hook branch December 9, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-tree Related to sidechains, reorgs and pending blocks C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants