diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a0752054b0..16744c8193 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -883,6 +883,11 @@ var ( Usage: "Disable transaction pool gossip.", Category: flags.RollupCategory, } + RollupEnableTxPoolAdmissionFlag = &cli.BoolFlag{ + Name: "rollup.enabletxpooladmission", + Usage: "Add RPC-submitted transactions to the txpool (on by default if --rollup.sequencerhttp is not set).", + Category: flags.RollupCategory, + } RollupComputePendingBlock = &cli.BoolFlag{ Name: "rollup.computependingblock", Usage: "By default the pending block equals the latest block to save resources and not leak txs from the tx-pool, this flag enables computing of the pending block from the tx-pool instead.", @@ -1838,6 +1843,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { cfg.RollupHistoricalRPCTimeout = ctx.Duration(RollupHistoricalRPCTimeoutFlag.Name) } cfg.RollupDisableTxPoolGossip = ctx.Bool(RollupDisableTxPoolGossipFlag.Name) + cfg.RollupDisableTxPoolAdmission = cfg.RollupSequencerHTTP != "" && !ctx.Bool(RollupEnableTxPoolAdmissionFlag.Name) cfg.RollupAllowPendingTxFilters = ctx.Bool(RollupAllowPendingTxFilters.Name) // Override any default configs for hard coded networks. switch { diff --git a/eth/api_backend.go b/eth/api_backend.go index 500ff7d95d..1351c009ff 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -49,6 +49,7 @@ import ( type EthAPIBackend struct { extRPCEnabled bool allowUnprotectedTxs bool + disableTxPool bool eth *Ethereum gpo *gasprice.Oracle } @@ -300,12 +301,18 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, tx *types.Transaction) error if err := b.eth.seqRPCService.CallContext(ctx, nil, "eth_sendRawTransaction", hexutil.Encode(data)); err != nil { return err } + if b.disableTxPool { + return nil + } // Retain tx in local tx pool after forwarding, for local RPC usage. if err := b.eth.txPool.AddLocal(tx); err != nil { log.Warn("successfully sent tx to sequencer, but failed to persist in local tx pool", "err", err, "tx", tx.Hash()) } return nil } + if b.disableTxPool { + return nil + } return b.eth.txPool.AddLocal(tx) } diff --git a/eth/backend.go b/eth/backend.go index f5c3995bd1..294fb4e12e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -251,7 +251,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { eth.miner = miner.New(eth, &config.Miner, eth.blockchain.Config(), eth.EventMux(), eth.engine, eth.isLocalBlock) eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData)) - eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil} + eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, config.RollupDisableTxPoolAdmission, eth, nil} if eth.APIBackend.allowUnprotectedTxs { log.Info("Unprotected transactions allowed") } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 6becf71d1f..c1b0e2ec56 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -168,11 +168,12 @@ type Config struct { OverrideOptimismRegolith *uint64 `toml:",omitempty"` OverrideOptimism *bool - RollupSequencerHTTP string - RollupHistoricalRPC string - RollupHistoricalRPCTimeout time.Duration - RollupDisableTxPoolGossip bool - RollupAllowPendingTxFilters bool + RollupSequencerHTTP string + RollupHistoricalRPC string + RollupHistoricalRPCTimeout time.Duration + RollupDisableTxPoolGossip bool + RollupDisableTxPoolAdmission bool + RollupAllowPendingTxFilters bool } // CreateConsensusEngine creates a consensus engine for the given chain config.