From dd9135a7501b0140a5eebdfc6735efdbbf15f19f Mon Sep 17 00:00:00 2001 From: Morty Date: Tue, 8 Jul 2025 05:57:07 +0800 Subject: [PATCH 1/8] feat: add flag to enable broadcast blocks and transactions to all peers --- cmd/geth/main.go | 5 +++-- cmd/geth/usage.go | 5 +++-- cmd/utils/flags.go | 30 ++++++++++++++++---------- eth/backend.go | 25 ++++++++++----------- eth/ethconfig/config.go | 5 +++-- eth/handler.go | 48 +++++++++++++++++++++++++---------------- 6 files changed, 71 insertions(+), 47 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index efffc9480ace..5fc4e74f1f53 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -176,8 +176,9 @@ var ( utils.CircuitCapacityCheckWorkersFlag, utils.RollupVerifyEnabledFlag, utils.ShadowforkPeersFlag, - utils.TxGossipBroadcastDisabledFlag, - utils.TxGossipReceivingDisabledFlag, + utils.GossipTxBroadcastDisabledFlag, + utils.GossipTxReceivingDisabledFlag, + utils.GossipBroadcastToAllEnabledFlag, utils.DASyncEnabledFlag, utils.DABlockNativeAPIEndpointFlag, utils.DABlobScanAPIEndpointFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 60b7e5416b01..9ecb2fe18c97 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -248,8 +248,9 @@ var AppHelpFlagGroups = []flags.FlagGroup{ utils.DARecoveryProduceBlocksFlag, utils.CircuitCapacityCheckEnabledFlag, utils.CircuitCapacityCheckWorkersFlag, - utils.TxGossipBroadcastDisabledFlag, - utils.TxGossipReceivingDisabledFlag, + utils.GossipTxBroadcastDisabledFlag, + utils.GossipTxReceivingDisabledFlag, + utils.GossipBroadcastToAllEnabledFlag, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a2a1655502d7..87290376609b 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -893,15 +893,19 @@ var ( Usage: "peer ids of shadow fork peers", } - // Tx gossip settings - TxGossipBroadcastDisabledFlag = cli.BoolFlag{ - Name: "txgossip.disablebroadcast", + // Gossip settings + GossipTxBroadcastDisabledFlag = cli.BoolFlag{ + Name: "gossip.disabletxbroadcast", Usage: "Disable gossip broadcast transactions to other peers", } - TxGossipReceivingDisabledFlag = cli.BoolFlag{ - Name: "txgossip.disablereceiving", + GossipTxReceivingDisabledFlag = cli.BoolFlag{ + Name: "txgossip.disabletxreceiving", Usage: "Disable gossip receiving transactions from other peers", } + GossipBroadcastToAllEnabledFlag = cli.BoolFlag{ + Name: "gossip.enablebroadcasttoall", + Usage: "Enable gossip broadcast blocks and transactions to all peers", + } // DA syncing settings DASyncEnabledFlag = cli.BoolFlag{ @@ -1800,13 +1804,17 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { cfg.ShadowForkPeerIDs = ctx.GlobalStringSlice(ShadowforkPeersFlag.Name) log.Info("Shadow fork peers", "ids", cfg.ShadowForkPeerIDs) } - if ctx.GlobalIsSet(TxGossipBroadcastDisabledFlag.Name) { - cfg.TxGossipBroadcastDisabled = ctx.GlobalBool(TxGossipBroadcastDisabledFlag.Name) - log.Info("Transaction gossip broadcast disabled", "disabled", cfg.TxGossipBroadcastDisabled) + if ctx.GlobalIsSet(GossipTxBroadcastDisabledFlag.Name) { + cfg.GossipTxBroadcastDisabled = ctx.GlobalBool(GossipTxBroadcastDisabledFlag.Name) + log.Info("Transaction gossip broadcast disabled", "disabled", cfg.GossipTxBroadcastDisabled) + } + if ctx.GlobalIsSet(GossipTxReceivingDisabledFlag.Name) { + cfg.GossipTxReceivingDisabled = ctx.GlobalBool(GossipTxReceivingDisabledFlag.Name) + log.Info("Transaction gossip receiving disabled", "disabled", cfg.GossipTxReceivingDisabled) } - if ctx.GlobalIsSet(TxGossipReceivingDisabledFlag.Name) { - cfg.TxGossipReceivingDisabled = ctx.GlobalBool(TxGossipReceivingDisabledFlag.Name) - log.Info("Transaction gossip receiving disabled", "disabled", cfg.TxGossipReceivingDisabled) + if ctx.GlobalIsSet(GossipBroadcastToAllEnabledFlag.Name) { + cfg.GossipTxReceivingDisabled = ctx.GlobalBool(GossipBroadcastToAllEnabledFlag.Name) + log.Info("Transaction gossip receiving disabled", "disabled", cfg.GossipTxReceivingDisabled) } // Cap the cache allowance and tune the garbage collector diff --git a/eth/backend.go b/eth/backend.go index 0050d3853b65..a264eb815bb7 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -273,18 +273,19 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ether checkpoint = params.TrustedCheckpoints[genesisHash] } if eth.handler, err = newHandler(&handlerConfig{ - Database: chainDb, - Chain: eth.blockchain, - TxPool: eth.txPool, - Network: config.NetworkId, - Sync: config.SyncMode, - BloomCache: uint64(cacheLimit), - EventMux: eth.eventMux, - Checkpoint: checkpoint, - Whitelist: config.Whitelist, - ShadowForkPeerIDs: config.ShadowForkPeerIDs, - DisableTxBroadcast: config.TxGossipBroadcastDisabled, - DisableTxReceiving: config.TxGossipReceivingDisabled, + Database: chainDb, + Chain: eth.blockchain, + TxPool: eth.txPool, + Network: config.NetworkId, + Sync: config.SyncMode, + BloomCache: uint64(cacheLimit), + EventMux: eth.eventMux, + Checkpoint: checkpoint, + Whitelist: config.Whitelist, + ShadowForkPeerIDs: config.ShadowForkPeerIDs, + DisableTxBroadcast: config.GossipTxBroadcastDisabled, + DisableTxReceiving: config.GossipTxReceivingDisabled, + EnableBroadcastToAll: config.GossipBroadcastToAllEnabled, }); err != nil { return nil, err } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 0f70eb2ed6c9..0f063eeeb86a 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -231,8 +231,9 @@ type Config struct { // DA syncer options DA da_syncer.Config - TxGossipBroadcastDisabled bool - TxGossipReceivingDisabled bool + GossipTxBroadcastDisabled bool + GossipTxReceivingDisabled bool + GossipBroadcastToAllEnabled bool } // CreateConsensusEngine creates a consensus engine for the given chain configuration. diff --git a/eth/handler.go b/eth/handler.go index 520723f18af2..4d7e75eff45a 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -94,8 +94,9 @@ type handlerConfig struct { Whitelist map[uint64]common.Hash // Hard coded whitelist for sync challenged ShadowForkPeerIDs []string // List of peer ids that take part in the shadow-fork - DisableTxBroadcast bool - DisableTxReceiving bool + DisableTxBroadcast bool + DisableTxReceiving bool + EnableBroadcastToAll bool } type handler struct { @@ -134,9 +135,10 @@ type handler struct { wg sync.WaitGroup peerWG sync.WaitGroup - shadowForkPeerIDs []string - disableTxBroadcast bool - disableTxReceiving bool + shadowForkPeerIDs []string + disableTxBroadcast bool + disableTxReceiving bool + enableBroadcastToAll bool } // newHandler returns a handler for all Ethereum chain management protocol. @@ -146,18 +148,19 @@ func newHandler(config *handlerConfig) (*handler, error) { config.EventMux = new(event.TypeMux) // Nicety initialization for tests } h := &handler{ - networkID: config.Network, - forkFilter: forkid.NewFilter(config.Chain), - eventMux: config.EventMux, - database: config.Database, - txpool: config.TxPool, - chain: config.Chain, - peers: newPeerSet(), - whitelist: config.Whitelist, - quitSync: make(chan struct{}), - shadowForkPeerIDs: config.ShadowForkPeerIDs, - disableTxBroadcast: config.DisableTxBroadcast, - disableTxReceiving: config.DisableTxReceiving, + networkID: config.Network, + forkFilter: forkid.NewFilter(config.Chain), + eventMux: config.EventMux, + database: config.Database, + txpool: config.TxPool, + chain: config.Chain, + peers: newPeerSet(), + whitelist: config.Whitelist, + quitSync: make(chan struct{}), + shadowForkPeerIDs: config.ShadowForkPeerIDs, + disableTxBroadcast: config.DisableTxBroadcast, + disableTxReceiving: config.DisableTxReceiving, + enableBroadcastToAll: config.EnableBroadcastToAll, } if config.Sync == downloader.FullSync { // The database seems empty as the current block is the genesis. Yet the fast @@ -477,7 +480,12 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) { return } // Send the block to a subset of our peers - transfer := peers[:int(math.Sqrt(float64(len(peers))))] + numDirect := int(math.Sqrt(float64(len(peers)))) + // If enableBroadcastToAll is true, broadcast blocks directly to all peers (capped at 100). + if h.enableBroadcastToAll { + numDirect = min(100, len(peers)) + } + transfer := peers[:numDirect] for _, peer := range transfer { peer.AsyncSendNewBlock(block, td) } @@ -518,6 +526,10 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) { peers := onlyShadowForkPeers(h.shadowForkPeerIDs, h.peers.peersWithoutTransaction(tx.Hash())) // Send the tx unconditionally to a subset of our peers numDirect := int(math.Sqrt(float64(len(peers)))) + // If enableBroadcastToAll is true, broadcast transactions directly to all peers (capped at 100). + if h.enableBroadcastToAll { + numDirect = min(100, len(peers)) + } for _, peer := range peers[:numDirect] { txset[peer] = append(txset[peer], tx.Hash()) } From 7a023b6473522c457e81014dbf0dbf19548c588b Mon Sep 17 00:00:00 2001 From: Morty Date: Tue, 8 Jul 2025 05:59:29 +0800 Subject: [PATCH 2/8] fix: typo --- 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 87290376609b..7cf4f3cf7cee 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -899,7 +899,7 @@ var ( Usage: "Disable gossip broadcast transactions to other peers", } GossipTxReceivingDisabledFlag = cli.BoolFlag{ - Name: "txgossip.disabletxreceiving", + Name: "gossip.disabletxreceiving", Usage: "Disable gossip receiving transactions from other peers", } GossipBroadcastToAllEnabledFlag = cli.BoolFlag{ From 458b6a0f132b95ee1511d6195e115ebaafb585de Mon Sep 17 00:00:00 2001 From: Morty Date: Tue, 8 Jul 2025 06:08:11 +0800 Subject: [PATCH 3/8] fix: cfg.GossipBroadcastToAllEnabled --- cmd/utils/flags.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7cf4f3cf7cee..0ead9ab5d440 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1806,15 +1806,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } if ctx.GlobalIsSet(GossipTxBroadcastDisabledFlag.Name) { cfg.GossipTxBroadcastDisabled = ctx.GlobalBool(GossipTxBroadcastDisabledFlag.Name) - log.Info("Transaction gossip broadcast disabled", "disabled", cfg.GossipTxBroadcastDisabled) + log.Info("Gossip transaction broadcast disabled", "disabled", cfg.GossipTxBroadcastDisabled) } if ctx.GlobalIsSet(GossipTxReceivingDisabledFlag.Name) { cfg.GossipTxReceivingDisabled = ctx.GlobalBool(GossipTxReceivingDisabledFlag.Name) - log.Info("Transaction gossip receiving disabled", "disabled", cfg.GossipTxReceivingDisabled) + log.Info("Gossip transaction receiving disabled", "disabled", cfg.GossipTxReceivingDisabled) } if ctx.GlobalIsSet(GossipBroadcastToAllEnabledFlag.Name) { - cfg.GossipTxReceivingDisabled = ctx.GlobalBool(GossipBroadcastToAllEnabledFlag.Name) - log.Info("Transaction gossip receiving disabled", "disabled", cfg.GossipTxReceivingDisabled) + cfg.GossipBroadcastToAllEnabled = ctx.GlobalBool(GossipBroadcastToAllEnabledFlag.Name) + log.Info("Gossip broadcast to all enabled", "enabled", cfg.GossipBroadcastToAllEnabled) } // Cap the cache allowance and tune the garbage collector From 794836f4133b298b00a1b550fd953578c70b4b9b Mon Sep 17 00:00:00 2001 From: Morty Date: Tue, 8 Jul 2025 17:45:25 +0800 Subject: [PATCH 4/8] feat: add broadcast to all cap --- cmd/geth/main.go | 1 + cmd/geth/usage.go | 1 + cmd/utils/flags.go | 10 ++++++++++ eth/backend.go | 1 + eth/ethconfig/config.go | 1 + eth/handler.go | 12 ++++++++++-- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 346a746f254f..56a8e9b1d038 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -179,6 +179,7 @@ var ( utils.GossipTxBroadcastDisabledFlag, utils.GossipTxReceivingDisabledFlag, utils.GossipBroadcastToAllEnabledFlag, + utils.GossipBroadcastToAllCapFlag, utils.DASyncEnabledFlag, utils.DABlockNativeAPIEndpointFlag, utils.DABlobScanAPIEndpointFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index afc8f308c731..7b7baa29e28f 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -252,6 +252,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ utils.GossipTxBroadcastDisabledFlag, utils.GossipTxReceivingDisabledFlag, utils.GossipBroadcastToAllEnabledFlag, + utils.GossipBroadcastToAllCapFlag, }, }, { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a891f68cc34d..3f7a6edc66a4 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -906,6 +906,10 @@ var ( Name: "gossip.enablebroadcasttoall", Usage: "Enable gossip broadcast blocks and transactions to all peers", } + GossipBroadcastToAllCapFlag = cli.IntFlag{ + Name: "gossip.broadcasttoallcap", + Usage: "Maximum number of peers for broadcasting blocks and transactions (effective only when gossip.enablebroadcasttoall is enabled)", + } // DA syncing settings DASyncEnabledFlag = cli.BoolFlag{ @@ -1823,6 +1827,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { cfg.GossipBroadcastToAllEnabled = ctx.GlobalBool(GossipBroadcastToAllEnabledFlag.Name) log.Info("Gossip broadcast to all enabled", "enabled", cfg.GossipBroadcastToAllEnabled) } + // Only configure the gossip broadcast-to-all flag if --gossip.enablebroadcasttoall is set to true. + if ctx.GlobalIsSet(GossipBroadcastToAllCapFlag.Name) && cfg.GossipBroadcastToAllEnabled { + cfg.GossipBroadcastToAllCap = ctx.GlobalInt(GossipBroadcastToAllCapFlag.Name) + log.Info("Maximum number of peers for broadcasting blocks and transactions is set", "cap", cfg.GossipBroadcastToAllCap) + } + // Cap the cache allowance and tune the garbage collector mem, err := gopsutil.VirtualMemory() diff --git a/eth/backend.go b/eth/backend.go index a264eb815bb7..46368b88a318 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -286,6 +286,7 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ether DisableTxBroadcast: config.GossipTxBroadcastDisabled, DisableTxReceiving: config.GossipTxReceivingDisabled, EnableBroadcastToAll: config.GossipBroadcastToAllEnabled, + BroadcastToAllCap: config.GossipBroadcastToAllCap, }); err != nil { return nil, err } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 0f063eeeb86a..814731d7e04d 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -234,6 +234,7 @@ type Config struct { GossipTxBroadcastDisabled bool GossipTxReceivingDisabled bool GossipBroadcastToAllEnabled bool + GossipBroadcastToAllCap int } // CreateConsensusEngine creates a consensus engine for the given chain configuration. diff --git a/eth/handler.go b/eth/handler.go index 4d7e75eff45a..f9b10c09d258 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -94,9 +94,11 @@ type handlerConfig struct { Whitelist map[uint64]common.Hash // Hard coded whitelist for sync challenged ShadowForkPeerIDs []string // List of peer ids that take part in the shadow-fork + // Gossip configs DisableTxBroadcast bool DisableTxReceiving bool EnableBroadcastToAll bool + BroadcastToAllCap int } type handler struct { @@ -139,6 +141,7 @@ type handler struct { disableTxBroadcast bool disableTxReceiving bool enableBroadcastToAll bool + broadcastToAllCap int } // newHandler returns a handler for all Ethereum chain management protocol. @@ -162,6 +165,11 @@ func newHandler(config *handlerConfig) (*handler, error) { disableTxReceiving: config.DisableTxReceiving, enableBroadcastToAll: config.EnableBroadcastToAll, } + h.broadcastToAllCap = config.BroadcastToAllCap + if config.BroadcastToAllCap == 0 && config.EnableBroadcastToAll { + // Set default broadcast cap to 30 if not specified + h.broadcastToAllCap = 30 + } if config.Sync == downloader.FullSync { // The database seems empty as the current block is the genesis. Yet the fast // block is ahead, so fast sync was enabled for this node at a certain point. @@ -483,7 +491,7 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) { numDirect := int(math.Sqrt(float64(len(peers)))) // If enableBroadcastToAll is true, broadcast blocks directly to all peers (capped at 100). if h.enableBroadcastToAll { - numDirect = min(100, len(peers)) + numDirect = min(h.broadcastToAllCap, len(peers)) } transfer := peers[:numDirect] for _, peer := range transfer { @@ -528,7 +536,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) { numDirect := int(math.Sqrt(float64(len(peers)))) // If enableBroadcastToAll is true, broadcast transactions directly to all peers (capped at 100). if h.enableBroadcastToAll { - numDirect = min(100, len(peers)) + numDirect = min(h.broadcastToAllCap, len(peers)) } for _, peer := range peers[:numDirect] { txset[peer] = append(txset[peer], tx.Hash()) From 70b1ec3e111e45bd5e95f9335dea975f45409418 Mon Sep 17 00:00:00 2001 From: yiweichi <70688412+yiweichi@users.noreply.github.com> Date: Tue, 8 Jul 2025 10:27:30 +0000 Subject: [PATCH 5/8] =?UTF-8?q?chore:=20auto=20version=20bump=E2=80=89[bot?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index 523d5ca47c51..555a1e557b27 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 8 // Minor version component of the current release - VersionPatch = 65 // Patch version component of the current release + VersionPatch = 66 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) From b62cab2653355c6e2953b2aec2f0b0873c1de17f Mon Sep 17 00:00:00 2001 From: yiweichi <70688412+yiweichi@users.noreply.github.com> Date: Wed, 9 Jul 2025 17:26:03 +0000 Subject: [PATCH 6/8] =?UTF-8?q?chore:=20auto=20version=20bump=E2=80=89[bot?= =?UTF-8?q?]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index 555a1e557b27..2163ecabbe06 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 8 // Minor version component of the current release - VersionPatch = 66 // Patch version component of the current release + VersionPatch = 67 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string ) From e89d3d18e3ae6aedaca0d7c91073954fc3b195d8 Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 10 Jul 2025 02:52:23 +0800 Subject: [PATCH 7/8] fix: comments --- cmd/utils/flags.go | 8 ++------ eth/handler.go | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 93664bd6566e..7735f04661e4 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -909,6 +909,7 @@ var ( GossipBroadcastToAllCapFlag = cli.IntFlag{ Name: "gossip.broadcasttoallcap", Usage: "Maximum number of peers for broadcasting blocks and transactions (effective only when gossip.enablebroadcasttoall is enabled)", + Value: 30, } // DA syncing settings @@ -1833,14 +1834,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } if ctx.GlobalIsSet(GossipBroadcastToAllEnabledFlag.Name) { cfg.GossipBroadcastToAllEnabled = ctx.GlobalBool(GossipBroadcastToAllEnabledFlag.Name) - log.Info("Gossip broadcast to all enabled", "enabled", cfg.GossipBroadcastToAllEnabled) - } - // Only configure the gossip broadcast-to-all flag if --gossip.enablebroadcasttoall is set to true. - if ctx.GlobalIsSet(GossipBroadcastToAllCapFlag.Name) && cfg.GossipBroadcastToAllEnabled { cfg.GossipBroadcastToAllCap = ctx.GlobalInt(GossipBroadcastToAllCapFlag.Name) - log.Info("Maximum number of peers for broadcasting blocks and transactions is set", "cap", cfg.GossipBroadcastToAllCap) + log.Info("Gossip broadcast to all enabled", "enabled", cfg.GossipBroadcastToAllEnabled, "cap", cfg.GossipBroadcastToAllCap) } - // Cap the cache allowance and tune the garbage collector mem, err := gopsutil.VirtualMemory() diff --git a/eth/handler.go b/eth/handler.go index f9b10c09d258..8b9250b43552 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -164,11 +164,7 @@ func newHandler(config *handlerConfig) (*handler, error) { disableTxBroadcast: config.DisableTxBroadcast, disableTxReceiving: config.DisableTxReceiving, enableBroadcastToAll: config.EnableBroadcastToAll, - } - h.broadcastToAllCap = config.BroadcastToAllCap - if config.BroadcastToAllCap == 0 && config.EnableBroadcastToAll { - // Set default broadcast cap to 30 if not specified - h.broadcastToAllCap = 30 + broadcastToAllCap: config.BroadcastToAllCap, } if config.Sync == downloader.FullSync { // The database seems empty as the current block is the genesis. Yet the fast @@ -489,7 +485,7 @@ func (h *handler) BroadcastBlock(block *types.Block, propagate bool) { } // Send the block to a subset of our peers numDirect := int(math.Sqrt(float64(len(peers)))) - // If enableBroadcastToAll is true, broadcast blocks directly to all peers (capped at 100). + // If enableBroadcastToAll is true, broadcast blocks directly to all peers (capped at broadcastToAllCap). if h.enableBroadcastToAll { numDirect = min(h.broadcastToAllCap, len(peers)) } From 6483948185d419942c8f48fe8e9bb3fa129b043f Mon Sep 17 00:00:00 2001 From: Morty Date: Thu, 10 Jul 2025 02:54:35 +0800 Subject: [PATCH 8/8] fix: typo --- eth/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/handler.go b/eth/handler.go index 8b9250b43552..d7b31d8d0b7f 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -530,7 +530,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) { peers := onlyShadowForkPeers(h.shadowForkPeerIDs, h.peers.peersWithoutTransaction(tx.Hash())) // Send the tx unconditionally to a subset of our peers numDirect := int(math.Sqrt(float64(len(peers)))) - // If enableBroadcastToAll is true, broadcast transactions directly to all peers (capped at 100). + // If enableBroadcastToAll is true, broadcast transactions directly to all peers (capped at broadcastToAllCap). if h.enableBroadcastToAll { numDirect = min(h.broadcastToAllCap, len(peers)) }