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 136 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
66 changes: 36 additions & 30 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ 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 @@ -1126,36 +1128,40 @@ 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,
ApricotPhase3Time: version.GetApricotPhase3Time(n.Config.NetworkID),
ApricotPhase5Time: version.GetApricotPhase5Time(n.Config.NetworkID),
BanffTime: version.GetBanffTime(n.Config.NetworkID),
CortinaTime: version.GetCortinaTime(n.Config.NetworkID),
DurangoTime: version.GetDurangoTime(n.Config.NetworkID),
EUpgradeTime: eUpgradeTime,
UseCurrentHeight: n.Config.UseCurrentHeight,
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),
BanffTime: version.GetBanffTime(n.Config.NetworkID),
CortinaTime: version.GetCortinaTime(n.Config.NetworkID),
DurangoTime: version.GetDurangoTime(n.Config.NetworkID),
EUpgradeTime: eUpgradeTime,
},
UseCurrentHeight: n.Config.UseCurrentHeight,
},
}),
n.VMManager.RegisterFactory(context.TODO(), constants.AVMID, &avm.Factory{
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/block/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func TestBuildBlockInvalidStakingDurations(t *testing.T) {

// Post-Durango, [StartTime] is no longer validated. Staking durations are
// based on the current chain timestamp and must be validated.
env.config.DurangoTime = time.Time{}
env.config.UpgradeConfig.DurangoTime = time.Time{}

var (
now = env.backend.Clk.Time()
Expand Down
46 changes: 26 additions & 20 deletions vms/platformvm/block/builder/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ 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"
"github.com/ava-labs/avalanchego/vms/platformvm/utxo"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"

Expand Down Expand Up @@ -307,46 +309,50 @@ 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,
MintingPeriod: 365 * 24 * time.Hour,
SupplyCap: 720 * units.MegaAvax,
},
ApricotPhase3Time: mockable.MaxTime,
ApricotPhase5Time: mockable.MaxTime,
BanffTime: mockable.MaxTime,
CortinaTime: mockable.MaxTime,
DurangoTime: mockable.MaxTime,
EUpgradeTime: mockable.MaxTime,
UpgradeConfig: upgrade.Config{
ApricotPhase3Time: mockable.MaxTime,
ApricotPhase5Time: mockable.MaxTime,
BanffTime: mockable.MaxTime,
CortinaTime: mockable.MaxTime,
DurangoTime: mockable.MaxTime,
EUpgradeTime: mockable.MaxTime,
},
}

switch f {
case eUpgrade:
c.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests
c.UpgradeConfig.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests
fallthrough
case durango:
c.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests
c.UpgradeConfig.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests
fallthrough
case cortina:
c.CortinaTime = time.Time{} // neglecting fork ordering for this package's tests
c.UpgradeConfig.CortinaTime = time.Time{} // neglecting fork ordering for this package's tests
fallthrough
case banff:
c.BanffTime = time.Time{} // neglecting fork ordering for this package's tests
c.UpgradeConfig.BanffTime = time.Time{} // neglecting fork ordering for this package's tests
fallthrough
case apricotPhase5:
c.ApricotPhase5Time = defaultValidateEndTime
c.UpgradeConfig.ApricotPhase5Time = defaultValidateEndTime
fallthrough
case apricotPhase3:
c.ApricotPhase3Time = defaultValidateEndTime
c.UpgradeConfig.ApricotPhase3Time = defaultValidateEndTime
default:
require.FailNow(t, "unhandled fork", f)
}
Expand Down
46 changes: 26 additions & 20 deletions vms/platformvm/block/executor/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ 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"
"github.com/ava-labs/avalanchego/vms/platformvm/utxo"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"

Expand Down Expand Up @@ -329,46 +331,50 @@ 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,
MintingPeriod: 365 * 24 * time.Hour,
SupplyCap: 720 * units.MegaAvax,
},
ApricotPhase3Time: mockable.MaxTime,
ApricotPhase5Time: mockable.MaxTime,
BanffTime: mockable.MaxTime,
CortinaTime: mockable.MaxTime,
DurangoTime: mockable.MaxTime,
EUpgradeTime: mockable.MaxTime,
UpgradeConfig: upgrade.Config{
ApricotPhase3Time: mockable.MaxTime,
ApricotPhase5Time: mockable.MaxTime,
BanffTime: mockable.MaxTime,
CortinaTime: mockable.MaxTime,
DurangoTime: mockable.MaxTime,
EUpgradeTime: mockable.MaxTime,
},
}

switch f {
case eUpgrade:
c.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests
c.UpgradeConfig.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests
fallthrough
case durango:
c.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests
c.UpgradeConfig.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests
fallthrough
case cortina:
c.CortinaTime = time.Time{} // neglecting fork ordering for this package's tests
c.UpgradeConfig.CortinaTime = time.Time{} // neglecting fork ordering for this package's tests
fallthrough
case banff:
c.BanffTime = time.Time{} // neglecting fork ordering for this package's tests
c.UpgradeConfig.BanffTime = time.Time{} // neglecting fork ordering for this package's tests
fallthrough
case apricotPhase5:
c.ApricotPhase5Time = defaultValidateEndTime
c.UpgradeConfig.ApricotPhase5Time = defaultValidateEndTime
fallthrough
case apricotPhase3:
c.ApricotPhase3Time = defaultValidateEndTime
c.UpgradeConfig.ApricotPhase3Time = defaultValidateEndTime
default:
require.FailNow(t, "unhandled fork", f)
}
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
6 changes: 3 additions & 3 deletions vms/platformvm/block/executor/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ func (v *verifier) ApricotAtomicBlock(b *block.ApricotAtomicBlock) error {
parentID := b.Parent()
currentTimestamp := v.getTimestamp(parentID)
cfg := v.txExecutorBackend.Config
if cfg.IsApricotPhase5Activated(currentTimestamp) {
if cfg.UpgradeConfig.IsApricotPhase5Activated(currentTimestamp) {
return fmt.Errorf(
"the chain timestamp (%d) is after the apricot phase 5 time (%d), hence atomic transactions should go through the standard block",
currentTimestamp.Unix(),
cfg.ApricotPhase5Time.Unix(),
cfg.UpgradeConfig.ApricotPhase5Time.Unix(),
)
}

Expand Down Expand Up @@ -290,7 +290,7 @@ func (v *verifier) apricotCommonBlock(b block.Block) error {
// during the verification of the ProposalBlock.
parentID := b.Parent()
timestamp := v.getTimestamp(parentID)
if v.txExecutorBackend.Config.IsBanffActivated(timestamp) {
if v.txExecutorBackend.Config.UpgradeConfig.IsBanffActivated(timestamp) {
return fmt.Errorf("%w: timestamp = %s", errApricotBlockIssuedAfterFork, timestamp)
}
return v.commonBlock(b)
Expand Down
Loading
Loading