diff --git a/.baedeker/up.sh b/.baedeker/up.sh index 205f929e3e..a8ee48e75d 100755 --- a/.baedeker/up.sh +++ b/.baedeker/up.sh @@ -1,6 +1,6 @@ #!/bin/sh set -e BDK_DIR=$(dirname $(readlink -f "$0")) -RUST_LOG=info baedeker --spec=docker -J$BDK_DIR/vendor/ --generator=docker_compose=$BDK_DIR/.bdk-env --generator=docker_compose_discover=$BDK_DIR/.bdk-env/discover.env --secret=file=$BDK_DIR/.bdk-env/secret --tla-str=relay_spec=rococo-local --tla-code=assethub_spec="import 'assethub-spec.json'" --input-modules='lib:baedeker-library/ops/nginx.libsonnet' --input-modules='lib:baedeker-library/ops/devtools.libsonnet' --tla-str=repoDir=$(realpath $BDK_DIR/..) $@ $BDK_DIR/rewrites.jsonnet +RUST_LOG=info baedeker --spec=docker -J$BDK_DIR/vendor/ --generator=docker_compose=$BDK_DIR/.bdk-env --generator=docker_compose_discover=$BDK_DIR/.bdk-env/discover.env --secret=file=$BDK_DIR/.bdk-env/secret --tla-str=relay_spec=westend-local --tla-code=assethub_spec="import 'assethub-spec.json'" --input-modules='lib:baedeker-library/ops/nginx.libsonnet' --input-modules='lib:baedeker-library/ops/devtools.libsonnet' --tla-str=repoDir=$(realpath $BDK_DIR/..) $@ $BDK_DIR/rewrites.jsonnet cd $BDK_DIR/.bdk-env docker compose up -d --wait --remove-orphans diff --git a/Cargo.lock b/Cargo.lock index 821e3be07d..caf31a9ddd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7806,6 +7806,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "up-common", ] [[package]] diff --git a/js-packages/playgrounds/unique.ts b/js-packages/playgrounds/unique.ts index 273c0f39e7..e000ead897 100644 --- a/js-packages/playgrounds/unique.ts +++ b/js-packages/playgrounds/unique.ts @@ -590,18 +590,16 @@ export class ChainHelperBase { } return new Promise(async (resolve, reject) => { try { - let inBlockResult; const unsub = await sign((result: any) => { const status = this.getTransactionStatus(result); if(status === this.transactionStatus.SUCCESS) { if (!result.status.isFinalized) { - inBlockResult = result; return; } this.logger.log(`${label} successful`); unsub(); - resolve({result: inBlockResult!, status, blockHash: inBlockResult!.status.asInBlock.toHuman()}); + resolve({result, status, blockHash: result.status.toHuman().Finalized}); } else if(status === this.transactionStatus.FAIL) { let moduleError = null; diff --git a/js-packages/test-utils/util.ts b/js-packages/test-utils/util.ts index 8836c1136f..a64643a1df 100644 --- a/js-packages/test-utils/util.ts +++ b/js-packages/test-utils/util.ts @@ -98,7 +98,8 @@ export const DONOR_FUNDING = 4_000_000n; // App-promotion periods: export const LOCKING_PERIOD = 12n; // 12 blocks of relay -export const UNLOCKING_PERIOD = 6n; // 6 blocks of parachain +export const CALCULATION_PERIOD = 12n; // 12 blocks of parachain +export const UNLOCKING_PERIOD = 24n; // 24 blocks of parachain // Native contracts export const COLLECTION_HELPER = '0x6c4e9fe1ae37a41e93cee429e8e1881abdcbb54f'; diff --git a/js-packages/tests/sub/appPromotion/appPromotion.test.ts b/js-packages/tests/sub/appPromotion/appPromotion.test.ts index 9c0af019e7..8ce298df79 100644 --- a/js-packages/tests/sub/appPromotion/appPromotion.test.ts +++ b/js-packages/tests/sub/appPromotion/appPromotion.test.ts @@ -16,7 +16,8 @@ import type {IKeyringPair} from '@polkadot/types/types'; import { - itSub, usingPlaygrounds, Pallets, requirePalletsOrSkip, LOCKING_PERIOD, UNLOCKING_PERIOD, + itSub, usingPlaygrounds, Pallets, requirePalletsOrSkip, LOCKING_PERIOD, + CALCULATION_PERIOD, } from '@unique/test-utils/util.js'; import {DevUniqueHelper} from '@unique/test-utils'; import {itEth, expect, SponsoringMode} from '@unique/test-utils/eth/util.js'; @@ -42,7 +43,7 @@ async function getAccounts(accountsNumber: number, balance?: bigint) { } // App promotion periods: // LOCKING_PERIOD = 12 blocks of relay -// UNLOCKING_PERIOD = 6 blocks of parachain +// UNLOCKING_PERIOD = 12 blocks of parachain describe('App promotion', () => { before(async function () { @@ -61,6 +62,8 @@ describe('App promotion', () => { afterEach(async () => { await usingPlaygrounds(async (helper) => { + const totalStakedBefore = await helper.staking.getTotalStaked(); + let stakedByUsedAccs = 0n; let unstakeTxs = []; for(const account of usedAccounts) { if(unstakeTxs.length === 3) { @@ -68,10 +71,12 @@ describe('App promotion', () => { unstakeTxs = []; } unstakeTxs.push(helper.staking.unstakeAll(account)); + stakedByUsedAccs += await helper.staking.getTotalStaked({ Substrate: account.address }); } await Promise.all(unstakeTxs); usedAccounts = []; - expect(await helper.staking.getTotalStaked()).to.eq(0n); // there are no active stakes after each test + const stakedAfterUnstake = totalStakedBefore - stakedByUsedAccs; + expect(await helper.staking.getTotalStaked()).to.eq(stakedAfterUnstake); // there are no active stakes (for test accs) after each test // Make sure previousCalculatedRecord is None to avoid problem with payout stakers; await helper.admin.payoutStakers(palletAdmin, 100); expect((await helper.getApi().query.appPromotion.previousCalculatedRecord() as any).isNone).to.be.true; @@ -980,11 +985,11 @@ async function payUntilRewardFor(account: string, helper: DevUniqueHelper) { throw Error(`Cannot find payout for ${account}`); } -function calculateIncome(base: bigint, iter = 0, calcPeriod: bigint = UNLOCKING_PERIOD): bigint { - const DAY = 7200n; +function calculateIncome(base: bigint, iter = 0, calcPeriod: bigint = CALCULATION_PERIOD): bigint { + const BLOCKS_DAY = 14400n; // blocks per day const ACCURACY = 1_000_000_000n; // 453_256n / 1_000_000_000n = 0.0453256% /day - const income = base + base * (ACCURACY * (calcPeriod * 453_256n) / (1_000_000_000n * DAY)) / ACCURACY ; + const income = base + base * (ACCURACY * (calcPeriod * 453_256n) / (1_000_000_000n * BLOCKS_DAY)) / ACCURACY; if(iter > 1) { return calculateIncome(income, iter - 1, calcPeriod); diff --git a/pallets/inflation/Cargo.toml b/pallets/inflation/Cargo.toml index 472b76e570..ae5eb46d37 100644 --- a/pallets/inflation/Cargo.toml +++ b/pallets/inflation/Cargo.toml @@ -42,3 +42,4 @@ sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } +up-common = { workspace = true } \ No newline at end of file diff --git a/pallets/inflation/src/lib.rs b/pallets/inflation/src/lib.rs index fb5654fe0a..8e5259ba8c 100644 --- a/pallets/inflation/src/lib.rs +++ b/pallets/inflation/src/lib.rs @@ -46,10 +46,12 @@ use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; use sp_runtime::{traits::BlockNumberProvider, Perbill}; +use up_common::constants::RELAY_DAYS; + type BalanceOf = <::Currency as Inspect<::AccountId>>::Balance; -pub const YEAR: u32 = 5_259_600; // 6-second block +pub const YEAR: u32 = RELAY_DAYS * 365 + RELAY_DAYS / 4; // 365 days plus quater of a day as average for leap year // pub const YEAR: u32 = 2_629_800; // 12-second block pub const TOTAL_YEARS_UNTIL_FLAT: u32 = 9; pub const START_INFLATION_PERCENT: u32 = 10; diff --git a/runtime/opal/build.rs b/runtime/opal/build.rs index 5a281b9284..f0032a70b6 100644 --- a/runtime/opal/build.rs +++ b/runtime/opal/build.rs @@ -22,7 +22,7 @@ fn main() { #[cfg(all(feature = "metadata-hash", feature = "std"))] fn main() { substrate_wasm_builder::WasmBuilder::init_with_defaults() - .enable_metadata_hash("WND", 12) + .enable_metadata_hash("OPL", 18) .build(); } diff --git a/runtime/quartz/build.rs b/runtime/quartz/build.rs index 270715b468..656dc1e266 100644 --- a/runtime/quartz/build.rs +++ b/runtime/quartz/build.rs @@ -6,7 +6,7 @@ fn main() { #[cfg(all(feature = "metadata-hash", feature = "std"))] fn main() { substrate_wasm_builder::WasmBuilder::init_with_defaults() - .enable_metadata_hash("WND", 12) + .enable_metadata_hash("QTZ", 18) .build(); } diff --git a/runtime/unique/build.rs b/runtime/unique/build.rs index 270715b468..bcdade29df 100644 --- a/runtime/unique/build.rs +++ b/runtime/unique/build.rs @@ -6,7 +6,7 @@ fn main() { #[cfg(all(feature = "metadata-hash", feature = "std"))] fn main() { substrate_wasm_builder::WasmBuilder::init_with_defaults() - .enable_metadata_hash("WND", 12) + .enable_metadata_hash("UNQ", 18) .build(); }