diff --git a/cmd/flags/proposer.go b/cmd/flags/proposer.go index 9a3c1414f..a780991f7 100644 --- a/cmd/flags/proposer.go +++ b/cmd/flags/proposer.go @@ -40,6 +40,12 @@ var ( Usage: "Comma separated accounts to treat as locals (priority inclusion)", Category: proposerCategory, } + TxPoolLocalsOnly = &cli.BoolFlag{ + Name: "txpool.localsOnly", + Usage: "If set to true, proposer will only propose transactions of local accounts", + Value: false, + Category: proposerCategory, + } ProposeEmptyBlocksInterval = &cli.StringFlag{ Name: "proposeEmptyBlockInterval", Usage: "Time interval to propose empty blocks", @@ -76,6 +82,7 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{ ProposeInterval, CommitSlot, TxPoolLocals, + TxPoolLocalsOnly, ProposeEmptyBlocksInterval, MinBlockGasLimit, MaxProposedTxListsPerEpoch, diff --git a/proposer/config.go b/proposer/config.go index 9db37f7f9..84eb8ba74 100644 --- a/proposer/config.go +++ b/proposer/config.go @@ -23,6 +23,7 @@ type Config struct { ProposeInterval *time.Duration CommitSlot uint64 LocalAddresses []common.Address + LocalAddressesOnly bool ProposeEmptyBlocksInterval *time.Duration MinBlockGasLimit uint64 MaxProposedTxListsPerEpoch uint64 @@ -99,6 +100,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { ProposeInterval: proposingInterval, CommitSlot: c.Uint64(flags.CommitSlot.Name), LocalAddresses: localAddresses, + LocalAddressesOnly: c.Bool(flags.TxPoolLocalsOnly.Name), ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval, MinBlockGasLimit: c.Uint64(flags.MinBlockGasLimit.Name), MaxProposedTxListsPerEpoch: c.Uint64(flags.MaxProposedTxListsPerEpoch.Name), diff --git a/proposer/proposer.go b/proposer/proposer.go index 2c228da3a..4f6adf45f 100644 --- a/proposer/proposer.go +++ b/proposer/proposer.go @@ -50,6 +50,7 @@ type Proposer struct { proposingTimer *time.Timer commitSlot uint64 locals []common.Address + localsOnly bool minBlockGasLimit *uint64 maxProposedTxListsPerEpoch uint64 proposeBlockTxGasLimit *uint64 @@ -86,6 +87,7 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) { p.proposeBlockTxGasLimit = cfg.ProposeBlockTxGasLimit p.wg = sync.WaitGroup{} p.locals = cfg.LocalAddresses + p.localsOnly = cfg.LocalAddressesOnly p.commitSlot = cfg.CommitSlot p.maxProposedTxListsPerEpoch = cfg.MaxProposedTxListsPerEpoch p.txReplacementTipMultiplier = cfg.ProposeBlockTxReplacementMultiplier @@ -211,6 +213,33 @@ func (p *Proposer) ProposeOp(ctx context.Context) error { return fmt.Errorf("failed to fetch transaction pool content: %w", err) } + if p.localsOnly { + var ( + localTxsLists []types.Transactions + signer = types.LatestSignerForChainID(p.rpc.L2ChainID) + ) + for _, txs := range txLists { + var filtered types.Transactions + for _, tx := range txs { + sender, err := types.Sender(signer, tx) + if err != nil { + return err + } + + for _, localAddress := range p.locals { + if sender == localAddress { + filtered = append(filtered, tx) + } + } + } + + if filtered.Len() != 0 { + localTxsLists = append(localTxsLists, filtered) + } + } + txLists = localTxsLists + } + log.Info("Transactions lists count", "count", len(txLists)) if len(txLists) == 0 {