@@ -31,11 +31,6 @@ import (
3131 "github.com/ethereum/go-ethereum/rpc"
3232)
3333
34- const (
35- // maxBidPerBuilderPerBlock is the max bid number per builder
36- maxBidPerBuilderPerBlock = 3
37- )
38-
3934var (
4035 bidSimTimer = metrics .NewRegisteredTimer ("bid/sim/duration" , nil )
4136)
@@ -118,6 +113,8 @@ type bidSimulator struct {
118113
119114 simBidMu sync.RWMutex
120115 simulatingBid map [common.Hash ]* BidRuntime // prevBlockHash -> bidRuntime, in the process of simulation
116+
117+ maxBidsPerBuilder uint32 // Maximum number of bids allowed per builder per block
121118}
122119
123120func newBidSimulator (
@@ -129,24 +126,31 @@ func newBidSimulator(
129126 engine consensus.Engine ,
130127 bidWorker bidWorker ,
131128) * bidSimulator {
129+ // Set default value
130+ maxBids := uint32 (3 )
131+ if config .MaxBidsPerBuilder > 0 {
132+ maxBids = config .MaxBidsPerBuilder
133+ }
134+
132135 b := & bidSimulator {
133- config : config ,
134- delayLeftOver : delayLeftOver ,
135- minGasPrice : minGasPrice ,
136- chain : eth .BlockChain (),
137- txpool : eth .TxPool (),
138- chainConfig : chainConfig ,
139- engine : engine ,
140- bidWorker : bidWorker ,
141- exitCh : make (chan struct {}),
142- chainHeadCh : make (chan core.ChainHeadEvent , chainHeadChanSize ),
143- builders : make (map [common.Address ]* builderclient.Client ),
144- simBidCh : make (chan * simBidReq ),
145- newBidCh : make (chan newBidPackage , 100 ),
146- pending : make (map [uint64 ]map [common.Address ]map [common.Hash ]struct {}),
147- bestBid : make (map [common.Hash ]* BidRuntime ),
148- bestBidToRun : make (map [common.Hash ]* types.Bid ),
149- simulatingBid : make (map [common.Hash ]* BidRuntime ),
136+ config : config ,
137+ delayLeftOver : delayLeftOver ,
138+ minGasPrice : minGasPrice ,
139+ chain : eth .BlockChain (),
140+ txpool : eth .TxPool (),
141+ chainConfig : chainConfig ,
142+ engine : engine ,
143+ bidWorker : bidWorker ,
144+ maxBidsPerBuilder : maxBids ,
145+ exitCh : make (chan struct {}),
146+ chainHeadCh : make (chan core.ChainHeadEvent , chainHeadChanSize ),
147+ builders : make (map [common.Address ]* builderclient.Client ),
148+ simBidCh : make (chan * simBidReq ),
149+ newBidCh : make (chan newBidPackage , 100 ),
150+ pending : make (map [uint64 ]map [common.Address ]map [common.Hash ]struct {}),
151+ bestBid : make (map [common.Hash ]* BidRuntime ),
152+ bestBidToRun : make (map [common.Hash ]* types.Bid ),
153+ simulatingBid : make (map [common.Hash ]* BidRuntime ),
150154 }
151155
152156 b .chainHeadSub = b .chain .SubscribeChainHeadEvent (b .chainHeadCh )
@@ -577,8 +581,8 @@ func (b *bidSimulator) CheckPending(blockNumber uint64, builder common.Address,
577581 return errors .New ("bid already exists" )
578582 }
579583
580- if len (b.pending [blockNumber ][builder ]) >= maxBidPerBuilderPerBlock {
581- return errors . New ("too many bids" )
584+ if len (b.pending [blockNumber ][builder ]) >= int ( b . maxBidsPerBuilder ) {
585+ return fmt . Errorf ("too many bids: exceeded limit of %d bids per builder per block" , b . maxBidsPerBuilder )
582586 }
583587
584588 return nil
0 commit comments