Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 87c8cfc

Browse files
authored
sync: coreth PR #1333: chore: update Firewood (#1816)
1 parent 834853b commit 87c8cfc

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

core/blockchain_ext_test.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package core
66
import (
77
"fmt"
88
"math/big"
9+
"os"
10+
"path/filepath"
911
"slices"
1012
"testing"
1113

@@ -139,6 +141,30 @@ func copyMemDB(db ethdb.Database) (ethdb.Database, error) {
139141
return newDB, nil
140142
}
141143

144+
// This copies all files from a flat directory [src] to a new temporary directory and returns
145+
// the path to the new directory.
146+
func copyFlatDir(t *testing.T, src string) string {
147+
t.Helper()
148+
if src == "" {
149+
return ""
150+
}
151+
152+
dst := t.TempDir()
153+
ents, err := os.ReadDir(src)
154+
require.NoError(t, err)
155+
156+
for _, e := range ents {
157+
require.False(t, e.IsDir(), "expected flat directory")
158+
name := e.Name()
159+
data, err := os.ReadFile(filepath.Join(src, name))
160+
require.NoError(t, err)
161+
info, err := e.Info()
162+
require.NoError(t, err)
163+
require.NoError(t, os.WriteFile(filepath.Join(dst, name), data, info.Mode().Perm()))
164+
}
165+
return dst
166+
}
167+
142168
// checkBlockChainState creates a new BlockChain instance and checks that exporting each block from
143169
// genesis to last accepted from the original instance yields the same last accepted block and state
144170
// root.
@@ -205,7 +231,8 @@ func checkBlockChainState(
205231
if err != nil {
206232
t.Fatal(err)
207233
}
208-
restartedChain, err := create(originalDB, gspec, lastAcceptedBlock.Hash(), oldChainDataDir)
234+
newChainDataDir := copyFlatDir(t, oldChainDataDir)
235+
restartedChain, err := create(originalDB, gspec, lastAcceptedBlock.Hash(), newChainDataDir)
209236
if err != nil {
210237
t.Fatal(err)
211238
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/VictoriaMetrics/fastcache v1.12.1
77
github.com/antithesishq/antithesis-sdk-go v0.3.8
88
github.com/ava-labs/avalanchego v1.13.6-rc.1
9-
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12
9+
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13
1010
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661
1111
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1212
github.com/deckarep/golang-set/v2 v2.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ github.com/ava-labs/avalanchego v1.13.6-rc.1 h1:O4qeGhxRVO5O8vfu2LMpwU5AdES/8bB2
3232
github.com/ava-labs/avalanchego v1.13.6-rc.1/go.mod h1:27SGpJ0L+3jVMfjY8X5nmgkZ3sFSc7vGeJj+SFjAKL0=
3333
github.com/ava-labs/coreth v0.15.4-rc.4 h1:ze7/IwDptWG1u2d32uUZz9Ix9ycVUtlB8JufuSKSSS4=
3434
github.com/ava-labs/coreth v0.15.4-rc.4/go.mod h1:yVwuMyPkZ48xzZ0y2OdIwaoUqvSsgPYoodyX9BZJ2uo=
35-
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12 h1:aMcrLbpJ/dyu2kZDf/Di/4JIWsUcYPyTDKymiHpejt0=
36-
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.12/go.mod h1:cq89ua3iiZ5wPBALTEQS5eG8DIZcs7ov6OiL4YR1BVY=
35+
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13 h1:obPwnVCkF5+B2f8WbTepHj0ZgiW21vKUgFCtATuAYNY=
36+
github.com/ava-labs/firewood-go-ethhash/ffi v0.0.13/go.mod h1:gsGr1ICjokI9CyPaaRHMqDoDCaT1VguC/IyOTx6rJ14=
3737
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661 h1:lt4yQE1HMvxWrdD5RFj+h9kWUsZK2rmNohvkeQsbG9M=
3838
github.com/ava-labs/libevm v1.13.15-0.20251002164226-35926db4d661/go.mod h1:ivRC/KojP8sai7j8WnpXIReQpcRklL2bIzoysnjpARQ=
3939
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=

0 commit comments

Comments
 (0)