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, trie: track state change set with account address #27815

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Jul 31, 2023

This PR tracks state change set with account address instead of addrHash.

The benefits of this changes are:

  • address is shorter than address hash, can save 12 bytes for each account
  • address is human-readable

Although it will cause inconsistency, because storage slots are still identified by
slothash. The reason of using hash for slot is: when the entire storage is nuked,
slots has to be iterated from trie, and only slot hash is available there(it's a pain).

accountsOrigin map[common.Hash][]byte // The original value of mutated accounts in 'slim RLP' encoding
storagesOrigin map[common.Hash]map[common.Hash][]byte // The original value of mutated slots in prefix-zero trimmed rlp format
accounts map[common.Hash][]byte // The mutated accounts in 'slim RLP' encoding
storages map[common.Hash]map[common.Hash][]byte // The mutated slots in prefix-zero trimmed rlp format
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't accounts and storages also be changed in the same vein?

Copy link
Member Author

Choose a reason for hiding this comment

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

Accounts and storages are used by snapshot. Unfortunately, in snapshot, everything is identified by hash.

technically, it's possible to covert from map[common.Address][]byte to map[common.Hash][]byte inside of snapshot. But i feel it's unworthwhile.

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

SGTM

@karalabe karalabe added this to the 1.12.1 milestone Jul 31, 2023
@karalabe karalabe merged commit 817553c into ethereum:master Jul 31, 2023
1 check passed
devopsbo3 pushed 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
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants