mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
feat: add flags to disable broadcast and receiving of tx gossip (#1194)
* add flags to disable broadcast and receiving of tx gossip respectively * chore: auto version bump [bot] --------- Co-authored-by: Morty <70688412+yiweichi@users.noreply.github.com>
This commit is contained in:
parent
a43881de94
commit
02b33db0bf
8 changed files with 65 additions and 26 deletions
|
|
@ -176,6 +176,8 @@ var (
|
||||||
utils.CircuitCapacityCheckWorkersFlag,
|
utils.CircuitCapacityCheckWorkersFlag,
|
||||||
utils.RollupVerifyEnabledFlag,
|
utils.RollupVerifyEnabledFlag,
|
||||||
utils.ShadowforkPeersFlag,
|
utils.ShadowforkPeersFlag,
|
||||||
|
utils.TxGossipBroadcastDisabledFlag,
|
||||||
|
utils.TxGossipReceivingDisabledFlag,
|
||||||
utils.DASyncEnabledFlag,
|
utils.DASyncEnabledFlag,
|
||||||
utils.DABlockNativeAPIEndpointFlag,
|
utils.DABlockNativeAPIEndpointFlag,
|
||||||
utils.DABlobScanAPIEndpointFlag,
|
utils.DABlobScanAPIEndpointFlag,
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,8 @@ var AppHelpFlagGroups = []flags.FlagGroup{
|
||||||
utils.DARecoveryProduceBlocksFlag,
|
utils.DARecoveryProduceBlocksFlag,
|
||||||
utils.CircuitCapacityCheckEnabledFlag,
|
utils.CircuitCapacityCheckEnabledFlag,
|
||||||
utils.CircuitCapacityCheckWorkersFlag,
|
utils.CircuitCapacityCheckWorkersFlag,
|
||||||
|
utils.TxGossipBroadcastDisabledFlag,
|
||||||
|
utils.TxGossipReceivingDisabledFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -893,6 +893,16 @@ var (
|
||||||
Usage: "peer ids of shadow fork peers",
|
Usage: "peer ids of shadow fork peers",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tx gossip settings
|
||||||
|
TxGossipBroadcastDisabledFlag = cli.BoolFlag{
|
||||||
|
Name: "txgossip.disablebroadcast",
|
||||||
|
Usage: "Disable gossip broadcast transactions to other peers",
|
||||||
|
}
|
||||||
|
TxGossipReceivingDisabledFlag = cli.BoolFlag{
|
||||||
|
Name: "txgossip.disablereceiving",
|
||||||
|
Usage: "Disable gossip receiving transactions from other peers",
|
||||||
|
}
|
||||||
|
|
||||||
// DA syncing settings
|
// DA syncing settings
|
||||||
DASyncEnabledFlag = cli.BoolFlag{
|
DASyncEnabledFlag = cli.BoolFlag{
|
||||||
Name: "da.sync",
|
Name: "da.sync",
|
||||||
|
|
@ -1790,6 +1800,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
cfg.ShadowForkPeerIDs = ctx.GlobalStringSlice(ShadowforkPeersFlag.Name)
|
cfg.ShadowForkPeerIDs = ctx.GlobalStringSlice(ShadowforkPeersFlag.Name)
|
||||||
log.Info("Shadow fork peers", "ids", cfg.ShadowForkPeerIDs)
|
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(TxGossipReceivingDisabledFlag.Name) {
|
||||||
|
cfg.TxGossipReceivingDisabled = ctx.GlobalBool(TxGossipReceivingDisabledFlag.Name)
|
||||||
|
log.Info("Transaction gossip receiving disabled", "disabled", cfg.TxGossipReceivingDisabled)
|
||||||
|
}
|
||||||
|
|
||||||
// Cap the cache allowance and tune the garbage collector
|
// Cap the cache allowance and tune the garbage collector
|
||||||
mem, err := gopsutil.VirtualMemory()
|
mem, err := gopsutil.VirtualMemory()
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,8 @@ func New(stack *node.Node, config *ethconfig.Config, l1Client l1.Client) (*Ether
|
||||||
Checkpoint: checkpoint,
|
Checkpoint: checkpoint,
|
||||||
Whitelist: config.Whitelist,
|
Whitelist: config.Whitelist,
|
||||||
ShadowForkPeerIDs: config.ShadowForkPeerIDs,
|
ShadowForkPeerIDs: config.ShadowForkPeerIDs,
|
||||||
|
DisableTxBroadcast: config.TxGossipBroadcastDisabled,
|
||||||
|
DisableTxReceiving: config.TxGossipReceivingDisabled,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,9 @@ type Config struct {
|
||||||
|
|
||||||
// DA syncer options
|
// DA syncer options
|
||||||
DA da_syncer.Config
|
DA da_syncer.Config
|
||||||
|
|
||||||
|
TxGossipBroadcastDisabled bool
|
||||||
|
TxGossipReceivingDisabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateConsensusEngine creates a consensus engine for the given chain configuration.
|
// CreateConsensusEngine creates a consensus engine for the given chain configuration.
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,9 @@ type handlerConfig struct {
|
||||||
Checkpoint *params.TrustedCheckpoint // Hard coded checkpoint for sync challenges
|
Checkpoint *params.TrustedCheckpoint // Hard coded checkpoint for sync challenges
|
||||||
Whitelist map[uint64]common.Hash // Hard coded whitelist for sync challenged
|
Whitelist map[uint64]common.Hash // Hard coded whitelist for sync challenged
|
||||||
ShadowForkPeerIDs []string // List of peer ids that take part in the shadow-fork
|
ShadowForkPeerIDs []string // List of peer ids that take part in the shadow-fork
|
||||||
|
|
||||||
|
DisableTxBroadcast bool
|
||||||
|
DisableTxReceiving bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type handler struct {
|
type handler struct {
|
||||||
|
|
@ -132,6 +135,8 @@ type handler struct {
|
||||||
peerWG sync.WaitGroup
|
peerWG sync.WaitGroup
|
||||||
|
|
||||||
shadowForkPeerIDs []string
|
shadowForkPeerIDs []string
|
||||||
|
disableTxBroadcast bool
|
||||||
|
disableTxReceiving bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHandler returns a handler for all Ethereum chain management protocol.
|
// newHandler returns a handler for all Ethereum chain management protocol.
|
||||||
|
|
@ -151,6 +156,8 @@ func newHandler(config *handlerConfig) (*handler, error) {
|
||||||
whitelist: config.Whitelist,
|
whitelist: config.Whitelist,
|
||||||
quitSync: make(chan struct{}),
|
quitSync: make(chan struct{}),
|
||||||
shadowForkPeerIDs: config.ShadowForkPeerIDs,
|
shadowForkPeerIDs: config.ShadowForkPeerIDs,
|
||||||
|
disableTxBroadcast: config.DisableTxBroadcast,
|
||||||
|
disableTxReceiving: config.DisableTxReceiving,
|
||||||
}
|
}
|
||||||
if config.Sync == downloader.FullSync {
|
if config.Sync == downloader.FullSync {
|
||||||
// The database seems empty as the current block is the genesis. Yet the fast
|
// The database seems empty as the current block is the genesis. Yet the fast
|
||||||
|
|
@ -415,10 +422,12 @@ func (h *handler) Start(maxPeers int) {
|
||||||
h.maxPeers = maxPeers
|
h.maxPeers = maxPeers
|
||||||
|
|
||||||
// broadcast transactions
|
// broadcast transactions
|
||||||
|
if !h.disableTxBroadcast {
|
||||||
h.wg.Add(1)
|
h.wg.Add(1)
|
||||||
h.txsCh = make(chan core.NewTxsEvent, txChanSize)
|
h.txsCh = make(chan core.NewTxsEvent, txChanSize)
|
||||||
h.txsSub = h.txpool.SubscribeNewTxsEvent(h.txsCh)
|
h.txsSub = h.txpool.SubscribeNewTxsEvent(h.txsCh)
|
||||||
go h.txBroadcastLoop()
|
go h.txBroadcastLoop()
|
||||||
|
}
|
||||||
|
|
||||||
// broadcast mined blocks
|
// broadcast mined blocks
|
||||||
h.wg.Add(1)
|
h.wg.Add(1)
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ func (h *ethHandler) PeerInfo(id enode.ID) interface{} {
|
||||||
// AcceptTxs retrieves whether transaction processing is enabled on the node
|
// AcceptTxs retrieves whether transaction processing is enabled on the node
|
||||||
// or if inbound transactions should simply be dropped.
|
// or if inbound transactions should simply be dropped.
|
||||||
func (h *ethHandler) AcceptTxs() bool {
|
func (h *ethHandler) AcceptTxs() bool {
|
||||||
|
if h.disableTxReceiving {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return atomic.LoadUint32(&h.acceptTxs) == 1
|
return atomic.LoadUint32(&h.acceptTxs) == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 5 // Major version component of the current release
|
VersionMajor = 5 // Major version component of the current release
|
||||||
VersionMinor = 8 // Minor version component of the current release
|
VersionMinor = 8 // Minor version component of the current release
|
||||||
VersionPatch = 56 // Patch version component of the current release
|
VersionPatch = 57 // Patch version component of the current release
|
||||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue