Skip to content

Commit

Permalink
Uses TriedbConfig from geth
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Jul 22, 2024
1 parent fc900cc commit 6f04d12
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
2 changes: 1 addition & 1 deletion arbos/arbosState/initialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin
stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0)
Require(t, err)

triedbConfig := TriedbConfig(cacheConfig)
triedbConfig := cacheConfig.TriedbConfig()
stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, triedbConfig), nil)
Require(t, err)

Expand Down
23 changes: 1 addition & 22 deletions arbos/arbosState/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/triedb"
"github.com/ethereum/go-ethereum/triedb/hashdb"
"github.com/ethereum/go-ethereum/triedb/pathdb"
"github.com/holiman/uint256"
"github.com/offchainlabs/nitro/arbos/arbostypes"
"github.com/offchainlabs/nitro/arbos/burn"
Expand Down Expand Up @@ -56,25 +52,8 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil))
}

func TriedbConfig(c *core.CacheConfig) *triedb.Config {
config := &triedb.Config{Preimages: c.Preimages}
if c.StateScheme == rawdb.HashScheme {
config.HashDB = &hashdb.Config{
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
}
}
if c.StateScheme == rawdb.PathScheme {
config.PathDB = &pathdb.Config{
StateHistory: c.StateHistory,
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
DirtyCacheSize: c.TrieDirtyLimit * 1024 * 1024,
}
}
return config
}

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 := cacheConfig.TriedbConfig()
triedbConfig.Preimages = false
stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig)
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion system_tests/state_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func FuzzStateTransition(f *testing.F) {
if err != nil {
panic(err)
}
trieDBConfig := arbosState.TriedbConfig(cacheConfig)
trieDBConfig := cacheConfig.TriedbConfig()
statedb, err := state.New(stateRoot, state.NewDatabaseWithConfig(chainDb, trieDBConfig), nil)
if err != nil {
panic(err)
Expand Down

0 comments on commit 6f04d12

Please sign in to comment.