Skip to content

Commit e1a2b8e

Browse files
committed
feat: init genesis
1 parent 6cf5169 commit e1a2b8e

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

core/blockchain.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ func (c *CacheConfig) triedbConfig() *triedb.Config {
196196
JournalFile: c.JournalFile,
197197
}
198198
}
199+
if c.StateScheme == rawdb.VersionScheme {
200+
config.IsVersion = true
201+
}
199202
return config
200203
}
201204

core/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func flushAlloc(ga *types.GenesisAlloc, db ethdb.Database, triedb *triedb.Databa
174174
return err
175175
}
176176
// Commit newly generated states into disk if it's not empty.
177-
if root != types.EmptyRootHash {
177+
if root != types.EmptyRootHash && triedb.Scheme() != rawdb.VersionScheme {
178178
if err := triedb.Commit(root, true); err != nil {
179179
return err
180180
}

core/state/caching_versa_db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func (cv *cachingVersaDB) OpenTrie(root common.Hash) (Trie, error) {
5252
panic("account tree has open")
5353
}
5454

55-
// TODO:: if root tree, versa db shouldb ignore check version
56-
state, err := cv.versionDB.OpenState(0, root, cv.mode)
55+
// TODO:: if root tree, versa db should ignore check version, temp use -1
56+
state, err := cv.versionDB.OpenState(-1, root, cv.mode)
5757
if err != nil {
5858
return nil, err
5959
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/aws/aws-sdk-go-v2/service/route53 v1.30.2
1313
github.com/bnb-chain/fastssz v0.1.2
1414
github.com/bnb-chain/ics23 v0.1.0
15-
github.com/bnb-chain/versioned-state-database v0.0.0-20240809035848-76ffc0e09a92
15+
github.com/bnb-chain/versioned-state-database v0.0.0-00010101000000-000000000000
1616
github.com/btcsuite/btcd/btcec/v2 v2.3.2
1717
github.com/cespare/cp v1.1.1
1818
github.com/cloudflare/cloudflare-go v0.79.0

triedb/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ type Database struct {
9696
// NewDatabase initializes the trie database with default settings, note
9797
// the legacy hash-based scheme is used by default.
9898
func NewDatabase(diskdb ethdb.Database, config *Config) *Database {
99-
if config.IsVersion {
99+
if config != nil && config.IsVersion {
100100
// TODO:: Wait for debugging to stabilize, and then consider initialization compatibility with other databases
101101
db := &Database{
102102
config: config,

0 commit comments

Comments
 (0)