-
Notifications
You must be signed in to change notification settings - Fork 21.9k
trie: introduce UpdateBatch #32448
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
Open
rjl493456442
wants to merge
1
commit into
ethereum:master
Choose a base branch
from
rjl493456442:trie-concurrent-insert
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
trie: introduce UpdateBatch #32448
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,6 +177,22 @@ func (t *VerkleTrie) UpdateAccount(addr common.Address, acc *types.StateAccount, | |
| return nil | ||
| } | ||
|
|
||
| // UpdateAccountBatch attempts to update a list accounts in the batch manner. | ||
| func (t *VerkleTrie) UpdateAccountBatch(addresses []common.Address, accounts []*types.StateAccount, codeLens []int) error { | ||
| if len(addresses) != len(accounts) { | ||
| return fmt.Errorf("address and accounts length mismatch: %d != %d", len(addresses), len(accounts)) | ||
| } | ||
| if len(addresses) != len(codeLens) { | ||
| return fmt.Errorf("address and code length mismatch: %d != %d", len(addresses), len(codeLens)) | ||
| } | ||
| for i, addr := range addresses { | ||
| if err := t.UpdateAccount(addr, accounts[i], codeLens[i]); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // UpdateStorage implements state.Trie, writing the provided storage slot into | ||
| // the tree. If the tree is corrupted, an error will be returned. | ||
| func (t *VerkleTrie) UpdateStorage(address common.Address, key, value []byte) error { | ||
|
|
@@ -191,6 +207,19 @@ func (t *VerkleTrie) UpdateStorage(address common.Address, key, value []byte) er | |
| return t.root.Insert(k, v[:], t.nodeResolver) | ||
| } | ||
|
|
||
| // UpdateStorageBatch attempts to update a list storages in the batch manner. | ||
| func (t *VerkleTrie) UpdateStorageBatch(address common.Address, keys [][]byte, values [][]byte) error { | ||
| if len(keys) != len(values) { | ||
| return fmt.Errorf("keys and values length mismatch: %d != %d", len(keys), len(values)) | ||
| } | ||
| for i, key := range keys { | ||
| if err := t.UpdateStorage(address, key, values[i]); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
|
Comment on lines
+211
to
+222
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. either implement it, or panic |
||
| // DeleteAccount leaves the account untouched, as no account deletion can happen | ||
| // in verkle. | ||
| // There is a special corner case, in which an account that is prefunded, CREATE2-d | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to reset the flag of the root node if there are any mutations. Otherwise, when it comes time to hash, the previous hashed node will be cached in the root.