Skip to content

Commit

Permalink
Bump the geth cache on OP stack mainnet chains
Browse files Browse the repository at this point in the history
This now checks if the `--beta.op-network` flag is set & then further
checks if it is a mainnet network or a testnet. If it is a mainnet network,
the cache sized is bumped to 4 gigs.
  • Loading branch information
trianglesphere committed Oct 17, 2023
1 parent ec46803 commit 404a6e7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ func prepare(ctx *cli.Context) {
to 0, and discovery is disabled.
`)

case ctx.IsSet(utils.BetaOPNetworkFlag.Name):
log.Info("Starting geth on an OP network...", "network", ctx.String(utils.BetaOPNetworkFlag.Name))

case !ctx.IsSet(utils.NetworkIdFlag.Name):
log.Info("Starting Geth on Ethereum mainnet...")
}
Expand All @@ -322,9 +325,16 @@ func prepare(ctx *cli.Context) {
!ctx.IsSet(utils.GoerliFlag.Name) &&
!ctx.IsSet(utils.DeveloperFlag.Name) {
// Nope, we're really on mainnet. Bump that cache up!
// Note: If we don't set the OPNetworkFlag and have already initialized the database, we may hit this case.
log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096)
ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096))
}
} else if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) && ctx.IsSet(utils.BetaOPNetworkFlag.Name) {
// We haven't set the cache, but may used the OP network flag we may be on an OP stack mainnet.
if strings.Contains(ctx.String(utils.BetaOPNetworkFlag.Name), "mainnet") {
log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096, "network", ctx.String(utils.BetaOPNetworkFlag.Name))
ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096))
}
}
// If we're running a light client on any network, drop the cache to some meaningfully low amount
if ctx.String(utils.SyncModeFlag.Name) == "light" && !ctx.IsSet(utils.CacheFlag.Name) {
Expand Down

0 comments on commit 404a6e7

Please sign in to comment.