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: compute world state #122

Merged
merged 17 commits into from
Jul 11, 2024
Merged

feat: compute world state #122

merged 17 commits into from
Jul 11, 2024

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.

crates/storage/src/world_state.rs Outdated Show resolved Hide resolved
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
3 checks passed
@fmoletta fmoletta deleted the compute-world-state branch July 11, 2024 13:29
mpaulucci pushed a commit to mpaulucci/lambda_ethereum_rust that referenced this pull request Oct 16, 2024
**Motivation**

Obtain world state from account info stored in db

**Description**

* Implement storage root computation
* Implement word state

<!-- Link to issues: Resolves lambdaclass#111, Resolves lambdaclass#222 -->

Closes lambdaclass#44
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
2 participants