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

feat: Add option for returning TrieNodes instead of RLP encoded Bytes #14335

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

varun-doshi
Copy link
Contributor

Ref #14313

Closely related to #14312

@varun-doshi
Copy link
Contributor Author

@Rjected please correct me if im going about this wrong

@@ -229,7 +233,7 @@ impl ProofSequencer {

// return early if we don't have the next expected proof
if !self.pending_proofs.contains_key(&self.next_to_deliver) {
return Vec::new()
return Vec::new();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return Vec::new();
return Vec::new()

pls revert unrelated formatting changes. makes it hard to see the actual diff to review.

@emhane emhane requested a review from shekhirin February 8, 2025 17:59
@emhane emhane added C-perf A change motivated by improving speed, memory usage or disk footprint A-consensus Related to the consensus engine labels Feb 8, 2025
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

much easier to read thx

@@ -66,13 +67,16 @@ pub struct StateRootComputeOutcome {
/// A trie update that can be applied to sparse trie alongside the proofs for touched parts of the
/// state.
#[derive(Default, Debug)]
#[allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

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

this attribute shouldn't be needed

@@ -438,6 +443,25 @@ where
}
}

#[derive(Debug, Default)]
struct DecodedProofs {
#[allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[allow(dead_code)]

this attribute shouldn't be needed

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

directionally we need to add the multiproof structs that contain DecodedProofNodes first. Left some feedback, although heads up I may take this over early this week as it will soon be an urgent perf item

Comment on lines +445 to +461
#[derive(Debug, Default)]
struct DecodedProofs {
pub decoded_nodes: Vec<TrieNode>,
}

fn decode_proofs(multiproof: MultiProof) -> Result<DecodedProofs, SparseStateTrieError> {
let mut nodes: Vec<TrieNode> = vec![];
let account_subtree = multiproof.account_subtree.into_nodes_sorted();
let account_nodes = account_subtree.into_iter();

// Reveal the remaining proof nodes.
for (_path, bytes) in account_nodes {
let node = TrieNode::decode(&mut &bytes[..])?;
nodes.push(node);
}
Ok(DecodedProofs { decoded_nodes: nodes })
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this, let's just start by creating a struct like StorageMultiProof:

pub struct StorageMultiProof {

In trie-common, that uses alloy_trie::DecodedProofNodes instead of ProofNodes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Related to the consensus engine C-perf A change motivated by improving speed, memory usage or disk footprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants