From b9e2af216df3818ad6339e29967c2157a6c30958 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Fri, 11 Oct 2024 17:54:46 -0400 Subject: [PATCH] ACP-77: Include validator capacity into the fee config (#3464) --- config/config.go | 2 +- config/flags.go | 2 +- genesis/genesis_fuji.go | 2 +- genesis/genesis_local.go | 2 +- genesis/genesis_mainnet.go | 2 +- genesis/params.go | 9 ++++----- node/node.go | 1 - vms/platformvm/config/config.go | 3 +-- vms/platformvm/validators/fee/fee.go | 1 + 9 files changed, 11 insertions(+), 13 deletions(-) diff --git a/config/config.go b/config/config.go index 46fd0aac8af5..8a95045b7f77 100644 --- a/config/config.go +++ b/config/config.go @@ -793,8 +793,8 @@ func getTxFeeConfig(v *viper.Viper, networkID uint32) genesis.TxFeeConfig { MinPrice: gas.Price(v.GetUint64(DynamicFeesMinGasPriceKey)), ExcessConversionConstant: gas.Gas(v.GetUint64(DynamicFeesExcessConversionConstantKey)), }, - ValidatorFeeCapacity: gas.Gas(v.GetUint64(ValidatorFeesCapacityKey)), ValidatorFeeConfig: validatorfee.Config{ + Capacity: gas.Gas(v.GetUint64(ValidatorFeesCapacityKey)), Target: gas.Gas(v.GetUint64(ValidatorFeesTargetKey)), MinPrice: gas.Price(v.GetUint64(ValidatorFeesMinPriceKey)), ExcessConversionConstant: gas.Gas(v.GetUint64(ValidatorFeesExcessConversionConstantKey)), diff --git a/config/flags.go b/config/flags.go index c20b243c8079..d8397ce40a2c 100644 --- a/config/flags.go +++ b/config/flags.go @@ -106,7 +106,7 @@ func addNodeFlags(fs *pflag.FlagSet) { // AVAX fees: // Validator fees: - fs.Uint64(ValidatorFeesCapacityKey, uint64(genesis.LocalParams.ValidatorFeeCapacity), "Maximum number of validators") + fs.Uint64(ValidatorFeesCapacityKey, uint64(genesis.LocalParams.ValidatorFeeConfig.Capacity), "Maximum number of validators") fs.Uint64(ValidatorFeesTargetKey, uint64(genesis.LocalParams.ValidatorFeeConfig.Target), "Target number of validators") fs.Uint64(ValidatorFeesMinPriceKey, uint64(genesis.LocalParams.ValidatorFeeConfig.MinPrice), "Minimum validator price in nAVAX per second") fs.Uint64(ValidatorFeesExcessConversionConstantKey, uint64(genesis.LocalParams.ValidatorFeeConfig.ExcessConversionConstant), "Constant to convert validator excess price") diff --git a/genesis/genesis_fuji.go b/genesis/genesis_fuji.go index 82a8ffecaa3c..509396c5af8f 100644 --- a/genesis/genesis_fuji.go +++ b/genesis/genesis_fuji.go @@ -48,8 +48,8 @@ var ( MinPrice: 1, ExcessConversionConstant: 5_000, }, - ValidatorFeeCapacity: 20_000, ValidatorFeeConfig: validatorfee.Config{ + Capacity: 20_000, Target: 10_000, MinPrice: gas.Price(512 * units.NanoAvax), // ExcessConversionConstant = (Capacity - Target) * NumberOfSecondsPerDoubling / ln(2) diff --git a/genesis/genesis_local.go b/genesis/genesis_local.go index aefdbf2c25be..f40d866caa65 100644 --- a/genesis/genesis_local.go +++ b/genesis/genesis_local.go @@ -66,8 +66,8 @@ var ( MinPrice: 1, ExcessConversionConstant: 5_000, }, - ValidatorFeeCapacity: 20_000, ValidatorFeeConfig: validatorfee.Config{ + Capacity: 20_000, Target: 10_000, MinPrice: gas.Price(1 * units.NanoAvax), // ExcessConversionConstant = (Capacity - Target) * NumberOfSecondsPerDoubling / ln(2) diff --git a/genesis/genesis_mainnet.go b/genesis/genesis_mainnet.go index 2395d88d34b4..1927762cda8f 100644 --- a/genesis/genesis_mainnet.go +++ b/genesis/genesis_mainnet.go @@ -48,8 +48,8 @@ var ( MinPrice: 1, ExcessConversionConstant: 5_000, }, - ValidatorFeeCapacity: 20_000, ValidatorFeeConfig: validatorfee.Config{ + Capacity: 20_000, Target: 10_000, MinPrice: gas.Price(512 * units.NanoAvax), // ExcessConversionConstant = (Capacity - Target) * NumberOfSecondsPerDoubling / ln(2) diff --git a/genesis/params.go b/genesis/params.go index 43c2f1c1301c..c591c9ed67d8 100644 --- a/genesis/params.go +++ b/genesis/params.go @@ -38,11 +38,10 @@ type StakingConfig struct { } type TxFeeConfig struct { - CreateAssetTxFee uint64 `json:"createAssetTxFee"` - StaticFeeConfig txfee.StaticConfig `json:"staticFeeConfig"` - DynamicFeeConfig gas.Config `json:"dynamicFeeConfig"` - ValidatorFeeCapacity gas.Gas `json:"validatorFeeCapacity"` - ValidatorFeeConfig validatorfee.Config `json:"validatorFeeConfig"` + CreateAssetTxFee uint64 `json:"createAssetTxFee"` + StaticFeeConfig txfee.StaticConfig `json:"staticFeeConfig"` + DynamicFeeConfig gas.Config `json:"dynamicFeeConfig"` + ValidatorFeeConfig validatorfee.Config `json:"validatorFeeConfig"` } type Params struct { diff --git a/node/node.go b/node/node.go index 3eb2f9b18447..1fedf35eb97e 100644 --- a/node/node.go +++ b/node/node.go @@ -1217,7 +1217,6 @@ func (n *Node) initVMs() error { CreateAssetTxFee: n.Config.CreateAssetTxFee, StaticFeeConfig: n.Config.StaticFeeConfig, DynamicFeeConfig: n.Config.DynamicFeeConfig, - ValidatorFeeCapacity: n.Config.ValidatorFeeCapacity, ValidatorFeeConfig: n.Config.ValidatorFeeConfig, UptimePercentage: n.Config.UptimeRequirement, MinValidatorStake: n.Config.MinValidatorStake, diff --git a/vms/platformvm/config/config.go b/vms/platformvm/config/config.go index f8bda923455c..897f910a1380 100644 --- a/vms/platformvm/config/config.go +++ b/vms/platformvm/config/config.go @@ -42,8 +42,7 @@ type Config struct { DynamicFeeConfig gas.Config // ACP-77 validator fees are active after Etna - ValidatorFeeCapacity gas.Gas - ValidatorFeeConfig validatorfee.Config + ValidatorFeeConfig validatorfee.Config // Provides access to the uptime manager as a thread safe data structure UptimeLockedCalculator uptime.LockedCalculator diff --git a/vms/platformvm/validators/fee/fee.go b/vms/platformvm/validators/fee/fee.go index 23705d8b25a2..df466a70770f 100644 --- a/vms/platformvm/validators/fee/fee.go +++ b/vms/platformvm/validators/fee/fee.go @@ -13,6 +13,7 @@ import ( // Config contains all the static parameters of the dynamic fee mechanism. type Config struct { + Capacity gas.Gas `json:"capacity"` Target gas.Gas `json:"target"` MinPrice gas.Price `json:"minPrice"` ExcessConversionConstant gas.Gas `json:"excessConversionConstant"`