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

Enforce dynamic fees #3246

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,8 @@ func getTxFeeConfig(v *viper.Viper, networkID uint32) genesis.TxFeeConfig {
AddSubnetValidatorFee: v.GetUint64(AddSubnetValidatorFeeKey),
AddSubnetDelegatorFee: v.GetUint64(AddSubnetDelegatorFeeKey),
},
// TODO: Set these values via flags
DynamicFeeConfig: genesis.LocalParams.DynamicFeeConfig,
}
}
return genesis.GetTxFeeConfig(networkID)
Expand Down
20 changes: 18 additions & 2 deletions genesis/genesis_fuji.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

feecomponent "github.com/ava-labs/avalanchego/vms/components/fee"
txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
)

var (
Expand All @@ -21,7 +23,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 @@ -31,6 +33,20 @@ var (
AddSubnetValidatorFee: units.MilliAvax,
AddSubnetDelegatorFee: units.MilliAvax,
},
// TODO: Set these values to something more reasonable
DynamicFeeConfig: feecomponent.Config{
Weights: feecomponent.Dimensions{
feecomponent.Bandwidth: 1,
feecomponent.DBRead: 1,
feecomponent.DBWrite: 1,
feecomponent.Compute: 1,
},
MaxGasCapacity: 1_000_000,
MaxGasPerSecond: 1_000,
TargetGasPerSecond: 500,
MinGasPrice: 1,
ExcessConversionConstant: 1,
},
},
StakingConfig: StakingConfig{
UptimeRequirement: .8, // 80%
Expand Down
20 changes: 18 additions & 2 deletions genesis/genesis_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

feecomponent "github.com/ava-labs/avalanchego/vms/components/fee"
txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
)

// PrivateKey-vmRQiZeXEXYMyJhEiqdC2z5JhuDbxL8ix9UVvjgMu2Er1NepE => P-local1g65uqn6t77p656w64023nh8nd9updzmxyymev2
Expand All @@ -39,7 +41,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 @@ -49,6 +51,20 @@ var (
AddSubnetValidatorFee: units.MilliAvax,
AddSubnetDelegatorFee: units.MilliAvax,
},
// TODO: Set these values to something more reasonable
DynamicFeeConfig: feecomponent.Config{
Weights: feecomponent.Dimensions{
feecomponent.Bandwidth: 1,
feecomponent.DBRead: 1,
feecomponent.DBWrite: 1,
feecomponent.Compute: 1,
},
MaxGasCapacity: 1_000_000,
MaxGasPerSecond: 1_000,
TargetGasPerSecond: 500,
MinGasPrice: 1,
ExcessConversionConstant: 1,
},
},
StakingConfig: StakingConfig{
UptimeRequirement: .8, // 80%
Expand Down
20 changes: 18 additions & 2 deletions genesis/genesis_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

feecomponent "github.com/ava-labs/avalanchego/vms/components/fee"
txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
)

var (
Expand All @@ -21,7 +23,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 @@ -31,6 +33,20 @@ var (
AddSubnetValidatorFee: units.MilliAvax,
AddSubnetDelegatorFee: units.MilliAvax,
},
// TODO: Set these values to something more reasonable
DynamicFeeConfig: feecomponent.Config{
Weights: feecomponent.Dimensions{
feecomponent.Bandwidth: 1,
feecomponent.DBRead: 1,
feecomponent.DBWrite: 1,
feecomponent.Compute: 1,
},
MaxGasCapacity: 1_000_000,
MaxGasPerSecond: 1_000,
TargetGasPerSecond: 500,
MinGasPrice: 1,
ExcessConversionConstant: 1,
},
},
StakingConfig: StakingConfig{
UptimeRequirement: .8, // 80%
Expand Down
9 changes: 6 additions & 3 deletions genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (

"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"

feecomponent "github.com/ava-labs/avalanchego/vms/components/fee"
txfee "github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
)

type StakingConfig struct {
Expand All @@ -35,8 +37,9 @@ type StakingConfig struct {
}

type TxFeeConfig struct {
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
StaticFeeConfig fee.StaticConfig `json:"staticFeeConfig"`
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
StaticFeeConfig txfee.StaticConfig `json:"staticFeeConfig"`
DynamicFeeConfig feecomponent.Config `json:"dynamicFeeConfig"`
}

type Params struct {
Expand Down
1 change: 1 addition & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ func (n *Node) initVMs() error {
TrackedSubnets: n.Config.TrackedSubnets,
CreateAssetTxFee: n.Config.CreateAssetTxFee,
StaticFeeConfig: n.Config.StaticFeeConfig,
DynamicFeeConfig: n.Config.DynamicFeeConfig,
UptimePercentage: n.Config.UptimeRequirement,
MinValidatorStake: n.Config.MinValidatorStake,
MaxValidatorStake: n.Config.MaxValidatorStake,
Expand Down
Loading
Loading