Skip to content

Conversation

@fmoletta
Copy link
Contributor

@fmoletta fmoletta commented Jul 5, 2024

Motivation

Obtain world state from account info stored in db

Description

  • Implement storage root computation
  • Implement word state

Closes #44

@fmoletta fmoletta changed the title [WIP] feat: compute world state feat: compute world state Jul 8, 2024
@fmoletta fmoletta marked this pull request as ready for review July 8, 2024 16:43
@fmoletta fmoletta requested a review from a team as a code owner July 8, 2024 16:43
Comment on lines +17 to +21
fn encode_to_vec(&self) -> Vec<u8> {
let mut buf = Vec::new();
self.encode(&mut buf);
buf
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can have this as a standalone generic function:

/// Function for encoding a value to RLP.
/// For encoding the value into a buffer directly, use [`RLPEncode::encode`].
pub fn encode<T: RLPEncode>(value: T) -> Vec<u8> {
    let mut buf = Vec::new();
    value.encode(&mut buf);
    buf
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not have it as part of the trait? It is more legible and it is a common use case

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having it in the trait lets implementors override the default implementation. However, since it's for internal use this won't happen so let's leave it inside the trait.

Copy link
Collaborator

@MegaRedHand MegaRedHand left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@fmoletta fmoletta merged commit c63e1ad into main Jul 11, 2024
@fmoletta fmoletta deleted the compute-world-state branch July 11, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compute world state from plain account state

3 participants