-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat(engine): proof fetching on state update for StateRootTask #12458
Conversation
d0f48d5
to
fdb55e9
Compare
14ca9a0
to
da06971
Compare
c38de83
to
a8e0cf2
Compare
fdb55e9
to
5d2048f
Compare
a8e0cf2
to
6e0e20e
Compare
6e0e20e
to
3b04efb
Compare
@@ -237,6 +241,7 @@ impl From<ParallelStateRootError> for ProviderError { | |||
ParallelStateRootError::StorageRoot(StorageRootError::Database(error)) => { | |||
Self::Database(error) | |||
} | |||
ParallelStateRootError::Other(other) => Self::Database(DatabaseError::Other(other)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be casted to database error. out of scope for this PR, but we have to fix this at some point ^^
52e1366
to
2ffe7c8
Compare
|
||
pending_proofs.push_back(rx); | ||
|
||
state.extend(hashed_state_update); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this extends the state immediately and that's what is used to perform state root updates, but this might result in invalid cached trie nodes. not sure yet, but worth double checking @fgimenez
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is still relevant and should be solved by updating the state only when we finish calculating the proof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a few questions
crates/engine/tree/src/tree/root.rs
Outdated
rayon::spawn(move || { | ||
let result = calculate_state_root_from_proofs( | ||
view, | ||
&input_nodes_sorted, | ||
&input_state_sorted, | ||
multiproof, | ||
state, | ||
); | ||
let _ = tx.send(result); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this spawns a new rayon job that then also branches out via par_iter
all of this looks very IO heavy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, that's the case
f982fa2
to
1665120
Compare
let destroyed = account.is_selfdestructed(); | ||
hashed_state_update.accounts.insert( | ||
hashed_address, | ||
if destroyed || account.is_empty() { None } else { Some(account.info.into()) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
account can be destroyed and recreated, worth checking again if this line is correct
|
||
// TODO: replace with parallel proof | ||
let result = | ||
Proof::overlay_multiproof(provider.tx_ref(), input.as_ref().clone(), targets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this clone is expensive, we should find a way to get rid of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it happens inside the ParallelProof
anyway, but maybe we can avoid it altogether
reth/crates/trie/parallel/src/proof.rs
Lines 65 to 69 in e8d63e4
let trie_nodes_sorted = Arc::new(self.input.nodes.into_sorted()); | |
let hashed_state_sorted = Arc::new(self.input.state.into_sorted()); | |
// Extend prefix sets with targets | |
let mut prefix_sets = self.input.prefix_sets.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in parallel proof it only re-allocates. here it clones and re-allocates
)?); | ||
} | ||
|
||
let storage_root = next_root_from_proofs(storage_trie_nodes, |key: Nibbles| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
next_root_from_proofs
function served its purpose, but is not always correct (see #12859). let's integrate sparse trie and debug it instead
… ongoing proof calculations received
…e_root_from_proofs
Co-authored-by: Roman Krasiuk <[email protected]>
…ate with single channel
Co-authored-by: Alexey Shekhirin <[email protected]>
fbc22f5
to
344a9b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taking notes of outstanding comments. let's merge this PR and iterate in follow ups
Towards #12053
Requires #12378 #12467 #12510