Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement acp-77 fee configs #3396

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ import (
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/proposervm"

txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
validatorfee "github.com/ava-labs/avalanchego/vms/platformvm/validators/fee"
)

const (
Expand Down Expand Up @@ -768,7 +770,7 @@ func getTxFeeConfig(v *viper.Viper, networkID uint32) genesis.TxFeeConfig {
if networkID != constants.MainnetID && networkID != constants.FujiID {
return genesis.TxFeeConfig{
CreateAssetTxFee: v.GetUint64(CreateAssetTxFeeKey),
StaticFeeConfig: fee.StaticConfig{
StaticFeeConfig: txfee.StaticConfig{
TxFee: v.GetUint64(TxFeeKey),
CreateSubnetTxFee: v.GetUint64(CreateSubnetTxFeeKey),
TransformSubnetTxFee: v.GetUint64(TransformSubnetTxFeeKey),
Expand All @@ -791,6 +793,12 @@ 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{
Target: gas.Gas(v.GetUint64(ValidatorFeesTargetKey)),
MinPrice: gas.Price(v.GetUint64(ValidatorFeesMinPriceKey)),
ExcessConversionConstant: gas.Gas(v.GetUint64(ValidatorFeesExcessConversionConstantKey)),
},
}
}
return genesis.GetTxFeeConfig(networkID)
Expand Down
5 changes: 5 additions & 0 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func addNodeFlags(fs *pflag.FlagSet) {
fs.IntSlice(ACPObjectKey, nil, "ACPs to object adoption")

// AVAX fees:
// Validator fees:
fs.Uint64(ValidatorFeesCapacityKey, uint64(genesis.LocalParams.ValidatorFeeCapacity), "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 per second")
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
fs.Uint64(ValidatorFeesExcessConversionConstantKey, uint64(genesis.LocalParams.ValidatorFeeConfig.ExcessConversionConstant), "Constant to convert validator excess price")
// Dynamic fees:
fs.Uint64(DynamicFeesBandwidthWeightKey, genesis.LocalParams.DynamicFeeConfig.Weights[gas.Bandwidth], "Complexity multiplier used to convert Bandwidth into Gas")
fs.Uint64(DynamicFeesDBReadWeightKey, genesis.LocalParams.DynamicFeeConfig.Weights[gas.DBRead], "Complexity multiplier used to convert DB Reads into Gas")
Expand Down
118 changes: 61 additions & 57 deletions config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,67 @@ package config
const HTTPWriteTimeoutKey = "http-write-timeout" // #nosec G101

const (
DataDirKey = "data-dir"
ConfigFileKey = "config-file"
ConfigContentKey = "config-file-content"
ConfigContentTypeKey = "config-file-content-type"
VersionKey = "version"
VersionJSONKey = "version-json"
GenesisFileKey = "genesis-file"
GenesisFileContentKey = "genesis-file-content"
UpgradeFileKey = "upgrade-file"
UpgradeFileContentKey = "upgrade-file-content"
NetworkNameKey = "network-id"
ACPSupportKey = "acp-support"
ACPObjectKey = "acp-object"
DynamicFeesBandwidthWeightKey = "dynamic-fees-bandwidth-weight"
DynamicFeesDBReadWeightKey = "dynamic-fees-db-read-weight"
DynamicFeesDBWriteWeightKey = "dynamic-fees-db-write-weight"
DynamicFeesComputeWeightKey = "dynamic-fees-compute-weight"
DynamicFeesMaxGasCapacityKey = "dynamic-fees-max-gas-capacity"
DynamicFeesMaxGasPerSecondKey = "dynamic-fees-max-gas-per-second"
DynamicFeesTargetGasPerSecondKey = "dynamic-fees-target-gas-per-second"
DynamicFeesMinGasPriceKey = "dynamic-fees-min-gas-price"
DynamicFeesExcessConversionConstantKey = "dynamic-fees-excess-conversion-constant"
TxFeeKey = "tx-fee"
CreateAssetTxFeeKey = "create-asset-tx-fee"
CreateSubnetTxFeeKey = "create-subnet-tx-fee"
TransformSubnetTxFeeKey = "transform-subnet-tx-fee"
CreateBlockchainTxFeeKey = "create-blockchain-tx-fee"
AddPrimaryNetworkValidatorFeeKey = "add-primary-network-validator-fee"
AddPrimaryNetworkDelegatorFeeKey = "add-primary-network-delegator-fee"
AddSubnetValidatorFeeKey = "add-subnet-validator-fee"
AddSubnetDelegatorFeeKey = "add-subnet-delegator-fee"
UptimeRequirementKey = "uptime-requirement"
MinValidatorStakeKey = "min-validator-stake"
MaxValidatorStakeKey = "max-validator-stake"
MinDelegatorStakeKey = "min-delegator-stake"
MinDelegatorFeeKey = "min-delegation-fee"
MinStakeDurationKey = "min-stake-duration"
MaxStakeDurationKey = "max-stake-duration"
StakeMaxConsumptionRateKey = "stake-max-consumption-rate"
StakeMinConsumptionRateKey = "stake-min-consumption-rate"
StakeMintingPeriodKey = "stake-minting-period"
StakeSupplyCapKey = "stake-supply-cap"
DBTypeKey = "db-type"
DBReadOnlyKey = "db-read-only"
DBPathKey = "db-dir"
DBConfigFileKey = "db-config-file"
DBConfigContentKey = "db-config-file-content"
PublicIPKey = "public-ip"
PublicIPResolutionFreqKey = "public-ip-resolution-frequency"
PublicIPResolutionServiceKey = "public-ip-resolution-service"
HTTPHostKey = "http-host"
HTTPPortKey = "http-port"
HTTPSEnabledKey = "http-tls-enabled"
HTTPSKeyFileKey = "http-tls-key-file"
HTTPSKeyContentKey = "http-tls-key-file-content"
HTTPSCertFileKey = "http-tls-cert-file"
HTTPSCertContentKey = "http-tls-cert-file-content"
DataDirKey = "data-dir"
ConfigFileKey = "config-file"
ConfigContentKey = "config-file-content"
ConfigContentTypeKey = "config-file-content-type"
VersionKey = "version"
VersionJSONKey = "version-json"
GenesisFileKey = "genesis-file"
GenesisFileContentKey = "genesis-file-content"
UpgradeFileKey = "upgrade-file"
UpgradeFileContentKey = "upgrade-file-content"
NetworkNameKey = "network-id"
ACPSupportKey = "acp-support"
ACPObjectKey = "acp-object"
DynamicFeesBandwidthWeightKey = "dynamic-fees-bandwidth-weight"
DynamicFeesDBReadWeightKey = "dynamic-fees-db-read-weight"
DynamicFeesDBWriteWeightKey = "dynamic-fees-db-write-weight"
DynamicFeesComputeWeightKey = "dynamic-fees-compute-weight"
DynamicFeesMaxGasCapacityKey = "dynamic-fees-max-gas-capacity"
DynamicFeesMaxGasPerSecondKey = "dynamic-fees-max-gas-per-second"
DynamicFeesTargetGasPerSecondKey = "dynamic-fees-target-gas-per-second"
DynamicFeesMinGasPriceKey = "dynamic-fees-min-gas-price"
DynamicFeesExcessConversionConstantKey = "dynamic-fees-excess-conversion-constant"
ValidatorFeesCapacityKey = "validator-fees-capacity"
ValidatorFeesTargetKey = "validator-fees-target"
ValidatorFeesMinPriceKey = "validator-fees-min-price"
ValidatorFeesExcessConversionConstantKey = "validator-fees-excess-conversion-constant"
TxFeeKey = "tx-fee"
CreateAssetTxFeeKey = "create-asset-tx-fee"
CreateSubnetTxFeeKey = "create-subnet-tx-fee"
TransformSubnetTxFeeKey = "transform-subnet-tx-fee"
CreateBlockchainTxFeeKey = "create-blockchain-tx-fee"
AddPrimaryNetworkValidatorFeeKey = "add-primary-network-validator-fee"
AddPrimaryNetworkDelegatorFeeKey = "add-primary-network-delegator-fee"
AddSubnetValidatorFeeKey = "add-subnet-validator-fee"
AddSubnetDelegatorFeeKey = "add-subnet-delegator-fee"
UptimeRequirementKey = "uptime-requirement"
MinValidatorStakeKey = "min-validator-stake"
MaxValidatorStakeKey = "max-validator-stake"
MinDelegatorStakeKey = "min-delegator-stake"
MinDelegatorFeeKey = "min-delegation-fee"
MinStakeDurationKey = "min-stake-duration"
MaxStakeDurationKey = "max-stake-duration"
StakeMaxConsumptionRateKey = "stake-max-consumption-rate"
StakeMinConsumptionRateKey = "stake-min-consumption-rate"
StakeMintingPeriodKey = "stake-minting-period"
StakeSupplyCapKey = "stake-supply-cap"
DBTypeKey = "db-type"
DBReadOnlyKey = "db-read-only"
DBPathKey = "db-dir"
DBConfigFileKey = "db-config-file"
DBConfigContentKey = "db-config-file-content"
PublicIPKey = "public-ip"
PublicIPResolutionFreqKey = "public-ip-resolution-frequency"
PublicIPResolutionServiceKey = "public-ip-resolution-service"
HTTPHostKey = "http-host"
HTTPPortKey = "http-port"
HTTPSEnabledKey = "http-tls-enabled"
HTTPSKeyFileKey = "http-tls-key-file"
HTTPSKeyContentKey = "http-tls-key-file-content"
HTTPSCertFileKey = "http-tls-cert-file"
HTTPSCertContentKey = "http-tls-cert-file-content"

HTTPAllowedOrigins = "http-allowed-origins"
HTTPAllowedHostsKey = "http-allowed-hosts"
Expand Down
12 changes: 10 additions & 2 deletions genesis/genesis_fuji.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
validatorfee "github.com/ava-labs/avalanchego/vms/platformvm/validators/fee"
)

var (
Expand All @@ -22,7 +24,7 @@ var (
FujiParams = Params{
TxFeeConfig: TxFeeConfig{
CreateAssetTxFee: 10 * units.MilliAvax,
StaticFeeConfig: fee.StaticConfig{
StaticFeeConfig: txfee.StaticConfig{
TxFee: units.MilliAvax,
CreateSubnetTxFee: 100 * units.MilliAvax,
TransformSubnetTxFee: 1 * units.Avax,
Expand All @@ -46,6 +48,12 @@ var (
MinPrice: 1,
ExcessConversionConstant: 5_000,
},
ValidatorFeeCapacity: 20_000,
ValidatorFeeConfig: validatorfee.Config{
Target: 10_000,
MinPrice: 512,
ExcessConversionConstant: 51_937_021, // Double every hour
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
},
},
StakingConfig: StakingConfig{
UptimeRequirement: .8, // 80%
Expand Down
12 changes: 10 additions & 2 deletions genesis/genesis_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
validatorfee "github.com/ava-labs/avalanchego/vms/platformvm/validators/fee"
)

// PrivateKey-vmRQiZeXEXYMyJhEiqdC2z5JhuDbxL8ix9UVvjgMu2Er1NepE => P-local1g65uqn6t77p656w64023nh8nd9updzmxyymev2
Expand All @@ -40,7 +42,7 @@ var (
LocalParams = Params{
TxFeeConfig: TxFeeConfig{
CreateAssetTxFee: units.MilliAvax,
StaticFeeConfig: fee.StaticConfig{
StaticFeeConfig: txfee.StaticConfig{
TxFee: units.MilliAvax,
CreateSubnetTxFee: 100 * units.MilliAvax,
TransformSubnetTxFee: 100 * units.MilliAvax,
Expand All @@ -64,6 +66,12 @@ var (
MinPrice: 1,
ExcessConversionConstant: 5_000,
},
ValidatorFeeCapacity: 20_000,
ValidatorFeeConfig: validatorfee.Config{
Target: 10_000,
MinPrice: 1,
ExcessConversionConstant: 865_617, // Double every minute
},
},
StakingConfig: StakingConfig{
UptimeRequirement: .8, // 80%
Expand Down
12 changes: 10 additions & 2 deletions genesis/genesis_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
validatorfee "github.com/ava-labs/avalanchego/vms/platformvm/validators/fee"
)

var (
Expand All @@ -22,7 +24,7 @@ var (
MainnetParams = Params{
TxFeeConfig: TxFeeConfig{
CreateAssetTxFee: 10 * units.MilliAvax,
StaticFeeConfig: fee.StaticConfig{
StaticFeeConfig: txfee.StaticConfig{
TxFee: units.MilliAvax,
CreateSubnetTxFee: 1 * units.Avax,
TransformSubnetTxFee: 10 * units.Avax,
Expand All @@ -46,6 +48,12 @@ var (
MinPrice: 1,
ExcessConversionConstant: 5_000,
},
ValidatorFeeCapacity: 20_000,
ValidatorFeeConfig: validatorfee.Config{
Target: 10_000,
MinPrice: 512,
ExcessConversionConstant: 1_246_488_515, // Double every day
},
},
StakingConfig: StakingConfig{
UptimeRequirement: .8, // 80%
Expand Down
12 changes: 8 additions & 4 deletions genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
validatorfee "github.com/ava-labs/avalanchego/vms/platformvm/validators/fee"
)

type StakingConfig struct {
Expand All @@ -36,9 +38,11 @@ type StakingConfig struct {
}

type TxFeeConfig struct {
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
StaticFeeConfig fee.StaticConfig `json:"staticFeeConfig"`
DynamicFeeConfig gas.Config `json:"dynamicFeeConfig"`
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
StaticFeeConfig txfee.StaticConfig `json:"staticFeeConfig"`
DynamicFeeConfig gas.Config `json:"dynamicFeeConfig"`
ValidatorFeeCapacity gas.Gas `json:"validatorFeeCapacity"`
ValidatorFeeConfig validatorfee.Config `json:"validatorFeeConfig"`
}

type Params struct {
Expand Down
2 changes: 2 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,8 @@ 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,
MaxValidatorStake: n.Config.MaxValidatorStake,
Expand Down
14 changes: 10 additions & 4 deletions vms/platformvm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (
"github.com/ava-labs/avalanchego/vms/components/gas"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
validatorfee "github.com/ava-labs/avalanchego/vms/platformvm/validators/fee"
)

// Struct collecting all foundational parameters of PlatformVM
Expand All @@ -32,13 +34,17 @@ type Config struct {
// calling VM.Initialize.
Validators validators.Manager

// Static fees are active before the E-upgrade
// Static fees are active before Etna
CreateAssetTxFee uint64 // Override for CreateSubnet and CreateChain before AP3
StaticFeeConfig fee.StaticConfig
StaticFeeConfig txfee.StaticConfig

// Dynamic fees are active after the E-upgrade
// Dynamic fees are active after Etna
DynamicFeeConfig gas.Config

// ACP-77 validator fees are active after Etna
ValidatorFeeCapacity gas.Gas
ValidatorFeeConfig validatorfee.Config

// Provides access to the uptime manager as a thread safe data structure
UptimeLockedCalculator uptime.LockedCalculator

Expand Down
Loading