@@ -51,6 +51,7 @@ import (
5151 "github.com/onflow/flow-go/module/mempool/herocache"
5252 "github.com/onflow/flow-go/module/mempool/queue"
5353 "github.com/onflow/flow-go/module/metrics"
54+ "github.com/onflow/flow-go/module/updatable_configs"
5455 "github.com/onflow/flow-go/network/channels"
5556 "github.com/onflow/flow-go/state/protocol"
5657 badgerState "github.com/onflow/flow-go/state/protocol/badger"
@@ -73,6 +74,7 @@ func main() {
7374 builderPayerRateLimitDryRun bool
7475 builderPayerRateLimit float64
7576 builderUnlimitedPayers []string
77+ builderPriorityPayers []string
7678 hotstuffMinTimeout time.Duration
7779 hotstuffTimeoutAdjustmentFactor float64
7880 hotstuffHappyPathMaxRoundFailures uint64
@@ -100,15 +102,16 @@ func main() {
100102 err error
101103
102104 // epoch qc contract client
103- machineAccountInfo * bootstrap.NodeMachineAccountInfo
104- flowClientConfigs []* grpcclient.FlowClientConfig
105- insecureAccessAPI bool
106- accessNodeIDS []string
107- apiRatelimits map [string ]int
108- apiBurstlimits map [string ]int
109- txRatelimits float64
110- txBurstlimits int
111- txRatelimitPayers string
105+ machineAccountInfo * bootstrap.NodeMachineAccountInfo
106+ flowClientConfigs []* grpcclient.FlowClientConfig
107+ insecureAccessAPI bool
108+ accessNodeIDS []string
109+ apiRatelimits map [string ]int
110+ apiBurstlimits map [string ]int
111+ txRatelimits float64
112+ txBurstlimits int
113+ txRatelimitPayers string
114+ bySealingLagRateLimiterConfigGetter module.ReadonlySealingLagRateLimiterConfig
112115 )
113116 var deprecatedFlagBlockRateDelay time.Duration
114117
@@ -142,6 +145,8 @@ func main() {
142145 "rate limit for each payer (transactions/collection)" )
143146 flags .StringSliceVar (& builderUnlimitedPayers , "builder-unlimited-payers" , []string {}, // no unlimited payers
144147 "set of payer addresses which are omitted from rate limiting" )
148+ flags .StringSliceVar (& builderPriorityPayers , "builder-priority-payers" , []string {}, // no priority payers
149+ "set of payer addresses which are prioritized in tx selection algorithm" )
145150 flags .UintVar (& maxCollectionSize , "builder-max-collection-size" , flow .DefaultMaxCollectionSize ,
146151 "maximum number of transactions in proposed collections" )
147152 flags .Uint64Var (& maxCollectionByteSize , "builder-max-collection-byte-size" , flow .DefaultMaxCollectionByteSize ,
@@ -294,6 +299,43 @@ func main() {
294299
295300 return nil
296301 }).
302+ Module ("updatable collection rate limiting config" , func (node * cmd.NodeConfig ) error {
303+ setter := updatable_configs .DefaultBySealingLagRateLimiterConfigs ()
304+
305+ // update the getter with the setter, so other modules can only get, but not set
306+ bySealingLagRateLimiterConfigGetter = setter
307+
308+ // admin tool is the only instance that have access to the setter interface, therefore, is
309+ // the only module can change this config
310+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-min-sealing-lag" ,
311+ setter .MinSealingLag ,
312+ setter .SetMinSealingLag )
313+ if err != nil {
314+ return err
315+ }
316+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-max-sealing-lag" ,
317+ setter .MaxSealingLag ,
318+ setter .SetMaxSealingLag )
319+ if err != nil {
320+ return err
321+ }
322+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-halving-interval" ,
323+ setter .HalvingInterval ,
324+ setter .SetHalvingInterval )
325+ if err != nil {
326+ return err
327+ }
328+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-min-collection-size" ,
329+ setter .MinCollectionSize ,
330+ setter .SetMinCollectionSize )
331+ if err != nil {
332+ return err
333+ }
334+
335+ // report the initial config value
336+ colMetrics .CollectionMaxSize (maxCollectionSize )
337+ return nil
338+ }).
297339 Component ("machine account config validator" , func (node * cmd.NodeConfig ) (module.ReadyDoneAware , error ) {
298340 // @TODO use fallback logic for flowClient similar to DKG/QC contract clients
299341 flowClient , err := grpcclient .FlowClient (flowClientConfigs [0 ])
@@ -501,6 +543,13 @@ func main() {
501543 unlimitedPayers = append (unlimitedPayers , payerAddr )
502544 }
503545
546+ // convert hex string flag values to addresses
547+ priorityPayers := make ([]flow.Address , 0 , len (builderPriorityPayers ))
548+ for _ , payerStr := range builderPriorityPayers {
549+ payerAddr := flow .HexToAddress (payerStr )
550+ priorityPayers = append (priorityPayers , payerAddr )
551+ }
552+
504553 builderFactory , err := factories .NewBuilderFactory (
505554 node .DB ,
506555 node .State ,
@@ -509,13 +558,15 @@ func main() {
509558 colMetrics ,
510559 push ,
511560 node .Logger ,
561+ bySealingLagRateLimiterConfigGetter ,
512562 builder .WithMaxCollectionSize (maxCollectionSize ),
513563 builder .WithMaxCollectionByteSize (maxCollectionByteSize ),
514564 builder .WithMaxCollectionTotalGas (maxCollectionTotalGas ),
515565 builder .WithExpiryBuffer (builderExpiryBuffer ),
516566 builder .WithRateLimitDryRun (builderPayerRateLimitDryRun ),
517567 builder .WithMaxPayerTransactionRate (builderPayerRateLimit ),
518568 builder .WithUnlimitedPayers (unlimitedPayers ... ),
569+ builder .WithPriorityPayers (priorityPayers ... ),
519570 )
520571 if err != nil {
521572 return nil , err
0 commit comments