From fc02af5493c7d3b8c868e5d237fca803dedf02a7 Mon Sep 17 00:00:00 2001 From: Andrei Navoichyk Date: Fri, 14 Jan 2022 12:27:35 +0300 Subject: [PATCH 1/4] Set shorted duration --- .../workflows/build-and-push-docker-image.yml | 2 +- bin/node/runtime/src/lib.rs | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-and-push-docker-image.yml b/.github/workflows/build-and-push-docker-image.yml index 64bd2d2a98a64..145bf1ae59f70 100644 --- a/.github/workflows/build-and-push-docker-image.yml +++ b/.github/workflows/build-and-push-docker-image.yml @@ -3,7 +3,7 @@ on: push: branches: - dev-cere - - 'feature/**' + - feature/decrease-durations-for-simulations env: ECR_REPOSITORY: pos-network-node jobs: diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index fd8e19e0c0403..c962f7f1f0e53 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -669,13 +669,13 @@ impl pallet_bags_list::Config for Runtime { } parameter_types! { - pub const LaunchPeriod: BlockNumber = 1 * 24 * 60 * MINUTES; - pub const VotingPeriod: BlockNumber = 1 * 24 * 60 * MINUTES; - pub const FastTrackVotingPeriod: BlockNumber = 3 * 60 * MINUTES; + pub const LaunchPeriod: BlockNumber = 5 * MINUTES; + pub const VotingPeriod: BlockNumber = 5 * MINUTES; + pub const FastTrackVotingPeriod: BlockNumber = 5 * MINUTES; pub const InstantAllowed: bool = true; - pub const MinimumDeposit: Balance = 5000 * DOLLARS; - pub const EnactmentPeriod: BlockNumber = 1 * 24 * 60 * MINUTES; - pub const CooloffPeriod: BlockNumber = 7 * 24 * 60 * MINUTES; + pub const MinimumDeposit: Balance = 10 * DOLLARS; + pub const EnactmentPeriod: BlockNumber = 5 * MINUTES; + pub const CooloffPeriod: BlockNumber = 5 * MINUTES; // One cent: $10,000 / MB pub const PreimageByteDeposit: Balance = 1 * CENTS; pub const MaxVotes: u32 = 100; @@ -735,7 +735,7 @@ impl pallet_democracy::Config for Runtime { } parameter_types! { - pub const CouncilMotionDuration: BlockNumber = 7 * DAYS; + pub const CouncilMotionDuration: BlockNumber = 5 * MINUTES; pub const CouncilMaxProposals: u32 = 100; pub const CouncilMaxMembers: u32 = 100; } @@ -757,7 +757,7 @@ parameter_types! { // 1 storage item created, key size is 32 bytes, value size is 16+16. pub const VotingBondBase: Balance = deposit(1, 64); pub const VotingBondFactor: Balance = 1 * DOLLARS; - pub const TermDuration: BlockNumber = 7 * DAYS; + pub const TermDuration: BlockNumber = 5 * MINUTES; pub const DesiredMembers: u32 = 13; pub const DesiredRunnersUp: u32 = 20; pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect"; @@ -787,7 +787,7 @@ impl pallet_elections_phragmen::Config for Runtime { } parameter_types! { - pub const TechnicalMotionDuration: BlockNumber = 5 * DAYS; + pub const TechnicalMotionDuration: BlockNumber = 5 * MINUTES; pub const TechnicalMaxProposals: u32 = 100; pub const TechnicalMaxMembers: u32 = 100; } @@ -825,14 +825,14 @@ impl pallet_membership::Config for Runtime { parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); pub const ProposalBondMinimum: Balance = 100 * DOLLARS; - pub const SpendPeriod: BlockNumber = 1 * DAYS; + pub const SpendPeriod: BlockNumber = 5 * MINUTES; pub const Burn: Permill = Permill::from_percent(0); - pub const TipCountdown: BlockNumber = 1 * DAYS; + pub const TipCountdown: BlockNumber = 5 * MINUTES; pub const TipFindersFee: Percent = Percent::from_percent(20); pub const TipReportDepositBase: Balance = 1 * DOLLARS; pub const DataDepositPerByte: Balance = 1 * CENTS; pub const BountyDepositBase: Balance = 1 * DOLLARS; - pub const BountyDepositPayoutDelay: BlockNumber = 8 * DAYS; + pub const BountyDepositPayoutDelay: BlockNumber = 5 * MINUTES; pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS; pub const MaximumReasonLength: u32 = 16384; @@ -1091,10 +1091,10 @@ parameter_types! { pub const CandidateDeposit: Balance = 10 * DOLLARS; pub const WrongSideDeduction: Balance = 2 * DOLLARS; pub const MaxStrikes: u32 = 10; - pub const RotationPeriod: BlockNumber = 80 * HOURS; + pub const RotationPeriod: BlockNumber = 5 * MINUTES; pub const PeriodSpend: Balance = 500 * DOLLARS; pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS; - pub const ChallengePeriod: BlockNumber = 7 * DAYS; + pub const ChallengePeriod: BlockNumber = 15 * MINUTES; pub const MaxCandidateIntake: u32 = 10; pub const SocietyPalletId: PalletId = PalletId(*b"py/socie"); } From 82725e5f40416ce21367f476ec8af37bc639dced Mon Sep 17 00:00:00 2001 From: Maksim Ramanenkau Date: Mon, 24 Oct 2022 12:55:09 +0300 Subject: [PATCH 2/4] Enable duild and push image action for small duration branches --- .github/workflows/build-and-push-docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-docker-image.yml b/.github/workflows/build-and-push-docker-image.yml index 145bf1ae59f70..64bd2d2a98a64 100644 --- a/.github/workflows/build-and-push-docker-image.yml +++ b/.github/workflows/build-and-push-docker-image.yml @@ -3,7 +3,7 @@ on: push: branches: - dev-cere - - feature/decrease-durations-for-simulations + - 'feature/**' env: ECR_REPOSITORY: pos-network-node jobs: From ac13414c9d048973b50f630fef1a25f99a20030f Mon Sep 17 00:00:00 2001 From: Maksim Ramanenkau Date: Tue, 1 Nov 2022 09:37:49 +0300 Subject: [PATCH 3/4] Update EPOCH_DURATION_IN_BLOCKS --- bin/node/runtime/src/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/src/constants.rs b/bin/node/runtime/src/constants.rs index 985fdfeacab1b..1e448c7b4c524 100644 --- a/bin/node/runtime/src/constants.rs +++ b/bin/node/runtime/src/constants.rs @@ -61,7 +61,7 @@ pub mod time { // 1 in 4 blocks (on average, not counting collisions) will be primary BABE blocks. pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); - pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 4 * HOURS; + pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 5 * MINUTES; pub const EPOCH_DURATION_IN_SLOTS: u64 = { const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64; From e9683539a2ef960c992bdf46334b5cde8c57ac1d Mon Sep 17 00:00:00 2001 From: Maksim Ramanenkau Date: Tue, 15 Nov 2022 10:47:44 +0300 Subject: [PATCH 4/4] Add storage migrations --- bin/node/runtime/src/lib.rs | 160 +++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index c962f7f1f0e53..bf763f6eee83c 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -27,7 +27,7 @@ use frame_support::{ construct_runtime, parameter_types, traits::{ Currency, Everything, Imbalance, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, - Nothing, OnUnbalanced, U128CurrencyToVote, + Nothing, OnUnbalanced, U128CurrencyToVote, OnRuntimeUpgrade, }, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, @@ -1283,9 +1283,165 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - (), + ( + CouncilStoragePrefixMigration, + BountiesPrefixMigration, + TechnicalCommitteeStoragePrefixMigration, + TechnicalMembershipStoragePrefixMigration, + MigrateTipsPalletPrefix + ), >; +const BOUNTIES_OLD_PREFIX: &str = "Treasury"; + +/// Migrate from 'Treasury' to the new prefix 'Bounties' +pub struct BountiesPrefixMigration; + +impl OnRuntimeUpgrade for BountiesPrefixMigration { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + use frame_support::traits::PalletInfo; + let name = ::PalletInfo::name::() + .expect("Bounties is part of runtime, so it has a name; qed"); + pallet_bounties::migrations::v4::migrate::(BOUNTIES_OLD_PREFIX, name) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + use frame_support::traits::PalletInfo; + let name = ::PalletInfo::name::() + .expect("Bounties is part of runtime, so it has a name; qed"); + pallet_bounties::migrations::v4::pre_migration::( + BOUNTIES_OLD_PREFIX, + name, + ); + Ok(()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + use frame_support::traits::PalletInfo; + let name = ::PalletInfo::name::() + .expect("Bounties is part of runtime, so it has a name; qed"); + pallet_bounties::migrations::v4::post_migration::( + BOUNTIES_OLD_PREFIX, + name, + ); + Ok(()) + } +} + +const COUNCIL_OLD_PREFIX: &str = "Instance1Collective"; +/// Migrate from `Instance1Collective` to the new pallet prefix `Council` +pub struct CouncilStoragePrefixMigration; + +impl OnRuntimeUpgrade for CouncilStoragePrefixMigration { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + pallet_collective::migrations::v4::migrate::(COUNCIL_OLD_PREFIX) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + pallet_collective::migrations::v4::pre_migrate::(COUNCIL_OLD_PREFIX); + Ok(()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + pallet_collective::migrations::v4::post_migrate::(COUNCIL_OLD_PREFIX); + Ok(()) + } +} + +const TECHNICAL_COMMITTEE_OLD_PREFIX: &str = "Instance2Collective"; +/// Migrate from `Instance2Collective` to the new pallet prefix `TechnicalCommittee` +pub struct TechnicalCommitteeStoragePrefixMigration; + +impl OnRuntimeUpgrade for TechnicalCommitteeStoragePrefixMigration { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + pallet_collective::migrations::v4::migrate::( + TECHNICAL_COMMITTEE_OLD_PREFIX, + ) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + pallet_collective::migrations::v4::pre_migrate::( + TECHNICAL_COMMITTEE_OLD_PREFIX, + ); + Ok(()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + pallet_collective::migrations::v4::post_migrate::( + TECHNICAL_COMMITTEE_OLD_PREFIX, + ); + Ok(()) + } +} + +const TECHNICAL_MEMBERSHIP_OLD_PREFIX: &str = "Instance1Membership"; +/// Migrate from `Instance1Membership` to the new pallet prefix `TechnicalMembership` +pub struct TechnicalMembershipStoragePrefixMigration; + +impl OnRuntimeUpgrade for TechnicalMembershipStoragePrefixMigration { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + use frame_support::traits::PalletInfo; + let name = ::PalletInfo::name::() + .expect("TechnialMembership is part of runtime, so it has a name; qed"); + pallet_membership::migrations::v4::migrate::( + TECHNICAL_MEMBERSHIP_OLD_PREFIX, + name, + ) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + use frame_support::traits::PalletInfo; + let name = ::PalletInfo::name::() + .expect("TechnicalMembership is part of runtime, so it has a name; qed"); + pallet_membership::migrations::v4::pre_migrate::( + TECHNICAL_MEMBERSHIP_OLD_PREFIX, + name, + ); + Ok(()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + use frame_support::traits::PalletInfo; + let name = ::PalletInfo::name::() + .expect("TechnicalMembership is part of runtime, so it has a name; qed"); + pallet_membership::migrations::v4::post_migrate::( + TECHNICAL_MEMBERSHIP_OLD_PREFIX, + name, + ); + Ok(()) + } +} + +const TIPS_OLD_PREFIX: &str = "Treasury"; +/// Migrate pallet-tips from `Treasury` to the new pallet prefix `Tips` +pub struct MigrateTipsPalletPrefix; + +impl OnRuntimeUpgrade for MigrateTipsPalletPrefix { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + pallet_tips::migrations::v4::migrate::(TIPS_OLD_PREFIX) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + pallet_tips::migrations::v4::pre_migrate::(TIPS_OLD_PREFIX); + Ok(()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + pallet_tips::migrations::v4::post_migrate::(TIPS_OLD_PREFIX); + Ok(()) + } +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion {