Skip to content

Commit 67fa243

Browse files
authored
Re-enable burn tests on Kusama and Polkadot relays (#599)
* Re-enable burn tests on Kusama relay; keep them disabled on Polkadot Kusama passes at the current known-good block because the AHM accounts migration has not yet run there, so validator accounts still have free balance on the relay chain and fee routing via DealWithFees/ToAuthor succeeds. Polkadot's known-good block is past that migration, leaving validator accounts with free = 0, which causes ToAuthor to silently drop the fee credit and reduce TotalIssuance by 0.2 * fee, breaking the strict equality assertion in the burn tests. Polkadot tests will be re-enabled once DealWithFees/ToAuthor is fixed upstream to not drop fee credits when the author account is below ED. See paritytech/polkadot-sdk#9986. * Update Bifrost Polkadot endpoint * Re-enable Polkadot relay burn tests with proviso for 9986 The 20% of the extrinsic fee which would go to the block author would be burned when the validator has had their relay balance zeroed because of AHM migration. This commit re-enables burn tests on relay chains, and accounts for the case in which this happens, as the known-good block's author may have had their relay balance zeroed post-AHM. * Bump block numbers
1 parent fbfbbdb commit 67fa243

6 files changed

Lines changed: 88 additions & 92 deletions

File tree

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
ASSETHUBKUSAMA_BLOCK_NUMBER=16117236
2-
BASILISK_BLOCK_NUMBER=13979556
3-
BIFROSTKUSAMA_BLOCK_NUMBER=13603047
4-
BRIDGEHUBKUSAMA_BLOCK_NUMBER=8093533
5-
CORETIMEKUSAMA_BLOCK_NUMBER=5028787
6-
ENCOINTERKUSAMA_BLOCK_NUMBER=13431695
7-
KARURA_BLOCK_NUMBER=11459919
8-
KUSAMA_BLOCK_NUMBER=33287711
9-
MOONRIVER_BLOCK_NUMBER=16069369
10-
PEOPLEKUSAMA_BLOCK_NUMBER=8837196
11-
SHIDEN_BLOCK_NUMBER=14593298
1+
ASSETHUBKUSAMA_BLOCK_NUMBER=16206825
2+
BASILISK_BLOCK_NUMBER=14005412
3+
BIFROSTKUSAMA_BLOCK_NUMBER=13636914
4+
BRIDGEHUBKUSAMA_BLOCK_NUMBER=8110565
5+
CORETIMEKUSAMA_BLOCK_NUMBER=5045562
6+
ENCOINTERKUSAMA_BLOCK_NUMBER=13460752
7+
KARURA_BLOCK_NUMBER=11476954
8+
KUSAMA_BLOCK_NUMBER=33321973
9+
MOONRIVER_BLOCK_NUMBER=16101333
10+
PEOPLEKUSAMA_BLOCK_NUMBER=8871143
11+
SHIDEN_BLOCK_NUMBER=14620911
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
ACALA_BLOCK_NUMBER=11002567
2-
ASSETHUBPOLKADOT_BLOCK_NUMBER=15071965
3-
ASTAR_BLOCK_NUMBER=13150626
4-
BIFROSTPOLKADOT_BLOCK_NUMBER=12035220
5-
BRIDGEHUBPOLKADOT_BLOCK_NUMBER=7540201
6-
COLLECTIVESPOLKADOT_BLOCK_NUMBER=8747176
7-
CORETIMEPOLKADOT_BLOCK_NUMBER=4131048
8-
HYDRATION_BLOCK_NUMBER=12235278
9-
MOONBEAM_BLOCK_NUMBER=15403969
10-
PEOPLEPOLKADOT_BLOCK_NUMBER=4456978
11-
POLKADOT_BLOCK_NUMBER=30994178
1+
ACALA_BLOCK_NUMBER=11019681
2+
ASSETHUBPOLKADOT_BLOCK_NUMBER=15167298
3+
ASTAR_BLOCK_NUMBER=13177290
4+
BIFROSTPOLKADOT_BLOCK_NUMBER=12064006
5+
BRIDGEHUBPOLKADOT_BLOCK_NUMBER=7557364
6+
COLLECTIVESPOLKADOT_BLOCK_NUMBER=8764227
7+
CORETIMEPOLKADOT_BLOCK_NUMBER=4148211
8+
HYDRATION_BLOCK_NUMBER=12259837
9+
MOONBEAM_BLOCK_NUMBER=15436402
10+
PEOPLEPOLKADOT_BLOCK_NUMBER=4474388
11+
POLKADOT_BLOCK_NUMBER=31028926

packages/kusama/src/kusama.accounts.e2e.test.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@ import { kusama } from '@e2e-test/networks/chains'
22
import {
33
accountsE2ETests,
44
createAccountsConfig,
5-
type DescribeNode,
65
manualLockAction,
76
manualReserveAction,
87
multisigCreationDepositAction,
98
proxyAdditionDepositAction,
10-
type RootTestTree,
119
registerTestTree,
1210
type TestConfig,
13-
type TestNode,
1411
} from '@e2e-test/shared'
1512

16-
import { match } from 'ts-pattern'
17-
1813
const generalTestConfig: TestConfig = {
1914
testSuiteName: 'Kusama Accounts',
2015
}
@@ -37,30 +32,4 @@ const accountsTestCfg = createAccountsConfig({
3732
},
3833
})
3934

40-
/**
41-
* `burn` tests are temporarily disabled on Kusama relay, see
42-
* https://github.com/paritytech/polkadot-sdk/issues/9986.
43-
*
44-
* TODO: reenable after fix
45-
*/
46-
const filterOutBurnTests = (tree: RootTestTree): RootTestTree => {
47-
const filterChildren = (children: (TestNode | DescribeNode)[]): (TestNode | DescribeNode)[] => {
48-
return children
49-
.filter((child) => !child.label.includes('burn'))
50-
.map((child) => {
51-
return match(child)
52-
.with({ kind: 'test' }, () => child)
53-
.with({ kind: 'describe' }, (desc) => {
54-
return { ...desc, children: filterChildren(desc.children) }
55-
})
56-
.exhaustive()
57-
})
58-
}
59-
60-
return {
61-
...tree,
62-
children: filterChildren(tree.children),
63-
}
64-
}
65-
66-
registerTestTree(filterOutBurnTests(accountsE2ETests(kusama, generalTestConfig, accountsTestCfg)))
35+
registerTestTree(accountsE2ETests(kusama, generalTestConfig, accountsTestCfg))

packages/networks/src/pet-chain-endpoints.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@
5757
"wss://acala-rpc-3.aca-api.network/ws"
5858
],
5959
"bifrostPolkadot": [
60-
"wss://hk.p.bifrost-rpc.liebi.com/ws",
61-
"wss://eu.bifrost-polkadot-rpc.liebi.com/ws"
60+
"wss://eu.bifrost-polkadot-rpc.liebi.com/ws",
61+
"wss://hk.p.bifrost-rpc.liebi.com/ws"
6262
],
6363
"hydration": [
6464
"wss://hydration.dotters.network",

packages/polkadot/src/polkadot.accounts.e2e.test.ts

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,25 @@ import { polkadot } from '@e2e-test/networks/chains'
22
import {
33
accountsE2ETests,
44
createAccountsConfig,
5-
type DescribeNode,
65
manualLockAction,
76
manualReserveAction,
87
multisigCreationDepositAction,
98
proxyAdditionDepositAction,
10-
type RootTestTree,
119
registerTestTree,
1210
type TestConfig,
13-
type TestNode,
1411
} from '@e2e-test/shared'
1512

16-
import { match } from 'ts-pattern'
17-
1813
const generalTestConfig: TestConfig = {
1914
testSuiteName: 'Polkadot Accounts',
2015
}
2116

2217
// Staking and nomination pools are disabled on Polkadot relay, so the only reserve action available is manual.
2318
const reserveActions = [manualReserveAction()]
2419

25-
// Vesting is also disabled, so the only lock action available is the manual lock.
20+
// Vesting is disabled on Polkadot relay, so the only lock action available is the manual lock.
2621
const lockActions = [manualLockAction()]
2722

28-
// Referenda submission is no longer available, either.
23+
// Referenda submission is no longer available on Polkadot relay.
2924
const depositActions = [proxyAdditionDepositAction(), multisigCreationDepositAction()]
3025

3126
const accountsTestCfg = createAccountsConfig({
@@ -37,24 +32,4 @@ const accountsTestCfg = createAccountsConfig({
3732
},
3833
})
3934

40-
const filterOutBurnTests = (tree: RootTestTree): RootTestTree => {
41-
const filterChildren = (children: (TestNode | DescribeNode)[]): (TestNode | DescribeNode)[] => {
42-
return children
43-
.filter((child) => !child.label.includes('burn'))
44-
.map((child) => {
45-
return match(child)
46-
.with({ kind: 'test' }, () => child)
47-
.with({ kind: 'describe' }, (desc) => {
48-
return { ...desc, children: filterChildren(desc.children) }
49-
})
50-
.exhaustive()
51-
})
52-
}
53-
54-
return {
55-
...tree,
56-
children: filterChildren(tree.children),
57-
}
58-
}
59-
60-
registerTestTree(filterOutBurnTests(accountsE2ETests(polkadot, generalTestConfig, accountsTestCfg)))
35+
registerTestTree(accountsE2ETests(polkadot, generalTestConfig, accountsTestCfg))

packages/shared/src/accounts.ts

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3748,7 +3748,15 @@ async function burnTestBaseCase<
37483748

37493749
// Check total issuance decreased by burn amount (fees are not included)
37503750
const totalIssuanceAfterBurn = await client.api.query.balances.totalIssuance()
3751-
expect(totalIssuanceAfterBurn.toBigInt()).toBe(initialTotalIssuance.toBigInt() - burnAmount)
3751+
const tiDelta = initialTotalIssuance.toBigInt() - totalIssuanceAfterBurn.toBigInt()
3752+
if (client.config.isRelayChain) {
3753+
// On relay chains the block author may be below ED; if so, the fee credit is dropped and
3754+
// TI shrinks by an extra authorShare on top of the burn (polkadot-sdk#9986).
3755+
const authorShare = burnFee - (burnFee * 4n) / 5n
3756+
expect(tiDelta === burnAmount || tiDelta === burnAmount + authorShare).toBe(true)
3757+
} else {
3758+
expect(tiDelta).toBe(burnAmount)
3759+
}
37523760

37533761
// Check burn event
37543762
const eventsAfterBurn = await client.api.query.system.events()
@@ -3845,8 +3853,17 @@ async function burnTestWithReaping<
38453853
// 4. Verify that the total issuance is decreased by the amount burned
38463854
const totalIssuanceAfterBurn = await client.api.query.balances.totalIssuance()
38473855
const isBifrost = chain.name.includes('bifrost')
3856+
const reapingFee = cumulativeFees.get(encodeAddress(alice.address, client.config.properties.addressEncoding))!
38483857
const expectedDecrease = isBifrost ? burnAmount : burnAmount + (existentialDeposit - 1n)
3849-
expect(totalIssuanceAfterBurn.toBigInt()).toBe(initialTotalIssuance.toBigInt() - expectedDecrease)
3858+
const tiAfter = totalIssuanceAfterBurn.toBigInt()
3859+
const tiExpect = initialTotalIssuance.toBigInt() - expectedDecrease
3860+
if (client.config.isRelayChain) {
3861+
// Block author may be below ED; fee credit may be dropped, shrinking TI further (polkadot-sdk#9986).
3862+
const reapingAuthorShare = reapingFee - (reapingFee * 4n) / 5n
3863+
expect(tiAfter === tiExpect || tiAfter === tiExpect - reapingAuthorShare).toBe(true)
3864+
} else {
3865+
expect(tiAfter).toBe(tiExpect)
3866+
}
38503867
}
38513868

38523869
/**
@@ -3928,10 +3945,21 @@ async function burnKeepAliveTest<
39283945
expect(aliceFinalBalance).toBe(aliceInitialBalance - transactionFee)
39293946
expect(await isAccountReaped(client, alice.address)).toBe(false)
39303947

3931-
// 6. Verify that total issuance is unchanged
3948+
// 6. Verify that total issuance is unchanged (see polkadot-sdk#9986 for relay-chain author-drop case)
39323949

39333950
const finalTotalIssuance = await client.api.query.balances.totalIssuance()
3934-
expect(finalTotalIssuance.toBigInt()).toBe(initialTotalIssuance.toBigInt())
3951+
const keepAliveFee = cumulativeFees.get(encodeAddress(alice.address, client.config.properties.addressEncoding))!
3952+
const keepAliveTI = finalTotalIssuance.toBigInt()
3953+
if (client.config.isRelayChain) {
3954+
// Block author may be below ED; fee credit may be dropped, shrinking TI (polkadot-sdk#9986).
3955+
const keepAliveAuthorShare = keepAliveFee - (keepAliveFee * 4n) / 5n
3956+
expect(
3957+
keepAliveTI === initialTotalIssuance.toBigInt() ||
3958+
keepAliveTI === initialTotalIssuance.toBigInt() - keepAliveAuthorShare,
3959+
).toBe(true)
3960+
} else {
3961+
expect(keepAliveTI).toBe(initialTotalIssuance.toBigInt())
3962+
}
39353963

39363964
// Verify no explicit Burned event for Alice (on Bifrost, fee-related Burned events are expected)
39373965
const explicitBurns = findExplicitBurnEventsForAccount(systemEvents, client, alice.address, chain)
@@ -4041,10 +4069,21 @@ async function burnWithDepositTest<
40414069
const expectedFreeBalance = aliceFreeBefore - totalFees
40424070
expect(aliceAccountAfterBurn.data.free.toBigInt()).toBe(expectedFreeBalance)
40434071

4044-
// 5. Verify that total issuance is unchanged
4072+
// 5. Verify that total issuance is unchanged (see polkadot-sdk#9986 for relay-chain author-drop case)
40454073

40464074
const finalTotalIssuance = await client.api.query.balances.totalIssuance()
4047-
expect(finalTotalIssuance.toBigInt()).toBe(initialTotalIssuance.toBigInt())
4075+
const depositFee = cumulativeFees.get(encodeAddress(alice.address, client.config.properties.addressEncoding))!
4076+
const depositTI = finalTotalIssuance.toBigInt()
4077+
if (client.config.isRelayChain) {
4078+
// Block author may be below ED; fee credit may be dropped, shrinking TI (polkadot-sdk#9986).
4079+
const depositAuthorShare = depositFee - (depositFee * 4n) / 5n
4080+
expect(
4081+
depositTI === initialTotalIssuance.toBigInt() ||
4082+
depositTI === initialTotalIssuance.toBigInt() - depositAuthorShare,
4083+
).toBe(true)
4084+
} else {
4085+
expect(depositTI).toBe(initialTotalIssuance.toBigInt())
4086+
}
40484087

40494088
// Verify no explicit Burned event for Alice
40504089
const systemEvents = await client.api.query.system.events()
@@ -4157,10 +4196,23 @@ async function burnDoubleAttemptTest<
41574196
expect(aliceFinalBalance).toBe(aliceInitialBalance - transactionFees)
41584197
expect(await isAccountReaped(client, alice.address)).toBe(false)
41594198

4160-
// 5. Verify total issuance is unchanged
4199+
// 5. Verify total issuance is unchanged (see polkadot-sdk#9986 for relay-chain author-drop case)
4200+
// Two transactions: each fee goes through ration(80,20) independently, so we check per-fee drops.
41614201

41624202
const finalTotalIssuance = await client.api.query.balances.totalIssuance()
4163-
expect(finalTotalIssuance.toBigInt()).toBe(initialTotalIssuance.toBigInt())
4203+
const doubleFee = cumulativeFees.get(encodeAddress(alice.address, client.config.properties.addressEncoding))!
4204+
const singleFee = doubleFee / 2n
4205+
const singleAuthorShare = singleFee - (singleFee * 4n) / 5n
4206+
const doubleTI = finalTotalIssuance.toBigInt()
4207+
const ti0 = initialTotalIssuance.toBigInt()
4208+
if (client.config.isRelayChain) {
4209+
// Block author is either consistently above or below ED for both txs in the same context;
4210+
// either both fee credits are dropped or neither is (polkadot-sdk#9986).
4211+
const doubleAuthorShare = singleAuthorShare * 2n
4212+
expect(doubleTI === ti0 || doubleTI === ti0 - doubleAuthorShare).toBe(true)
4213+
} else {
4214+
expect(doubleTI).toBe(ti0)
4215+
}
41644216

41654217
// Verify no explicit Burned event for Alice
41664218
const explicitBurns = findExplicitBurnEventsForAccount(systemEvents, client, alice.address, chain)

0 commit comments

Comments
 (0)