Skip to content

Commit

Permalink
Removes unncessary path logic when initializing arbos in database
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Jul 12, 2024
1 parent eb4df87 commit 6273c13
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions arbos/arbosState/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,9 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig,
if err != nil {
return common.Hash{}, err
}
// When using PathScheme TrieDB.Commit should only be called once.
// When using HashScheme it is called multiple times to avoid keeping
// the entire trie in memory.
if cacheConfig.StateScheme == rawdb.HashScheme {
err = stateDatabase.TrieDB().Commit(root, true)
if err != nil {
return common.Hash{}, err
}
err = stateDatabase.TrieDB().Commit(root, true)
if err != nil {
return common.Hash{}, err
}
statedb, err = state.New(root, stateDatabase, nil)
if err != nil {
Expand Down Expand Up @@ -196,18 +191,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig,
if err := accountDataReader.Close(); err != nil {
return common.Hash{}, err
}

root, err = commit()
if err != nil {
return common.Hash{}, err
}
if cacheConfig.StateScheme == rawdb.PathScheme {
err = stateDatabase.TrieDB().Commit(root, true)
if err != nil {
return common.Hash{}, err
}
}
return root, nil
return commit()
}

func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState, initData statetransfer.RetryableDataReader, currentTimestamp uint64) error {
Expand Down

0 comments on commit 6273c13

Please sign in to comment.