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(root): drop sparse trie tx sender when state updates finished #14004

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

shekhirin
Copy link
Collaborator

If StateRootMessage::FinishedStateUpdates is received after the last StateRootMessage::ProofCalculated is processed, we never drop the sparse_trie_tx.

To fix that, we need to do the same checks for dropping the sender in StateRootMessage::FinishedStateUpdates, as we do in StateRootMessage::ProofCalculated.

@shekhirin shekhirin added C-bug An unexpected or incorrect behavior A-trie Related to Merkle Patricia Trie implementation labels Jan 27, 2025
@shekhirin shekhirin marked this pull request as ready for review January 27, 2025 14:01
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

why is this necessary?

not obvious why we need to do this, I assume because there is some internal wiring that will only close the channel if this sender is dropped, but unclear why the loop here doesn't just break naturally

@shekhirin
Copy link
Collaborator Author

@mattsse we can't just break the loop, because we're still waiting on the RootCalculated message to be received

StateRootMessage::RootCalculated { state_root, trie_updates, iterations } => {
trace!(target: "engine::root", "processing StateRootMessage::RootCalculated");
let total_time =
first_update_time.expect("first update time should be set").elapsed();
let time_from_last_update =
last_update_time.expect("last update time should be set").elapsed();
debug!(
target: "engine::root",
total_updates = updates_received,
total_proofs = proofs_processed,
roots_calculated = iterations,
?total_time,
?time_from_last_update,
"All proofs processed, ending calculation"
);
return Ok(StateRootComputeOutcome {
state_root: (state_root, trie_updates),
total_time,
time_from_last_update,
});
}
, and it will be only be sent once this loop exits
while let Ok(mut update) = update_rx.recv() {
and we send the result on the channel
let result = match run_sparse_trie(config, rx) {
Ok((state_root, trie_updates, iterations)) => {
StateRootMessage::RootCalculated { state_root, trie_updates, iterations }
}
Err(error) => StateRootMessage::RootCalculationError(error),
};

@shekhirin shekhirin requested a review from mattsse January 27, 2025 15:11
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

ah okay, I get this now

lgtm

@shekhirin shekhirin added this pull request to the merge queue Jan 27, 2025
Merged via the queue into main with commit 0fa79c6 Jan 27, 2025
44 checks passed
@shekhirin shekhirin deleted the alexey/state-root-task-drop-sender branch January 27, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants