difftreelog
feat speedup inflation pallet
in: master
4 files changed
js-packages/tests/creditFeesToTreasury.seqtest.tsdiffbeforeafterboth--- a/js-packages/tests/creditFeesToTreasury.seqtest.ts
+++ b/js-packages/tests/creditFeesToTreasury.seqtest.ts
@@ -33,7 +33,7 @@
const blockInterval = inflationBlockInterval.toNumber();
const unsubscribe = await api.rpc.chain.subscribeNewHeads(head => {
const currentBlock = head.number.toNumber();
- if(currentBlock % blockInterval < blockInterval - 10) {
+ if(currentBlock % blockInterval < blockInterval - 2) {
unsubscribe();
resolve();
} else {
js-packages/tests/inflation.seqtest.tsdiffbeforeafterboth17import type {IKeyringPair} from '@polkadot/types/types';17import type {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, usingPlaygrounds} from './util/index.js';18import {expect, itSub, usingPlaygrounds} from './util/index.js';1920const TREASURY = '5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z';192120// todo:playgrounds requires sudo, look into on the later stage22// todo:playgrounds requires sudo, look into on the later stage21describe('integration test: Inflation', () => {23describe('integration test: Inflation', () => {56 expect(Math.abs(Number(expectedInflation))).to.be.lessThanOrEqual(tolerance);58 expect(Math.abs(Number(expectedInflation))).to.be.lessThanOrEqual(tolerance);57 });59 });6061 itSub('Inflation happens after inflation block interval', async ({helper}) => {62 const api = helper.getApi();63 const blockInterval = await api.consts.inflation.inflationBlockInterval.toNumber();6465 const relayBlock = (await api.query.parachainSystem.lastRelayChainBlockNumber()).toNumber();66 await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [helper.constructApiCall('api.tx.inflation.startInflation', [relayBlock])]);67 const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();68 const startBlock = (relayBlock + blockInterval) - (relayBlock % blockInterval) + 1;6970 await helper.wait.forRelayBlockNumber(startBlock);7172 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);7374 await helper.wait.forRelayBlockNumber(startBlock + blockInterval);7576 const treasuryBalanceAfter = await helper.balance.getSubstrate(TREASURY);77 expect(Number(treasuryBalanceAfter)).to.be.eqls(Number(treasuryBalanceBefore + blockInflation));78 });58});79});5980pallets/inflation/src/tests.rsdiffbeforeafterboth--- a/pallets/inflation/src/tests.rs
+++ b/pallets/inflation/src/tests.rs
@@ -106,7 +106,7 @@
parameter_types! {
pub TreasuryAccountId: u64 = 1234;
- pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied
+ pub const InflationBlockInterval: u32 = 10; // every time per how many blocks inflation is applied
pub static MockBlockNumberProvider: u32 = 0;
}
runtime/common/config/pallets/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -102,7 +102,7 @@
}
parameter_types! {
- pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied
+ pub const InflationBlockInterval: BlockNumber = 10; // every time per how many blocks inflation is applied
}
/// Pallet-inflation needs block number in on_initialize, where there is no `validation_data` exists yet