-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
eth/protocols/snap: save nodes on right boundary in hash mode #29791
base: master
Are you sure you want to change the base?
Conversation
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.
LGTM
It panics, need investigation
|
@@ -280,8 +280,9 @@ func (t *hashTrie) update(key, value []byte) error { | |||
|
|||
// commit implements genTrie interface, committing the nodes on right boundary. | |||
func (t *hashTrie) commit(complete bool) common.Hash { | |||
hash := t.tr.Hash() // flush the nodes on right boundary |
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.
For the stacktrie, this will forcibly "The main purpose here is to commit the nodes on right boundary", and this make it so that it's not possible to add more data to this stacktrie. (because there will be no nodes to insert into, only one hashed rootnodes).
However, this method is used in places where there's more data to come, e..g
} else if task.genBatch.ValueSize() > batchSizeThreshold {
task.genTrie.commit(false)
A "time to push to disk for now" invocation^
There are two concerns, but only one flag
- Caller wants to commit to release a bit of memory,
- Caller wants to force-commit to flush right-hand boundary
The stacktrie doesn't really need "commit to release some memory", since it does so continuously. Perhaps we need two flags
Anyway, that's the cause for the panic
This pull request fixes an issue in hash gentrie.
In hash-mode, no matter the gentrie is complete or not, all the nodes on the right boundary should be flushed into disk if
commit
is called. As the garbage nodes will be unlinked from the trie by state healer.Currently, if the right boundary of gentrie is claimed as incomplete, nodes on it are silently discarded. Given that the nodes on incomplete boundary are usually useless, but still the behavior should be aligned in hash gentrie.