@@ -23,49 +23,39 @@ import (
2323)
2424
2525var (
26- // Hard and soft balance limits for collection and consensus nodes.
27- // We will log a warning once for a soft limit, and will log an error
28- // in perpetuity for a hard limit.
26+ // Balance limits for collection and consensus nodes.
2927 // Taken from https://www.notion.so/dapperlabs/Machine-Account-f3c293593ea442a39614fcebf705a132
30- // TODO update these for FLIP74
3128
32- defaultSoftMinBalanceLN cadence.UFix64
33- defaultHardMinBalanceLN cadence.UFix64
34- defaultSoftMinBalanceSN cadence.UFix64
35- defaultHardMinBalanceSN cadence.UFix64
29+ cdcRecommendedMinBalanceLN cadence.UFix64
30+ cdcRecommendedMinBalanceSN cadence.UFix64
3631)
3732
3833const (
39- recommendedMinBalanceLN = 0.002
40- recommendedMinBalanceSN = 0.05
34+ // We recommend node operators refill once they reach this threshold
35+ recommendedMinBalanceLN = 0.25
36+ recommendedMinBalanceSN = 2.0
37+ recommendedRefillToBalanceLN = 0.75
38+ recommendedRefillToBalanceSN = 6.0
4139)
4240
4341func init () {
4442 var err error
45- defaultSoftMinBalanceLN , err = cadence .NewUFix64 ("0.0025" )
46- if err != nil {
47- panic (fmt .Errorf ("could not convert soft min balance for LN: %w" , err ))
48- }
49- defaultHardMinBalanceLN , err = cadence .NewUFix64 ("0.002" )
43+ cdcRecommendedMinBalanceLN , err = cadence .NewUFix64 ("0.25" )
5044 if err != nil {
5145 panic (fmt .Errorf ("could not convert hard min balance for LN: %w" , err ))
5246 }
53- defaultSoftMinBalanceSN , err = cadence .NewUFix64 ("0.125" )
54- if err != nil {
55- panic (fmt .Errorf ("could not convert soft min balance for SN: %w" , err ))
56- }
57- defaultHardMinBalanceSN , err = cadence .NewUFix64 ("0.05" )
47+ cdcRecommendedMinBalanceSN , err = cadence .NewUFix64 ("2.0" )
5848 if err != nil {
5949 panic (fmt .Errorf ("could not convert hard min balance for SN: %w" , err ))
6050 }
6151
6252 // sanity checks
63- if asFloat , err := ufix64Tofloat64 (defaultHardMinBalanceLN ); err != nil {
53+ if asFloat , err := ufix64Tofloat64 (cdcRecommendedMinBalanceLN ); err != nil {
6454 panic (err )
6555 } else if asFloat != recommendedMinBalanceLN {
6656 panic (fmt .Errorf ("failed sanity check: %f!=%f" , asFloat , recommendedMinBalanceLN ))
6757 }
68- if asFloat , err := ufix64Tofloat64 (defaultHardMinBalanceSN ); err != nil {
58+ if asFloat , err := ufix64Tofloat64 (cdcRecommendedMinBalanceSN ); err != nil {
6959 panic (err )
7060 } else if asFloat != recommendedMinBalanceSN {
7161 panic (fmt .Errorf ("failed sanity check: %f!=%f" , asFloat , recommendedMinBalanceSN ))
@@ -91,28 +81,22 @@ func checkMachineAccountRetryBackoff() retry.Backoff {
9181
9282// MachineAccountValidatorConfig defines configuration options for MachineAccountConfigValidator.
9383type MachineAccountValidatorConfig struct {
94- SoftMinBalanceLN cadence.UFix64
9584 HardMinBalanceLN cadence.UFix64
96- SoftMinBalanceSN cadence.UFix64
9785 HardMinBalanceSN cadence.UFix64
9886}
9987
10088func DefaultMachineAccountValidatorConfig () MachineAccountValidatorConfig {
10189 return MachineAccountValidatorConfig {
102- SoftMinBalanceLN : defaultSoftMinBalanceLN ,
103- HardMinBalanceLN : defaultHardMinBalanceLN ,
104- SoftMinBalanceSN : defaultSoftMinBalanceSN ,
105- HardMinBalanceSN : defaultHardMinBalanceSN ,
90+ HardMinBalanceLN : cdcRecommendedMinBalanceLN ,
91+ HardMinBalanceSN : cdcRecommendedMinBalanceSN ,
10692 }
10793}
10894
10995// WithoutBalanceChecks sets minimum balances to 0 to effectively disable minimum
11096// balance checks. This is useful for test networks where transaction fees are
11197// disabled.
11298func WithoutBalanceChecks (conf * MachineAccountValidatorConfig ) {
113- conf .SoftMinBalanceLN = 0
11499 conf .HardMinBalanceLN = 0
115- conf .SoftMinBalanceSN = 0
116100 conf .HardMinBalanceSN = 0
117101}
118102
@@ -323,17 +307,11 @@ func CheckMachineAccountInfo(
323307 switch role {
324308 case flow .RoleCollection :
325309 if balance < conf .HardMinBalanceLN {
326- return fmt .Errorf ("machine account balance is below hard minimum (%s < %s)" , balance , conf .HardMinBalanceLN )
327- }
328- if balance < conf .SoftMinBalanceLN {
329- log .Warn ().Msgf ("machine account balance is below recommended balance (%s < %s)" , balance , conf .SoftMinBalanceLN )
310+ return fmt .Errorf ("machine account balance is below minimum (%s < %s). Please refill to %f FLOW" , balance , conf .HardMinBalanceLN , recommendedRefillToBalanceLN )
330311 }
331312 case flow .RoleConsensus :
332313 if balance < conf .HardMinBalanceSN {
333- return fmt .Errorf ("machine account balance is below hard minimum (%s < %s)" , balance , conf .HardMinBalanceSN )
334- }
335- if balance < conf .SoftMinBalanceSN {
336- log .Warn ().Msgf ("machine account balance is below recommended balance (%s < %s)" , balance , conf .SoftMinBalanceSN )
314+ return fmt .Errorf ("machine account balance is below minimum (%s < %s). Please refill to %f FLOW" , balance , conf .HardMinBalanceSN , recommendedRefillToBalanceSN )
337315 }
338316 default :
339317 // sanity check - should be caught earlier in this function
0 commit comments