Merge branch 'ethereum:master' into chore/map-pointer

This commit is contained in:
caseylove 2024-07-17 10:45:53 +08:00 committed by GitHub
commit f2e427b80f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 308 additions and 117 deletions

View file

@ -171,5 +171,5 @@ i4O1UeWKs9owWttan9+PI47ozBSKOTxmMqLSQ0f56Np9FJsV0ilGxRKfjhzJ4KniOMUBA7mP
epy6lH7HmxjjOR7eo0DaSxQGQpThAtFGwkWkFh8yki8j3E42kkrxvEyyYZDXn2YcI3bpqhJx epy6lH7HmxjjOR7eo0DaSxQGQpThAtFGwkWkFh8yki8j3E42kkrxvEyyYZDXn2YcI3bpqhJx
PtwCMZUJ3kc/skOrs6bOI19iBNaEoNX5Dllm7UHjOgWNDQkcCuOCxucKano= PtwCMZUJ3kc/skOrs6bOI19iBNaEoNX5Dllm7UHjOgWNDQkcCuOCxucKano=
=arte =arte
-----END PGP PUBLIC KEY BLOCK------ -----END PGP PUBLIC KEY BLOCK-----
``` ```

View file

@ -114,7 +114,7 @@ func TestWatchNewFile(t *testing.T) {
func TestWatchNoDir(t *testing.T) { func TestWatchNoDir(t *testing.T) {
t.Parallel() t.Parallel()
// Create ks but not the directory that it watches. // Create ks but not the directory that it watches.
dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watchnodir-test-%d-%d", os.Getpid(), rand.Int())) dir := filepath.Join(t.TempDir(), fmt.Sprintf("eth-keystore-watchnodir-test-%d-%d", os.Getpid(), rand.Int()))
ks := NewKeyStore(dir, LightScryptN, LightScryptP) ks := NewKeyStore(dir, LightScryptN, LightScryptP)
list := ks.Accounts() list := ks.Accounts()
if len(list) > 0 { if len(list) > 0 {
@ -126,7 +126,6 @@ func TestWatchNoDir(t *testing.T) {
} }
// Create the directory and copy a key file into it. // Create the directory and copy a key file into it.
os.MkdirAll(dir, 0700) os.MkdirAll(dir, 0700)
defer os.RemoveAll(dir)
file := filepath.Join(dir, "aaa") file := filepath.Join(dir, "aaa")
if err := cp.CopyFile(file, cachetestAccounts[0].URL.Path); err != nil { if err := cp.CopyFile(file, cachetestAccounts[0].URL.Path); err != nil {
t.Fatal(err) t.Fatal(err)

View file

@ -27,9 +27,8 @@ import (
// TestImportRaw tests clef --importraw // TestImportRaw tests clef --importraw
func TestImportRaw(t *testing.T) { func TestImportRaw(t *testing.T) {
t.Parallel() t.Parallel()
keyPath := filepath.Join(os.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name())) keyPath := filepath.Join(t.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name()))
os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777) os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777)
t.Cleanup(func() { os.Remove(keyPath) })
t.Run("happy-path", func(t *testing.T) { t.Run("happy-path", func(t *testing.T) {
t.Parallel() t.Parallel()
@ -68,9 +67,8 @@ func TestImportRaw(t *testing.T) {
// TestListAccounts tests clef --list-accounts // TestListAccounts tests clef --list-accounts
func TestListAccounts(t *testing.T) { func TestListAccounts(t *testing.T) {
t.Parallel() t.Parallel()
keyPath := filepath.Join(os.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name())) keyPath := filepath.Join(t.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name()))
os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777) os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777)
t.Cleanup(func() { os.Remove(keyPath) })
t.Run("no-accounts", func(t *testing.T) { t.Run("no-accounts", func(t *testing.T) {
t.Parallel() t.Parallel()
@ -97,9 +95,8 @@ func TestListAccounts(t *testing.T) {
// TestListWallets tests clef --list-wallets // TestListWallets tests clef --list-wallets
func TestListWallets(t *testing.T) { func TestListWallets(t *testing.T) {
t.Parallel() t.Parallel()
keyPath := filepath.Join(os.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name())) keyPath := filepath.Join(t.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name()))
os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777) os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777)
t.Cleanup(func() { os.Remove(keyPath) })
t.Run("no-accounts", func(t *testing.T) { t.Run("no-accounts", func(t *testing.T) {
t.Parallel() t.Parallel()

View file

@ -34,12 +34,12 @@ import (
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
) )
func makeJWTSecret() (string, [32]byte, error) { func makeJWTSecret(t *testing.T) (string, [32]byte, error) {
var secret [32]byte var secret [32]byte
if _, err := crand.Read(secret[:]); err != nil { if _, err := crand.Read(secret[:]); err != nil {
return "", secret, fmt.Errorf("failed to create jwt secret: %v", err) return "", secret, fmt.Errorf("failed to create jwt secret: %v", err)
} }
jwtPath := filepath.Join(os.TempDir(), "jwt_secret") jwtPath := filepath.Join(t.TempDir(), "jwt_secret")
if err := os.WriteFile(jwtPath, []byte(hexutil.Encode(secret[:])), 0600); err != nil { if err := os.WriteFile(jwtPath, []byte(hexutil.Encode(secret[:])), 0600); err != nil {
return "", secret, fmt.Errorf("failed to prepare jwt secret file: %v", err) return "", secret, fmt.Errorf("failed to prepare jwt secret file: %v", err)
} }
@ -47,7 +47,7 @@ func makeJWTSecret() (string, [32]byte, error) {
} }
func TestEthSuite(t *testing.T) { func TestEthSuite(t *testing.T) {
jwtPath, secret, err := makeJWTSecret() jwtPath, secret, err := makeJWTSecret(t)
if err != nil { if err != nil {
t.Fatalf("could not make jwt secret: %v", err) t.Fatalf("could not make jwt secret: %v", err)
} }
@ -75,7 +75,7 @@ func TestEthSuite(t *testing.T) {
} }
func TestSnapSuite(t *testing.T) { func TestSnapSuite(t *testing.T) {
jwtPath, secret, err := makeJWTSecret() jwtPath, secret, err := makeJWTSecret(t)
if err != nil { if err != nil {
t.Fatalf("could not make jwt secret: %v", err) t.Fatalf("could not make jwt secret: %v", err)
} }

View file

@ -248,7 +248,8 @@ func removeDB(ctx *cli.Context) error {
// Delete state data // Delete state data
statePaths := []string{ statePaths := []string{
rootDir, rootDir,
filepath.Join(ancientDir, rawdb.StateFreezerName), filepath.Join(ancientDir, rawdb.MerkleStateFreezerName),
filepath.Join(ancientDir, rawdb.VerkleStateFreezerName),
} }
confirmAndRemoveDB(statePaths, "state data", ctx, removeStateDataFlag.Name) confirmAndRemoveDB(statePaths, "state data", ctx, removeStateDataFlag.Name)

View file

@ -28,8 +28,7 @@ import (
// TestExport does a basic test of "geth export", exporting the test-genesis. // TestExport does a basic test of "geth export", exporting the test-genesis.
func TestExport(t *testing.T) { func TestExport(t *testing.T) {
t.Parallel() t.Parallel()
outfile := fmt.Sprintf("%v/testExport.out", os.TempDir()) outfile := fmt.Sprintf("%v/testExport.out", t.TempDir())
defer os.Remove(outfile)
geth := runGeth(t, "--datadir", initGeth(t), "export", outfile) geth := runGeth(t, "--datadir", initGeth(t), "export", outfile)
geth.WaitExit() geth.WaitExit()
if have, want := geth.ExitStatus(), 0; have != want { if have, want := geth.ExitStatus(), 0; have != want {

View file

@ -201,9 +201,8 @@ func TestFileOut(t *testing.T) {
var ( var (
have, want []byte have, want []byte
err error err error
path = fmt.Sprintf("%s/test_file_out-%d", os.TempDir(), rand.Int63()) path = fmt.Sprintf("%s/test_file_out-%d", t.TempDir(), rand.Int63())
) )
t.Cleanup(func() { os.Remove(path) })
if want, err = runSelf(fmt.Sprintf("--log.file=%s", path), "logtest"); err != nil { if want, err = runSelf(fmt.Sprintf("--log.file=%s", path), "logtest"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -222,9 +221,8 @@ func TestRotatingFileOut(t *testing.T) {
var ( var (
have, want []byte have, want []byte
err error err error
path = fmt.Sprintf("%s/test_file_out-%d", os.TempDir(), rand.Int63()) path = fmt.Sprintf("%s/test_file_out-%d", t.TempDir(), rand.Int63())
) )
t.Cleanup(func() { os.Remove(path) })
if want, err = runSelf(fmt.Sprintf("--log.file=%s", path), "--log.rotate", "logtest"); err != nil { if want, err = runSelf(fmt.Sprintf("--log.file=%s", path), "--log.rotate", "logtest"); err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -29,18 +29,12 @@ import (
// TestExport does basic sanity checks on the export/import functionality // TestExport does basic sanity checks on the export/import functionality
func TestExport(t *testing.T) { func TestExport(t *testing.T) {
f := fmt.Sprintf("%v/tempdump", os.TempDir()) f := fmt.Sprintf("%v/tempdump", t.TempDir())
defer func() {
os.Remove(f)
}()
testExport(t, f) testExport(t, f)
} }
func TestExportGzip(t *testing.T) { func TestExportGzip(t *testing.T) {
f := fmt.Sprintf("%v/tempdump.gz", os.TempDir()) f := fmt.Sprintf("%v/tempdump.gz", t.TempDir())
defer func() {
os.Remove(f)
}()
testExport(t, f) testExport(t, f)
} }
@ -99,20 +93,14 @@ func testExport(t *testing.T, f string) {
// TestDeletionExport tests if the deletion markers can be exported/imported correctly // TestDeletionExport tests if the deletion markers can be exported/imported correctly
func TestDeletionExport(t *testing.T) { func TestDeletionExport(t *testing.T) {
f := fmt.Sprintf("%v/tempdump", os.TempDir()) f := fmt.Sprintf("%v/tempdump", t.TempDir())
defer func() {
os.Remove(f)
}()
testDeletion(t, f) testDeletion(t, f)
} }
// TestDeletionExportGzip tests if the deletion markers can be exported/imported // TestDeletionExportGzip tests if the deletion markers can be exported/imported
// correctly with gz compression. // correctly with gz compression.
func TestDeletionExportGzip(t *testing.T) { func TestDeletionExportGzip(t *testing.T) {
f := fmt.Sprintf("%v/tempdump.gz", os.TempDir()) f := fmt.Sprintf("%v/tempdump.gz", t.TempDir())
defer func() {
os.Remove(f)
}()
testDeletion(t, f) testDeletion(t, f)
} }
@ -171,10 +159,7 @@ func testDeletion(t *testing.T, f string) {
// TestImportFutureFormat tests that we reject unsupported future versions. // TestImportFutureFormat tests that we reject unsupported future versions.
func TestImportFutureFormat(t *testing.T) { func TestImportFutureFormat(t *testing.T) {
t.Parallel() t.Parallel()
f := fmt.Sprintf("%v/tempdump-future", os.TempDir()) f := fmt.Sprintf("%v/tempdump-future", t.TempDir())
defer func() {
os.Remove(f)
}()
fh, err := os.OpenFile(f, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm) fh, err := os.OpenFile(f, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View file

@ -291,7 +291,7 @@ var (
} }
BeaconApiHeaderFlag = &cli.StringSliceFlag{ BeaconApiHeaderFlag = &cli.StringSliceFlag{
Name: "beacon.api.header", Name: "beacon.api.header",
Usage: "Pass custom HTTP header fields to the emote beacon node API in \"key:value\" format. This flag can be given multiple times.", Usage: "Pass custom HTTP header fields to the remote beacon node API in \"key:value\" format. This flag can be given multiple times.",
Category: flags.BeaconCategory, Category: flags.BeaconCategory,
} }
BeaconThresholdFlag = &cli.IntFlag{ BeaconThresholdFlag = &cli.IntFlag{

View file

@ -311,7 +311,7 @@ func TestVerkleGenesisCommit(t *testing.T) {
} }
db := rawdb.NewMemoryDatabase() db := rawdb.NewMemoryDatabase()
triedb := triedb.NewDatabase(db, &triedb.Config{IsVerkle: true, PathDB: pathdb.Defaults}) triedb := triedb.NewDatabase(db, triedb.VerkleDefaults)
block := genesis.MustCommit(db, triedb) block := genesis.MustCommit(db, triedb)
if !bytes.Equal(block.Root().Bytes(), expected) { if !bytes.Equal(block.Root().Bytes(), expected) {
t.Fatalf("invalid genesis state root, expected %x, got %x", expected, block.Root()) t.Fatalf("invalid genesis state root, expected %x, got %x", expected, block.Root())
@ -321,8 +321,8 @@ func TestVerkleGenesisCommit(t *testing.T) {
if !triedb.IsVerkle() { if !triedb.IsVerkle() {
t.Fatalf("expected trie to be verkle") t.Fatalf("expected trie to be verkle")
} }
vdb := rawdb.NewTable(db, string(rawdb.VerklePrefix))
if !rawdb.HasAccountTrieNode(db, nil) { if !rawdb.HasAccountTrieNode(vdb, nil) {
t.Fatal("could not find node") t.Fatal("could not find node")
} }
} }

View file

@ -245,7 +245,7 @@ func DeleteTrieNode(db ethdb.KeyValueWriter, owner common.Hash, path []byte, has
// ReadStateScheme reads the state scheme of persistent state, or none // ReadStateScheme reads the state scheme of persistent state, or none
// if the state is not present in database. // if the state is not present in database.
func ReadStateScheme(db ethdb.Reader) string { func ReadStateScheme(db ethdb.Database) string {
// Check if state in path-based scheme is present. // Check if state in path-based scheme is present.
if HasAccountTrieNode(db, nil) { if HasAccountTrieNode(db, nil) {
return PathScheme return PathScheme
@ -255,6 +255,16 @@ func ReadStateScheme(db ethdb.Reader) string {
if id := ReadPersistentStateID(db); id != 0 { if id := ReadPersistentStateID(db); id != 0 {
return PathScheme return PathScheme
} }
// Check if verkle state in path-based scheme is present.
vdb := NewTable(db, string(VerklePrefix))
if HasAccountTrieNode(vdb, nil) {
return PathScheme
}
// The root node of verkle might be deleted during the initial snap sync,
// check the persistent state id then.
if id := ReadPersistentStateID(vdb); id != 0 {
return PathScheme
}
// In a hash-based scheme, the genesis state is consistently stored // In a hash-based scheme, the genesis state is consistently stored
// on the disk. To assess the scheme of the persistent state, it // on the disk. To assess the scheme of the persistent state, it
// suffices to inspect the scheme of the genesis state. // suffices to inspect the scheme of the genesis state.

View file

@ -73,11 +73,12 @@ var stateFreezerNoSnappy = map[string]bool{
// The list of identifiers of ancient stores. // The list of identifiers of ancient stores.
var ( var (
ChainFreezerName = "chain" // the folder name of chain segment ancient store. ChainFreezerName = "chain" // the folder name of chain segment ancient store.
StateFreezerName = "state" // the folder name of reverse diff ancient store. MerkleStateFreezerName = "state" // the folder name of state history ancient store.
VerkleStateFreezerName = "state_verkle" // the folder name of state history ancient store.
) )
// freezers the collections of all builtin freezers. // freezers the collections of all builtin freezers.
var freezers = []string{ChainFreezerName, StateFreezerName} var freezers = []string{ChainFreezerName, MerkleStateFreezerName, VerkleStateFreezerName}
// NewStateFreezer initializes the ancient store for state history. // NewStateFreezer initializes the ancient store for state history.
// //
@ -85,9 +86,15 @@ var freezers = []string{ChainFreezerName, StateFreezerName}
// state freezer (e.g. dev mode). // state freezer (e.g. dev mode).
// - if non-empty directory is given, initializes the regular file-based // - if non-empty directory is given, initializes the regular file-based
// state freezer. // state freezer.
func NewStateFreezer(ancientDir string, readOnly bool) (ethdb.ResettableAncientStore, error) { func NewStateFreezer(ancientDir string, verkle bool, readOnly bool) (ethdb.ResettableAncientStore, error) {
if ancientDir == "" { if ancientDir == "" {
return NewMemoryFreezer(readOnly, stateFreezerNoSnappy), nil return NewMemoryFreezer(readOnly, stateFreezerNoSnappy), nil
} }
return newResettableFreezer(filepath.Join(ancientDir, StateFreezerName), "eth/db/state", readOnly, stateHistoryTableSize, stateFreezerNoSnappy) var name string
if verkle {
name = filepath.Join(ancientDir, VerkleStateFreezerName)
} else {
name = filepath.Join(ancientDir, MerkleStateFreezerName)
}
return newResettableFreezer(name, "eth/db/state", readOnly, stateHistoryTableSize, stateFreezerNoSnappy)
} }

View file

@ -88,12 +88,12 @@ func inspectFreezers(db ethdb.Database) ([]freezerInfo, error) {
} }
infos = append(infos, info) infos = append(infos, info)
case StateFreezerName: case MerkleStateFreezerName, VerkleStateFreezerName:
datadir, err := db.AncientDatadir() datadir, err := db.AncientDatadir()
if err != nil { if err != nil {
return nil, err return nil, err
} }
f, err := NewStateFreezer(datadir, true) f, err := NewStateFreezer(datadir, freezer == VerkleStateFreezerName, true)
if err != nil { if err != nil {
continue // might be possible the state freezer is not existent continue // might be possible the state freezer is not existent
} }
@ -124,7 +124,7 @@ func InspectFreezerTable(ancient string, freezerName string, tableName string, s
switch freezerName { switch freezerName {
case ChainFreezerName: case ChainFreezerName:
path, tables = resolveChainFreezerDir(ancient), chainFreezerNoSnappy path, tables = resolveChainFreezerDir(ancient), chainFreezerNoSnappy
case StateFreezerName: case MerkleStateFreezerName, VerkleStateFreezerName:
path, tables = filepath.Join(ancient, freezerName), stateFreezerNoSnappy path, tables = filepath.Join(ancient, freezerName), stateFreezerNoSnappy
default: default:
return fmt.Errorf("unknown freezer, supported ones: %v", freezers) return fmt.Errorf("unknown freezer, supported ones: %v", freezers)

View file

@ -481,6 +481,10 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
beaconHeaders stat beaconHeaders stat
cliqueSnaps stat cliqueSnaps stat
// Verkle statistics
verkleTries stat
verkleStateLookups stat
// Les statistic // Les statistic
chtTrieNodes stat chtTrieNodes stat
bloomTrieNodes stat bloomTrieNodes stat
@ -550,6 +554,24 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
bytes.HasPrefix(key, BloomTrieIndexPrefix) || bytes.HasPrefix(key, BloomTrieIndexPrefix) ||
bytes.HasPrefix(key, BloomTriePrefix): // Bloomtrie sub bytes.HasPrefix(key, BloomTriePrefix): // Bloomtrie sub
bloomTrieNodes.Add(size) bloomTrieNodes.Add(size)
// Verkle trie data is detected, determine the sub-category
case bytes.HasPrefix(key, VerklePrefix):
remain := key[len(VerklePrefix):]
switch {
case IsAccountTrieNode(remain):
verkleTries.Add(size)
case bytes.HasPrefix(remain, stateIDPrefix) && len(remain) == len(stateIDPrefix)+common.HashLength:
verkleStateLookups.Add(size)
case bytes.Equal(remain, persistentStateIDKey):
metadata.Add(size)
case bytes.Equal(remain, trieJournalKey):
metadata.Add(size)
case bytes.Equal(remain, snapSyncStatusFlagKey):
metadata.Add(size)
default:
unaccounted.Add(size)
}
default: default:
var accounted bool var accounted bool
for _, meta := range [][]byte{ for _, meta := range [][]byte{
@ -590,6 +612,8 @@ func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error {
{"Key-Value store", "Path trie state lookups", stateLookups.Size(), stateLookups.Count()}, {"Key-Value store", "Path trie state lookups", stateLookups.Size(), stateLookups.Count()},
{"Key-Value store", "Path trie account nodes", accountTries.Size(), accountTries.Count()}, {"Key-Value store", "Path trie account nodes", accountTries.Size(), accountTries.Count()},
{"Key-Value store", "Path trie storage nodes", storageTries.Size(), storageTries.Count()}, {"Key-Value store", "Path trie storage nodes", storageTries.Size(), storageTries.Count()},
{"Key-Value store", "Verkle trie nodes", verkleTries.Size(), verkleTries.Count()},
{"Key-Value store", "Verkle trie state lookups", verkleStateLookups.Size(), verkleStateLookups.Count()},
{"Key-Value store", "Trie preimages", preimages.Size(), preimages.Count()}, {"Key-Value store", "Trie preimages", preimages.Size(), preimages.Count()},
{"Key-Value store", "Account snapshot", accountSnaps.Size(), accountSnaps.Count()}, {"Key-Value store", "Account snapshot", accountSnaps.Size(), accountSnaps.Count()},
{"Key-Value store", "Storage snapshot", storageSnaps.Size(), storageSnaps.Count()}, {"Key-Value store", "Storage snapshot", storageSnaps.Size(), storageSnaps.Count()},

View file

@ -22,10 +22,11 @@ import (
) )
func TestReadWriteFreezerTableMeta(t *testing.T) { func TestReadWriteFreezerTableMeta(t *testing.T) {
f, err := os.CreateTemp(os.TempDir(), "*") f, err := os.CreateTemp(t.TempDir(), "*")
if err != nil { if err != nil {
t.Fatalf("Failed to create file %v", err) t.Fatalf("Failed to create file %v", err)
} }
defer f.Close()
err = writeMetadata(f, newMetadata(100)) err = writeMetadata(f, newMetadata(100))
if err != nil { if err != nil {
t.Fatalf("Failed to write metadata %v", err) t.Fatalf("Failed to write metadata %v", err)
@ -43,10 +44,11 @@ func TestReadWriteFreezerTableMeta(t *testing.T) {
} }
func TestInitializeFreezerTableMeta(t *testing.T) { func TestInitializeFreezerTableMeta(t *testing.T) {
f, err := os.CreateTemp(os.TempDir(), "*") f, err := os.CreateTemp(t.TempDir(), "*")
if err != nil { if err != nil {
t.Fatalf("Failed to create file %v", err) t.Fatalf("Failed to create file %v", err)
} }
defer f.Close()
meta, err := loadMetadata(f, uint64(100)) meta, err := loadMetadata(f, uint64(100))
if err != nil { if err != nil {
t.Fatalf("Failed to read metadata %v", err) t.Fatalf("Failed to read metadata %v", err)

View file

@ -117,6 +117,13 @@ var (
TrieNodeStoragePrefix = []byte("O") // TrieNodeStoragePrefix + accountHash + hexPath -> trie node TrieNodeStoragePrefix = []byte("O") // TrieNodeStoragePrefix + accountHash + hexPath -> trie node
stateIDPrefix = []byte("L") // stateIDPrefix + state root -> state id stateIDPrefix = []byte("L") // stateIDPrefix + state root -> state id
// VerklePrefix is the database prefix for Verkle trie data, which includes:
// (a) Trie nodes
// (b) In-memory trie node journal
// (c) Persistent state ID
// (d) State ID lookups, etc.
VerklePrefix = []byte("v")
PreimagePrefix = []byte("secure-key-") // PreimagePrefix + hash -> preimage PreimagePrefix = []byte("secure-key-") // PreimagePrefix + hash -> preimage
configPrefix = []byte("ethereum-config-") // config prefix for the db configPrefix = []byte("ethereum-config-") // config prefix for the db
genesisPrefix = []byte("ethereum-genesis-") // genesis state prefix for the db genesisPrefix = []byte("ethereum-genesis-") // genesis state prefix for the db

View file

@ -860,6 +860,9 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
} }
obj := s.stateObjects[addr] // closure for the task runner below obj := s.stateObjects[addr] // closure for the task runner below
workers.Go(func() error { workers.Go(func() error {
if s.db.TrieDB().IsVerkle() {
obj.updateTrie()
} else {
obj.updateRoot() obj.updateRoot()
// If witness building is enabled and the state object has a trie, // If witness building is enabled and the state object has a trie,
@ -867,6 +870,7 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
if s.witness != nil && obj.trie != nil { if s.witness != nil && obj.trie != nil {
s.witness.AddState(obj.trie.Witness()) s.witness.AddState(obj.trie.Witness())
} }
}
return nil return nil
}) })
} }

View file

@ -1116,7 +1116,7 @@ func (p *BlobPool) validateTx(tx *types.Transaction) error {
ExistingCost: func(addr common.Address, nonce uint64) *big.Int { ExistingCost: func(addr common.Address, nonce uint64) *big.Int {
next := p.state.GetNonce(addr) next := p.state.GetNonce(addr)
if uint64(len(p.index[addr])) > nonce-next { if uint64(len(p.index[addr])) > nonce-next {
return p.index[addr][int(tx.Nonce()-next)].costCap.ToBig() return p.index[addr][int(nonce-next)].costCap.ToBig()
} }
return nil return nil
}, },

View file

@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256" "github.com/holiman/uint256"
"golang.org/x/exp/maps"
) )
const ( const (
@ -1717,7 +1718,7 @@ func (a addressesByHeartbeat) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
type accountSet struct { type accountSet struct {
accounts map[common.Address]struct{} accounts map[common.Address]struct{}
signer types.Signer signer types.Signer
cache *[]common.Address cache []common.Address
} }
// newAccountSet creates a new address set with an associated signer for sender // newAccountSet creates a new address set with an associated signer for sender
@ -1765,20 +1766,14 @@ func (as *accountSet) addTx(tx *types.Transaction) {
// reuse. The returned slice should not be changed! // reuse. The returned slice should not be changed!
func (as *accountSet) flatten() []common.Address { func (as *accountSet) flatten() []common.Address {
if as.cache == nil { if as.cache == nil {
accounts := make([]common.Address, 0, len(as.accounts)) as.cache = maps.Keys(as.accounts)
for account := range as.accounts {
accounts = append(accounts, account)
} }
as.cache = &accounts return as.cache
}
return *as.cache
} }
// merge adds all addresses from the 'other' set into 'as'. // merge adds all addresses from the 'other' set into 'as'.
func (as *accountSet) merge(other *accountSet) { func (as *accountSet) merge(other *accountSet) {
for addr := range other.accounts { maps.Copy(as.accounts, other.accounts)
as.accounts[addr] = struct{}{}
}
as.cache = nil as.cache = nil
} }

View file

@ -572,6 +572,6 @@ func deriveChainId(v *big.Int) *big.Int {
} }
return new(big.Int).SetUint64((v - 35) / 2) return new(big.Int).SetUint64((v - 35) / 2)
} }
v.Sub(v, big.NewInt(35)) vCopy := new(big.Int).Sub(v, big.NewInt(35))
return v.Rsh(v, 1) return vCopy.Rsh(vCopy, 1)
} }

View file

@ -345,6 +345,41 @@ func TestTransactionCoding(t *testing.T) {
} }
} }
func TestLegacyTransaction_ConsistentV_LargeChainIds(t *testing.T) {
chainId := new(big.Int).SetUint64(13317435930671861669)
txdata := &LegacyTx{
Nonce: 1,
Gas: 1,
GasPrice: big.NewInt(2),
Data: []byte("abcdef"),
}
key, err := crypto.GenerateKey()
if err != nil {
t.Fatalf("could not generate key: %v", err)
}
tx, err := SignNewTx(key, NewEIP2930Signer(chainId), txdata)
if err != nil {
t.Fatalf("could not sign transaction: %v", err)
}
// Make a copy of the initial V value
preV, _, _ := tx.RawSignatureValues()
preV = new(big.Int).Set(preV)
if tx.ChainId().Cmp(chainId) != 0 {
t.Fatalf("wrong chain id: %v", tx.ChainId())
}
v, _, _ := tx.RawSignatureValues()
if v.Cmp(preV) != 0 {
t.Fatalf("wrong v value: %v", v)
}
}
func encodeDecodeJSON(tx *Transaction) (*Transaction, error) { func encodeDecodeJSON(tx *Transaction) (*Transaction, error) {
data, err := json.Marshal(tx) data, err := json.Marshal(tx)
if err != nil { if err != nil {

View file

@ -302,7 +302,7 @@ func (c *SimulatedBeacon) AdjustTime(adjustment time.Duration) error {
return errors.New("parent not found") return errors.New("parent not found")
} }
withdrawals := c.withdrawals.gatherPending(10) withdrawals := c.withdrawals.gatherPending(10)
return c.sealBlock(withdrawals, parent.Time+uint64(adjustment)) return c.sealBlock(withdrawals, parent.Time+uint64(adjustment/time.Second))
} }
func RegisterSimulatedBeaconAPIs(stack *node.Node, sim *SimulatedBeacon) { func RegisterSimulatedBeaconAPIs(stack *node.Node, sim *SimulatedBeacon) {

View file

@ -106,7 +106,7 @@ func TestAdjustTime(t *testing.T) {
block2, _ := client.BlockByNumber(context.Background(), nil) block2, _ := client.BlockByNumber(context.Background(), nil)
prevTime := block1.Time() prevTime := block1.Time()
newTime := block2.Time() newTime := block2.Time()
if newTime-prevTime != uint64(time.Minute) { if newTime-prevTime != 60 {
t.Errorf("adjusted time not equal to 60 seconds. prev: %v, new: %v", prevTime, newTime) t.Errorf("adjusted time not equal to 60 seconds. prev: %v, new: %v", prevTime, newTime)
} }
} }

View file

@ -125,7 +125,7 @@ func (srv *Server) portMappingLoop() {
if err != nil { if err != nil {
log.Debug("Couldn't get external IP", "err", err, "interface", srv.NAT) log.Debug("Couldn't get external IP", "err", err, "interface", srv.NAT)
} else if !ip.Equal(lastExtIP) { } else if !ip.Equal(lastExtIP) {
log.Debug("External IP changed", "ip", extip, "interface", srv.NAT) log.Debug("External IP changed", "ip", ip, "interface", srv.NAT)
} else { } else {
continue continue
} }

View file

@ -154,12 +154,8 @@ func (c *committer) store(path []byte, n node) node {
return hash return hash
} }
// MerkleResolver the children resolver in merkle-patricia-tree. // ForGatherChildren decodes the provided node and traverses the children inside.
type MerkleResolver struct{} func ForGatherChildren(node []byte, onChild func(common.Hash)) {
// ForEach implements childResolver, decodes the provided node and
// traverses the children inside.
func (resolver MerkleResolver) ForEach(node []byte, onChild func(common.Hash)) {
forGatherChildren(mustDecodeNodeUnsafe(nil, node), onChild) forGatherChildren(mustDecodeNodeUnsafe(nil, node), onChild)
} }

View file

@ -199,6 +199,57 @@ func (t *VerkleTrie) DeleteAccount(addr common.Address) error {
return nil return nil
} }
// RollBackAccount removes the account info + code from the tree, unlike DeleteAccount
// that will overwrite it with 0s. The first 64 storage slots are also removed.
func (t *VerkleTrie) RollBackAccount(addr common.Address) error {
var (
evaluatedAddr = t.cache.Get(addr.Bytes())
codeSizeKey = utils.CodeSizeKeyWithEvaluatedAddress(evaluatedAddr)
)
codeSizeBytes, err := t.root.Get(codeSizeKey, t.nodeResolver)
if err != nil {
return fmt.Errorf("rollback: error finding code size: %w", err)
}
if len(codeSizeBytes) == 0 {
return errors.New("rollback: code size is not existent")
}
codeSize := binary.LittleEndian.Uint64(codeSizeBytes)
// Delete the account header + first 64 slots + first 128 code chunks
key := common.CopyBytes(codeSizeKey)
for i := 0; i < verkle.NodeWidth; i++ {
key[31] = byte(i)
// this is a workaround to avoid deleting nil leaves, the lib needs to be
// fixed to be able to handle that
v, err := t.root.Get(key, t.nodeResolver)
if err != nil {
return fmt.Errorf("error rolling back account header: %w", err)
}
if len(v) == 0 {
continue
}
_, err = t.root.Delete(key, t.nodeResolver)
if err != nil {
return fmt.Errorf("error rolling back account header: %w", err)
}
}
// Delete all further code
for i, chunknr := uint64(32*128), uint64(128); i < codeSize; i, chunknr = i+32, chunknr+1 {
// evaluate group key at the start of a new group
groupOffset := (chunknr + 128) % 256
if groupOffset == 0 {
key = utils.CodeChunkKeyWithEvaluatedAddress(evaluatedAddr, uint256.NewInt(chunknr))
}
key[31] = byte(groupOffset)
_, err = t.root.Delete(key[:], t.nodeResolver)
if err != nil {
return fmt.Errorf("error deleting code chunk (addr=%x) error: %w", addr[:], err)
}
}
return nil
}
// DeleteStorage implements state.Trie, deleting the specified storage slot from // DeleteStorage implements state.Trie, deleting the specified storage slot from
// the trie. If the storage slot was not existent in the trie, no error will be // the trie. If the storage slot was not existent in the trie, no error will be
// returned. If the trie is corrupted, an error will be returned. // returned. If the trie is corrupted, an error will be returned.

View file

@ -24,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/trie/utils" "github.com/ethereum/go-ethereum/trie/utils"
"github.com/holiman/uint256" "github.com/holiman/uint256"
) )
@ -89,3 +90,84 @@ func TestVerkleTreeReadWrite(t *testing.T) {
} }
} }
} }
func TestVerkleRollBack(t *testing.T) {
db := newTestDatabase(rawdb.NewMemoryDatabase(), rawdb.PathScheme)
tr, _ := NewVerkleTrie(types.EmptyVerkleHash, db, utils.NewPointCache(100))
for addr, acct := range accounts {
if err := tr.UpdateAccount(addr, acct); err != nil {
t.Fatalf("Failed to update account, %v", err)
}
for key, val := range storages[addr] {
if err := tr.UpdateStorage(addr, key.Bytes(), val); err != nil {
t.Fatalf("Failed to update account, %v", err)
}
}
// create more than 128 chunks of code
code := make([]byte, 129*32)
for i := 0; i < len(code); i += 2 {
code[i] = 0x60
code[i+1] = byte(i % 256)
}
hash := crypto.Keccak256Hash(code)
if err := tr.UpdateContractCode(addr, hash, code); err != nil {
t.Fatalf("Failed to update contract, %v", err)
}
}
// Check that things were created
for addr, acct := range accounts {
stored, err := tr.GetAccount(addr)
if err != nil {
t.Fatalf("Failed to get account, %v", err)
}
if !reflect.DeepEqual(stored, acct) {
t.Fatal("account is not matched")
}
for key, val := range storages[addr] {
stored, err := tr.GetStorage(addr, key.Bytes())
if err != nil {
t.Fatalf("Failed to get storage, %v", err)
}
if !bytes.Equal(stored, val) {
t.Fatal("storage is not matched")
}
}
}
// ensure there is some code in the 2nd group
keyOf2ndGroup := []byte{141, 124, 185, 236, 50, 22, 185, 39, 244, 47, 97, 209, 96, 235, 22, 13, 205, 38, 18, 201, 128, 223, 0, 59, 146, 199, 222, 119, 133, 13, 91, 0}
chunk, err := tr.root.Get(keyOf2ndGroup, nil)
if err != nil {
t.Fatalf("Failed to get account, %v", err)
}
if len(chunk) == 0 {
t.Fatal("account was not created ")
}
// Rollback first account and check that it is gone
addr1 := common.Address{1}
err = tr.RollBackAccount(addr1)
if err != nil {
t.Fatalf("error rolling back address 1: %v", err)
}
// ensure the account is gone
stored, err := tr.GetAccount(addr1)
if err != nil {
t.Fatalf("Failed to get account, %v", err)
}
if stored != nil {
t.Fatal("account was not deleted")
}
// ensure that the last code chunk is also gone from the tree
chunk, err = tr.root.Get(keyOf2ndGroup, nil)
if err != nil {
t.Fatalf("Failed to get account, %v", err)
}
if len(chunk) != 0 {
t.Fatal("account was not deleted")
}
}

View file

@ -23,7 +23,6 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/trienode" "github.com/ethereum/go-ethereum/trie/trienode"
"github.com/ethereum/go-ethereum/trie/triestate" "github.com/ethereum/go-ethereum/trie/triestate"
"github.com/ethereum/go-ethereum/triedb/database" "github.com/ethereum/go-ethereum/triedb/database"
@ -43,9 +42,18 @@ type Config struct {
// default settings. // default settings.
var HashDefaults = &Config{ var HashDefaults = &Config{
Preimages: false, Preimages: false,
IsVerkle: false,
HashDB: hashdb.Defaults, HashDB: hashdb.Defaults,
} }
// VerkleDefaults represents a config for holding verkle trie data
// using path-based scheme with default settings.
var VerkleDefaults = &Config{
Preimages: false,
IsVerkle: true,
PathDB: pathdb.Defaults,
}
// backend defines the methods needed to access/update trie nodes in different // backend defines the methods needed to access/update trie nodes in different
// state scheme. // state scheme.
type backend interface { type backend interface {
@ -85,7 +93,6 @@ type backend interface {
// relevant with trie nodes and node preimages. // relevant with trie nodes and node preimages.
type Database struct { type Database struct {
config *Config // Configuration for trie database config *Config // Configuration for trie database
diskdb ethdb.Database // Persistent database to store the snapshot
preimages *preimageStore // The store for caching preimages preimages *preimageStore // The store for caching preimages
backend backend // The backend for managing trie nodes backend backend // The backend for managing trie nodes
} }
@ -103,7 +110,6 @@ func NewDatabase(diskdb ethdb.Database, config *Config) *Database {
} }
db := &Database{ db := &Database{
config: config, config: config,
diskdb: diskdb,
preimages: preimages, preimages: preimages,
} }
if config.HashDB != nil && config.PathDB != nil { if config.HashDB != nil && config.PathDB != nil {
@ -112,14 +118,7 @@ func NewDatabase(diskdb ethdb.Database, config *Config) *Database {
if config.PathDB != nil { if config.PathDB != nil {
db.backend = pathdb.New(diskdb, config.PathDB, config.IsVerkle) db.backend = pathdb.New(diskdb, config.PathDB, config.IsVerkle)
} else { } else {
var resolver hashdb.ChildResolver db.backend = hashdb.New(diskdb, config.HashDB)
if config.IsVerkle {
// TODO define verkle resolver
log.Crit("verkle does not use a hash db")
} else {
resolver = trie.MerkleResolver{}
}
db.backend = hashdb.New(diskdb, config.HashDB, resolver)
} }
return db return db
} }

View file

@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/trienode" "github.com/ethereum/go-ethereum/trie/trienode"
"github.com/ethereum/go-ethereum/trie/triestate" "github.com/ethereum/go-ethereum/trie/triestate"
"github.com/ethereum/go-ethereum/triedb/database" "github.com/ethereum/go-ethereum/triedb/database"
@ -60,12 +61,6 @@ var (
memcacheCommitBytesMeter = metrics.NewRegisteredMeter("hashdb/memcache/commit/bytes", nil) memcacheCommitBytesMeter = metrics.NewRegisteredMeter("hashdb/memcache/commit/bytes", nil)
) )
// ChildResolver defines the required method to decode the provided
// trie node and iterate the children on top.
type ChildResolver interface {
ForEach(node []byte, onChild func(common.Hash))
}
// Config contains the settings for database. // Config contains the settings for database.
type Config struct { type Config struct {
CleanCacheSize int // Maximum memory allowance (in bytes) for caching clean nodes CleanCacheSize int // Maximum memory allowance (in bytes) for caching clean nodes
@ -85,8 +80,6 @@ var Defaults = &Config{
// periodically flush a couple tries to disk, garbage collecting the remainder. // periodically flush a couple tries to disk, garbage collecting the remainder.
type Database struct { type Database struct {
diskdb ethdb.Database // Persistent storage for matured trie nodes diskdb ethdb.Database // Persistent storage for matured trie nodes
resolver ChildResolver // The handler to resolve children of nodes
cleans *fastcache.Cache // GC friendly memory cache of clean node RLPs cleans *fastcache.Cache // GC friendly memory cache of clean node RLPs
dirties map[common.Hash]*cachedNode // Data and references relationships of dirty trie nodes dirties map[common.Hash]*cachedNode // Data and references relationships of dirty trie nodes
oldest common.Hash // Oldest tracked node, flush-list head oldest common.Hash // Oldest tracked node, flush-list head
@ -124,15 +117,15 @@ var cachedNodeSize = int(reflect.TypeOf(cachedNode{}).Size())
// forChildren invokes the callback for all the tracked children of this node, // forChildren invokes the callback for all the tracked children of this node,
// both the implicit ones from inside the node as well as the explicit ones // both the implicit ones from inside the node as well as the explicit ones
// from outside the node. // from outside the node.
func (n *cachedNode) forChildren(resolver ChildResolver, onChild func(hash common.Hash)) { func (n *cachedNode) forChildren(onChild func(hash common.Hash)) {
for child := range n.external { for child := range n.external {
onChild(child) onChild(child)
} }
resolver.ForEach(n.node, onChild) trie.ForGatherChildren(n.node, onChild)
} }
// New initializes the hash-based node database. // New initializes the hash-based node database.
func New(diskdb ethdb.Database, config *Config, resolver ChildResolver) *Database { func New(diskdb ethdb.Database, config *Config) *Database {
if config == nil { if config == nil {
config = Defaults config = Defaults
} }
@ -142,7 +135,6 @@ func New(diskdb ethdb.Database, config *Config, resolver ChildResolver) *Databas
} }
return &Database{ return &Database{
diskdb: diskdb, diskdb: diskdb,
resolver: resolver,
cleans: cleans, cleans: cleans,
dirties: make(map[common.Hash]*cachedNode), dirties: make(map[common.Hash]*cachedNode),
} }
@ -163,7 +155,7 @@ func (db *Database) insert(hash common.Hash, node []byte) {
node: node, node: node,
flushPrev: db.newest, flushPrev: db.newest,
} }
entry.forChildren(db.resolver, func(child common.Hash) { entry.forChildren(func(child common.Hash) {
if c := db.dirties[child]; c != nil { if c := db.dirties[child]; c != nil {
c.parents++ c.parents++
} }
@ -316,7 +308,7 @@ func (db *Database) dereference(hash common.Hash) {
db.dirties[node.flushNext].flushPrev = node.flushPrev db.dirties[node.flushNext].flushPrev = node.flushPrev
} }
// Dereference all children and delete the node // Dereference all children and delete the node
node.forChildren(db.resolver, func(child common.Hash) { node.forChildren(func(child common.Hash) {
db.dereference(child) db.dereference(child)
}) })
delete(db.dirties, hash) delete(db.dirties, hash)
@ -465,7 +457,7 @@ func (db *Database) commit(hash common.Hash, batch ethdb.Batch, uncacher *cleane
var err error var err error
// Dereference all children and delete the node // Dereference all children and delete the node
node.forChildren(db.resolver, func(child common.Hash) { node.forChildren(func(child common.Hash) {
if err == nil { if err == nil {
err = db.commit(child, batch, uncacher) err = db.commit(child, batch, uncacher)
} }

View file

@ -152,6 +152,14 @@ func New(diskdb ethdb.Database, config *Config, isVerkle bool) *Database {
} }
config = config.sanitize() config = config.sanitize()
// Establish a dedicated database namespace tailored for verkle-specific
// data, ensuring the isolation of both verkle and merkle tree data. It's
// important to note that the introduction of a prefix won't lead to
// substantial storage overhead, as the underlying database will efficiently
// compress the shared key prefix.
if isVerkle {
diskdb = rawdb.NewTable(diskdb, string(rawdb.VerklePrefix))
}
db := &Database{ db := &Database{
readOnly: config.ReadOnly, readOnly: config.ReadOnly,
isVerkle: isVerkle, isVerkle: isVerkle,
@ -190,7 +198,7 @@ func (db *Database) repairHistory() error {
// all of them. Fix the tests first. // all of them. Fix the tests first.
return nil return nil
} }
freezer, err := rawdb.NewStateFreezer(ancient, db.readOnly) freezer, err := rawdb.NewStateFreezer(ancient, db.isVerkle, db.readOnly)
if err != nil { if err != nil {
log.Crit("Failed to open state history freezer", "err", err) log.Crit("Failed to open state history freezer", "err", err)
} }

View file

@ -129,7 +129,7 @@ func TestTruncateHeadHistory(t *testing.T) {
roots []common.Hash roots []common.Hash
hs = makeHistories(10) hs = makeHistories(10)
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false) freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false, false)
) )
defer freezer.Close() defer freezer.Close()
@ -157,7 +157,7 @@ func TestTruncateTailHistory(t *testing.T) {
roots []common.Hash roots []common.Hash
hs = makeHistories(10) hs = makeHistories(10)
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false) freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false, false)
) )
defer freezer.Close() defer freezer.Close()
@ -200,7 +200,7 @@ func TestTruncateTailHistories(t *testing.T) {
roots []common.Hash roots []common.Hash
hs = makeHistories(10) hs = makeHistories(10)
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
freezer, _ = rawdb.NewStateFreezer(t.TempDir()+fmt.Sprintf("%d", i), false) freezer, _ = rawdb.NewStateFreezer(t.TempDir()+fmt.Sprintf("%d", i), false, false)
) )
defer freezer.Close() defer freezer.Close()
@ -228,7 +228,7 @@ func TestTruncateOutOfRange(t *testing.T) {
var ( var (
hs = makeHistories(10) hs = makeHistories(10)
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false) freezer, _ = rawdb.NewStateFreezer(t.TempDir(), false, false)
) )
defer freezer.Close() defer freezer.Close()