@@ -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 ,
@@ -291,6 +296,43 @@ func main() {
291296
292297 return nil
293298 }).
299+ Module ("updatable collection rate limiting config" , func (node * cmd.NodeConfig ) error {
300+ setter := updatable_configs .DefaultBySealingLagRateLimiterConfigs ()
301+
302+ // update the getter with the setter, so other modules can only get, but not set
303+ bySealingLagRateLimiterConfigGetter = setter
304+
305+ // admin tool is the only instance that have access to the setter interface, therefore, is
306+ // the only module can change this config
307+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-min-sealing-lag" ,
308+ setter .MinSealingLag ,
309+ setter .SetMinSealingLag )
310+ if err != nil {
311+ return err
312+ }
313+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-max-sealing-lag" ,
314+ setter .MaxSealingLag ,
315+ setter .SetMaxSealingLag )
316+ if err != nil {
317+ return err
318+ }
319+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-halving-interval" ,
320+ setter .HalvingInterval ,
321+ setter .SetHalvingInterval )
322+ if err != nil {
323+ return err
324+ }
325+ err = node .ConfigManager .RegisterUintConfig ("collection-builder-rate-limiter-min-collection-size" ,
326+ setter .MinCollectionSize ,
327+ setter .SetMinCollectionSize )
328+ if err != nil {
329+ return err
330+ }
331+
332+ // report the initial config value
333+ colMetrics .CollectionMaxSize (maxCollectionSize )
334+ return nil
335+ }).
294336 Component ("machine account config validator" , func (node * cmd.NodeConfig ) (module.ReadyDoneAware , error ) {
295337 // @TODO use fallback logic for flowClient similar to DKG/QC contract clients
296338 flowClient , err := grpcclient .FlowClient (flowClientConfigs [0 ])
@@ -498,6 +540,13 @@ func main() {
498540 unlimitedPayers = append (unlimitedPayers , payerAddr )
499541 }
500542
543+ // convert hex string flag values to addresses
544+ priorityPayers := make ([]flow.Address , 0 , len (builderPriorityPayers ))
545+ for _ , payerStr := range builderPriorityPayers {
546+ payerAddr := flow .HexToAddress (payerStr )
547+ priorityPayers = append (priorityPayers , payerAddr )
548+ }
549+
501550 builderFactory , err := factories .NewBuilderFactory (
502551 node .ProtocolDB ,
503552 node .State ,
@@ -507,13 +556,15 @@ func main() {
507556 colMetrics ,
508557 push ,
509558 node .Logger ,
559+ bySealingLagRateLimiterConfigGetter ,
510560 builder .WithMaxCollectionSize (maxCollectionSize ),
511561 builder .WithMaxCollectionByteSize (maxCollectionByteSize ),
512562 builder .WithMaxCollectionTotalGas (maxCollectionTotalGas ),
513563 builder .WithExpiryBuffer (builderExpiryBuffer ),
514564 builder .WithRateLimitDryRun (builderPayerRateLimitDryRun ),
515565 builder .WithMaxPayerTransactionRate (builderPayerRateLimit ),
516566 builder .WithUnlimitedPayers (unlimitedPayers ... ),
567+ builder .WithPriorityPayers (priorityPayers ... ),
517568 )
518569 if err != nil {
519570 return nil , err
0 commit comments