Skip to content

Commit 2698a01

Browse files
committed
chore: update firewood
1 parent 3484a30 commit 2698a01

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
77
github.com/Microsoft/go-winio v0.6.1
88
github.com/VictoriaMetrics/fastcache v1.12.1
9-
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.14
9+
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.15
1010
github.com/aws/aws-sdk-go-v2 v1.21.2
1111
github.com/aws/aws-sdk-go-v2/config v1.18.45
1212
github.com/aws/aws-sdk-go-v2/credentials v1.13.43

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY
3232
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
3333
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
3434
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
35-
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.14 h1:Be+LO61hwmo7XKNm57Yoqx7ld8SgBapjVBEPjUcgI8o=
36-
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.14/go.mod h1:hR/JSGXxST9B9olwu/NpLXHAykfAyNGfyKnYQqiiOeE=
35+
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.15 h1:NAVjEu508HwdgbxH/xQxMQoBUgYUn9RQf0VeCrhtYMY=
36+
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.15/go.mod h1:hR/JSGXxST9B9olwu/NpLXHAykfAyNGfyKnYQqiiOeE=
3737
github.com/aws/aws-sdk-go-v2 v1.21.2 h1:+LXZ0sgo8quN9UOKXXzAWRT3FWd4NxeXWOZom9pE7GA=
3838
github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM=
3939
github.com/aws/aws-sdk-go-v2/config v1.18.45 h1:Aka9bI7n8ysuwPeFdm77nfbyHCAKQ3z9ghB3S/38zes=

libevm/triedb/firewood/firewood.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package firewood
2121

2222
import (
23-
"bytes"
2423
"context"
2524
"errors"
2625
"fmt"
@@ -159,7 +158,7 @@ func New(config Config) (*Database, error) {
159158
return nil, err
160159
}
161160

162-
currentRoot, err := fw.Root()
161+
intialRoot, err := fw.Root()
163162
if err != nil {
164163
if closeErr := fw.Close(context.Background()); closeErr != nil {
165164
return nil, fmt.Errorf("%w: error while closing: %w", err, closeErr)
@@ -173,7 +172,7 @@ func New(config Config) (*Database, error) {
173172
byStateRoot: make(map[common.Hash][]*proposal),
174173
tree: &proposal{
175174
proposalMeta: &proposalMeta{
176-
root: common.Hash(currentRoot),
175+
root: common.Hash(intialRoot),
177176
blockHashes: map[common.Hash]struct{}{
178177
{}: {}, // genesis block has empty hash
179178
},
@@ -225,7 +224,7 @@ func (db *Database) Initialized(common.Hash) bool {
225224

226225
// If the current root isn't empty, then unless the genesis block is empty,
227226
// the database is initialized.
228-
return !bytes.Equal(root, types.EmptyRootHash[:])
227+
return common.Hash(root) != types.EmptyRootHash
229228
}
230229

231230
// Size returns the storage size of diff layer nodes above the persistent disk
@@ -437,7 +436,7 @@ func (db *Database) Commit(root common.Hash, report bool) error {
437436
if err != nil {
438437
return fmt.Errorf("firewood: error getting current root after commit: %w", err)
439438
}
440-
if !bytes.Equal(newRoot, root[:]) {
439+
if common.Hash(newRoot) != root {
441440
return fmt.Errorf("firewood: root after commit (%#x) does not match expected root %#x", newRoot, root)
442441
}
443442

@@ -501,11 +500,11 @@ func (db *Database) createProposal(parent *proposal, keys, values [][]byte) (*pr
501500
},
502501
}
503502

504-
currentRootBytes, err := handle.Root()
503+
root, err := handle.Root()
505504
if err != nil {
506505
return nil, fmt.Errorf("firewood: error getting root of proposals: %w", err)
507506
}
508-
p.root = common.BytesToHash(currentRootBytes)
507+
p.root = common.Hash(root)
509508

510509
return p, nil
511510
}
@@ -612,7 +611,7 @@ func (db *Database) getProposalHash(parentRoot common.Hash, keys, values [][]byt
612611
// Reader retrieves a node reader belonging to the given state root.
613612
// An error will be returned if the requested state is not available.
614613
func (db *Database) Reader(root common.Hash) (database.Reader, error) {
615-
if _, err := db.Firewood.GetFromRoot(root.Bytes(), []byte{}); err != nil {
614+
if _, err := db.Firewood.GetFromRoot(ffi.Hash(root), []byte{}); err != nil {
616615
return nil, fmt.Errorf("firewood: unable to retrieve from root %s: %w", root.Hex(), err)
617616
}
618617
return &reader{db: db, root: root}, nil
@@ -629,5 +628,5 @@ type reader struct {
629628
func (reader *reader) Node(_ common.Hash, path []byte, _ common.Hash) ([]byte, error) {
630629
// This function relies on Firewood's internal locking to ensure concurrent reads are safe.
631630
// This is safe even if a proposal is being committed concurrently.
632-
return reader.db.Firewood.GetFromRoot(reader.root.Bytes(), path)
631+
return reader.db.Firewood.GetFromRoot(ffi.Hash(reader.root), path)
633632
}

0 commit comments

Comments
 (0)