Skip to content

Commit

Permalink
Disable tx admission into the txpool if --rollup.sequencerhttp is s…
Browse files Browse the repository at this point in the history
…et (#122)
  • Loading branch information
mdehoog authored Aug 23, 2023
1 parent a74d56b commit 3683102
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
type EthAPIBackend struct {
extRPCEnabled bool
allowUnprotectedTxs bool
disableTxPool bool
eth *Ethereum
gpo *gasprice.Oracle
}
Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
11 changes: 6 additions & 5 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3683102

Please sign in to comment.