diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index ea23f61abd..68c6367140 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -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) @@ -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 }