Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't save every state on archive node #1542

Merged
merged 28 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c97fac3
update geth
magicxyyz Mar 29, 2023
65aaa49
add initial test for skipping saving states
magicxyyz Mar 29, 2023
3f46628
improve not saving states tests
magicxyyz Mar 30, 2023
4cbf2eb
update geth
magicxyyz Apr 11, 2023
9d7f088
fix test failure message
magicxyyz Apr 11, 2023
22c9df3
update geth
magicxyyz Jun 13, 2023
482eb81
Merge branch 'recreate-state-for-rpcs' into dont-save-every-state
magicxyyz Jun 13, 2023
1bf5586
update geth
magicxyyz Jun 13, 2023
cb65f7e
fix recreate state test build
magicxyyz Jun 13, 2023
e165f3d
update geth
magicxyyz Jun 15, 2023
fad06ab
Merge branch 'master' into dont-save-every-state
magicxyyz Jun 15, 2023
e8767b7
update geth
magicxyyz Jun 15, 2023
2773f3b
Merge branch 'recreate-state-for-rpcs' into dont-save-every-state
magicxyyz Jun 15, 2023
cba9cea
add MaxNumberOfBlocksToSkipStateSaving and MaxAmountOfGasToSkipStateS…
magicxyyz Jun 16, 2023
3c4ba0a
update geth
magicxyyz Sep 7, 2023
295c90d
Merge branch 'master' into dont-save-every-state
magicxyyz Sep 7, 2023
8e9d787
remove not used parameter of stackConfigForTest
magicxyyz Sep 7, 2023
0b42d1f
make sure that each test tx is included in next block
magicxyyz Sep 7, 2023
68c0039
simplify test params
magicxyyz Sep 7, 2023
c67b318
shorten state saving skipping test
magicxyyz Sep 7, 2023
20b213a
clean extra return values form prepareNodeWithHistory
magicxyyz Sep 7, 2023
0e0fe26
refactor setting cache config in tests
magicxyyz Sep 8, 2023
cc58fbb
fix staker test
magicxyyz Sep 8, 2023
97c0ec5
Merge branch 'master' into dont-save-every-state
magicxyyz Sep 8, 2023
d0aac0f
Merge branch 'master' into dont-save-every-state
magicxyyz Sep 19, 2023
3bf7dd0
update geth
magicxyyz Sep 26, 2023
90a2599
Merge branch 'master' into dont-save-every-state
magicxyyz Sep 26, 2023
4d2ddce
Merge branch 'master' into dont-save-every-state
magicxyyz Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 38 additions & 30 deletions arbnode/execution/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ import (
)

type CachingConfig struct {
Archive bool `koanf:"archive"`
BlockCount uint64 `koanf:"block-count"`
BlockAge time.Duration `koanf:"block-age"`
TrieTimeLimit time.Duration `koanf:"trie-time-limit"`
TrieDirtyCache int `koanf:"trie-dirty-cache"`
TrieCleanCache int `koanf:"trie-clean-cache"`
SnapshotCache int `koanf:"snapshot-cache"`
DatabaseCache int `koanf:"database-cache"`
SnapshotRestoreMaxGas uint64 `koanf:"snapshot-restore-gas-limit"`
Archive bool `koanf:"archive"`
BlockCount uint64 `koanf:"block-count"`
BlockAge time.Duration `koanf:"block-age"`
TrieTimeLimit time.Duration `koanf:"trie-time-limit"`
TrieDirtyCache int `koanf:"trie-dirty-cache"`
TrieCleanCache int `koanf:"trie-clean-cache"`
SnapshotCache int `koanf:"snapshot-cache"`
DatabaseCache int `koanf:"database-cache"`
SnapshotRestoreMaxGas uint64 `koanf:"snapshot-restore-gas-limit"`
MaxNumberOfBlocksToSkipStateSaving uint32 `koanf:"max-number-of-blocks-to-skip-state-saving"`
MaxAmountOfGasToSkipStateSaving uint64 `koanf:"max-amount-of-gas-to-skip-state-saving"`
}

func CachingConfigAddOptions(prefix string, f *flag.FlagSet) {
Expand All @@ -46,18 +48,22 @@ func CachingConfigAddOptions(prefix string, f *flag.FlagSet) {
f.Int(prefix+".snapshot-cache", DefaultCachingConfig.SnapshotCache, "amount of memory in megabytes to cache state snapshots with")
f.Int(prefix+".database-cache", DefaultCachingConfig.DatabaseCache, "amount of memory in megabytes to cache database contents with")
f.Uint64(prefix+".snapshot-restore-gas-limit", DefaultCachingConfig.SnapshotRestoreMaxGas, "maximum gas rolled back to recover snapshot")
f.Uint32(prefix+".max-number-of-blocks-to-skip-state-saving", DefaultCachingConfig.MaxNumberOfBlocksToSkipStateSaving, "maximum number of blocks to skip state saving to persistent storage (archive node only)")
f.Uint64(prefix+".max-amount-of-gas-to-skip-state-saving", DefaultCachingConfig.MaxAmountOfGasToSkipStateSaving, "maximum amount of gas in blocks to skip saving state to Persistent storage (archive node only)")
}

var DefaultCachingConfig = CachingConfig{
Archive: false,
BlockCount: 128,
BlockAge: 30 * time.Minute,
TrieTimeLimit: time.Hour,
TrieDirtyCache: 1024,
TrieCleanCache: 600,
SnapshotCache: 400,
DatabaseCache: 2048,
SnapshotRestoreMaxGas: 300_000_000_000,
Archive: false,
BlockCount: 128,
BlockAge: 30 * time.Minute,
TrieTimeLimit: time.Hour,
TrieDirtyCache: 1024,
TrieCleanCache: 600,
SnapshotCache: 400,
DatabaseCache: 2048,
SnapshotRestoreMaxGas: 300_000_000_000,
MaxNumberOfBlocksToSkipStateSaving: 127,
MaxAmountOfGasToSkipStateSaving: 15 * 1000 * 1000,
}

func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core.CacheConfig {
Expand All @@ -67,18 +73,20 @@ func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core
}

return &core.CacheConfig{
TrieCleanLimit: cachingConfig.TrieCleanCache,
TrieCleanJournal: stack.ResolvePath(baseConf.TrieCleanCacheJournal),
TrieCleanRejournal: baseConf.TrieCleanCacheRejournal,
TrieCleanNoPrefetch: baseConf.NoPrefetch,
TrieDirtyLimit: cachingConfig.TrieDirtyCache,
TrieDirtyDisabled: cachingConfig.Archive,
TrieTimeLimit: cachingConfig.TrieTimeLimit,
TriesInMemory: cachingConfig.BlockCount,
TrieRetention: cachingConfig.BlockAge,
SnapshotLimit: cachingConfig.SnapshotCache,
Preimages: baseConf.Preimages,
SnapshotRestoreMaxGas: cachingConfig.SnapshotRestoreMaxGas,
TrieCleanLimit: cachingConfig.TrieCleanCache,
TrieCleanJournal: stack.ResolvePath(baseConf.TrieCleanCacheJournal),
TrieCleanRejournal: baseConf.TrieCleanCacheRejournal,
TrieCleanNoPrefetch: baseConf.NoPrefetch,
TrieDirtyLimit: cachingConfig.TrieDirtyCache,
TrieDirtyDisabled: cachingConfig.Archive,
TrieTimeLimit: cachingConfig.TrieTimeLimit,
TriesInMemory: cachingConfig.BlockCount,
TrieRetention: cachingConfig.BlockAge,
SnapshotLimit: cachingConfig.SnapshotCache,
Preimages: baseConf.Preimages,
SnapshotRestoreMaxGas: cachingConfig.SnapshotRestoreMaxGas,
MaxNumberOfBlocksToSkipStateSaving: cachingConfig.MaxNumberOfBlocksToSkipStateSaving,
MaxAmountOfGasToSkipStateSaving: cachingConfig.MaxAmountOfGasToSkipStateSaving,
}
}

Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 1 files
+33 −3 core/blockchain.go
12 changes: 8 additions & 4 deletions system_tests/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func createTestL1BlockChain(t *testing.T, l1info info) (info, *ethclient.Client,
return createTestL1BlockChainWithConfig(t, l1info, nil)
}

func stackConfigForTest(t *testing.T) *node.Config {
func stackConfigForTest(t *testing.T, dataDir string) *node.Config {
magicxyyz marked this conversation as resolved.
Show resolved Hide resolved
stackConfig := node.DefaultConfig
stackConfig.HTTPPort = 0
stackConfig.WSPort = 0
Expand All @@ -290,7 +290,11 @@ func stackConfigForTest(t *testing.T) *node.Config {
stackConfig.P2P.NoDial = true
stackConfig.P2P.NoDiscovery = true
stackConfig.P2P.NAT = nil
stackConfig.DataDir = t.TempDir()
if dataDir != "" {
stackConfig.DataDir = dataDir
} else {
stackConfig.DataDir = t.TempDir()
}
return &stackConfig
}

Expand Down Expand Up @@ -381,7 +385,7 @@ func createTestL1BlockChainWithConfig(t *testing.T, l1info info, stackConfig *no
l1info = NewL1TestInfo(t)
}
if stackConfig == nil {
stackConfig = stackConfigForTest(t)
stackConfig = stackConfigForTest(t, "")
}
l1info.GenerateAccount("Faucet")

Expand Down Expand Up @@ -699,7 +703,7 @@ func Create2ndNodeWithConfig(
l1client := ethclient.NewClient(l1rpcClient)

if stackConfig == nil {
stackConfig = stackConfigForTest(t)
stackConfig = stackConfigForTest(t, "")
}
l2stack, err := node.New(stackConfig)
Require(t, err)
Expand Down
8 changes: 4 additions & 4 deletions system_tests/forwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestStaticForwarder(t *testing.T) {
ipcPath := filepath.Join(t.TempDir(), "test.ipc")
ipcConfig := genericconf.IPCConfigDefault
ipcConfig.Path = ipcPath
stackConfig := stackConfigForTest(t)
stackConfig := stackConfigForTest(t, "")
ipcConfig.Apply(stackConfig)
nodeConfigA := arbnode.ConfigDefaultL1Test()
nodeConfigA.BatchPoster.Enable = false
Expand Down Expand Up @@ -96,7 +96,7 @@ func fallbackSequencer(
ctx context.Context, t *testing.T, opts *fallbackSequencerOpts,
) (l2info info, currentNode *arbnode.Node, l2client *ethclient.Client,
l1info info, l1backend *eth.Ethereum, l1client *ethclient.Client, l1stack *node.Node) {
stackConfig := stackConfigForTest(t)
stackConfig := stackConfigForTest(t, "")
ipcConfig := genericconf.IPCConfigDefault
ipcConfig.Path = opts.ipcPath
ipcConfig.Apply(stackConfig)
Expand All @@ -117,7 +117,7 @@ func createForwardingNode(
redisUrl string,
fallbackPath string,
) (*ethclient.Client, *arbnode.Node) {
stackConfig := stackConfigForTest(t)
stackConfig := stackConfigForTest(t, "")
if ipcPath != "" {
ipcConfig := genericconf.IPCConfigDefault
ipcConfig.Path = ipcPath
Expand All @@ -142,7 +142,7 @@ func createSequencer(
ipcPath string,
redisUrl string,
) (*ethclient.Client, *arbnode.Node) {
stackConfig := stackConfigForTest(t)
stackConfig := stackConfigForTest(t, "")
ipcConfig := genericconf.IPCConfigDefault
ipcConfig.Path = ipcPath
ipcConfig.Apply(stackConfig)
Expand Down
2 changes: 1 addition & 1 deletion system_tests/ipc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestIpcRpc(t *testing.T) {
ipcConfig := genericconf.IPCConfigDefault
ipcConfig.Path = ipcPath

stackConf := stackConfigForTest(t)
stackConf := stackConfigForTest(t, "")
ipcConfig.Apply(stackConf)

ctx, cancel := context.WithCancel(context.Background())
Expand Down
Loading