Skip to content

Commit e93930d

Browse files
authored
feat: use --gcmode=archive and --cache.noprefetch=true by default (#482)
* feat: use --gcmode=archive and --cache.noprefetch=true by default * refuse to start with invalid config * lint * lint
1 parent d02a410 commit e93930d

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

cmd/utils/flags.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ func printHelp(out io.Writer, templ string, data interface{}) {
104104
w.Flush()
105105
}
106106

107+
const (
108+
GCModeFull = "full"
109+
GCModeArchive = "archive"
110+
)
111+
107112
// These are all the command line flags we support.
108113
// If you add to this list, please remember to include the
109114
// flag in the appropriate command definition.
@@ -233,7 +238,7 @@ var (
233238
GCModeFlag = cli.StringFlag{
234239
Name: "gcmode",
235240
Usage: `Blockchain garbage collection mode ("full", "archive")`,
236-
Value: "full",
241+
Value: GCModeArchive,
237242
}
238243
SnapshotFlag = cli.BoolTFlag{
239244
Name: "snapshot",
@@ -432,7 +437,7 @@ var (
432437
Usage: "Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)",
433438
Value: 10,
434439
}
435-
CacheNoPrefetchFlag = cli.BoolFlag{
440+
CacheNoPrefetchFlag = cli.BoolTFlag{
436441
Name: "cache.noprefetch",
437442
Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)",
438443
}
@@ -1564,7 +1569,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
15641569
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, ScrollAlphaFlag, ScrollSepoliaFlag)
15651570
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
15661571
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
1567-
if ctx.GlobalString(GCModeFlag.Name) == "archive" && ctx.GlobalUint64(TxLookupLimitFlag.Name) != 0 {
1572+
if ctx.GlobalString(GCModeFlag.Name) == GCModeArchive && ctx.GlobalUint64(TxLookupLimitFlag.Name) != 0 {
15681573
ctx.GlobalSet(TxLookupLimitFlag.Name, "0")
15691574
log.Warn("Disable transaction unindexing for archive node")
15701575
}
@@ -1618,11 +1623,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16181623
cfg.DatabaseFreezer = ctx.GlobalString(AncientFlag.Name)
16191624
}
16201625

1621-
if gcmode := ctx.GlobalString(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" {
1626+
if gcmode := ctx.GlobalString(GCModeFlag.Name); gcmode != GCModeFull && gcmode != GCModeArchive {
16221627
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
16231628
}
16241629
if ctx.GlobalIsSet(GCModeFlag.Name) {
1625-
cfg.NoPruning = ctx.GlobalString(GCModeFlag.Name) == "archive"
1630+
cfg.NoPruning = ctx.GlobalString(GCModeFlag.Name) == GCModeArchive
16261631
}
16271632
if ctx.GlobalIsSet(CacheNoPrefetchFlag.Name) {
16281633
cfg.NoPrefetch = ctx.GlobalBool(CacheNoPrefetchFlag.Name)
@@ -1740,6 +1745,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
17401745
stack.Config().L1Confirmations = rpc.FinalizedBlockNumber
17411746
log.Info("Setting flag", "--l1.sync.startblock", "4038000")
17421747
stack.Config().L1DeploymentBlock = 4038000
1748+
// double check correct config
1749+
if ctx.GlobalString(GCModeFlag.Name) != GCModeArchive {
1750+
log.Crit("Must use --gcmode=archive")
1751+
}
1752+
log.Info("Setting flag", "--gcmode", ctx.GlobalString(GCModeFlag.Name))
1753+
if !ctx.GlobalBool(CacheNoPrefetchFlag.Name) {
1754+
log.Crit("Must use --cache.noprefetch")
1755+
}
1756+
log.Info("Setting flag", "--cache.noprefetch", ctx.GlobalBool(CacheNoPrefetchFlag.Name))
17431757
case ctx.GlobalBool(DeveloperFlag.Name):
17441758
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
17451759
cfg.NetworkId = 1337
@@ -2014,14 +2028,14 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
20142028
}, nil, false)
20152029
}
20162030
}
2017-
if gcmode := ctx.GlobalString(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" {
2031+
if gcmode := ctx.GlobalString(GCModeFlag.Name); gcmode != GCModeFull && gcmode != GCModeArchive {
20182032
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
20192033
}
20202034
cache := &core.CacheConfig{
20212035
TrieCleanLimit: ethconfig.Defaults.TrieCleanCache,
20222036
TrieCleanNoPrefetch: ctx.GlobalBool(CacheNoPrefetchFlag.Name),
20232037
TrieDirtyLimit: ethconfig.Defaults.TrieDirtyCache,
2024-
TrieDirtyDisabled: ctx.GlobalString(GCModeFlag.Name) == "archive",
2038+
TrieDirtyDisabled: ctx.GlobalString(GCModeFlag.Name) == GCModeArchive,
20252039
TrieTimeLimit: ethconfig.Defaults.TrieTimeout,
20262040
SnapshotLimit: ethconfig.Defaults.SnapshotCache,
20272041
Preimages: ctx.GlobalBool(CachePreimagesFlag.Name),

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 4 // Major version component of the current release
2626
VersionMinor = 3 // Minor version component of the current release
27-
VersionPatch = 49 // Patch version component of the current release
27+
VersionPatch = 50 // Patch version component of the current release
2828
VersionMeta = "sepolia" // Version metadata to append to the version string
2929
)
3030

0 commit comments

Comments
 (0)