Skip to content

Commit

Permalink
Moves maintenance trie cap limit config to execution config
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Jan 24, 2025
1 parent ddd1e3e commit e9bda8d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
13 changes: 5 additions & 8 deletions arbnode/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ type MaintenanceRunner struct {
}

type MaintenanceConfig struct {
TimeOfDay string `koanf:"time-of-day" reload:"hot"`
Lock redislock.SimpleCfg `koanf:"lock" reload:"hot"`
TrieDBCapLimit int64 `koanf:"triedb-cap-limit" reload:"hot"`
TimeOfDay string `koanf:"time-of-day" reload:"hot"`
Lock redislock.SimpleCfg `koanf:"lock" reload:"hot"`

// Generated: the minutes since start of UTC day to compact at
minutesAfterMidnight int
Expand Down Expand Up @@ -76,14 +75,12 @@ func (c *MaintenanceConfig) Validate() error {

func MaintenanceConfigAddOptions(prefix string, f *flag.FlagSet) {
f.String(prefix+".time-of-day", DefaultMaintenanceConfig.TimeOfDay, "UTC 24-hour time of day to run maintenance (currently only db compaction) at (e.g. 15:00)")
f.Int(prefix+".triedb-cap-limit", int(DefaultMaintenanceConfig.TrieDBCapLimit), "amount of memory in bytes to be used in the TrieDB Cap operation")
redislock.AddConfigOptions(prefix+".lock", f)
}

var DefaultMaintenanceConfig = MaintenanceConfig{
TimeOfDay: "",
TrieDBCapLimit: 100 * 1024 * 1024,
Lock: redislock.DefaultCfg,
TimeOfDay: "",
Lock: redislock.DefaultCfg,

minutesAfterMidnight: 0,
}
Expand Down Expand Up @@ -186,7 +183,7 @@ func (mr *MaintenanceRunner) runMaintenance() {
}
expected++
go func() {
results <- mr.exec.Maintenance(mr.config().TrieDBCapLimit)
results <- mr.exec.Maintenance()
}()
for i := 0; i < expected; i++ {
err := <-results
Expand Down
3 changes: 3 additions & 0 deletions execution/gethexec/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type CachingConfig struct {
TrieTimeLimit time.Duration `koanf:"trie-time-limit"`
TrieDirtyCache int `koanf:"trie-dirty-cache"`
TrieCleanCache int `koanf:"trie-clean-cache"`
TrieCapLimit uint32 `koanf:"trie-cap-limit"`
SnapshotCache int `koanf:"snapshot-cache"`
DatabaseCache int `koanf:"database-cache"`
SnapshotRestoreGasLimit uint64 `koanf:"snapshot-restore-gas-limit"`
Expand All @@ -53,6 +54,7 @@ func CachingConfigAddOptions(prefix string, f *flag.FlagSet) {
f.Int(prefix+".trie-clean-cache", DefaultCachingConfig.TrieCleanCache, "amount of memory in megabytes to cache unchanged state trie nodes with")
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.Uint32(prefix+".trie-cap-limit", DefaultCachingConfig.TrieCapLimit, "amount of memory in megabytes to be used in the TrieDB Cap operation during maintenance")
f.Uint64(prefix+".snapshot-restore-gas-limit", DefaultCachingConfig.SnapshotRestoreGasLimit, "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) -- warning: this option seems to cause issues")
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) -- warning: this option seems to cause issues")
Expand All @@ -74,6 +76,7 @@ var DefaultCachingConfig = CachingConfig{
TrieTimeLimit: time.Hour,
TrieDirtyCache: 1024,
TrieCleanCache: 600,
TrieCapLimit: 100 * 1024 * 1024,
SnapshotCache: 400,
DatabaseCache: 2048,
SnapshotRestoreGasLimit: 300_000_000_000,
Expand Down
2 changes: 1 addition & 1 deletion execution/gethexec/executionengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,6 @@ func (s *ExecutionEngine) Start(ctx_in context.Context) {
}
}

func (s *ExecutionEngine) Maintenance(capLimit int64) error {
func (s *ExecutionEngine) Maintenance(capLimit uint64) error {
return s.bc.FlushTrieDB(&s.createBlocksMutex, common.StorageSize(capLimit))
}
5 changes: 3 additions & 2 deletions execution/gethexec/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,9 @@ func (n *ExecutionNode) MessageIndexToBlockNumber(messageNum arbutil.MessageInde
return n.ExecEngine.MessageIndexToBlockNumber(messageNum)
}

func (n *ExecutionNode) Maintenance(capLimit int64) error {
err := n.ExecEngine.Maintenance(capLimit)
func (n *ExecutionNode) Maintenance() error {
trieCapLimitBytes := 1024 * uint64(n.ConfigFetcher().Caching.TrieCapLimit)
err := n.ExecEngine.Maintenance(trieCapLimitBytes)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion execution/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type FullExecutionClient interface {
Start(ctx context.Context) error
StopAndWait()

Maintenance(capLimit int64) error
Maintenance() error

ArbOSVersionForMessageNumber(messageNum arbutil.MessageIndex) (uint64, error)
}
Expand Down
2 changes: 1 addition & 1 deletion system_tests/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestMaintenance(t *testing.T) {
Require(t, err)
}

err := builder.L2.ExecNode.Maintenance(100 * 1024 * 1024)
err := builder.L2.ExecNode.Maintenance()
Require(t, err)

for i := 2; i < 3+numberOfTransfers; i++ {
Expand Down

0 comments on commit e9bda8d

Please sign in to comment.