Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
234 commits
Select commit Hold shift + click to select a range
95df851
wip: meter P-chain txs
abi87 Feb 4, 2024
74f0c18
appease linter
abi87 Feb 5, 2024
9eda7f3
nits
abi87 Feb 5, 2024
71b5930
fixed AddValidatorTx AddDelegatorTx fees post EUpgrade
abi87 Feb 5, 2024
0c0022e
fixed AddPermissionlessValidatorTx AddPermissionlessDelegatorTx fees …
abi87 Feb 5, 2024
f498af9
removed some code duplication
abi87 Feb 5, 2024
fc8afd8
drop duplicated test
abi87 Feb 5, 2024
3afc8e4
reduced fees calculator UTs code duplication
abi87 Feb 5, 2024
40031d0
minor dynamic fee builder refactoring in wallet
abi87 Feb 7, 2024
52c94da
wip: consolidating dynamic fee builder code in wallet
abi87 Feb 7, 2024
8bbc897
merged dynamic builder into builder
abi87 Feb 7, 2024
50c2ab9
nit
abi87 Feb 7, 2024
6ae1419
wip: cleaning up p-chain tx builder
abi87 Feb 7, 2024
0be756e
refactored dynamic fees config getter + UTs fix
abi87 Feb 8, 2024
126fdc2
minor cleanup of txs.Tx credentials
abi87 Feb 8, 2024
014a5ff
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 8, 2024
572aed5
txBuilder added memo field
abi87 Feb 8, 2024
78176ad
removed calls to utxos.Spend
abi87 Feb 8, 2024
5761976
removed utxo.Spend method
abi87 Feb 8, 2024
1861ce4
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 8, 2024
5c236e3
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 9, 2024
22f69c0
fixed txbuilder + updated block builder tests to e-upgrade
abi87 Feb 9, 2024
c285909
updated platformvm tests to e upgrade
abi87 Feb 9, 2024
d75b029
minor code duplication removal
abi87 Feb 9, 2024
e1144d5
consolidated code around tx metering
abi87 Feb 9, 2024
dcc3b06
fixed compute dimension of p-chain tx metering
abi87 Feb 10, 2024
25b99e4
nit
abi87 Feb 10, 2024
c025a6e
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 13, 2024
bb0cbe2
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 15, 2024
d505154
nit
abi87 Feb 17, 2024
818c781
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 17, 2024
231ff5e
dropped SignerBackend mock
abi87 Feb 18, 2024
16fdab7
cleaned up wallet mocks
abi87 Feb 18, 2024
7f11841
minor fix
abi87 Feb 19, 2024
f5ff8d6
spend cleanup
abi87 Feb 19, 2024
26a9e31
Merge branch 'master' into p-chain_spend_cleanup
abi87 Feb 19, 2024
8b06089
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 19, 2024
7f594ea
repackaged signer from wallet to pchain txs subpackage
abi87 Feb 19, 2024
89da2ba
introduced wallet signer visitor in pchain txs builder subpackage
abi87 Feb 20, 2024
e26bec9
drop signers from utxos.Spend handler
abi87 Feb 20, 2024
dd17dbb
moved wallet builder backend to pchain
abi87 Feb 20, 2024
0904787
some more repackaging
abi87 Feb 20, 2024
2087443
wip: chaining p-chain txbuilder with wallet builder and signer
abi87 Feb 20, 2024
2ef66ea
nit
abi87 Feb 21, 2024
0cd2d7e
Merge branch 'master' into p-chain_spend_cleanup
abi87 Feb 21, 2024
95d64cc
wip: some more chaining p-chain txbuilder with wallet builder and signer
abi87 Feb 21, 2024
131c198
txbuilder constructor cleanup
abi87 Feb 21, 2024
979e30d
removed utxos Spend and Authorize
abi87 Feb 21, 2024
566b09b
moved backends package to wallet
abi87 Feb 21, 2024
1b22091
nit
abi87 Feb 21, 2024
f7d288c
nits
abi87 Feb 21, 2024
fa0eb5a
repackaged wallet backend for P-chain
abi87 Feb 21, 2024
4405a2e
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Feb 21, 2024
480fb45
consolidated backend implementation
abi87 Feb 21, 2024
30498e7
some more cleanup
abi87 Feb 21, 2024
1881282
nits
abi87 Feb 21, 2024
fca9d28
fixed create chain tx fee
abi87 Feb 21, 2024
0f24a1a
fixed UTs
abi87 Feb 21, 2024
ba8e792
Merge branch 'master' into p-chain_wallet_backends
abi87 Feb 22, 2024
174b551
Merge branch 'p-chain_spend_cleanup' into p-chainin_meter_fees
abi87 Feb 22, 2024
78bf907
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 22, 2024
d2d6aec
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Feb 22, 2024
5aa5932
some more fixes
abi87 Feb 22, 2024
20a7c41
Merge branch 'p-chain_spend_cleanup' of github.com:ava-labs/avalanche…
abi87 Feb 22, 2024
3b6b5f5
Merge branch 'master' into p-chain_wallet_backends
abi87 Feb 25, 2024
655e402
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Feb 25, 2024
35fc006
Merge branch 'p-chain_spend_cleanup' into p-chainin_meter_fees
abi87 Feb 25, 2024
035b35a
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 25, 2024
32ce3e0
added block complexity metrics+
abi87 Feb 26, 2024
ebc1b50
minor renaming
abi87 Feb 26, 2024
065ba42
Merge branch 'p-chain_spend_cleanup' into p-chainin_meter_fees
abi87 Feb 26, 2024
952ed47
Merge branch 'master' into p-chain_wallet_backends
abi87 Feb 29, 2024
c050a42
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Feb 29, 2024
a71fba1
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Feb 29, 2024
2aa4b70
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 4, 2024
4b47e03
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 4, 2024
50e818f
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 4, 2024
4aedae5
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 5, 2024
a92b693
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 6, 2024
e418d7e
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 6, 2024
f1e5a44
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 7, 2024
0d5a1af
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 7, 2024
04c0b36
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 7, 2024
08def6a
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 11, 2024
e9860dc
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 11, 2024
c6cedd2
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 11, 2024
b01a2d2
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 11, 2024
eb59fda
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 11, 2024
5792e89
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 11, 2024
2661016
wip: refactored feeConfig getter
abi87 Mar 11, 2024
153e0ea
wip: added custom dynamic fees config
abi87 Mar 11, 2024
a56a753
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 12, 2024
2039a84
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 12, 2024
5569e4d
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 12, 2024
4c5787e
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 13, 2024
a581616
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 13, 2024
3e74610
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 13, 2024
9ac3a33
Merge branch 'master' into p-chain_wallet_backends
abi87 Mar 18, 2024
2c3f2a5
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
abi87 Mar 18, 2024
46e3895
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 18, 2024
5ad8365
moved dynamic fees config to common components
abi87 Mar 18, 2024
16cf7c4
cleanup
StephenButtolph Mar 18, 2024
51729d9
nit
StephenButtolph Mar 18, 2024
6772d28
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
StephenButtolph Mar 18, 2024
9481ff7
nit
StephenButtolph Mar 19, 2024
ade5178
fix merge
StephenButtolph Mar 19, 2024
ba48394
nit
StephenButtolph Mar 19, 2024
c6f7143
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
StephenButtolph Mar 19, 2024
6de663b
save
StephenButtolph Mar 19, 2024
6c9004d
nit
StephenButtolph Mar 19, 2024
318be91
nit
StephenButtolph Mar 19, 2024
41f1405
nit
StephenButtolph Mar 19, 2024
edbfd16
nit
StephenButtolph Mar 19, 2024
bc5b5e0
nit
StephenButtolph Mar 19, 2024
264706d
Merge branch 'p-chain_wallet_backends' into p-chain_spend_cleanup
StephenButtolph Mar 19, 2024
b2d11ce
nit
StephenButtolph Mar 19, 2024
ff6f721
Merge branch 'master' into p-chain_spend_cleanup
abi87 Mar 19, 2024
5b6e9d8
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 19, 2024
7b9a26c
Merge branch 'p-chain_spend_cleanup' into p-chainin_meter_fees
abi87 Mar 19, 2024
de272e6
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 21, 2024
09be1c4
minor renaming for clarify
abi87 Mar 21, 2024
b4f5329
some more renaming
abi87 Mar 21, 2024
711733e
nits
abi87 Mar 21, 2024
b896652
minor code consolidation
abi87 Mar 21, 2024
4b9987a
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 22, 2024
320bc2d
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 25, 2024
7295437
nits
abi87 Mar 26, 2024
26e8392
some more cleanup
abi87 Mar 26, 2024
f0d573f
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 26, 2024
ac35175
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 27, 2024
4b6804b
fixed merge
abi87 Mar 27, 2024
cb1fefe
fixed leftover
abi87 Mar 27, 2024
0e536e9
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 28, 2024
804c04f
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 29, 2024
5d3fce9
reduced diffs
abi87 Mar 29, 2024
8e83a99
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Mar 29, 2024
5719eae
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 2, 2024
9ad5ed4
introduced p-chain fees calculators ctors
abi87 Apr 2, 2024
feb8f93
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 2, 2024
cad0650
hardened AddFees RemoveFees in p-chain wallet
abi87 Apr 2, 2024
fdf25b2
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 3, 2024
270ce3e
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 4, 2024
98c7784
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 8, 2024
47cefa1
fix proposal blocks block-complexity
abi87 Apr 8, 2024
bf36767
minor cleanup
abi87 Apr 8, 2024
f54eb12
some more minor cleanups
abi87 Apr 8, 2024
f3b4936
nit
abi87 Apr 8, 2024
f4d3bef
added block complexity UTs
abi87 Apr 9, 2024
e8c33b8
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 9, 2024
3c85eb4
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 11, 2024
6ff6418
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 12, 2024
ebd5d11
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 15, 2024
bd31d35
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 15, 2024
d1ad5fa
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 15, 2024
703c58c
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 16, 2024
91a6e49
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 21, 2024
36d3c3c
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 23, 2024
a979da3
P chain meter fees fee config (#2961)
abi87 Apr 23, 2024
a1d127d
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 23, 2024
d90ee0f
nits
joshua-kim Apr 23, 2024
8e22671
Merge branch 'fee-calculator-nits' into p-chain_meter_fees-fee_getter
abi87 Apr 23, 2024
0fd16cd
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 24, 2024
4043ffd
Merge branch 'p-chainin_meter_fees' into p-chain_meter_fees-fee_getter
abi87 Apr 24, 2024
4aa7c3d
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 26, 2024
09c615f
nits for wallet builder UTs
abi87 Apr 26, 2024
6413178
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 Apr 29, 2024
9f9c520
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 2, 2024
afe83b1
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 6, 2024
373a953
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 9, 2024
8981e5a
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 10, 2024
6379288
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 14, 2024
a95b53e
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 14, 2024
3aaa4be
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 15, 2024
7c05c64
drop duplicated fields
abi87 May 20, 2024
beef890
replaced genesis.TxFeeConfig with fee.StaticConfig
abi87 May 20, 2024
e966579
nit
abi87 May 20, 2024
6e7c9d5
Merge branch 'p-chain_block_level_fee_calculator' into p-chain_meter_…
abi87 May 20, 2024
0b3e3f7
Merge branch 'p-chain_introducing-fees-calculators' into p-chainin_me…
abi87 May 20, 2024
c21f726
Merge branch 'p-chainin_meter_fees' into p-chain_meter_fees_block_lev…
abi87 May 20, 2024
6d2003d
introduced config.PickFeeCalculator
abi87 May 20, 2024
6e03a16
reusing PickFeeCalculator
abi87 May 20, 2024
fe206db
reset fees when ComputeFees is called
abi87 May 21, 2024
5f224f9
moved dynamic fee config to fee package
abi87 May 21, 2024
1a317a3
moved dynamic fee config to fee package
abi87 May 21, 2024
b768c7a
Merge branch 'p-chainin_meter_fees' into p-chain_meter_fees_block_lev…
abi87 May 21, 2024
04e18ba
minor renaming
abi87 May 21, 2024
6b3b23e
minor renaming
abi87 May 21, 2024
520a942
Merge branch 'master' into p-chainin_meter_fees
abi87 May 21, 2024
4cf3cce
Merge branch 'master' into p-chainin_meter_fees
abi87 May 21, 2024
65f00e9
Merge branch 'p-chain_block_level_fee_calculator' into p-chain_meter_…
abi87 May 21, 2024
2cd621a
Merge branch 'p-chain_meter_fees_block_level_fee_calculator' into p-c…
abi87 May 21, 2024
520ef72
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 May 29, 2024
acddf41
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jun 3, 2024
7d82af2
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jun 7, 2024
366b46c
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jun 11, 2024
7dc8900
simplified Dynamic fee calculator ctor
abi87 Jun 11, 2024
227b677
simplified GetDynamicConfigù
abi87 Jun 11, 2024
f31f1ac
wip: consolidating fee dimensions into single gas scalar
abi87 Jun 11, 2024
69e46c6
wip: fixing gas in UTs
abi87 Jun 12, 2024
c398294
nit
abi87 Jun 12, 2024
b0edb2a
nit
abi87 Jun 12, 2024
4b04fbb
Merge branch 'p-chainin_meter_fees' of github.com:ava-labs/avalancheg…
abi87 Jun 12, 2024
48f5e5a
nit
abi87 Jun 12, 2024
ec918b3
repackaged some txexecutor functions to state package
abi87 Jun 14, 2024
bb4c591
wip: introducing leaky bucket for blocks gas
abi87 Jun 14, 2024
36b424f
cleanup
abi87 Jun 18, 2024
931561e
renamed fees package to fee
abi87 Jun 18, 2024
4f71f0c
calculator ctor cleanup
abi87 Jun 18, 2024
963bc8d
nit
abi87 Jun 18, 2024
6f619a9
fixed gas cap update
abi87 Jun 18, 2024
f505830
refreshed mocks
abi87 Jun 18, 2024
eb11869
decoupled static and dynamic fee calculators
abi87 Jun 18, 2024
0840496
added UT
abi87 Jun 18, 2024
f2b2d5e
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jun 20, 2024
a2edef0
nit
abi87 Jun 20, 2024
b26f87c
dropped TempGasCap
abi87 Jun 20, 2024
45a5752
nit: fixed RPC invocation
abi87 Jun 20, 2024
99e9574
nit
abi87 Jun 20, 2024
1548cff
minor code consolidation
abi87 Jun 20, 2024
6f61cc3
added stakers state lookup cost
abi87 Jun 20, 2024
30379a3
nit
abi87 Jun 20, 2024
5500b2e
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jun 24, 2024
6cbe7c4
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jun 24, 2024
3f2862b
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jun 27, 2024
58c1c07
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jul 1, 2024
48de2c1
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jul 3, 2024
5c97117
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jul 4, 2024
0bf1e4f
nit
abi87 Jul 4, 2024
531b21f
nit
abi87 Jul 4, 2024
3fa3168
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jul 9, 2024
08e17ca
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jul 10, 2024
839a285
Merge branch 'p-chain_block_level_fee_calculator' into p-chainin_mete…
abi87 Jul 12, 2024
df43eb2
Merge branch 'p-chain_update_wallet' into p-chainin_meter_fees
abi87 Jul 15, 2024
38a6b92
Merge branch 'p-chain_update_wallet' into p-chainin_meter_fees
abi87 Jul 15, 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
4 changes: 2 additions & 2 deletions tests/e2e/p/permissionless_subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() {
owner,
e2e.WithDefaultContext(),
)

subnetID = subnetTx.ID()
require.NoError(err)
subnetID = subnetTx.ID()

require.NotEqual(subnetID, constants.PrimaryNetworkID)
})

Expand Down
23 changes: 17 additions & 6 deletions tests/e2e/p/staking_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() {
delegatorData := data[0].Delegators[0]
actualGammaDelegationPeriod := time.Duration(delegatorData.EndTime-delegatorData.StartTime) * time.Second

preRewardBalances := make(map[ids.ShortID]uint64, len(rewardKeys))
for _, rewardKey := range rewardKeys {
keychain := secp256k1fx.NewKeychain(rewardKey)
baseWallet := e2e.NewWallet(keychain, nodeURI)
pWallet := baseWallet.P()
balances, err := pWallet.Builder().GetBalance()
require.NoError(err)
preRewardBalances[rewardKey.Address()] = balances[pWallet.Builder().Context().AVAXAssetID]
}
require.Len(preRewardBalances, len(rewardKeys))

ginkgo.By("waiting until all validation periods are over")
// The beta validator was the last added and so has the latest end time. The
// delegation periods are shorter than the validation periods.
Expand Down Expand Up @@ -293,12 +304,12 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() {

ginkgo.By("checking expected rewards against actual rewards")
expectedRewardBalances := map[ids.ShortID]uint64{
alphaValidationRewardKey.Address(): expectedValidationReward,
alphaDelegationRewardKey.Address(): expectedDelegationFee,
betaValidationRewardKey.Address(): 0, // Validator didn't meet uptime requirement
betaDelegationRewardKey.Address(): 0, // Validator didn't meet uptime requirement
gammaDelegationRewardKey.Address(): expectedDelegatorReward,
deltaDelegationRewardKey.Address(): 0, // Validator didn't meet uptime requirement
alphaValidationRewardKey.Address(): preRewardBalances[alphaValidationRewardKey.Address()] + expectedValidationReward,
alphaDelegationRewardKey.Address(): preRewardBalances[alphaDelegationRewardKey.Address()] + expectedDelegationFee,
betaValidationRewardKey.Address(): preRewardBalances[betaValidationRewardKey.Address()] + 0, // Validator didn't meet uptime requirement
betaDelegationRewardKey.Address(): preRewardBalances[betaDelegationRewardKey.Address()] + 0, // Validator didn't meet uptime requirement
gammaDelegationRewardKey.Address(): preRewardBalances[gammaDelegationRewardKey.Address()] + expectedDelegatorReward,
deltaDelegationRewardKey.Address(): preRewardBalances[deltaDelegationRewardKey.Address()] + 0, // Validator didn't meet uptime requirement
}
for address := range expectedRewardBalances {
require.Equal(expectedRewardBalances[address], rewardBalances[address])
Expand Down
38 changes: 24 additions & 14 deletions tests/e2e/p/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import (
"github.com/ava-labs/avalanchego/vms/platformvm"
"github.com/ava-labs/avalanchego/vms/platformvm/signer"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/platformvm/txs/fee"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"

commonfee "github.com/ava-labs/avalanchego/vms/components/fee"
ginkgo "github.com/onsi/ginkgo/v2"
)

Expand Down Expand Up @@ -57,25 +59,24 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
tests.Outf("{{green}} minimal validator stake: %d {{/}}\n", minValStake)
tests.Outf("{{green}} minimal delegator stake: %d {{/}}\n", minDelStake)

tests.Outf("{{blue}} fetching tx fee {{/}}\n")
tests.Outf("{{blue}} fetching minimal stake amounts {{/}}\n")
feeCfg, err := pChainClient.GetDynamicFeeConfig(e2e.DefaultContext())
require.NoError(err)
tests.Outf("{{green}} fee config: %v {{/}}\n", feeCfg)

tests.Outf("{{blue}} fetching X-chain tx fee {{/}}\n")
infoClient := info.NewClient(nodeURI.URI)
fees, err := infoClient.GetTxFee(e2e.DefaultContext())
staticFees, err := infoClient.GetTxFee(e2e.DefaultContext())
require.NoError(err)
txFees := uint64(fees.TxFee)
tests.Outf("{{green}} txFee: %d {{/}}\n", txFees)

xChainTxFees := uint64(staticFees.TxFee)
tests.Outf("{{green}} X-chain TxFee: %d {{/}}\n", xChainTxFees)

// amount to transfer from P to X chain
toTransfer := 1 * units.Avax

pShortAddr := keychain.Keys[0].Address()
xTargetAddr := keychain.Keys[1].Address()
ginkgo.By("check selected keys have sufficient funds", func() {
pBalances, err := pWallet.Builder().GetBalance()
pBalance := pBalances[avaxAssetID]
minBalance := minValStake + txFees + minDelStake + txFees + toTransfer + txFees
require.NoError(err)
require.GreaterOrEqual(pBalance, minBalance)
})

// Use a random node ID to ensure that repeated test runs
// will succeed against a network that persists across runs.
Expand Down Expand Up @@ -145,8 +146,12 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
OutputOwners: outputOwner,
}

pChainExportFee := uint64(0)
ginkgo.By("export avax from P to X chain", func() {
_, err := pWallet.IssueExportTx(
nextGasPrice, nextGasCap, err := pChainClient.GetNextGasData(e2e.DefaultContext())
require.NoError(err)

tx, err := pWallet.IssueExportTx(
xContext.BlockchainID,
[]*avax.TransferableOutput{
{
Expand All @@ -159,6 +164,11 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
e2e.WithDefaultContext(),
)
require.NoError(err)

// retrieve fees paid for the tx
feeCalc := fee.NewDynamicCalculator(commonfee.NewCalculator(feeCfg.FeeDimensionWeights, nextGasPrice, nextGasCap))
pChainExportFee, err = feeCalc.CalculateFee(tx)
require.NoError(err)
})

// check balances post export
Expand All @@ -173,7 +183,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
tests.Outf("{{blue}} X-chain balance after P->X export: %d {{/}}\n", xPreImportBalance)

require.Equal(xPreImportBalance, xStartBalance) // import not performed yet
require.Equal(pPreImportBalance, pStartBalance-toTransfer-txFees)
require.Equal(pPreImportBalance, pStartBalance-toTransfer-pChainExportFee)

ginkgo.By("import avax from P into X chain", func() {
_, err := xWallet.IssueImportTx(
Expand All @@ -195,7 +205,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
xFinalBalance := xBalances[avaxAssetID]
tests.Outf("{{blue}} X-chain balance after P->X import: %d {{/}}\n", xFinalBalance)

require.Equal(xFinalBalance, xPreImportBalance+toTransfer-txFees) // import not performed yet
require.Equal(xFinalBalance, xPreImportBalance+toTransfer-xChainTxFees) // import not performed yet
require.Equal(pFinalBalance, pPreImportBalance)
})
})
2 changes: 1 addition & 1 deletion vms/platformvm/block/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func packBlockTxs(
return nil, err
}

feeCalculator, err := state.PickFeeCalculator(backend.Config, stateDiff)
feeCalculator, err := state.PickFeeCalculator(backend.Config, stateDiff, parentState.GetTimestamp())
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/block/builder/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func addSubnet(t *testing.T, env *environment) {
stateDiff, err := state.NewDiff(genesisID, env.blkManager)
require.NoError(err)

feeCalculator, err := state.PickFeeCalculator(env.config, stateDiff)
feeCalculator, err := state.PickFeeCalculator(env.config, stateDiff, stateDiff.GetTimestamp())
require.NoError(err)

executor := txexecutor.StandardTxExecutor{
Expand Down
10 changes: 10 additions & 0 deletions vms/platformvm/block/executor/acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func (a *acceptor) ApricotAtomicBlock(b *block.ApricotAtomicBlock) error {
return fmt.Errorf("%w %s", errMissingBlockState, blkID)
}

a.metrics.SetBlockGas(blkState.blockGas)

// Update the state to reflect the changes made in [onAcceptState].
if err := blkState.onAcceptState.Apply(a.state); err != nil {
return err
Expand Down Expand Up @@ -136,6 +138,8 @@ func (a *acceptor) optionBlock(b block.Block, blockType string) error {
return err
}

a.metrics.SetBlockGas(parentState.blockGas)

if err := a.commonAccept(b); err != nil {
return err
}
Expand All @@ -150,6 +154,10 @@ func (a *acceptor) optionBlock(b block.Block, blockType string) error {
if !ok {
return fmt.Errorf("%w %s", errMissingBlockState, blkID)
}

// we set option complexity at its parent block's one.
a.metrics.SetBlockGas(parentState.blockGas)

if err := blkState.onAcceptState.Apply(a.state); err != nil {
return err
}
Expand Down Expand Up @@ -228,6 +236,8 @@ func (a *acceptor) standardBlock(b block.Block, blockType string) error {
return fmt.Errorf("%w %s", errMissingBlockState, blkID)
}

a.metrics.SetBlockGas(blkState.blockGas)

// Update the state to reflect the changes made in [onAcceptState].
if err := blkState.onAcceptState.Apply(a.state); err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions vms/platformvm/block/executor/block_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/vms/platformvm/block"
"github.com/ava-labs/avalanchego/vms/platformvm/state"

commonfee "github.com/ava-labs/avalanchego/vms/components/fee"
)

type proposalBlockState struct {
Expand All @@ -30,5 +32,6 @@ type blockState struct {

inputs set.Set[ids.ID]
timestamp time.Time
blockGas commonfee.Gas
atomicRequests map[ids.ID]*atomic.Requests
}
96 changes: 84 additions & 12 deletions vms/platformvm/block/executor/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package executor
import (
"context"
"fmt"
"math/rand"
"testing"
"time"

Expand Down Expand Up @@ -36,6 +37,7 @@ import (
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/timer/mockable"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/platformvm/api"
"github.com/ava-labs/avalanchego/vms/platformvm/config"
"github.com/ava-labs/avalanchego/vms/platformvm/fx"
Expand All @@ -61,15 +63,14 @@ const (
pending stakerStatus = iota
current

defaultWeight = 10000
trackChecksum = false

apricotPhase3 fork = iota
apricotPhase5
banff
cortina
durango
eUpgrade

latestFork = eUpgrade
)

var (
Expand All @@ -78,17 +79,24 @@ var (
defaultGenesisTime = time.Date(1997, 1, 1, 0, 0, 0, 0, time.UTC)
defaultValidateStartTime = defaultGenesisTime
defaultValidateEndTime = defaultValidateStartTime.Add(10 * defaultMinStakingDuration)
defaultMinValidatorStake = 5 * units.MilliAvax
defaultBalance = 100 * defaultMinValidatorStake
preFundedKeys = secp256k1.TestKeys()
avaxAssetID = ids.ID{'y', 'e', 'e', 't'}
defaultTxFee = uint64(100)

defaultMinValidatorStake = 5 * units.MilliAvax
defaultMaxValidatorStake = 500 * units.MilliAvax
defaultMinDelegatorStake = 1 * units.MilliAvax
Comment on lines +83 to +85
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor code duplication removal

defaultBalance = 100 * defaultMinValidatorStake
defaultWeight = defaultBalance / 2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes to unlock TestStandardBlockComplexity for AddPermissionlessDelegatorTx


preFundedKeys = secp256k1.TestKeys()
avaxAssetID = ids.ID{'y', 'e', 'e', 't'}
defaultTxFee = uint64(100)

genesisBlkID ids.ID
testSubnet1 *txs.Tx

// Node IDs of genesis validators. Initialized in init function
genesisNodeIDs []ids.NodeID

fundedSharedMemoryCalls byte
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied from txs/executor package to allow transactions creation for TestStandardBlockComplexity

)

func init() {
Expand All @@ -102,6 +110,10 @@ type stakerStatus uint

type fork uint8

type mutableSharedMemory struct {
atomic.SharedMemory
}

type staker struct {
nodeID ids.NodeID
rewardAddress ids.ShortID
Expand All @@ -127,6 +139,7 @@ type environment struct {
clk *mockable.Clock
baseDB *versiondb.Database
ctx *snow.Context
msm *mutableSharedMemory
fx fx.Fx
state state.State
mockedState *state.MockState
Expand All @@ -152,6 +165,12 @@ func newEnvironment(t *testing.T, ctrl *gomock.Controller, f fork) *environment
res.ctx.AVAXAssetID = avaxAssetID
res.ctx.SharedMemory = m.NewSharedMemory(res.ctx.ChainID)

msm := &mutableSharedMemory{
SharedMemory: m.NewSharedMemory(res.ctx.ChainID),
}
res.ctx.SharedMemory = msm
res.msm = msm

res.fx = defaultFx(res.clk, res.ctx.Log, res.isBootstrapped.Get())

rewardsCalc := reward.NewCalculator(res.config.RewardConfig)
Expand Down Expand Up @@ -288,7 +307,7 @@ func addSubnet(env *environment) {
if err != nil {
panic(err)
}
feeCalculator, err := state.PickFeeCalculator(env.config, stateDiff)
feeCalculator, err := state.PickFeeCalculator(env.config, stateDiff, stateDiff.GetTimestamp())
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -354,9 +373,9 @@ func defaultConfig(t *testing.T, f fork) *config.Config {
CreateSubnetTxFee: 100 * defaultTxFee,
CreateBlockchainTxFee: 100 * defaultTxFee,
},
MinValidatorStake: 5 * units.MilliAvax,
MaxValidatorStake: 500 * units.MilliAvax,
MinDelegatorStake: 1 * units.MilliAvax,
MinValidatorStake: defaultMinValidatorStake,
MaxValidatorStake: defaultMaxValidatorStake,
MinDelegatorStake: defaultMinDelegatorStake,
MinStakeDuration: defaultMinStakingDuration,
MaxStakeDuration: defaultMaxStakingDuration,
RewardConfig: reward.Config{
Expand Down Expand Up @@ -557,3 +576,56 @@ func addPendingValidator(
}
return addPendingValidatorTx, nil
}

// Returns a shared memory where GetDatabase returns a database
// where [recipientKey] has a balance of [amt]
func fundedSharedMemory(
t *testing.T,
env *environment,
sourceKey *secp256k1.PrivateKey,
peerChain ids.ID,
assets map[ids.ID]uint64,
) atomic.SharedMemory {
fundedSharedMemoryCalls++
m := atomic.NewMemory(prefixdb.New([]byte{fundedSharedMemoryCalls}, env.baseDB))

sm := m.NewSharedMemory(env.ctx.ChainID)
peerSharedMemory := m.NewSharedMemory(peerChain)

for assetID, amt := range assets {
utxo := &avax.UTXO{
UTXOID: avax.UTXOID{
TxID: ids.GenerateTestID(),
OutputIndex: rand.Uint32(), // #nosec G404
},
Asset: avax.Asset{ID: assetID},
Out: &secp256k1fx.TransferOutput{
Amt: amt,
OutputOwners: secp256k1fx.OutputOwners{
Locktime: 0,
Addrs: []ids.ShortID{sourceKey.PublicKey().Address()},
Threshold: 1,
},
},
}
utxoBytes, err := txs.Codec.Marshal(txs.CodecVersion, utxo)
require.NoError(t, err)

inputID := utxo.InputID()
require.NoError(t, peerSharedMemory.Apply(map[ids.ID]*atomic.Requests{
env.ctx.ChainID: {
PutRequests: []*atomic.Element{
{
Key: inputID[:],
Value: utxoBytes,
Traits: [][]byte{
sourceKey.PublicKey().Address().Bytes(),
},
},
},
},
}))
}

return sm
}
Loading