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

P-chain - introducing fees calculators #2698

Merged
merged 158 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
1adc328
E fork scaffolding
abi87 Jan 10, 2024
f6d7382
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 10, 2024
3889e51
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 12, 2024
e725961
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 15, 2024
30a4343
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 16, 2024
add3a35
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 17, 2024
3d08216
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 18, 2024
8f35564
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 19, 2024
2b16538
Merge branch 'master' into e-fork-scaffolding
abi87 Jan 26, 2024
4751e79
Merge branch 'master' into e-fork-scaffolding
abi87 Jan 29, 2024
e00d7c9
drop temporary fork time
abi87 Jan 29, 2024
b454987
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 1, 2024
f832034
nits
abi87 Feb 1, 2024
e01eb83
introduced fees calculator in P-chain
abi87 Feb 2, 2024
62ab6d0
upgraded codec for dynamic fees
abi87 Feb 2, 2024
9af11ca
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 2, 2024
d33a6a2
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 7, 2024
d846cba
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 7, 2024
af2c721
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 7, 2024
8a89505
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 8, 2024
3daec34
cleanup
abi87 Feb 8, 2024
b1fdd62
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 8, 2024
e27e938
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 8, 2024
a0020b1
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 9, 2024
1fb0662
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 9, 2024
0dfe25a
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 9, 2024
f28b80b
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 12, 2024
26fcb79
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 13, 2024
4d100eb
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 13, 2024
5e09b5e
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 13, 2024
199424b
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 15, 2024
3b76de5
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 15, 2024
5ea9c0b
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 15, 2024
603fbec
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 15, 2024
da5df60
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 15, 2024
2b05cf1
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 16, 2024
0baba01
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 16, 2024
9c4a2b3
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 16, 2024
9b97764
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 19, 2024
1368b48
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 19, 2024
56343d3
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 19, 2024
a4b81e6
fork switch to the avm
abi87 Feb 20, 2024
392e935
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 21, 2024
78a1a5c
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 21, 2024
59348c7
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 21, 2024
d3a733e
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 22, 2024
a362312
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 22, 2024
3bcb51a
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 22, 2024
f735491
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 25, 2024
6a1af7c
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 25, 2024
e375a83
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 25, 2024
33e3b70
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 29, 2024
507636e
latestFork in avm
abi87 Feb 29, 2024
399dfc8
default test config for a few unit tests
abi87 Feb 29, 2024
089af5e
come more unit tests helpers
abi87 Feb 29, 2024
bf58efb
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Feb 29, 2024
cf039ed
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Feb 29, 2024
3c52428
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 4, 2024
198c910
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 4, 2024
4c674f0
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 4, 2024
e34e3de
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 5, 2024
7feb04f
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 6, 2024
43169f4
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 6, 2024
9265060
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 6, 2024
7d7d1f7
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 7, 2024
2dd14a8
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 7, 2024
d82f588
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 7, 2024
5992b33
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 11, 2024
d5ccb3b
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 11, 2024
dca34a5
fixed merge
abi87 Mar 11, 2024
2e4e469
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 11, 2024
cda811f
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 11, 2024
cd989f3
nits from code reviews
abi87 Mar 11, 2024
32da156
some more nits from code reviews
abi87 Mar 11, 2024
be7cf3e
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 11, 2024
d2525d5
fixed merge
abi87 Mar 11, 2024
287dbb5
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 11, 2024
ae8231b
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 12, 2024
8270220
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 12, 2024
210bac8
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 12, 2024
95d3ab5
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 13, 2024
7a17a9b
drop DurangoTime from avm config
abi87 Mar 13, 2024
2906756
nit
abi87 Mar 13, 2024
d3edbaa
nit
abi87 Mar 13, 2024
3dbdd6b
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 13, 2024
1c7f823
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 13, 2024
737d429
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 18, 2024
b47ef55
Merge branch 'e-fork-scaffolding' into codec_upgrades_dynamic_fees
abi87 Mar 18, 2024
9646588
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 18, 2024
ee6bd99
Merge branch 'master' into codec_upgrades_dynamic_fees
abi87 Mar 19, 2024
65b11b7
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 19, 2024
cede533
Merge branch 'master' into codec_upgrades_dynamic_fees
abi87 Mar 20, 2024
7aff1c8
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 20, 2024
d2772ec
Merge branch 'master' into codec_upgrades_dynamic_fees
abi87 Mar 22, 2024
d03e145
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 22, 2024
50e75f9
Merge branch 'master' into codec_upgrades_dynamic_fees
abi87 Mar 25, 2024
b391c11
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 25, 2024
6f36d2e
Merge branch 'master' into codec_upgrades_dynamic_fees
abi87 Mar 26, 2024
9111a95
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 26, 2024
b2e0b3e
Merge branch 'master' into codec_upgrades_dynamic_fees
abi87 Mar 27, 2024
bd2311e
reverted unnecessary changes
abi87 Mar 27, 2024
326a6d5
Merge branch 'codec_upgrades_dynamic_fees' into p-chain_introducing-f…
abi87 Mar 27, 2024
4a8141a
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Mar 27, 2024
b979b51
reduced diff
abi87 Mar 27, 2024
d09f885
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Mar 28, 2024
e43c69f
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Mar 29, 2024
b5962db
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Mar 29, 2024
c313a0f
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 2, 2024
5c22480
introduced fee StaticCalculator constructor
abi87 Apr 2, 2024
23060c5
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 2, 2024
0ffc651
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 3, 2024
fed7e67
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 4, 2024
231b2eb
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 8, 2024
6b72744
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 9, 2024
ced3f8d
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 11, 2024
c00888c
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 12, 2024
465f97d
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 15, 2024
4a1f2fe
nit
abi87 Apr 15, 2024
c078f1d
simplified p-chain config
abi87 Apr 15, 2024
c81c85e
added UTs
abi87 Apr 15, 2024
1867461
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 16, 2024
3d45cc4
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 17, 2024
ab782a5
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 21, 2024
8358f84
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 23, 2024
4583289
P chain introducing fees calculators fee config (#2960)
abi87 Apr 23, 2024
095a8f6
nits to address code reviews comments
abi87 Apr 24, 2024
796fc2f
minor renaming
abi87 Apr 24, 2024
6bc3091
simplified unit tests
abi87 Apr 24, 2024
eea8069
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 24, 2024
73cc339
Fee Calculator Refactor (#2964)
joshua-kim Apr 24, 2024
f008446
nit
abi87 Apr 25, 2024
dda8de7
Merge branch 'p-chain_introducing-fees-calculators' of github.com:ava…
abi87 Apr 25, 2024
2776ea7
nit
abi87 Apr 26, 2024
7bcd8f7
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 26, 2024
a104358
nit
abi87 Apr 26, 2024
cbc99ee
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 Apr 29, 2024
2b4cdbc
nits
abi87 Apr 29, 2024
54d05d7
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 2, 2024
09cfe24
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 6, 2024
eb98d60
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 7, 2024
62fc922
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 9, 2024
bf2d5e9
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 10, 2024
db597d3
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 13, 2024
6bc5f25
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 13, 2024
66ef59c
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 14, 2024
1747485
repackaged upgrades times into upgrade package
abi87 May 14, 2024
c1d8df8
Merge branch 'p-chain_repack_config' into p-chain_introducing-fees-ca…
abi87 May 14, 2024
8cbc4e2
simplified fee unit test setup
abi87 May 14, 2024
8a268b0
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 14, 2024
8852376
nits
abi87 May 14, 2024
10176c9
nit
abi87 May 15, 2024
530084e
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 16, 2024
c815178
nit
abi87 May 16, 2024
3fd10bc
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 20, 2024
eee5aba
drop duplicated fields
abi87 May 20, 2024
be373e2
replaced genesis.TxFeeConfig with fee.StaticConfig
abi87 May 20, 2024
e2f8809
nit
abi87 May 21, 2024
0fe0367
Merge branch 'master' into p-chain_introducing-fees-calculators
abi87 May 21, 2024
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
7 changes: 4 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/ava-labs/avalanchego/utils/timer"
"github.com/ava-labs/avalanchego/version"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/proposervm"
)

Expand Down Expand Up @@ -758,9 +759,9 @@ func getStakingConfig(v *viper.Viper, networkID uint32) (node.StakingConfig, err
return config, nil
}

func getTxFeeConfig(v *viper.Viper, networkID uint32) genesis.TxFeeConfig {
func getTxFeeConfig(v *viper.Viper, networkID uint32) fee.StaticConfig {
if networkID != constants.MainnetID && networkID != constants.FujiID {
return genesis.TxFeeConfig{
return fee.StaticConfig{
TxFee: v.GetUint64(TxFeeKey),
CreateAssetTxFee: v.GetUint64(CreateAssetTxFeeKey),
CreateSubnetTxFee: v.GetUint64(CreateSubnetTxFeeKey),
Expand Down Expand Up @@ -1325,7 +1326,7 @@ func GetNodeConfig(v *viper.Viper) (node.Config, error) {
nodeConfig.FdLimit = v.GetUint64(FdLimitKey)

// Tx Fee
nodeConfig.TxFeeConfig = getTxFeeConfig(v, nodeConfig.NetworkID)
nodeConfig.StaticConfig = getTxFeeConfig(v, nodeConfig.NetworkID)

// Genesis Data
genesisStakingCfg := nodeConfig.StakingConfig.StakingConfig
Expand Down
3 changes: 2 additions & 1 deletion genesis/genesis_fuji.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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"
)

var (
Expand All @@ -18,7 +19,7 @@ var (

// FujiParams are the params used for the fuji testnet
FujiParams = Params{
TxFeeConfig: TxFeeConfig{
StaticConfig: fee.StaticConfig{
TxFee: units.MilliAvax,
CreateAssetTxFee: 10 * units.MilliAvax,
CreateSubnetTxFee: 100 * units.MilliAvax,
Expand Down
3 changes: 2 additions & 1 deletion genesis/genesis_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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"
)

// PrivateKey-vmRQiZeXEXYMyJhEiqdC2z5JhuDbxL8ix9UVvjgMu2Er1NepE => P-local1g65uqn6t77p656w64023nh8nd9updzmxyymev2
Expand All @@ -36,7 +37,7 @@ var (

// LocalParams are the params used for local networks
LocalParams = Params{
TxFeeConfig: TxFeeConfig{
StaticConfig: fee.StaticConfig{
TxFee: units.MilliAvax,
CreateAssetTxFee: units.MilliAvax,
CreateSubnetTxFee: 100 * units.MilliAvax,
Expand Down
3 changes: 2 additions & 1 deletion genesis/genesis_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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"
)

var (
Expand All @@ -18,7 +19,7 @@ var (

// MainnetParams are the params used for mainnet
MainnetParams = Params{
TxFeeConfig: TxFeeConfig{
StaticConfig: fee.StaticConfig{
TxFee: units.MilliAvax,
CreateAssetTxFee: 10 * units.MilliAvax,
CreateSubnetTxFee: 1 * units.Avax,
Expand Down
34 changes: 7 additions & 27 deletions genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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"
)

type StakingConfig struct {
Expand All @@ -33,42 +34,21 @@ type StakingConfig struct {
RewardConfig reward.Config `json:"rewardConfig"`
}

type TxFeeConfig struct {
// Transaction fee
TxFee uint64 `json:"txFee"`
// Transaction fee for create asset transactions
CreateAssetTxFee uint64 `json:"createAssetTxFee"`
// Transaction fee for create subnet transactions
CreateSubnetTxFee uint64 `json:"createSubnetTxFee"`
// Transaction fee for transform subnet transactions
TransformSubnetTxFee uint64 `json:"transformSubnetTxFee"`
// Transaction fee for create blockchain transactions
CreateBlockchainTxFee uint64 `json:"createBlockchainTxFee"`
// Transaction fee for adding a primary network validator
AddPrimaryNetworkValidatorFee uint64 `json:"addPrimaryNetworkValidatorFee"`
// Transaction fee for adding a primary network delegator
AddPrimaryNetworkDelegatorFee uint64 `json:"addPrimaryNetworkDelegatorFee"`
// Transaction fee for adding a subnet validator
AddSubnetValidatorFee uint64 `json:"addSubnetValidatorFee"`
// Transaction fee for adding a subnet delegator
AddSubnetDelegatorFee uint64 `json:"addSubnetDelegatorFee"`
}

type Params struct {
StakingConfig
TxFeeConfig
fee.StaticConfig
}

func GetTxFeeConfig(networkID uint32) TxFeeConfig {
func GetTxFeeConfig(networkID uint32) fee.StaticConfig {
switch networkID {
case constants.MainnetID:
return MainnetParams.TxFeeConfig
return MainnetParams.StaticConfig
case constants.FujiID:
return FujiParams.TxFeeConfig
return FujiParams.StaticConfig
case constants.LocalID:
return LocalParams.TxFeeConfig
return LocalParams.StaticConfig
default:
return LocalParams.TxFeeConfig
return LocalParams.StaticConfig
}
}

Expand Down
15 changes: 8 additions & 7 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/ava-labs/avalanchego/utils/profiler"
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/timer"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
)

type APIIndexerConfig struct {
Expand Down Expand Up @@ -122,13 +123,13 @@ type DatabaseConfig struct {

// Config contains all of the configurations of an Avalanche node.
type Config struct {
HTTPConfig `json:"httpConfig"`
IPConfig `json:"ipConfig"`
StakingConfig `json:"stakingConfig"`
genesis.TxFeeConfig `json:"txFeeConfig"`
StateSyncConfig `json:"stateSyncConfig"`
BootstrapConfig `json:"bootstrapConfig"`
DatabaseConfig `json:"databaseConfig"`
HTTPConfig `json:"httpConfig"`
IPConfig `json:"ipConfig"`
StakingConfig `json:"stakingConfig"`
fee.StaticConfig `json:"txFeeConfig"`
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
StateSyncConfig `json:"stateSyncConfig"`
BootstrapConfig `json:"bootstrapConfig"`
DatabaseConfig `json:"databaseConfig"`

// Genesis information
GenesisBytes []byte `json:"-"`
Expand Down
49 changes: 26 additions & 23 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import (
"github.com/ava-labs/avalanchego/vms/avm"
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/platformvm/upgrade"
"github.com/ava-labs/avalanchego/vms/registry"
"github.com/ava-labs/avalanchego/vms/rpcchainvm/runtime"
Expand Down Expand Up @@ -1127,29 +1128,31 @@ func (n *Node) initVMs() error {
err := utils.Err(
n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{
Config: platformconfig.Config{
Chains: n.chainManager,
Validators: vdrs,
UptimeLockedCalculator: n.uptimeCalculator,
SybilProtectionEnabled: n.Config.SybilProtectionEnabled,
PartialSyncPrimaryNetwork: n.Config.PartialSyncPrimaryNetwork,
TrackedSubnets: n.Config.TrackedSubnets,
TxFee: n.Config.TxFee,
CreateAssetTxFee: n.Config.CreateAssetTxFee,
CreateSubnetTxFee: n.Config.CreateSubnetTxFee,
TransformSubnetTxFee: n.Config.TransformSubnetTxFee,
CreateBlockchainTxFee: n.Config.CreateBlockchainTxFee,
AddPrimaryNetworkValidatorFee: n.Config.AddPrimaryNetworkValidatorFee,
AddPrimaryNetworkDelegatorFee: n.Config.AddPrimaryNetworkDelegatorFee,
AddSubnetValidatorFee: n.Config.AddSubnetValidatorFee,
AddSubnetDelegatorFee: n.Config.AddSubnetDelegatorFee,
UptimePercentage: n.Config.UptimeRequirement,
MinValidatorStake: n.Config.MinValidatorStake,
MaxValidatorStake: n.Config.MaxValidatorStake,
MinDelegatorStake: n.Config.MinDelegatorStake,
MinDelegationFee: n.Config.MinDelegationFee,
MinStakeDuration: n.Config.MinStakeDuration,
MaxStakeDuration: n.Config.MaxStakeDuration,
RewardConfig: n.Config.RewardConfig,
Chains: n.chainManager,
Validators: vdrs,
UptimeLockedCalculator: n.uptimeCalculator,
SybilProtectionEnabled: n.Config.SybilProtectionEnabled,
PartialSyncPrimaryNetwork: n.Config.PartialSyncPrimaryNetwork,
TrackedSubnets: n.Config.TrackedSubnets,
StaticFeeConfig: fee.StaticConfig{
TxFee: n.Config.TxFee,
CreateAssetTxFee: n.Config.CreateAssetTxFee,
CreateSubnetTxFee: n.Config.CreateSubnetTxFee,
TransformSubnetTxFee: n.Config.TransformSubnetTxFee,
CreateBlockchainTxFee: n.Config.CreateBlockchainTxFee,
AddPrimaryNetworkValidatorFee: n.Config.AddPrimaryNetworkValidatorFee,
AddPrimaryNetworkDelegatorFee: n.Config.AddPrimaryNetworkDelegatorFee,
AddSubnetValidatorFee: n.Config.AddSubnetValidatorFee,
AddSubnetDelegatorFee: n.Config.AddSubnetDelegatorFee,
},
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
UptimePercentage: n.Config.UptimeRequirement,
MinValidatorStake: n.Config.MinValidatorStake,
MaxValidatorStake: n.Config.MaxValidatorStake,
MinDelegatorStake: n.Config.MinDelegatorStake,
MinDelegationFee: n.Config.MinDelegationFee,
MinStakeDuration: n.Config.MinStakeDuration,
MaxStakeDuration: n.Config.MaxStakeDuration,
RewardConfig: n.Config.RewardConfig,
UpgradeConfig: upgrade.Config{
ApricotPhase3Time: version.GetApricotPhase3Time(n.Config.NetworkID),
ApricotPhase5Time: version.GetApricotPhase5Time(n.Config.NetworkID),
Expand Down
19 changes: 11 additions & 8 deletions vms/platformvm/block/builder/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/ava-labs/avalanchego/vms/platformvm/state"
"github.com/ava-labs/avalanchego/vms/platformvm/status"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest"
"github.com/ava-labs/avalanchego/vms/platformvm/upgrade"
Expand Down Expand Up @@ -308,14 +309,16 @@ func defaultConfig(t *testing.T, f fork) *config.Config {
Chains: chains.TestManager,
UptimeLockedCalculator: uptime.NewLockedCalculator(),
Validators: validators.NewManager(),
TxFee: defaultTxFee,
CreateSubnetTxFee: 100 * defaultTxFee,
CreateBlockchainTxFee: 100 * defaultTxFee,
MinValidatorStake: 5 * units.MilliAvax,
MaxValidatorStake: 500 * units.MilliAvax,
MinDelegatorStake: 1 * units.MilliAvax,
MinStakeDuration: defaultMinStakingDuration,
MaxStakeDuration: defaultMaxStakingDuration,
StaticFeeConfig: fee.StaticConfig{
TxFee: defaultTxFee,
CreateSubnetTxFee: 100 * defaultTxFee,
CreateBlockchainTxFee: 100 * defaultTxFee,
},
MinValidatorStake: 5 * units.MilliAvax,
MaxValidatorStake: 500 * units.MilliAvax,
MinDelegatorStake: 1 * units.MilliAvax,
MinStakeDuration: defaultMinStakingDuration,
MaxStakeDuration: defaultMaxStakingDuration,
RewardConfig: reward.Config{
MaxConsumptionRate: .12 * reward.PercentDenominator,
MinConsumptionRate: .10 * reward.PercentDenominator,
Expand Down
19 changes: 11 additions & 8 deletions vms/platformvm/block/executor/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/ava-labs/avalanchego/vms/platformvm/status"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/executor"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/mempool"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/txstest"
"github.com/ava-labs/avalanchego/vms/platformvm/upgrade"
Expand Down Expand Up @@ -330,14 +331,16 @@ func defaultConfig(t *testing.T, f fork) *config.Config {
Chains: chains.TestManager,
UptimeLockedCalculator: uptime.NewLockedCalculator(),
Validators: validators.NewManager(),
TxFee: defaultTxFee,
CreateSubnetTxFee: 100 * defaultTxFee,
CreateBlockchainTxFee: 100 * defaultTxFee,
MinValidatorStake: 5 * units.MilliAvax,
MaxValidatorStake: 500 * units.MilliAvax,
MinDelegatorStake: 1 * units.MilliAvax,
MinStakeDuration: defaultMinStakingDuration,
MaxStakeDuration: defaultMaxStakingDuration,
StaticFeeConfig: fee.StaticConfig{
TxFee: defaultTxFee,
CreateSubnetTxFee: 100 * defaultTxFee,
CreateBlockchainTxFee: 100 * defaultTxFee,
},
MinValidatorStake: 5 * units.MilliAvax,
MaxValidatorStake: 500 * units.MilliAvax,
MinDelegatorStake: 1 * units.MilliAvax,
MinStakeDuration: defaultMinStakingDuration,
MaxStakeDuration: defaultMaxStakingDuration,
RewardConfig: reward.Config{
MaxConsumptionRate: .12 * reward.PercentDenominator,
MinConsumptionRate: .10 * reward.PercentDenominator,
Expand Down
4 changes: 2 additions & 2 deletions vms/platformvm/block/executor/standard_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestBanffStandardBlockTimeVerification(t *testing.T) {
ID: avaxAssetID,
},
Out: &secp256k1fx.TransferOutput{
Amt: env.config.CreateSubnetTxFee,
Amt: env.config.StaticFeeConfig.CreateSubnetTxFee,
},
}
utxoID := utxo.InputID()
Expand All @@ -158,7 +158,7 @@ func TestBanffStandardBlockTimeVerification(t *testing.T) {
UTXOID: utxo.UTXOID,
Asset: utxo.Asset,
In: &secp256k1fx.TransferInput{
Amt: env.config.CreateSubnetTxFee,
Amt: env.config.StaticFeeConfig.CreateSubnetTxFee,
},
}},
}},
Expand Down
45 changes: 4 additions & 41 deletions vms/platformvm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
"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"
"github.com/ava-labs/avalanchego/vms/platformvm/upgrade"
)

Expand All @@ -30,6 +31,9 @@ type Config struct {
// calling VM.Initialize.
Validators validators.Manager

// All static fees config active before E-upgrade
StaticFeeConfig fee.StaticConfig

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

Expand All @@ -42,33 +46,6 @@ type Config struct {
// Set of subnets that this node is validating
TrackedSubnets set.Set[ids.ID]

// Fee that is burned by every non-state creating transaction
TxFee uint64

// Fee that must be burned by every state creating transaction before AP3
CreateAssetTxFee uint64

// Fee that must be burned by every subnet creating transaction after AP3
CreateSubnetTxFee uint64

// Fee that must be burned by every transform subnet transaction
TransformSubnetTxFee uint64

// Fee that must be burned by every blockchain creating transaction after AP3
CreateBlockchainTxFee uint64

// Transaction fee for adding a primary network validator
AddPrimaryNetworkValidatorFee uint64

// Transaction fee for adding a primary network delegator
AddPrimaryNetworkDelegatorFee uint64

// Transaction fee for adding a subnet validator
AddSubnetValidatorFee uint64

// Transaction fee for adding a subnet delegator
AddSubnetDelegatorFee uint64

// The minimum amount of tokens one must bond to be a validator
MinValidatorStake uint64

Expand Down Expand Up @@ -106,20 +83,6 @@ type Config struct {
UseCurrentHeight bool
}

func (c *Config) GetCreateBlockchainTxFee(timestamp time.Time) uint64 {
if c.UpgradeConfig.IsApricotPhase3Activated(timestamp) {
return c.CreateBlockchainTxFee
}
return c.CreateAssetTxFee
}

func (c *Config) GetCreateSubnetTxFee(timestamp time.Time) uint64 {
if c.UpgradeConfig.IsApricotPhase3Activated(timestamp) {
return c.CreateSubnetTxFee
}
return c.CreateAssetTxFee
}

// Create the blockchain described in [tx], but only if this node is a member of
// the subnet that validates the chain
func (c *Config) CreateChain(chainID ids.ID, tx *txs.CreateChainTx) {
Expand Down
Loading
Loading