Skip to content

Commit 8c06cce

Browse files
committed
rename VerkleTrie to BinaryTrie
Signed-off-by: Guillaume Ballet <[email protected]>
1 parent ba1ad7f commit 8c06cce

File tree

8 files changed

+51
-51
lines changed

8 files changed

+51
-51
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
165165
}
166166
var (
167167
parentStateRoot, statedb = MakePreState(rawdb.NewMemoryDatabase(), chainConfig, pre, chainConfig.IsVerkle(big.NewInt(int64(pre.Env.Number)), pre.Env.Timestamp))
168-
signer = types.MakeSigner(chainConfig, new(big.Int).SetUint64(pre.Env.Number), pre.Env.Timestamp)
169-
gaspool = new(core.GasPool)
170-
blockHash = common.Hash{0x13, 0x37}
171-
rejectedTxs []*rejectedTx
172-
includedTxs types.Transactions
173-
gasUsed = uint64(0)
174-
receipts = make(types.Receipts, 0)
175-
txIndex = 0
168+
signer = types.MakeSigner(chainConfig, new(big.Int).SetUint64(pre.Env.Number), pre.Env.Timestamp)
169+
gaspool = new(core.GasPool)
170+
blockHash = common.Hash{0x13, 0x37}
171+
rejectedTxs []*rejectedTx
172+
includedTxs types.Transactions
173+
gasUsed = uint64(0)
174+
receipts = make(types.Receipts, 0)
175+
txIndex = 0
176176
)
177177

178178
gaspool.AddGas(pre.Env.GasLimit)
@@ -433,7 +433,7 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest
433433
statedb, _ := state.New(types.EmptyRootHash, sdb, nil)
434434

435435
if pre.Env.Ended != nil && *pre.Env.Ended {
436-
vtr := statedb.GetTrie().(*trie.VerkleTrie)
436+
vtr := statedb.GetTrie().(*trie.BinaryTrie)
437437

438438
// create the vkt, should be empty on first insert
439439
for k, v := range pre.VKT {
@@ -478,7 +478,7 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest
478478
if verkle {
479479
// If the current tree is a VerkleTrie, it means the state conversion has ended.
480480
// We don't need to continue with conversion setups and can return early.
481-
if _, ok := statedb.GetTrie().(*trie.VerkleTrie); ok {
481+
if _, ok := statedb.GetTrie().(*trie.BinaryTrie); ok {
482482
return parentRoot, statedb
483483
}
484484

@@ -530,9 +530,9 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest
530530
}
531531

532532
// Load verkle tree from prestate
533-
var vtr *trie.VerkleTrie
533+
var vtr *trie.BinaryTrie
534534
switch tr := statedb.GetTrie().(type) {
535-
case *trie.VerkleTrie:
535+
case *trie.BinaryTrie:
536536
vtr = tr
537537
case *trie.TransitionTrie:
538538
vtr = tr.Overlay()

cmd/evm/internal/t8ntool/transition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ func VerkleRoot(ctx *cli.Context) error {
600600
return nil
601601
}
602602

603-
func genVktFromAlloc(alloc core.GenesisAlloc) (*trie.VerkleTrie, error) {
603+
func genVktFromAlloc(alloc core.GenesisAlloc) (*trie.BinaryTrie, error) {
604604
vkt := trie.NewVerkleTrie(trie.NewBinaryNode(), trie.NewDatabase(rawdb.NewMemoryDatabase()), true)
605605

606606
for addr, acc := range alloc {

core/chain_makers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func GenerateVerkleChain(config *params.ChainConfig, parent *types.Block, engine
384384
b := &BlockGen{i: i, chain: blocks, parent: parent, statedb: statedb, config: config, engine: engine}
385385
b.header = makeHeader(chainreader, parent, statedb, b.engine)
386386
preState := statedb.Copy()
387-
fmt.Println("prestate", preState.GetTrie().(*trie.VerkleTrie).ToDot())
387+
fmt.Println("prestate", preState.GetTrie().(*trie.BinaryTrie).ToDot())
388388

389389
if config.IsVerkle(b.header.Number, b.header.Time) {
390390
if !config.IsVerkle(b.parent.Number(), b.parent.Time()) {

core/state/database.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
374374
return nil, err
375375
}
376376

377-
return trie.NewTransitionTree(mpt.(*trie.SecureTrie), vkt.(*trie.VerkleTrie), false), nil
377+
return trie.NewTransitionTree(mpt.(*trie.SecureTrie), vkt.(*trie.BinaryTrie), false), nil
378378
}
379379

380380
log.Info("not in transition, opening mpt alone", "root", root)
@@ -400,7 +400,7 @@ func (db *cachingDB) OpenStorageTrie(stateRoot common.Hash, address common.Addre
400400
// Return a "storage trie" that is an adapter between the storge MPT
401401
// and the unique verkle tree.
402402
switch self := self.(type) {
403-
case *trie.VerkleTrie:
403+
case *trie.BinaryTrie:
404404
return trie.NewTransitionTree(mpt.(*trie.StateTrie), self, true), nil
405405
case *trie.TransitionTrie:
406406
return trie.NewTransitionTree(mpt.(*trie.StateTrie), self.Overlay(), true), nil
@@ -417,7 +417,7 @@ func (db *cachingDB) OpenStorageTrie(stateRoot common.Hash, address common.Addre
417417
// Return a "storage trie" that is an adapter between the storge MPT
418418
// and the unique verkle tree.
419419
switch self := self.(type) {
420-
case *trie.VerkleTrie:
420+
case *trie.BinaryTrie:
421421
return trie.NewTransitionTree(mpt.(*trie.SecureTrie), self, true), nil
422422
case *trie.TransitionTrie:
423423
return trie.NewTransitionTree(mpt.(*trie.SecureTrie), self.Overlay(), true), nil
@@ -436,7 +436,7 @@ func (db *cachingDB) CopyTrie(t Trie) Trie {
436436
return t.Copy()
437437
case *trie.TransitionTrie:
438438
return t.Copy()
439-
case *trie.VerkleTrie:
439+
case *trie.BinaryTrie:
440440
return t.Copy()
441441
default:
442442
panic(fmt.Errorf("unknown trie type %T", t))

core/state/dump.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
221221
}
222222

223223
func (s *StateDB) DumpVKTLeaves(collector map[common.Hash]hexutil.Bytes) {
224-
var vtr *trie.VerkleTrie
224+
var vtr *trie.BinaryTrie
225225
switch tr := s.trie.(type) {
226-
case *trie.VerkleTrie:
226+
case *trie.BinaryTrie:
227227
vtr = tr
228228
case *trie.TransitionTrie:
229229
vtr = tr.Overlay()

trie/binary.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -557,14 +557,14 @@ func DeserializeNode(serialized []byte, depth int) (BinaryNode, error) {
557557
}
558558
}
559559

560-
// VerkleTrie is a wrapper around VerkleNode that implements the trie.Trie
560+
// BinaryTrie is a wrapper around VerkleNode that implements the trie.Trie
561561
// interface so that Verkle trees can be reused verbatim.
562-
type VerkleTrie struct {
562+
type BinaryTrie struct {
563563
root BinaryNode
564564
db *Database
565565
}
566566

567-
func (vt *VerkleTrie) ToDot() string {
567+
func (vt *BinaryTrie) ToDot() string {
568568
vt.root.Commit()
569569
return vt.root.toDot("", "")
570570
}
@@ -586,14 +586,14 @@ func (n *InternalNode) toDot(parent, path string) string {
586586
return ret
587587
}
588588

589-
func NewVerkleTrie(root BinaryNode, db *Database, ended bool) *VerkleTrie {
590-
return &VerkleTrie{
589+
func NewVerkleTrie(root BinaryNode, db *Database, ended bool) *BinaryTrie {
590+
return &BinaryTrie{
591591
root: root,
592592
db: db,
593593
}
594594
}
595595

596-
func (trie *VerkleTrie) FlatdbNodeResolver(path []byte) ([]byte, error) {
596+
func (trie *BinaryTrie) FlatdbNodeResolver(path []byte) ([]byte, error) {
597597
return trie.db.diskdb.Get(append(FlatDBVerkleNodeKeyPrefix, path...))
598598
}
599599

@@ -614,24 +614,24 @@ var (
614614

615615
// GetKey returns the sha3 preimage of a hashed key that was previously used
616616
// to store a value.
617-
func (trie *VerkleTrie) GetKey(key []byte) []byte {
617+
func (trie *BinaryTrie) GetKey(key []byte) []byte {
618618
return key
619619
}
620620

621621
// Get returns the value for key stored in the trie. The value bytes must
622622
// not be modified by the caller. If a node was not found in the database, a
623623
// trie.MissingNodeError is returned.
624-
func (trie *VerkleTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) {
624+
func (trie *BinaryTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) {
625625
return trie.root.Get(utils.GetTreeKey(addr, key), trie.FlatdbNodeResolver)
626626
}
627627

628628
// GetWithHashedKey returns the value, assuming that the key has already
629629
// been hashed.
630-
func (trie *VerkleTrie) GetWithHashedKey(key []byte) ([]byte, error) {
630+
func (trie *BinaryTrie) GetWithHashedKey(key []byte) ([]byte, error) {
631631
return trie.root.Get(key, trie.FlatdbNodeResolver)
632632
}
633633

634-
func (t *VerkleTrie) GetAccount(addr common.Address) (*types.StateAccount, error) {
634+
func (t *BinaryTrie) GetAccount(addr common.Address) (*types.StateAccount, error) {
635635
acc := &types.StateAccount{}
636636
versionkey := utils.GetTreeKey(addr, zero[:])
637637
var (
@@ -685,7 +685,7 @@ func (t *VerkleTrie) GetAccount(addr common.Address) (*types.StateAccount, error
685685

686686
var zero [32]byte
687687

688-
func (t *VerkleTrie) UpdateAccount(addr common.Address, acc *types.StateAccount, codeLen int) error {
688+
func (t *BinaryTrie) UpdateAccount(addr common.Address, acc *types.StateAccount, codeLen int) error {
689689
var (
690690
err error
691691
basicData [32]byte
@@ -712,7 +712,7 @@ func (t *VerkleTrie) UpdateAccount(addr common.Address, acc *types.StateAccount,
712712
return err
713713
}
714714

715-
func (trie *VerkleTrie) UpdateStem(key []byte, values [][]byte) error {
715+
func (trie *BinaryTrie) UpdateStem(key []byte, values [][]byte) error {
716716
var err error
717717
trie.root, err = trie.root.InsertValuesAtStem(key, values, trie.FlatdbNodeResolver, 0)
718718
return err
@@ -722,7 +722,7 @@ func (trie *VerkleTrie) UpdateStem(key []byte, values [][]byte) error {
722722
// existing value is deleted from the trie. The value bytes must not be modified
723723
// by the caller while they are stored in the trie. If a node was not found in the
724724
// database, a trie.MissingNodeError is returned.
725-
func (trie *VerkleTrie) UpdateStorage(address common.Address, key, value []byte) error {
725+
func (trie *BinaryTrie) UpdateStorage(address common.Address, key, value []byte) error {
726726
k := utils.GetTreeKeyStorageSlot(address, key)
727727
var v [32]byte
728728
if len(value) >= 32 {
@@ -738,13 +738,13 @@ func (trie *VerkleTrie) UpdateStorage(address common.Address, key, value []byte)
738738
return nil
739739
}
740740

741-
func (t *VerkleTrie) DeleteAccount(addr common.Address) error {
741+
func (t *BinaryTrie) DeleteAccount(addr common.Address) error {
742742
return nil
743743
}
744744

745745
// Delete removes any existing value for key from the trie. If a node was not
746746
// found in the database, a trie.MissingNodeError is returned.
747-
func (trie *VerkleTrie) DeleteStorage(addr common.Address, key []byte) error {
747+
func (trie *BinaryTrie) DeleteStorage(addr common.Address, key []byte) error {
748748
k := utils.GetTreeKey(addr, key)
749749
var zero [32]byte
750750
root, err := trie.root.Insert(k, zero[:], trie.FlatdbNodeResolver)
@@ -757,13 +757,13 @@ func (trie *VerkleTrie) DeleteStorage(addr common.Address, key []byte) error {
757757

758758
// Hash returns the root hash of the trie. It does not write to the database and
759759
// can be used even if the trie doesn't have one.
760-
func (trie *VerkleTrie) Hash() common.Hash {
760+
func (trie *BinaryTrie) Hash() common.Hash {
761761
return trie.root.Commit()
762762
}
763763

764764
// Commit writes all nodes to the trie's memory database, tracking the internal
765765
// and external (for account tries) references.
766-
func (trie *VerkleTrie) Commit(_ bool) (common.Hash, *trienode.NodeSet, error) {
766+
func (trie *BinaryTrie) Commit(_ bool) (common.Hash, *trienode.NodeSet, error) {
767767
root := trie.root.(*InternalNode)
768768
nodeset := trienode.NewNodeSet(common.Hash{})
769769

@@ -781,7 +781,7 @@ func (trie *VerkleTrie) Commit(_ bool) (common.Hash, *trienode.NodeSet, error) {
781781

782782
// NodeIterator returns an iterator that returns nodes of the trie. Iteration
783783
// starts at the key after the given start key.
784-
func (trie *VerkleTrie) NodeIterator(startKey []byte) (NodeIterator, error) {
784+
func (trie *BinaryTrie) NodeIterator(startKey []byte) (NodeIterator, error) {
785785
return newVerkleNodeIterator(trie, nil)
786786
}
787787

@@ -792,18 +792,18 @@ func (trie *VerkleTrie) NodeIterator(startKey []byte) (NodeIterator, error) {
792792
// If the trie does not contain a value for key, the returned proof contains all
793793
// nodes of the longest existing prefix of the key (at least the root), ending
794794
// with the node that proves the absence of the key.
795-
func (trie *VerkleTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error {
795+
func (trie *BinaryTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error {
796796
panic("not implemented")
797797
}
798798

799-
func (trie *VerkleTrie) Copy() *VerkleTrie {
800-
return &VerkleTrie{
799+
func (trie *BinaryTrie) Copy() *BinaryTrie {
800+
return &BinaryTrie{
801801
root: trie.root.Copy(),
802802
db: trie.db,
803803
}
804804
}
805805

806-
func (trie *VerkleTrie) IsVerkle() bool {
806+
func (trie *BinaryTrie) IsVerkle() bool {
807807
return true
808808
}
809809

@@ -815,7 +815,7 @@ func SerializeProof(proof *verkle.VerkleProof) (*verkle.VerkleProof, verkle.Stat
815815
return nil, nil, nil
816816
}
817817

818-
func ProveAndSerialize(pretrie, posttrie *VerkleTrie, keys [][]byte, resolver NodeResolverFn) (*verkle.VerkleProof, verkle.StateDiff, error) {
818+
func ProveAndSerialize(pretrie, posttrie *BinaryTrie, keys [][]byte, resolver NodeResolverFn) (*verkle.VerkleProof, verkle.StateDiff, error) {
819819
var postroot BinaryNode
820820
if posttrie != nil {
821821
postroot = posttrie.root
@@ -896,16 +896,16 @@ func ChunkifyCode(code []byte) ChunkedCode {
896896
return chunks
897897
}
898898

899-
func (t *VerkleTrie) SetStorageRootConversion(addr common.Address, root common.Hash) {
899+
func (t *BinaryTrie) SetStorageRootConversion(addr common.Address, root common.Hash) {
900900
t.db.SetStorageRootConversion(addr, root)
901901
}
902902

903-
func (t *VerkleTrie) ClearStrorageRootConversion(addr common.Address) {
903+
func (t *BinaryTrie) ClearStrorageRootConversion(addr common.Address) {
904904
t.db.ClearStorageRootConversion(addr)
905905
}
906906

907907
// Note: the basic data leaf needs to have been previously created for this to work
908-
func (t *VerkleTrie) UpdateContractCode(addr common.Address, codeHash common.Hash, code []byte) error {
908+
func (t *BinaryTrie) UpdateContractCode(addr common.Address, codeHash common.Hash, code []byte) error {
909909
var (
910910
chunks = ChunkifyCode(code)
911911
values [][]byte

trie/binary_iterator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ type verkleNodeIteratorState struct {
2626
}
2727

2828
type verkleNodeIterator struct {
29-
trie *VerkleTrie
29+
trie *BinaryTrie
3030
current BinaryNode
3131
lastErr error
3232

3333
stack []verkleNodeIteratorState
3434
}
3535

36-
func newVerkleNodeIterator(trie *VerkleTrie, _ []byte) (NodeIterator, error) {
36+
func newVerkleNodeIterator(trie *BinaryTrie, _ []byte) (NodeIterator, error) {
3737
if trie.Hash() == zero {
3838
return new(nodeIterator), nil
3939
}

trie/transition.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import (
2626
)
2727

2828
type TransitionTrie struct {
29-
overlay *VerkleTrie
29+
overlay *BinaryTrie
3030
base *SecureTrie
3131
storage bool
3232
}
3333

34-
func NewTransitionTree(base *SecureTrie, overlay *VerkleTrie, st bool) *TransitionTrie {
34+
func NewTransitionTree(base *SecureTrie, overlay *BinaryTrie, st bool) *TransitionTrie {
3535
return &TransitionTrie{
3636
overlay: overlay,
3737
base: base,
@@ -44,7 +44,7 @@ func (t *TransitionTrie) Base() *SecureTrie {
4444
}
4545

4646
// TODO(gballet/jsign): consider removing this API.
47-
func (t *TransitionTrie) Overlay() *VerkleTrie {
47+
func (t *TransitionTrie) Overlay() *BinaryTrie {
4848
return t.overlay
4949
}
5050

0 commit comments

Comments
 (0)