Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.DARecoveryProduceBlocksFlag,
utils.CircuitCapacityCheckEnabledFlag,
utils.CircuitCapacityCheckWorkersFlag,
utils.TxGossipBroadcastDisabledFlag,
utils.TxGossipReceivingDisabledFlag,
utils.GossipTxBroadcastDisabledFlag,
utils.GossipTxReceivingDisabledFlag,
utils.GossipBroadcastToAllEnabledFlag,
},
},
{
Expand Down
30 changes: 19 additions & 11 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "gossip.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{
Expand Down Expand Up @@ -1807,13 +1811,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("Gossip transaction broadcast disabled", "disabled", cfg.GossipTxBroadcastDisabled)
}
if ctx.GlobalIsSet(GossipTxReceivingDisabledFlag.Name) {
cfg.GossipTxReceivingDisabled = ctx.GlobalBool(GossipTxReceivingDisabledFlag.Name)
log.Info("Gossip transaction 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.GossipBroadcastToAllEnabled = ctx.GlobalBool(GossipBroadcastToAllEnabledFlag.Name)
log.Info("Gossip broadcast to all enabled", "enabled", cfg.GossipBroadcastToAllEnabled)
}
Comment thread
yiweichi marked this conversation as resolved.

// Cap the cache allowance and tune the garbage collector
Expand Down
25 changes: 13 additions & 12 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 3 additions & 2 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
48 changes: 30 additions & 18 deletions eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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).
Comment thread
yiweichi marked this conversation as resolved.
Outdated
if h.enableBroadcastToAll {
numDirect = min(100, len(peers))
}
transfer := peers[:numDirect]
for _, peer := range transfer {
peer.AsyncSendNewBlock(block, td)
}
Expand Down Expand Up @@ -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())
}
Expand Down
Loading