Skip to content

Commit

Permalink
feat: init genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
joeylichang committed Aug 12, 2024
1 parent 6cf5169 commit e1a2b8e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ func (c *CacheConfig) triedbConfig() *triedb.Config {
JournalFile: c.JournalFile,
}
}
if c.StateScheme == rawdb.VersionScheme {
config.IsVersion = true
}
return config
}

Expand Down
2 changes: 1 addition & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func flushAlloc(ga *types.GenesisAlloc, db ethdb.Database, triedb *triedb.Databa
return err
}
// Commit newly generated states into disk if it's not empty.
if root != types.EmptyRootHash {
if root != types.EmptyRootHash && triedb.Scheme() != rawdb.VersionScheme {
if err := triedb.Commit(root, true); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions core/state/caching_versa_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (cv *cachingVersaDB) OpenTrie(root common.Hash) (Trie, error) {
panic("account tree has open")
}

// TODO:: if root tree, versa db shouldb ignore check version
state, err := cv.versionDB.OpenState(0, root, cv.mode)
// TODO:: if root tree, versa db should ignore check version, temp use -1
state, err := cv.versionDB.OpenState(-1, root, cv.mode)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/route53 v1.30.2
github.com/bnb-chain/fastssz v0.1.2
github.com/bnb-chain/ics23 v0.1.0
github.com/bnb-chain/versioned-state-database v0.0.0-20240809035848-76ffc0e09a92
github.com/bnb-chain/versioned-state-database v0.0.0-00010101000000-000000000000
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/cespare/cp v1.1.1
github.com/cloudflare/cloudflare-go v0.79.0
Expand Down
2 changes: 1 addition & 1 deletion triedb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type Database struct {
// NewDatabase initializes the trie database with default settings, note
// the legacy hash-based scheme is used by default.
func NewDatabase(diskdb ethdb.Database, config *Config) *Database {
if config.IsVersion {
if config != nil && config.IsVersion {
// TODO:: Wait for debugging to stabilize, and then consider initialization compatibility with other databases
db := &Database{
config: config,
Expand Down

0 comments on commit e1a2b8e

Please sign in to comment.