-
Notifications
You must be signed in to change notification settings - Fork 13
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
use fastest non-master go-verkle version & pull trie/Verkle.go changes to use new api #184
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,10 +149,9 @@ func (t *VerkleTrie) TryUpdateAccount(key []byte, acc *types.StateAccount) error | |
} | ||
|
||
func (trie *VerkleTrie) TryUpdateStem(key []byte, values [][]byte) error { | ||
resolver := | ||
func(h []byte) ([]byte, error) { | ||
return trie.db.diskdb.Get(h) | ||
} | ||
resolver := func(h []byte) ([]byte, error) { | ||
return trie.db.diskdb.Get(h) | ||
} | ||
switch root := trie.root.(type) { | ||
case *verkle.InternalNode: | ||
return root.InsertStem(key, values, resolver) | ||
|
@@ -184,7 +183,6 @@ func (t *VerkleTrie) TryDeleteAccount(key []byte) error { | |
) | ||
|
||
for i := 0; i < verkle.NodeWidth; i++ { | ||
|
||
values[i] = zero[:] | ||
} | ||
|
||
|
@@ -230,33 +228,22 @@ func nodeToDBKey(n verkle.VerkleNode) []byte { | |
// Commit writes all nodes to the trie's memory database, tracking the internal | ||
// and external (for account tries) references. | ||
func (trie *VerkleTrie) Commit(_ bool) (common.Hash, *NodeSet, error) { | ||
flush := make(chan verkle.VerkleNode) | ||
resolver := func(n verkle.VerkleNode) { | ||
flush <- n | ||
root, ok := trie.root.(*verkle.InternalNode) | ||
if !ok { | ||
return common.Hash{}, nil, errors.New("unexpected root node type") | ||
} | ||
nodes, err := root.BatchSerialize() | ||
if err != nil { | ||
return common.Hash{}, nil, fmt.Errorf("serializing tree nodes: %s", err) | ||
} | ||
go func() { | ||
switch root := trie.root.(type) { | ||
case *verkle.InternalNode: | ||
root.Flush(resolver) | ||
case *verkle.StatelessNode: | ||
root.Flush(resolver) | ||
} | ||
close(flush) | ||
}() | ||
var commitCount int | ||
for n := range flush { | ||
commitCount += 1 | ||
value, err := n.Serialize() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if err := trie.db.diskdb.Put(nodeToDBKey(n), value); err != nil { | ||
return common.Hash{}, NewNodeSet(common.Hash{}), err | ||
for _, node := range nodes { | ||
if err := trie.db.diskdb.Put(node.CommitmentBytes[:], node.SerializedBytes); err != nil { | ||
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. I noticed that the 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. it's part of the preparations for this new database schema, iirc that's more or less what you assumed. |
||
return common.Hash{}, nil, fmt.Errorf("put node to disk: %s", err) | ||
} | ||
} | ||
|
||
return trie.Hash(), NewNodeSet(common.Hash{}), nil | ||
return nodes[0].CommitmentBytes, NewNodeSet(common.Hash{}), nil | ||
} | ||
|
||
// NodeIterator returns an iterator that returns nodes of the trie. Iteration | ||
|
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.
Noticed also that in the current replay block branch we had some
onLeaf
callback here, which isn't present.I honored this version; but just mentioning if that's relevant.
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.
it's only used for stuff we don't do in verkle, so that's why it's not called. But that might change with the new DB schema, we will see very soon.