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

core/state: move slot RLP encoding into the MPT implementation #27000

Merged
merged 4 commits into from
Jun 1, 2023

Conversation

gballet
Copy link
Member

@gballet gballet commented Mar 28, 2023

Continuing with a series of PRs to make the Trie interface more generic, this PR moves the RLP encoding of storage slots inside the secure_trie and light.Trie implementations, as other types of tries don't use this.

This PR is still in draft, as the snapshot still uses RLP. While I think the snapshot should also get rid of RLP, this would cause a bunch of issues:

  • rlp encoding would have to be added to the snapsync code
  • an upgrade path needs to be devised

Until a solution has been found, this means the RLP decoding happens twice for a snapshot-enabled MPT client.

v, _ = rlp.EncodeToBytes(common.TrimLeftZeroes(value[:]))
if err := tr.UpdateStorage(s.address, key[:], v); err != nil {
v, _ = rlp.EncodeToBytes(trimmedVal)
if err := tr.UpdateStorage(s.address, key[:], trimmedVal); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change this to make it more obvious that v will be used for the snapshot later.

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, we could add a comment saying that.

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed it to snapshotVal and added a comment.

@gballet gballet force-pushed the bring-rlp-inside-trie-iface branch from 9c8a06b to d21aaf9 Compare May 8, 2023 13:25
@gballet gballet marked this pull request as ready for review May 11, 2023 08:08
@gballet
Copy link
Member Author

gballet commented May 25, 2023

Need to test on the benchmarkers before we revisit it

@gballet
Copy link
Member Author

gballet commented May 30, 2023

It has been running for a few days on bench07/08. No issue at first glance:

image

Slightly higher pressure on the GC:
image

@fjl fjl changed the title core/state, light, trie: move slot RLP encoding inside MPT implementation core/state: move slot RLP encoding into the MPT implementation Jun 1, 2023
@fjl fjl merged commit 45a3ab4 into ethereum:master Jun 1, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
…eum#27000)

Continuing with a series of PRs to make the Trie interface more generic, this PR moves
the RLP encoding of storage slots inside the StateTrie and light.Trie implementations,
as other types of tries don't use RLP.
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants