From c02298ad7c3b100aaa5bc752a072c8b4576d6baf Mon Sep 17 00:00:00 2001 From: redhdx Date: Thu, 11 Apr 2024 15:02:45 +0800 Subject: [PATCH 01/15] feature(op-geth): update config --- cmd/geth/main.go | 12 +++++++----- eth/ethconfig/config.go | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 05b34344a0..5c065c32ab 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -325,7 +325,7 @@ func prepare(ctx *cli.Context) { log.Info("Starting geth on an opBNB QAnet network...", "network", ctx.String(utils.OpBNBQANetFlag.Name)) case !ctx.IsSet(utils.NetworkIdFlag.Name): - log.Info("Starting Geth on Ethereum mainnet...") + log.Info("Starting Geth on opBNB mainnet...") } // If we're a full node on mainnet without --cache specified, bump default cache allowance if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) && !ctx.IsSet(utils.NetworkIdFlag.Name) { @@ -345,10 +345,6 @@ func prepare(ctx *cli.Context) { log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096, "network", ctx.String(utils.OPNetworkFlag.Name)) ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096)) } - } else if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) && ctx.IsSet(utils.OpBNBMainnetFlag.Name) { - // we're really on opBNB mainnet. Bump that cache up - log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096, "network", ctx.String(utils.OpBNBMainnetFlag.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) { @@ -356,6 +352,12 @@ func prepare(ctx *cli.Context) { ctx.Set(utils.CacheFlag.Name, strconv.Itoa(128)) } + // For opBNB, we set default cache to 32000, can override by setting cache flag + if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) { + log.Info("Bumping default cache on opBNB", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 32000) + ctx.Set(utils.CacheFlag.Name, strconv.Itoa(32000)) + } + // Start metrics export if enabled utils.SetupMetrics(ctx) diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 7f31961a9c..551b2e9c44 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -57,6 +57,30 @@ var LightClientGPO = gasprice.Config{ IgnorePrice: gasprice.DefaultIgnorePrice, } +// OpBNBDefaults contains default settings for use on the opBNB main net. +var OpBNBDefaults = Config{ + SyncMode: downloader.FullSync, + NetworkId: 204, + TxLookupLimit: 2350000, + TransactionHistory: 2350000, + StateHistory: params.FullImmutabilityThreshold, + LightPeers: 100, + DatabaseCache: 512, + TrieCleanCache: 154, + TrieDirtyCache: 256, + TrieTimeout: 60 * time.Minute, + TrieCommitInterval: 0, + SnapshotCache: 102, + FilterLogCacheSize: 32, + Miner: miner.DefaultConfig, + TxPool: legacypool.DefaultConfig, + BlobPool: blobpool.DefaultConfig, + RPCGasCap: 50000000, + RPCEVMTimeout: 5 * time.Second, + GPO: FullNodeGPO, + RPCTxFeeCap: 1, // 1 ether +} + // Defaults contains default settings for use on the Ethereum main net. var Defaults = Config{ SyncMode: downloader.SnapSync, From 072776a38760c61269da3d4dbb41f342aaa803e8 Mon Sep 17 00:00:00 2001 From: redhdx Date: Tue, 23 Apr 2024 16:06:23 +0800 Subject: [PATCH 02/15] feature(op-geth): opBNB default settings --- cmd/geth/config.go | 6 +++--- cmd/utils/flags.go | 10 ++++++++++ core/txpool/legacypool/legacypool.go | 18 ++++++++++++++++++ eth/ethconfig/config.go | 21 +++++++++++---------- metrics/config.go | 20 ++++++++++++++++++++ miner/miner.go | 21 +++++++++++++++++---- node/defaults.go | 28 ++++++++++++++++++++++++++++ 7 files changed, 107 insertions(+), 17 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 81128ab007..f1c751269a 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -115,7 +115,7 @@ func loadConfig(file string, cfg *gethConfig) error { func defaultNodeConfig() node.Config { git, _ := version.VCS() - cfg := node.DefaultConfig + cfg := node.DefaultOpBNBConfig cfg.Name = clientIdentifier cfg.Version = params.VersionWithCommit(git.Commit, git.Date) cfg.HTTPModules = append(cfg.HTTPModules, "eth") @@ -129,9 +129,9 @@ func defaultNodeConfig() node.Config { func loadBaseConfig(ctx *cli.Context) gethConfig { // Load defaults. cfg := gethConfig{ - Eth: ethconfig.Defaults, + Eth: ethconfig.OpBNBDefaults, Node: defaultNodeConfig(), - Metrics: metrics.DefaultConfig, + Metrics: metrics.DefaultOpBNBConfig, } // Load config file. diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index fc9ae0f96a..717b496333 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1171,6 +1171,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { if ctx.Uint64(NetworkIdFlag.Name) == params.OpBNBTestnet { urls = params.OpBNBTestnetBootnodes } + case ctx.Bool(OpBNBTestnetFlag.Name): + urls = params.OpBNBTestnetBootnodes } } cfg.BootstrapNodes = mustParseBootnodes(urls) @@ -1826,6 +1828,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc)) godebug.SetGCPercent(int(gogc)) + // set gc mode default value is archive for opBNB + if !ctx.IsSet(GCModeFlag.Name) { + err = ctx.Set(GCModeFlag.Name, "archive") + if err != nil { + log.Error("can't set gc mode", "err", err) + } + } + if ctx.IsSet(SyncTargetFlag.Name) { cfg.SyncMode = downloader.FullSync // dev sync target forces full sync } else if ctx.IsSet(SyncModeFlag.Name) { diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 41c96476be..2f2eb020a0 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -171,6 +171,24 @@ var DefaultConfig = Config{ ReannounceTime: 10 * 365 * 24 * time.Hour, } +// DefaultOpBNBConfig contains the default opBNB configurations for the transaction pool. +var DefaultOpBNBConfig = Config{ + Journal: "transactions.rlp", + Rejournal: time.Hour, + + PriceLimit: 1, + PriceBump: 10, + + AccountSlots: 200, + GlobalSlots: 10000, // urgent + floating queue capacity with 4:1 ratio + AccountQueue: 200, + GlobalQueue: 5000, + + Lifetime: 3 * time.Hour, + + ReannounceTime: 10 * 365 * 24 * time.Hour, +} + // sanitize checks the provided user configurations and changes anything that's // unreasonable or unworkable. func (config *Config) sanitize() Config { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 0ea2a951e5..800b3464df 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -58,10 +58,10 @@ var LightClientGPO = gasprice.Config{ IgnorePrice: gasprice.DefaultIgnorePrice, } -// OpBNBDefaults contains default settings for use on the opBNB main net. -var OpBNBDefaults = Config{ - SyncMode: downloader.FullSync, - NetworkId: 204, +// Defaults contains default settings for use on the Ethereum main net. +var Defaults = Config{ + SyncMode: downloader.SnapSync, + NetworkId: 1, TxLookupLimit: 2350000, TransactionHistory: 2350000, StateHistory: params.FullImmutabilityThreshold, @@ -82,10 +82,10 @@ var OpBNBDefaults = Config{ RPCTxFeeCap: 1, // 1 ether } -// Defaults contains default settings for use on the Ethereum main net. -var Defaults = Config{ - SyncMode: downloader.SnapSync, - NetworkId: 1, +// OpBNBDefaults contains default settings for use on the opBNB main net. +var OpBNBDefaults = Config{ + SyncMode: downloader.FullSync, + NetworkId: 204, TxLookupLimit: 2350000, TransactionHistory: 2350000, StateHistory: params.FullImmutabilityThreshold, @@ -97,13 +97,14 @@ var Defaults = Config{ TrieCommitInterval: 0, SnapshotCache: 102, FilterLogCacheSize: 32, - Miner: miner.DefaultConfig, - TxPool: legacypool.DefaultConfig, + Miner: miner.DefaultOpBNBConfig, + TxPool: legacypool.DefaultOpBNBConfig, BlobPool: blobpool.DefaultConfig, RPCGasCap: 50000000, RPCEVMTimeout: 5 * time.Second, GPO: FullNodeGPO, RPCTxFeeCap: 1, // 1 ether + Preimages: true, EnableOpcodeOptimizing: false, } diff --git a/metrics/config.go b/metrics/config.go index 2eb09fb48a..f3e6979fd9 100644 --- a/metrics/config.go +++ b/metrics/config.go @@ -54,3 +54,23 @@ var DefaultConfig = Config{ InfluxDBBucket: "geth", InfluxDBOrganization: "geth", } + +// DefaultOpBNBConfig is the default config for metrics used in opBNB. +var DefaultOpBNBConfig = Config{ + Enabled: true, + EnabledExpensive: false, + HTTP: "0.0.0.0", + Port: 6060, + EnableInfluxDB: false, + InfluxDBEndpoint: "http://localhost:8086", + InfluxDBDatabase: "geth", + InfluxDBUsername: "test", + InfluxDBPassword: "test", + InfluxDBTags: "host=localhost", + + // influxdbv2-specific flags + EnableInfluxDBV2: false, + InfluxDBToken: "test", + InfluxDBBucket: "geth", + InfluxDBOrganization: "geth", +} diff --git a/miner/miner.go b/miner/miner.go index 5c0ba3f815..940565d7e6 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -41,10 +41,10 @@ import ( var ( commitDepositTxsTimer = metrics.NewRegisteredTimer("miner/commit/deposit/txs", nil) - packFromTxpoolTimer = metrics.NewRegisteredTimer("miner/pack/txpool/txs", nil) - commitTxpoolTxsTimer = metrics.NewRegisteredTimer("miner/commit/txpool/txs", nil) - assembleBlockTimer = metrics.NewRegisteredTimer("miner/assemble/block", nil) - buildBlockTimer = metrics.NewRegisteredTimer("miner/build/block", nil) + packFromTxpoolTimer = metrics.NewRegisteredTimer("miner/pack/txpool/txs", nil) + commitTxpoolTxsTimer = metrics.NewRegisteredTimer("miner/commit/txpool/txs", nil) + assembleBlockTimer = metrics.NewRegisteredTimer("miner/assemble/block", nil) + buildBlockTimer = metrics.NewRegisteredTimer("miner/build/block", nil) accountReadTimer = metrics.NewRegisteredTimer("miner/account/reads", nil) accountHashTimer = metrics.NewRegisteredTimer("miner/account/hashes", nil) @@ -102,6 +102,19 @@ var DefaultConfig = Config{ NewPayloadTimeout: 2 * time.Second, } +// DefaultOpBNBConfig contains default opBNB settings for miner. +var DefaultOpBNBConfig = Config{ + GasCeil: 150000000, + GasPrice: big.NewInt(params.GWei), + + // The default recommit time is chosen as two seconds since + // consensus-layer usually will wait a half slot of time(6s) + // for payload generation. It should be enough for Geth to + // run 3 rounds. + Recommit: 2 * time.Second, + NewPayloadTimeout: 2 * time.Second, +} + // Miner creates blocks and searches for proof-of-work values. type Miner struct { mux *event.TypeMux diff --git a/node/defaults.go b/node/defaults.go index 42d9d4cde0..a3bb805b6d 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -74,6 +74,34 @@ var DefaultConfig = Config{ DBEngine: "", // Use whatever exists, will default to Pebble if non-existent and supported } +// DefaultOpBNBConfig contains reasonable default opBNB settings. +var DefaultOpBNBConfig = Config{ + DataDir: DefaultDataDir(), + HTTPCors: []string{"*"}, + HTTPHost: "0.0.0.0", + HTTPPort: 8545, + AuthAddr: "0.0.0.0", + AuthPort: 8551, + AuthVirtualHosts: []string{"*"}, + HTTPModules: []string{"net", "web3", "engine"}, + HTTPVirtualHosts: []string{"*"}, + HTTPTimeouts: rpc.DefaultHTTPTimeouts, + WSHost: "0.0.0.0", + WSPort: 8546, + WSOrigins: []string{"*"}, + WSModules: []string{"net", "web3", "engine"}, + BatchRequestLimit: 1000, + BatchResponseMaxSize: 25 * 1000 * 1000, + GraphQLVirtualHosts: []string{"localhost"}, + P2P: p2p.Config{ + ListenAddr: ":30303", + MaxPeers: 10, + NAT: nat.Any(), + }, + DBEngine: "", // Use whatever exists, will default to Pebble if non-existent and supported + InsecureUnlockAllowed: true, +} + // DefaultDataDir is the default data directory to use for the databases and other // persistence requirements. func DefaultDataDir() string { From 3fe0119817ecd4ecc5c4433892d03537b15cee70 Mon Sep 17 00:00:00 2001 From: redhdx Date: Tue, 23 Apr 2024 17:43:03 +0800 Subject: [PATCH 03/15] feature(op-geth): decrease code intrusiveness --- cmd/geth/config.go | 24 ++++++++++++++++++++++-- cmd/utils/flags.go | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index f1c751269a..3af48a60a6 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -114,6 +114,17 @@ func loadConfig(file string, cfg *gethConfig) error { } func defaultNodeConfig() node.Config { + git, _ := version.VCS() + cfg := node.DefaultConfig + cfg.Name = clientIdentifier + cfg.Version = params.VersionWithCommit(git.Commit, git.Date) + cfg.HTTPModules = append(cfg.HTTPModules, "eth") + cfg.WSModules = append(cfg.WSModules, "eth") + cfg.IPCPath = "geth.ipc" + return cfg +} + +func defaultOpBNBNodeConfig() node.Config { git, _ := version.VCS() cfg := node.DefaultOpBNBConfig cfg.Name = clientIdentifier @@ -129,9 +140,18 @@ func defaultNodeConfig() node.Config { func loadBaseConfig(ctx *cli.Context) gethConfig { // Load defaults. cfg := gethConfig{ - Eth: ethconfig.OpBNBDefaults, + Eth: ethconfig.Defaults, Node: defaultNodeConfig(), - Metrics: metrics.DefaultOpBNBConfig, + Metrics: metrics.DefaultConfig, + } + + if ctx.Bool(utils.OpBNBMainnetFlag.Name) || ctx.Bool(utils.OpBNBTestnetFlag.Name) { + cfg.Eth = ethconfig.OpBNBDefaults + cfg.Node = defaultOpBNBNodeConfig() + cfg.Metrics = metrics.DefaultOpBNBConfig + if ctx.Bool(utils.OpBNBTestnetFlag.Name) { + cfg.Eth.NetworkId = 5611 + } } // Load config file. diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 717b496333..fc901cf3b5 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1829,7 +1829,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { godebug.SetGCPercent(int(gogc)) // set gc mode default value is archive for opBNB - if !ctx.IsSet(GCModeFlag.Name) { + if !ctx.IsSet(GCModeFlag.Name) && (ctx.Bool(OpBNBMainnetFlag.Name) || ctx.Bool(OpBNBTestnetFlag.Name)) { err = ctx.Set(GCModeFlag.Name, "archive") if err != nil { log.Error("can't set gc mode", "err", err) From c221a23739577129be9a27f5aed767c05e8cf409 Mon Sep 17 00:00:00 2001 From: redhdx Date: Tue, 23 Apr 2024 17:56:50 +0800 Subject: [PATCH 04/15] feature(op-geth): decrease code intrusiveness --- cmd/geth/main.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index a0cb3f61a3..d4ef3294fc 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -328,7 +328,7 @@ func prepare(ctx *cli.Context) { log.Info("Starting geth on an opBNB QAnet network...", "network", ctx.String(utils.OpBNBQANetFlag.Name)) case !ctx.IsSet(utils.NetworkIdFlag.Name): - log.Info("Starting Geth on opBNB mainnet...") + log.Info("Starting Geth on Ethereum mainnet...") } // If we're a full node on mainnet without --cache specified, bump default cache allowance if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) && !ctx.IsSet(utils.NetworkIdFlag.Name) { @@ -348,6 +348,11 @@ func prepare(ctx *cli.Context) { log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096, "network", ctx.String(utils.OPNetworkFlag.Name)) ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096)) } + } else if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) && + (ctx.IsSet(utils.OpBNBMainnetFlag.Name) || ctx.IsSet(utils.OpBNBTestnetFlag.Name)) { + // we're really on opBNB network. Bump that cache up + log.Info("Bumping default cache on opBNB", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 32000) + ctx.Set(utils.CacheFlag.Name, strconv.Itoa(32000)) } // 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) { @@ -355,12 +360,6 @@ func prepare(ctx *cli.Context) { ctx.Set(utils.CacheFlag.Name, strconv.Itoa(128)) } - // For opBNB, we set default cache to 32000, can override by setting cache flag - if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) { - log.Info("Bumping default cache on opBNB", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 32000) - ctx.Set(utils.CacheFlag.Name, strconv.Itoa(32000)) - } - // Start metrics export if enabled utils.SetupMetrics(ctx) From 263d07078bc338cfeabc967401ffbde86e493add Mon Sep 17 00:00:00 2001 From: redhdx Date: Tue, 23 Apr 2024 22:47:32 +0800 Subject: [PATCH 05/15] fix(op-geth): fix setting bootnodes --- cmd/utils/flags.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index fc901cf3b5..246665257d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1167,12 +1167,12 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { urls = params.SepoliaBootnodes case ctx.Bool(GoerliFlag.Name): urls = params.GoerliBootnodes + case ctx.Bool(OpBNBTestnetFlag.Name): + urls = params.OpBNBTestnetBootnodes case ctx.Bool(NetworkIdFlag.Name): if ctx.Uint64(NetworkIdFlag.Name) == params.OpBNBTestnet { urls = params.OpBNBTestnetBootnodes } - case ctx.Bool(OpBNBTestnetFlag.Name): - urls = params.OpBNBTestnetBootnodes } } cfg.BootstrapNodes = mustParseBootnodes(urls) From 766d56dfcfd8ca7204a03d96c5287be5e18f02e4 Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 14:01:38 +0800 Subject: [PATCH 06/15] fix(op-geth): fix default settings --- cmd/geth/config.go | 1 + cmd/utils/flags.go | 2 +- core/txpool/legacypool/legacypool.go | 18 ------------------ eth/ethconfig/config.go | 6 +++--- miner/miner.go | 13 ------------- 5 files changed, 5 insertions(+), 35 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 3af48a60a6..d77486c955 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -151,6 +151,7 @@ func loadBaseConfig(ctx *cli.Context) gethConfig { cfg.Metrics = metrics.DefaultOpBNBConfig if ctx.Bool(utils.OpBNBTestnetFlag.Name) { cfg.Eth.NetworkId = 5611 + cfg.Eth.TrieCommitInterval = 240 } } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 246665257d..7ad5439b59 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1830,7 +1830,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { // set gc mode default value is archive for opBNB if !ctx.IsSet(GCModeFlag.Name) && (ctx.Bool(OpBNBMainnetFlag.Name) || ctx.Bool(OpBNBTestnetFlag.Name)) { - err = ctx.Set(GCModeFlag.Name, "archive") + err = ctx.Set(GCModeFlag.Name, "full") if err != nil { log.Error("can't set gc mode", "err", err) } diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index 2f2eb020a0..41c96476be 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -171,24 +171,6 @@ var DefaultConfig = Config{ ReannounceTime: 10 * 365 * 24 * time.Hour, } -// DefaultOpBNBConfig contains the default opBNB configurations for the transaction pool. -var DefaultOpBNBConfig = Config{ - Journal: "transactions.rlp", - Rejournal: time.Hour, - - PriceLimit: 1, - PriceBump: 10, - - AccountSlots: 200, - GlobalSlots: 10000, // urgent + floating queue capacity with 4:1 ratio - AccountQueue: 200, - GlobalQueue: 5000, - - Lifetime: 3 * time.Hour, - - ReannounceTime: 10 * 365 * 24 * time.Hour, -} - // sanitize checks the provided user configurations and changes anything that's // unreasonable or unworkable. func (config *Config) sanitize() Config { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 800b3464df..aa7a8bc8a2 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -94,11 +94,11 @@ var OpBNBDefaults = Config{ TrieCleanCache: 154, TrieDirtyCache: 256, TrieTimeout: 60 * time.Minute, - TrieCommitInterval: 0, + TrieCommitInterval: 3600, SnapshotCache: 102, FilterLogCacheSize: 32, - Miner: miner.DefaultOpBNBConfig, - TxPool: legacypool.DefaultOpBNBConfig, + Miner: miner.DefaultConfig, + TxPool: legacypool.DefaultConfig, BlobPool: blobpool.DefaultConfig, RPCGasCap: 50000000, RPCEVMTimeout: 5 * time.Second, diff --git a/miner/miner.go b/miner/miner.go index 940565d7e6..0706d49cce 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -102,19 +102,6 @@ var DefaultConfig = Config{ NewPayloadTimeout: 2 * time.Second, } -// DefaultOpBNBConfig contains default opBNB settings for miner. -var DefaultOpBNBConfig = Config{ - GasCeil: 150000000, - GasPrice: big.NewInt(params.GWei), - - // The default recommit time is chosen as two seconds since - // consensus-layer usually will wait a half slot of time(6s) - // for payload generation. It should be enough for Geth to - // run 3 rounds. - Recommit: 2 * time.Second, - NewPayloadTimeout: 2 * time.Second, -} - // Miner creates blocks and searches for proof-of-work values. type Miner struct { mux *event.TypeMux From c7dca33d8c349189f3a5fcb9b187dfdcd6175ca0 Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 14:05:06 +0800 Subject: [PATCH 07/15] fix(op-geth): fix comment --- cmd/utils/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7ad5439b59..84ea9134da 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1828,7 +1828,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc)) godebug.SetGCPercent(int(gogc)) - // set gc mode default value is archive for opBNB + // set gc mode default value is full for opBNB if !ctx.IsSet(GCModeFlag.Name) && (ctx.Bool(OpBNBMainnetFlag.Name) || ctx.Bool(OpBNBTestnetFlag.Name)) { err = ctx.Set(GCModeFlag.Name, "full") if err != nil { From f21f3d26feb138713480ecefa132081f3ecbe3c5 Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 14:08:28 +0800 Subject: [PATCH 08/15] fix(op-geth): remove useless change, keep default setting --- cmd/utils/flags.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 84ea9134da..3ee351bec4 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1828,14 +1828,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc)) godebug.SetGCPercent(int(gogc)) - // set gc mode default value is full for opBNB - if !ctx.IsSet(GCModeFlag.Name) && (ctx.Bool(OpBNBMainnetFlag.Name) || ctx.Bool(OpBNBTestnetFlag.Name)) { - err = ctx.Set(GCModeFlag.Name, "full") - if err != nil { - log.Error("can't set gc mode", "err", err) - } - } - if ctx.IsSet(SyncTargetFlag.Name) { cfg.SyncMode = downloader.FullSync // dev sync target forces full sync } else if ctx.IsSet(SyncModeFlag.Name) { From fd63998bda7501975baa3a1ed780208d94dd9de7 Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 15:33:57 +0800 Subject: [PATCH 09/15] fix(op-geth): optimize default settings --- cmd/geth/config.go | 1 - cmd/utils/flags.go | 4 ++++ metrics/config.go | 20 -------------------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index d77486c955..7a24bb547d 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -148,7 +148,6 @@ func loadBaseConfig(ctx *cli.Context) gethConfig { if ctx.Bool(utils.OpBNBMainnetFlag.Name) || ctx.Bool(utils.OpBNBTestnetFlag.Name) { cfg.Eth = ethconfig.OpBNBDefaults cfg.Node = defaultOpBNBNodeConfig() - cfg.Metrics = metrics.DefaultOpBNBConfig if ctx.Bool(utils.OpBNBTestnetFlag.Name) { cfg.Eth.NetworkId = 5611 cfg.Eth.TrieCommitInterval = 240 diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 3ee351bec4..89fca2f05a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1625,6 +1625,10 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) { cfg.DataDir = filepath.Join(node.DefaultDataDir(), "holesky") case ctx.IsSet(OPNetworkFlag.Name) && cfg.DataDir == node.DefaultDataDir(): cfg.DataDir = filepath.Join(node.DefaultDataDir(), ctx.String(OPNetworkFlag.Name)) + case ctx.IsSet(OpBNBMainnetFlag.Name) && cfg.DataDir == node.DefaultDataDir(): + cfg.DataDir = filepath.Join(node.DefaultDataDir(), ctx.String(OpBNBMainnetFlag.Name)) + case ctx.IsSet(OpBNBTestnetFlag.Name) && cfg.DataDir == node.DefaultDataDir(): + cfg.DataDir = filepath.Join(node.DefaultDataDir(), ctx.String(OpBNBTestnetFlag.Name)) } } diff --git a/metrics/config.go b/metrics/config.go index f3e6979fd9..2eb09fb48a 100644 --- a/metrics/config.go +++ b/metrics/config.go @@ -54,23 +54,3 @@ var DefaultConfig = Config{ InfluxDBBucket: "geth", InfluxDBOrganization: "geth", } - -// DefaultOpBNBConfig is the default config for metrics used in opBNB. -var DefaultOpBNBConfig = Config{ - Enabled: true, - EnabledExpensive: false, - HTTP: "0.0.0.0", - Port: 6060, - EnableInfluxDB: false, - InfluxDBEndpoint: "http://localhost:8086", - InfluxDBDatabase: "geth", - InfluxDBUsername: "test", - InfluxDBPassword: "test", - InfluxDBTags: "host=localhost", - - // influxdbv2-specific flags - EnableInfluxDBV2: false, - InfluxDBToken: "test", - InfluxDBBucket: "geth", - InfluxDBOrganization: "geth", -} From 7eeeb26a745a80aa394ed10194ee72bd8bbb16ec Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 15:42:48 +0800 Subject: [PATCH 10/15] revert change --- miner/miner.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index 0706d49cce..5c0ba3f815 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -41,10 +41,10 @@ import ( var ( commitDepositTxsTimer = metrics.NewRegisteredTimer("miner/commit/deposit/txs", nil) - packFromTxpoolTimer = metrics.NewRegisteredTimer("miner/pack/txpool/txs", nil) - commitTxpoolTxsTimer = metrics.NewRegisteredTimer("miner/commit/txpool/txs", nil) - assembleBlockTimer = metrics.NewRegisteredTimer("miner/assemble/block", nil) - buildBlockTimer = metrics.NewRegisteredTimer("miner/build/block", nil) + packFromTxpoolTimer = metrics.NewRegisteredTimer("miner/pack/txpool/txs", nil) + commitTxpoolTxsTimer = metrics.NewRegisteredTimer("miner/commit/txpool/txs", nil) + assembleBlockTimer = metrics.NewRegisteredTimer("miner/assemble/block", nil) + buildBlockTimer = metrics.NewRegisteredTimer("miner/build/block", nil) accountReadTimer = metrics.NewRegisteredTimer("miner/account/reads", nil) accountHashTimer = metrics.NewRegisteredTimer("miner/account/hashes", nil) From df3f41fb63878d7a3d7fddc4fd55d725f9ad03f1 Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 16:28:29 +0800 Subject: [PATCH 11/15] fix(op-geth): optimize default settings --- cmd/utils/flags.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 89fca2f05a..a3a4641641 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1626,9 +1626,9 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) { case ctx.IsSet(OPNetworkFlag.Name) && cfg.DataDir == node.DefaultDataDir(): cfg.DataDir = filepath.Join(node.DefaultDataDir(), ctx.String(OPNetworkFlag.Name)) case ctx.IsSet(OpBNBMainnetFlag.Name) && cfg.DataDir == node.DefaultDataDir(): - cfg.DataDir = filepath.Join(node.DefaultDataDir(), ctx.String(OpBNBMainnetFlag.Name)) + cfg.DataDir = filepath.Join(node.DefaultDataDir(), "opBNBMainnet") case ctx.IsSet(OpBNBTestnetFlag.Name) && cfg.DataDir == node.DefaultDataDir(): - cfg.DataDir = filepath.Join(node.DefaultDataDir(), ctx.String(OpBNBTestnetFlag.Name)) + cfg.DataDir = filepath.Join(node.DefaultDataDir(), "opBNBTestnet") } } From f6b36af4db4424ccf93d56fa9643c7b23fc5252b Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 16:50:52 +0800 Subject: [PATCH 12/15] fix(op-geth): optimize default settings --- node/defaults.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/node/defaults.go b/node/defaults.go index a3bb805b6d..a4008ea253 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -77,18 +77,15 @@ var DefaultConfig = Config{ // DefaultOpBNBConfig contains reasonable default opBNB settings. var DefaultOpBNBConfig = Config{ DataDir: DefaultDataDir(), - HTTPCors: []string{"*"}, - HTTPHost: "0.0.0.0", - HTTPPort: 8545, - AuthAddr: "0.0.0.0", - AuthPort: 8551, - AuthVirtualHosts: []string{"*"}, + HTTPHost: DefaultHTTPHost, + HTTPPort: DefaultHTTPPort, + AuthAddr: DefaultAuthHost, + AuthPort: DefaultAuthPort, + AuthVirtualHosts: DefaultAuthVhosts, HTTPModules: []string{"net", "web3", "engine"}, - HTTPVirtualHosts: []string{"*"}, + HTTPVirtualHosts: []string{"localhost"}, HTTPTimeouts: rpc.DefaultHTTPTimeouts, - WSHost: "0.0.0.0", - WSPort: 8546, - WSOrigins: []string{"*"}, + WSPort: DefaultWSPort, WSModules: []string{"net", "web3", "engine"}, BatchRequestLimit: 1000, BatchResponseMaxSize: 25 * 1000 * 1000, From 6ee2311b1d9facf97002abd2cabaf84c268acf13 Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 16:54:19 +0800 Subject: [PATCH 13/15] fix(op-geth): optimize default settings --- node/defaults.go | 1 - 1 file changed, 1 deletion(-) diff --git a/node/defaults.go b/node/defaults.go index a4008ea253..c20e062d8a 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -77,7 +77,6 @@ var DefaultConfig = Config{ // DefaultOpBNBConfig contains reasonable default opBNB settings. var DefaultOpBNBConfig = Config{ DataDir: DefaultDataDir(), - HTTPHost: DefaultHTTPHost, HTTPPort: DefaultHTTPPort, AuthAddr: DefaultAuthHost, AuthPort: DefaultAuthPort, From 4b80de18e89e5d181ea4f40dab8ed25628a485ea Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 17:22:51 +0800 Subject: [PATCH 14/15] fix(op-geth): optimize default settings --- node/defaults.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/node/defaults.go b/node/defaults.go index c20e062d8a..e7ec278723 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -77,6 +77,7 @@ var DefaultConfig = Config{ // DefaultOpBNBConfig contains reasonable default opBNB settings. var DefaultOpBNBConfig = Config{ DataDir: DefaultDataDir(), + HTTPHost: DefaultHTTPHost, HTTPPort: DefaultHTTPPort, AuthAddr: DefaultAuthHost, AuthPort: DefaultAuthPort, @@ -84,6 +85,7 @@ var DefaultOpBNBConfig = Config{ HTTPModules: []string{"net", "web3", "engine"}, HTTPVirtualHosts: []string{"localhost"}, HTTPTimeouts: rpc.DefaultHTTPTimeouts, + WSHost: DefaultWSHost, WSPort: DefaultWSPort, WSModules: []string{"net", "web3", "engine"}, BatchRequestLimit: 1000, From 015e74479f559838bf37047237fb55241e42eeab Mon Sep 17 00:00:00 2001 From: redhdx Date: Wed, 24 Apr 2024 17:43:33 +0800 Subject: [PATCH 15/15] fix(op-geth): optimize default settings --- cmd/geth/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index d4ef3294fc..050e3514bf 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -351,8 +351,8 @@ func prepare(ctx *cli.Context) { } else if ctx.String(utils.SyncModeFlag.Name) != "light" && !ctx.IsSet(utils.CacheFlag.Name) && (ctx.IsSet(utils.OpBNBMainnetFlag.Name) || ctx.IsSet(utils.OpBNBTestnetFlag.Name)) { // we're really on opBNB network. Bump that cache up - log.Info("Bumping default cache on opBNB", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 32000) - ctx.Set(utils.CacheFlag.Name, strconv.Itoa(32000)) + log.Info("Bumping default cache on opBNB", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 22000) + ctx.Set(utils.CacheFlag.Name, strconv.Itoa(22000)) } // 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) {