Skip to content

Commit

Permalink
Closes stateDatabase.TrieDB() after finishing using it
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed May 24, 2024
1 parent b58fd17 commit 5536d22
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions arbos/arbosState/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ func TriedbConfig(c *core.CacheConfig) *trie.Config {
return config
}

func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (common.Hash, error) {
func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) {
triedbConfig := TriedbConfig(cacheConfig)
triedbConfig.Preimages = false
stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig)
defer func() {
err = stateDatabase.TrieDB().Close()
}()
statedb, err := state.New(common.Hash{}, stateDatabase, nil)
if err != nil {
log.Crit("failed to init empty statedb", "error", err)
Expand Down Expand Up @@ -160,7 +163,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig,
return common.Hash{}, err
}

root, err := statedb.Commit(chainConfig.ArbitrumChainParams.GenesisBlockNum, true)
root, err = statedb.Commit(chainConfig.ArbitrumChainParams.GenesisBlockNum, true)
if err != nil {
return common.Hash{}, err
}
Expand Down

0 comments on commit 5536d22

Please sign in to comment.