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

fix(engine): wait for all state updates before returning state root task result #13156

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

fgimenez
Copy link
Member

@fgimenez fgimenez commented Dec 5, 2024

Depending on timing, the current condition for returning the state root from task can allow to return too early, when not all state updates have been processed https://github.com/paradigmxyz/reth/blob/main/crates/engine/tree/src/tree/root.rs#L437

These changes allow the state root task to detect when the sender in the state hook is dropped, so that no new state updates are expected. It should be used from the EngineApiTreeHandler like:

let state_hook_sender = root::StateHookSender { tx: state_root_tx.clone() };
let state_hook = move |state: &EvmState| {
    let _ = state_hook_sender.send(StateRootMessage::StateUpdate(state.clone()));
};       

@fgimenez fgimenez force-pushed the fgimenez/fix-srt-end-condition branch from cbfce48 to 9583148 Compare December 5, 2024 14:12
@fgimenez fgimenez changed the title fix(engine): allow state hook consumers to signal stream end fix(engine): wait for all tate updates before returning state root task result Dec 5, 2024
@shekhirin shekhirin changed the title fix(engine): wait for all tate updates before returning state root task result fix(engine): wait for all state updates before returning state root task result Dec 5, 2024
Copy link
Collaborator

@shekhirin shekhirin left a comment

Choose a reason for hiding this comment

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

LGTM. We can also make StateHookSender a thin wrapper over the Sender like pub(crate) struct StateHookSender(Sender<_>) with a Deref, but either works.

@fgimenez
Copy link
Member Author

fgimenez commented Dec 5, 2024

We can also make StateHookSender a thin wrapper over the Sender like pub(crate) struct StateHookSender(Sender<_>) with a Deref, but either works.

good point, done here a613633

@fgimenez fgimenez added this pull request to the merge queue Dec 5, 2024
Merged via the queue into main with commit eb4aa2c Dec 5, 2024
41 checks passed
@fgimenez fgimenez deleted the fgimenez/fix-srt-end-condition branch December 5, 2024 15:45
@fgimenez fgimenez added C-bug An unexpected or incorrect behavior A-engine Related to the engine implementation A-trie Related to Merkle Patricia Trie implementation labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-engine Related to the engine implementation A-trie Related to Merkle Patricia Trie implementation C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants