From 5eb0175087fb6c78b26313c6bcdd040f97df4834 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Tue, 6 Aug 2024 17:19:22 +0200 Subject: [PATCH 01/24] add async backing to zombienet config --- rococo-local/config-zombienet.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rococo-local/config-zombienet.json b/rococo-local/config-zombienet.json index bfe22ce08c..a8f2799be3 100644 --- a/rococo-local/config-zombienet.json +++ b/rococo-local/config-zombienet.json @@ -5,6 +5,23 @@ "relaychain": { "default_command": "../../polkadot/target/release/polkadot", "chain": "rococo-local", + "genesis": { + "runtimeGenesis": { + "patch": { + "configuration": { + "config": { + "scheduler_params": { + "scheduling_lookahead": 2 + }, + "async_backing_params": { + "max_candidate_depth": 3, + "allowed_ancestry_len": 2 + } + } + } + } + } + }, "nodes": [ { "name": "alice", From d5250a1885cb1031391b209de08e22bb286f726a Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 14 Aug 2024 17:27:35 +0200 Subject: [PATCH 02/24] Prepare runtime for async backing --- Cargo.lock | 1 + Cargo.toml | 5 ++++- primitives/src/constants.rs | 23 +++++------------------ runtime/basilisk/Cargo.toml | 2 ++ runtime/basilisk/src/lib.rs | 15 ++++++++++++--- runtime/basilisk/src/system.rs | 21 ++++++++++++++++++++- 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ce60e0edc..5d491c6ca3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -959,6 +959,7 @@ dependencies = [ "cumulus-pallet-parachain-system", "cumulus-pallet-xcm", "cumulus-pallet-xcmp-queue", + "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", "cumulus-primitives-timestamp", diff --git a/Cargo.toml b/Cargo.toml index b3ceefeab6..6b691ea325 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -219,9 +219,12 @@ cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", b cumulus-client-collator = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } -cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } +cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false, features = [ + "parameterized-consensus-hook", +] } cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } +cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } cumulus-primitives-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.7.2", default-features = false } diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 2334bb795e..1ac8da55d5 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -39,32 +39,19 @@ pub mod currency { pub mod time { use crate::{BlockNumber, Moment}; - /// Since BABE is probabilistic this is the average expected block time that - /// we are targeting. Blocks will be produced at a minimum duration defined - /// by `SLOT_DURATION`, but some slots will not be allocated to any - /// authority and hence no block will be produced. We expect to have this - /// block time on average following the defined slot duration and the value - /// of `c` configured for BABE (where `1 - c` represents the probability of - /// a slot being empty). - /// This value is only used indirectly to define the unit constants below - /// that are expressed in blocks. The rest of the code should use - /// `SLOT_DURATION` instead (like the Timestamp pallet for calculating the - /// minimum period). + /// BLOCKS will be produced at a minimum duration defined by `SLOT_DURATION`. + /// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked + /// up by `pallet_aura` to implement `fn slot_duration()`. /// - /// If using BABE with secondary slots (default) then all of the slots will - /// always be assigned, in which case `MILLISECS_PER_BLOCK` and - /// `SLOT_DURATION` should have the same value. - /// - /// - + /// Change this to adjust the block time. pub const MILLISECS_PER_BLOCK: u64 = 12000; + pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; // Time is measured by number of blocks. pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; - pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000; pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 4 * HOURS; } diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index e4c53792a9..59c00693a7 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -74,6 +74,7 @@ cumulus-pallet-aura-ext = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-xcm = { workspace = true } cumulus-pallet-xcmp-queue = { workspace = true } +cumulus-primitives-aura = { workspace = true } cumulus-primitives-core = { workspace = true } cumulus-primitives-utility = { workspace = true } cumulus-primitives-parachain-inherent = { workspace = true } @@ -198,6 +199,7 @@ std = [ "cumulus-pallet-aura-ext/std", "cumulus-pallet-xcm/std", "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-aura/std", "cumulus-primitives-core/std", "polkadot-xcm/std", "xcm-builder/std", diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 8614c7893a..c5e2bb4d09 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -48,7 +48,8 @@ pub use system::*; pub use xcm::*; pub use primitives::{ - AccountId, Amount, AssetId, Balance, BlockNumber, CollectionId, Hash, Index, ItemId, Price, Signature, + constants::time::SLOT_DURATION, AccountId, Amount, AssetId, Balance, BlockNumber, CollectionId, Hash, Index, + ItemId, Price, Signature, }; use frame_support::sp_runtime::{ @@ -363,7 +364,7 @@ impl_runtime_apis! { impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION) } fn authorities() -> Vec { @@ -425,6 +426,15 @@ impl_runtime_apis! { } } + impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime { + fn can_build_upon( + included_hash: ::Hash, + slot: cumulus_primitives_aura::Slot, + ) -> bool { + ConsensusHook::can_build_upon(included_hash, slot) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( @@ -619,5 +629,4 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { cumulus_pallet_parachain_system::register_validate_block! { Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, - CheckInherents = CheckInherents, } diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 00be8436db..2d736962a8 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -55,6 +55,15 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25); /// by Operational extrinsics. pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included into the +/// relay chain. +pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; +/// How many parachain blocks are processed by the relay chain per parent. Limits the number of +/// blocks authored per slot. +pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; +/// Relay chain slot duration, in milliseconds. +pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; + pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &RuntimeCall) -> bool { @@ -401,11 +410,19 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type ReservedDmpWeight = ReservedDmpWeight; type XcmpMessageHandler = XcmpQueue; type ReservedXcmpWeight = ReservedXcmpWeight; - type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; + type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; type DmpQueue = frame_support::traits::EnqueueWithOrigin; + type ConsensusHook = ConsensusHook; type WeightInfo = weights::cumulus_pallet_parachain_system::BasiliskWeight; } +pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< + Runtime, + RELAY_CHAIN_SLOT_DURATION_MILLIS, + BLOCK_PROCESSING_VELOCITY, + UNINCLUDED_SEGMENT_CAPACITY, +>; + parameter_types! { pub const MaxAuthorities: u32 = 50; } @@ -415,6 +432,8 @@ impl pallet_aura::Config for Runtime { type MaxAuthorities = MaxAuthorities; type DisabledValidators = (); type AllowMultipleBlocksPerSlot = ConstBool; + #[cfg(feature = "experimental")] + type SlotDuration = ConstU64; } impl pallet_utility::Config for Runtime { From a7f2f379ae728dfd001a24fdba79eefea9a5dc23 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 14 Aug 2024 17:40:09 +0200 Subject: [PATCH 03/24] Prepare node for async backing --- node/src/service.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/node/src/service.rs b/node/src/service.rs index b76df98783..263845d01e 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -37,7 +37,10 @@ use cumulus_client_service::{ build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams, }; -use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId}; +use cumulus_primitives_core::{ + relay_chain::{CollatorPair, ValidationCode}, + ParaId, +}; use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; // Substrate Imports @@ -259,7 +262,7 @@ async fn start_node_impl( task_manager: &mut task_manager, config: parachain_config, keystore: params.keystore_container.keystore(), - backend, + backend: backend.clone(), network: network.clone(), sync_service: sync_service.clone(), system_rpc_tx, @@ -324,6 +327,7 @@ async fn start_node_impl( if validator { start_consensus( client.clone(), + backend.clone(), block_import, prometheus_registry.as_ref(), telemetry.as_ref().map(|t| t.handle()), @@ -379,6 +383,7 @@ fn build_import_queue( fn start_consensus( client: Arc, + backend: Arc, block_import: ParachainBlockImport, prometheus_registry: Option<&Registry>, telemetry: Option, @@ -393,7 +398,7 @@ fn start_consensus( overseer_handle: OverseerHandle, announce_block: Arc>) + Send + Sync>, ) -> Result<(), sc_service::Error> { - use cumulus_client_consensus_aura::collators::basic::{self as basic_aura, Params as BasicAuraParams}; + use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; // NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant` // when starting the network. @@ -417,11 +422,13 @@ fn start_consensus( client.clone(), ); - let params = BasicAuraParams { + let params = AuraParams { create_inherent_data_providers: move |_, ()| async move { Ok(()) }, block_import, - para_client: client, + para_client: client.clone(), + para_backend: backend.clone(), relay_client: relay_chain_interface, + code_hash_provider: move |block_hash| client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash()), sync_oracle, keystore, collator_key, @@ -431,12 +438,11 @@ fn start_consensus( relay_chain_slot_duration, proposer, collator_service, - // Very limited proposal time. - authoring_duration: Duration::from_millis(500), - collation_request_receiver: None, + authoring_duration: Duration::from_millis(1500), + reinitialize: false, }; - let fut = basic_aura::run::(params); + let fut = aura::run::(params); task_manager.spawn_essential_handle().spawn("aura", None, fut); Ok(()) From c37a4d29626b12e24bb07e69de80f5c44148ed44 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 14 Aug 2024 17:44:44 +0200 Subject: [PATCH 04/24] Activate async backing --- primitives/src/constants.rs | 6 +++--- runtime/basilisk/src/system.rs | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index 1ac8da55d5..8008c638ee 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -44,7 +44,7 @@ pub mod time { /// up by `pallet_aura` to implement `fn slot_duration()`. /// /// Change this to adjust the block time. - pub const MILLISECS_PER_BLOCK: u64 = 12000; + pub const MILLISECS_PER_BLOCK: u64 = 6000; pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; // Time is measured by number of blocks. @@ -75,9 +75,9 @@ pub mod chain { /// Minimum pool liquidity pub const MIN_POOL_LIQUIDITY: Balance = 1000; - /// We allow for + /// We allow for 2 seconds of compute with a 6 second average block. pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( - WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), polkadot_primitives::v6::MAX_POV_SIZE as u64, ); diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 2d736962a8..54de8fe9c3 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -47,6 +47,7 @@ use hydradx_adapters::RelayChainBlockNumberProvider; use hydradx_traits::evm::InspectEvmAccounts; use primitives::constants::time::DAYS; use scale_info::TypeInfo; +use sp_core::ConstU64; /// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic /// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`. @@ -57,7 +58,7 @@ pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included into the /// relay chain. -pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; +pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3; /// How many parachain blocks are processed by the relay chain per parent. Limits the number of /// blocks authored per slot. pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; @@ -173,7 +174,6 @@ impl frame_system::Config for Runtime { } parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; pub const NativeAssetId : AssetId = CORE_ASSET_ID; } @@ -181,7 +181,10 @@ impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + #[cfg(feature = "experimental")] + type MinimumPeriod = ConstU64<0>; + #[cfg(not(feature = "experimental"))] + type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; type WeightInfo = weights::pallet_timestamp::BasiliskWeight; } @@ -431,7 +434,7 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type MaxAuthorities = MaxAuthorities; type DisabledValidators = (); - type AllowMultipleBlocksPerSlot = ConstBool; + type AllowMultipleBlocksPerSlot = ConstBool; #[cfg(feature = "experimental")] type SlotDuration = ConstU64; } From 8c8793a70c251001977210f68c8dd1845b95bc2e Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Thu, 15 Aug 2024 10:51:02 +0200 Subject: [PATCH 05/24] zobienet config --- rococo-local/config-zombienet.json | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/rococo-local/config-zombienet.json b/rococo-local/config-zombienet.json index a8f2799be3..6f987dc985 100644 --- a/rococo-local/config-zombienet.json +++ b/rococo-local/config-zombienet.json @@ -5,14 +5,17 @@ "relaychain": { "default_command": "../../polkadot/target/release/polkadot", "chain": "rococo-local", + "default_args": [ + "--no-hardware-benchmarks", + "-lparachain=debug", + "--database=paritydb" + ], "genesis": { "runtimeGenesis": { "patch": { "configuration": { "config": { - "scheduler_params": { - "scheduling_lookahead": 2 - }, + "scheduling_lookahead": 2, "async_backing_params": { "max_candidate_depth": 3, "allowed_ancestry_len": 2 @@ -57,12 +60,24 @@ "name": "alice", "command": "../target/release/basilisk", "ws_port": 9988, - "rpc_port": 9999 + "rpc_port": 9999, + "args": [ + "--no-hardware-benchmarks", + "--force-authoring", + "-lparachain=debug", + "--database=paritydb" + ] }, { "name": "bob", "command": "../target/release/basilisk", - "ws_port": 9989 + "ws_port": 9989, + "args": [ + "--no-hardware-benchmarks", + "--force-authoring", + "-lparachain=debug", + "--database=paritydb" + ] } ] } From 5cdd524ef07ff33bc2d60f69ab5bfbde61fe9333 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Thu, 15 Aug 2024 11:03:14 +0200 Subject: [PATCH 06/24] fix zombienet config --- rococo-local/config-zombienet.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rococo-local/config-zombienet.json b/rococo-local/config-zombienet.json index 6f987dc985..d41bad5a03 100644 --- a/rococo-local/config-zombienet.json +++ b/rococo-local/config-zombienet.json @@ -48,7 +48,6 @@ } ] }, - "types": {}, "hrmp_channels": [], "parachains": [ { @@ -81,5 +80,12 @@ } ] } - ] + ], + "types": { + "Header": { + "number": "u64", + "parent_hash": "Hash", + "post_state": "Hash" + } + } } From e8be7af38386e54f78ad6cabd856810cf8136d33 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 4 Sep 2024 21:54:18 +0200 Subject: [PATCH 07/24] merge conflicts --- launch-configs/zombienet/local.json | 15 +++++++++++++++ runtime/basilisk/src/lib.rs | 3 --- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/launch-configs/zombienet/local.json b/launch-configs/zombienet/local.json index 3df2b8cb2a..5be03ae0c9 100644 --- a/launch-configs/zombienet/local.json +++ b/launch-configs/zombienet/local.json @@ -10,6 +10,21 @@ "--no-hardware-benchmarks", "--database=paritydb" ], + "genesis": { + "runtimeGenesis": { + "patch": { + "configuration": { + "config": { + "scheduling_lookahead": 2, + "async_backing_params": { + "max_candidate_depth": 3, + "allowed_ancestry_len": 2 + } + } + } + } + } + }, "nodes": [ { "name": "alice", diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index d0b48723ec..b939d194c0 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -59,9 +59,6 @@ use frame_support::sp_runtime::{ ApplyExtrinsicResult, }; use frame_system::pallet_prelude::BlockNumberFor; -pub use primitives::{ - AccountId, Amount, AssetId, Balance, BlockNumber, CollectionId, Hash, Index, ItemId, Price, Signature, -}; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{ConstU32, OpaqueMetadata}; From 3d0017def702717d804e212d2657be4edbc27f01 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 2 Oct 2024 13:21:00 +0200 Subject: [PATCH 08/24] merge conflict --- runtime/basilisk/src/apis.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/runtime/basilisk/src/apis.rs b/runtime/basilisk/src/apis.rs index 4891c13e6f..31280fbd41 100644 --- a/runtime/basilisk/src/apis.rs +++ b/runtime/basilisk/src/apis.rs @@ -247,6 +247,15 @@ impl_runtime_apis! { } } + impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime { + fn can_build_upon( + included_hash: ::Hash, + slot: cumulus_primitives_aura::Slot, + ) -> bool { + ConsensusHook::can_build_upon(included_hash, slot) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( From d3db553a995ceadc9f1660ede173122cc9fa1ab5 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 2 Oct 2024 13:23:14 +0200 Subject: [PATCH 09/24] merge conflict --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5fe04d3e62..ea11e0d88d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -240,7 +240,7 @@ cumulus-pallet-parachain-system = { git = "https://github.com/galacticcouncil/po ] } cumulus-pallet-xcm = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch ="release-polkadot-v1.11.0-patch", default-features = false } cumulus-pallet-xcmp-queue = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch ="release-polkadot-v1.11.0-patch", default-features = false } -cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch ="release-polkadot-v1.11.0-patch", default-features = false } +cumulus-primitives-aura = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch ="release-polkadot-v1.11.0-patch", default-features = false } cumulus-primitives-core = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch ="release-polkadot-v1.11.0-patch", default-features = false } cumulus-primitives-parachain-inherent = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch ="release-polkadot-v1.11.0-patch", default-features = false } cumulus-primitives-timestamp = { git = "https://github.com/galacticcouncil/polkadot-sdk", branch ="release-polkadot-v1.11.0-patch", default-features = false } From 67f2441f089838e97dade48547e554c734b9acfd Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 2 Oct 2024 15:10:22 +0200 Subject: [PATCH 10/24] Remove experimental feature flag --- runtime/basilisk/src/lib.rs | 25 +------------------------ runtime/basilisk/src/system.rs | 4 ---- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 0bac65128a..d13e7e7ae9 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -59,9 +59,8 @@ pub use primitives::{ constants::time::SLOT_DURATION, AccountId, Amount, AssetId, Balance, BlockNumber, CollectionId, Hash, Index, ItemId, Price, Signature, }; -use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_core::{ConstU32, ConstU64}; +use sp_core::ConstU32; use sp_std::{convert::From, marker::PhantomData, prelude::*, vec}; #[cfg(feature = "std")] use sp_version::NativeVersion; @@ -362,28 +361,6 @@ mod benches { ); } -struct CheckInherents; - -impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { - fn check_inherents( - block: &Block, - relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, - ) -> sp_inherents::CheckInherentsResult { - let relay_chain_slot = relay_state_proof - .read_slot() - .expect("Could not read the relay chain slot from the proof"); - - let inherent_data = cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); - - inherent_data.check_extrinsics(block) - } -} - cumulus_pallet_parachain_system::register_validate_block! { Runtime = Runtime, BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 1dfb8a13db..4fd6f9b064 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -194,9 +194,6 @@ impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = (); - #[cfg(feature = "experimental")] - type MinimumPeriod = ConstU64<0>; - #[cfg(not(feature = "experimental"))] type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; type WeightInfo = weights::pallet_timestamp::BasiliskWeight; } @@ -448,7 +445,6 @@ impl pallet_aura::Config for Runtime { type MaxAuthorities = MaxAuthorities; type DisabledValidators = (); type AllowMultipleBlocksPerSlot = ConstBool; - #[cfg(feature = "experimental")] type SlotDuration = ConstU64; } From f3cd1369e5fb8c5438af893e7fa5f7083b1ebc26 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 2 Oct 2024 15:15:21 +0200 Subject: [PATCH 11/24] versions and fmt --- Cargo.lock | 18 +++++++++--------- node/Cargo.toml | 2 +- primitives/Cargo.toml | 2 +- runtime/basilisk/Cargo.toml | 2 +- runtime/basilisk/src/lib.rs | 3 +-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 676be3b15e..17441d9e33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -891,7 +891,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basilisk" -version = "16.0.0" +version = "17.0.0" dependencies = [ "basilisk-runtime", "clap", @@ -923,7 +923,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-service", - "primitives 6.6.3", + "primitives 6.6.4", "sc-basic-authorship", "sc-block-builder", "sc-chain-spec", @@ -973,7 +973,7 @@ dependencies = [ [[package]] name = "basilisk-runtime" -version = "121.0.0" +version = "122.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", @@ -1051,7 +1051,7 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-runtime-common", "primitive-types", - "primitives 6.6.3", + "primitives 6.6.4", "scale-info", "serde", "smallvec", @@ -7673,7 +7673,7 @@ dependencies = [ "pallet-uniques", "parity-scale-codec", "pretty_assertions", - "primitives 6.6.3", + "primitives 6.6.4", "scale-info", "serde", "sp-arithmetic", @@ -8580,7 +8580,7 @@ dependencies = [ "pallet-xyk", "parity-scale-codec", "pretty_assertions", - "primitives 6.6.3", + "primitives 6.6.4", "scale-info", "sp-arithmetic", "sp-core", @@ -8608,7 +8608,7 @@ dependencies = [ "pallet-xyk", "pallet-xyk-liquidity-mining", "parity-scale-codec", - "primitives 6.6.3", + "primitives 6.6.4", "scale-info", "sp-arithmetic", "sp-core", @@ -10298,7 +10298,7 @@ dependencies = [ [[package]] name = "primitives" -version = "6.6.3" +version = "6.6.4" dependencies = [ "frame-support", "parity-scale-codec", @@ -11238,7 +11238,7 @@ dependencies = [ "polkadot-runtime-parachains", "polkadot-service", "pretty_assertions", - "primitives 6.6.3", + "primitives 6.6.4", "rococo-runtime", "sc-consensus-grandpa", "sp-api", diff --git a/node/Cargo.toml b/node/Cargo.toml index 87055455c7..365f6bde67 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "basilisk" -version = "16.0.0" +version = "17.0.0" description = "Basilisk node" authors = ["GalacticCouncil"] edition = "2021" diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index cc1c9e6e1c..c754a26e74 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "primitives" -version = "6.6.3" +version = "6.6.4" authors = ["GalacticCouncil"] edition = "2021" repository = "https://github.com/galacticcouncil/Basilisk-node" diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index 98d46ad0bb..aa3b2d79ab 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "basilisk-runtime" -version = "121.0.0" +version = "122.0.0" authors = ["GalacticCouncil"] edition = "2021" homepage = "https://github.com/galacticcouncil/Basilisk-node" diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index d13e7e7ae9..c7e2413505 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -48,7 +48,6 @@ pub use governance::*; pub use system::*; pub use xcm::*; - use frame_support::parameter_types; use frame_support::sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, @@ -102,7 +101,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("basilisk"), impl_name: create_runtime_str!("basilisk"), authoring_version: 1, - spec_version: 121, + spec_version: 122, impl_version: 0, apis: apis::RUNTIME_API_VERSIONS, transaction_version: 1, From f59f8616948986258835613a96e375cda7e80447 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 2 Oct 2024 15:39:08 +0200 Subject: [PATCH 12/24] fix tests for time units --- primitives/src/constants.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/primitives/src/constants.rs b/primitives/src/constants.rs index c9e5b3e38d..fbc6ff3a97 100644 --- a/primitives/src/constants.rs +++ b/primitives/src/constants.rs @@ -96,10 +96,10 @@ mod tests { assert_eq!(DAYS / 24, HOURS); // 60 minuts in an hour assert_eq!(HOURS / 60, MINUTES); - // 1 minute = 60s = 5 blocks 12s each - assert_eq!(MINUTES, 5); + // 1 minute = 60s = 10 blocks 6s each + assert_eq!(MINUTES, 10); // 6s per block - assert_eq!(SECS_PER_BLOCK, 12); + assert_eq!(SECS_PER_BLOCK, 6); // 1s = 1000ms assert_eq!(MILLISECS_PER_BLOCK / 1000, SECS_PER_BLOCK); // Extra check for epoch time because changing it bricks the block production and requires regenesis From 463f392672a1f83b4d0ae9bc18251a04061f76c4 Mon Sep 17 00:00:00 2001 From: Valery Gantchev Date: Wed, 2 Oct 2024 15:47:43 +0200 Subject: [PATCH 13/24] collator rewards --- runtime/basilisk/src/system.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/basilisk/src/system.rs b/runtime/basilisk/src/system.rs index 4fd6f9b064..e62c09abb5 100644 --- a/runtime/basilisk/src/system.rs +++ b/runtime/basilisk/src/system.rs @@ -524,7 +524,7 @@ impl pallet_transaction_pause::Config for Runtime { } parameter_types! { - pub const RewardPerCollator: Balance = 15_216_000_000_000_000; // 12.68[BSX/block] * 1200[block] + pub const RewardPerCollator: Balance = 15_240_000_000_000_000; // 6.35[BSX/block] * 2400[block] //GalacticCouncil collators pub ExcludedCollators: Vec = vec![ // bXn5CfJB2qHvqnuMqTpXn6un9Fjch8mwkb9i3JUsGVD4ChLoe From 938605e1b8b23891ca20ac017aa44500d5ddd323 Mon Sep 17 00:00:00 2001 From: cl0w <> Date: Fri, 4 Oct 2024 16:19:05 +0200 Subject: [PATCH 14/24] fixing integration tests --- Cargo.lock | 1 + integration-tests/Cargo.toml | 1 + integration-tests/src/kusama_test_net.rs | 164 +++++++++++++++++++++-- integration-tests/src/router.rs | 2 +- 4 files changed, 153 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17441d9e33..27751dbf86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11248,6 +11248,7 @@ dependencies = [ "sp-consensus-aura", "sp-consensus-babe", "sp-consensus-beefy", + "sp-consensus-slots", "sp-core", "sp-externalities", "sp-inherents", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index cf5a340c85..ee2919c536 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -85,6 +85,7 @@ sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-consensus-babe = { workspace = true } sp-consensus-beefy = { workspace = true } +sp-consensus-slots = { workspace = true } sp-authority-discovery = { workspace = true } sp-core = { workspace = true } sp-inherents = { workspace = true } diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index 4a9b2f46f4..22611404a9 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -41,8 +41,12 @@ pub fn parachain_reserve_account() -> AccountId { polkadot_parachain::primitives::Sibling::from(OTHER_PARA_ID).into_account_truncating() } -pub use basilisk_runtime::{AccountId, VestingPalletId}; +pub use basilisk_runtime::{AccountId, VestingPalletId, ParachainSystem}; +use cumulus_pallet_parachain_system::RelaychainDataProvider; +use sp_runtime::traits::BlockNumberProvider; use cumulus_primitives_core::ParaId; +use sp_consensus_aura::AURA_ENGINE_ID; +use sp_consensus_slots::{Slot, SlotDuration}; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use frame_support::assert_ok; use frame_support::traits::OnInitialize; @@ -51,13 +55,13 @@ pub use pallet_xyk::types::AssetPair; use polkadot_primitives::v7::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_runtime_parachains::configuration::HostConfiguration; use pretty_assertions::assert_eq; -use primitives::{AssetId, Balance}; -use sp_core::storage::Storage; -use sp_runtime::{traits::AccountIdConversion, BuildStorage}; +use primitives::{AssetId, Balance, constants::time::SLOT_DURATION}; +use sp_core::{Encode, storage::Storage}; +use sp_runtime::{traits::AccountIdConversion, BuildStorage, Digest, DigestItem}; use primitives::constants::chain::CORE_ASSET_ID; pub use xcm_emulator::Network; -use xcm_emulator::{decl_test_networks, decl_test_parachains, decl_test_relay_chains}; +use xcm_emulator::{decl_test_networks, decl_test_parachains, decl_test_relay_chains, TestExt}; pub type Rococo = RococoRelayChain; pub type Basilisk = BasiliskParachain; @@ -78,7 +82,10 @@ decl_test_relay_chains! { #[api_version(11)] pub struct RococoRelayChain { genesis = rococo::genesis(), - on_init = (), + on_init = { + rococo_runtime::System::on_initialize(1); + rococo_runtime::System::set_block_number(1); + }, runtime = rococo_runtime, core = { SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, @@ -95,9 +102,26 @@ decl_test_parachains! { pub struct BasiliskParachain { genesis = basilisk::genesis(), on_init = { - basilisk_runtime::System::set_block_number(1); + // let slot = Slot::from_timestamp( + // (pallet_timestamp::Now::::get()).into(), + // SlotDuration::from_millis(SLOT_DURATION), + // ); + // basilisk_runtime::System::initialize( + // &1, + // &Default::default(), + // &Digest { + // logs: vec![DigestItem::PreRuntime( + // AURA_ENGINE_ID, + // slot.encode(), + // )], + // }, + // ); // Make sure the prices are up-to-date. + basilisk_runtime::System::set_block_number(1); basilisk_runtime::MultiTransactionPayment::on_initialize(1); + basilisk_runtime::System::on_initialize(1); + set_slot_info(0); + // set_validation_data(); }, runtime = basilisk_runtime, core = { @@ -114,9 +138,26 @@ decl_test_parachains! { pub struct OtherPara { genesis = other_parachain::genesis(), on_init = { + // let slot = Slot::from_timestamp( + // (pallet_timestamp::Now::::get()).into(), + // SlotDuration::from_millis(SLOT_DURATION), + // ); + // basilisk_runtime::System::initialize( + // &1, + // &Default::default(), + // &Digest { + // logs: vec![DigestItem::PreRuntime( + // AURA_ENGINE_ID, + // slot.encode(), + // )], + // }, + // ); + basilisk_runtime::System::on_initialize(1); basilisk_runtime::System::set_block_number(1); // Make sure the prices are up-to-date. basilisk_runtime::MultiTransactionPayment::on_initialize(1); + set_slot_info(0); + // set_validation_data(); }, runtime = basilisk_runtime, core = { @@ -526,22 +567,86 @@ pub fn basilisk_run_to_next_block() { basilisk_runtime::System::set_block_number(b + 1); } -pub fn set_relaychain_block_number(number: BlockNumber) { - use basilisk_runtime::ParachainSystem; - use basilisk_runtime::RuntimeOrigin; +pub fn set_slot_info(number: u64) { + sp_io::storage::clear(&frame_support::storage::storage_prefix( + b"ParachainSystem", + b"UnincludedSegment", + )); + frame_support::storage::unhashed::put( + &frame_support::storage::storage_prefix(b"AuraExt", b"SlotInfo"), + &((Slot::from(number), 0)) + ); +} + +fn set_timestamp() { + assert_ok!(rococo_runtime::Timestamp::set( + rococo_runtime::RuntimeOrigin::none(), + pallet_timestamp::Now::::get() + primitives::constants::time::SLOT_DURATION + )); +} - rococo_run_to_block(number); //We need to set block number this way as well because tarpaulin code coverage tool does not like the way how we set the block number with `cumulus-test-relay-sproof-builder` package +fn set_timestamp2(number: u64) { + assert_ok!(rococo_runtime::Timestamp::set( + rococo_runtime::RuntimeOrigin::none(), + pallet_timestamp::Now::::get() + (primitives::constants::time::SLOT_DURATION * number) + )); +} - ParachainSystem::on_initialize(number); +pub fn go_to_relaychain_block(number: BlockNumber) { + use frame_support::traits::OnFinalize; - let (relay_storage_root, proof) = RelayStateSproofBuilder::default().into_state_root_and_proof(); + while rococo_runtime::System::block_number() < number { + let current_block = rococo_runtime::System::block_number(); + let next_block = current_block + 1; + rococo_runtime::System::on_finalize(current_block); + + let slot = Slot::from_timestamp( + (pallet_timestamp::Now::::get() + SLOT_DURATION).into(), + SlotDuration::from_millis(SLOT_DURATION), + ); + rococo_runtime::System::on_initialize(next_block); + rococo_runtime::System::initialize( + &(next_block), + &Default::default(), + &Digest { + logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, slot.encode())], + }, + ); + + rococo_runtime::System::set_block_number(next_block); + + basilisk_run_to_next_block(); + + // ParachainSystem::on_initialize(next_block); + // set_slot_info((next_block).into()); + set_timestamp(); + set_validation_data(next_block); + } +} + +fn set_validation_data(next_block: u32) { + use basilisk_runtime::RuntimeOrigin; + use polkadot_primitives::HeadData; + + let parent_head = HeadData(b"deadbeef".into()); + let sproof_builder = RelayStateSproofBuilder { + para_id: BASILISK_PARA_ID.into(), + included_para_head: Some(parent_head.clone()), + current_slot: Slot::from_timestamp( + pallet_timestamp::Now::::get().into(), + SlotDuration::from_millis(6_000), + ), + ..Default::default() + }; + + let (relay_storage_root, proof) = sproof_builder.into_state_root_and_proof(); assert_ok!(ParachainSystem::set_validation_data( RuntimeOrigin::none(), cumulus_primitives_parachain_inherent::ParachainInherentData { validation_data: cumulus_primitives_core::PersistedValidationData { parent_head: Default::default(), - relay_parent_number: number, + relay_parent_number: next_block, relay_parent_storage_root: relay_storage_root, max_pov_size: Default::default(), }, @@ -550,8 +655,38 @@ pub fn set_relaychain_block_number(number: BlockNumber) { horizontal_messages: Default::default(), } )); + } +// pub fn set_relaychain_block_number(number: BlockNumber) { +// use basilisk_runtime::ParachainSystem; +// use basilisk_runtime::RuntimeOrigin; + +// rococo_run_to_block(number); //We need to set block number this way as well because tarpaulin code coverage tool does not like the way how we set the block number with `cumulus-test-relay-sproof-builder` package +// set_slot_info(number.into()); + +// ParachainSystem::on_initialize(number); + +// set_timestamp2((number-2).into()); + +// let (relay_storage_root, proof) = RelayStateSproofBuilder::default().into_state_root_and_proof(); +// assert_ok!(ParachainSystem::set_validation_data( +// RuntimeOrigin::none(), +// cumulus_primitives_parachain_inherent::ParachainInherentData { +// validation_data: cumulus_primitives_core::PersistedValidationData { +// parent_head: Default::default(), +// relay_parent_number: number, +// relay_parent_storage_root: relay_storage_root, +// max_pov_size: Default::default(), +// }, +// relay_chain_state: proof, +// downward_messages: Default::default(), +// horizontal_messages: Default::default(), +// } +// )); +// // set_slot_info(number.into()); +// } + pub fn rococo_run_to_block(to: BlockNumber) { use frame_support::traits::OnFinalize; @@ -560,6 +695,7 @@ pub fn rococo_run_to_block(to: BlockNumber) { rococo_runtime::System::on_finalize(b); rococo_runtime::System::on_initialize(b + 1); rococo_runtime::System::set_block_number(b + 1); + // set_slot_info((b + 1).into()); } } diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index 9eaafaccdd..e7733a5557 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -1399,7 +1399,7 @@ fn get_lbp_pair_account_id(asset_a: AssetId, asset_b: AssetId) -> AccountId { } fn start_lbp_campaign() { - set_relaychain_block_number(SALE_START.unwrap() + 1); + go_to_relaychain_block(SALE_START.unwrap() + 1); } #[macro_export] From 91d902cbab53e6762eff2233982d14375b530869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20P=C3=A1nik?= Date: Wed, 23 Oct 2024 02:55:52 +0200 Subject: [PATCH 15/24] working tests --- integration-tests/src/exchange_asset.rs | 2 +- integration-tests/src/kusama_test_net.rs | 501 ++++++++++++++++------- integration-tests/src/non_native_fee.rs | 3 +- integration-tests/src/oracle.rs | 5 +- integration-tests/src/router.rs | 2 +- rust-toolchain | 2 +- 6 files changed, 353 insertions(+), 162 deletions(-) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 366f99c590..29d2d2ce1c 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -193,7 +193,7 @@ fn basilisk_should_swap_assets_coming_from_karura_when_onchain_route_present() { ] )); - basilisk_run_to_next_block(); + go_to_next_block(true, false); //Register onchain route from KAR to KSM assert_ok!(basilisk_runtime::Router::set_route( diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index 22611404a9..5e5ad0692d 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -41,12 +41,8 @@ pub fn parachain_reserve_account() -> AccountId { polkadot_parachain::primitives::Sibling::from(OTHER_PARA_ID).into_account_truncating() } -pub use basilisk_runtime::{AccountId, VestingPalletId, ParachainSystem}; -use cumulus_pallet_parachain_system::RelaychainDataProvider; -use sp_runtime::traits::BlockNumberProvider; +pub use basilisk_runtime::{AccountId, VestingPalletId}; use cumulus_primitives_core::ParaId; -use sp_consensus_aura::AURA_ENGINE_ID; -use sp_consensus_slots::{Slot, SlotDuration}; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use frame_support::assert_ok; use frame_support::traits::OnInitialize; @@ -55,13 +51,17 @@ pub use pallet_xyk::types::AssetPair; use polkadot_primitives::v7::{BlockNumber, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_runtime_parachains::configuration::HostConfiguration; use pretty_assertions::assert_eq; -use primitives::{AssetId, Balance, constants::time::SLOT_DURATION}; -use sp_core::{Encode, storage::Storage}; +use primitives::{constants::time::SLOT_DURATION, AssetId, Balance}; +use sp_consensus_aura::AURA_ENGINE_ID; +use sp_consensus_babe::digests::SecondaryPlainPreDigest; +use sp_consensus_babe::BABE_ENGINE_ID; +use sp_consensus_slots::{Slot, SlotDuration}; +use sp_core::{storage::Storage, Encode}; use sp_runtime::{traits::AccountIdConversion, BuildStorage, Digest, DigestItem}; use primitives::constants::chain::CORE_ASSET_ID; pub use xcm_emulator::Network; -use xcm_emulator::{decl_test_networks, decl_test_parachains, decl_test_relay_chains, TestExt}; +use xcm_emulator::{decl_test_networks, decl_test_parachains, decl_test_relay_chains, Parachain, TestExt}; pub type Rococo = RococoRelayChain; pub type Basilisk = BasiliskParachain; @@ -82,10 +82,7 @@ decl_test_relay_chains! { #[api_version(11)] pub struct RococoRelayChain { genesis = rococo::genesis(), - on_init = { - rococo_runtime::System::on_initialize(1); - rococo_runtime::System::set_block_number(1); - }, + on_init = (), runtime = rococo_runtime, core = { SovereignAccountOf: rococo_runtime::xcm_config::LocationConverter, @@ -102,26 +99,7 @@ decl_test_parachains! { pub struct BasiliskParachain { genesis = basilisk::genesis(), on_init = { - // let slot = Slot::from_timestamp( - // (pallet_timestamp::Now::::get()).into(), - // SlotDuration::from_millis(SLOT_DURATION), - // ); - // basilisk_runtime::System::initialize( - // &1, - // &Default::default(), - // &Digest { - // logs: vec![DigestItem::PreRuntime( - // AURA_ENGINE_ID, - // slot.encode(), - // )], - // }, - // ); - // Make sure the prices are up-to-date. - basilisk_runtime::System::set_block_number(1); - basilisk_runtime::MultiTransactionPayment::on_initialize(1); - basilisk_runtime::System::on_initialize(1); - set_slot_info(0); - // set_validation_data(); + set_para_slot_info(0); }, runtime = basilisk_runtime, core = { @@ -138,26 +116,7 @@ decl_test_parachains! { pub struct OtherPara { genesis = other_parachain::genesis(), on_init = { - // let slot = Slot::from_timestamp( - // (pallet_timestamp::Now::::get()).into(), - // SlotDuration::from_millis(SLOT_DURATION), - // ); - // basilisk_runtime::System::initialize( - // &1, - // &Default::default(), - // &Digest { - // logs: vec![DigestItem::PreRuntime( - // AURA_ENGINE_ID, - // slot.encode(), - // )], - // }, - // ); - basilisk_runtime::System::on_initialize(1); - basilisk_runtime::System::set_block_number(1); - // Make sure the prices are up-to-date. - basilisk_runtime::MultiTransactionPayment::on_initialize(1); - set_slot_info(0); - // set_validation_data(); + set_para_slot_info(0); }, runtime = basilisk_runtime, core = { @@ -551,101 +510,360 @@ pub fn vesting_account() -> AccountId { VestingPalletId::get().into_account_truncating() } -pub fn basilisk_run_to_next_block() { - use frame_support::traits::OnFinalize; +pub fn go_to_block(target_block: BlockNumber) { + println!("Going to block {}", target_block); + while rococo_runtime::System::block_number() < target_block { + let stop = rococo_runtime::System::block_number() == target_block - 1; + go_to_next_block(true, !stop); + } +} - let b = basilisk_runtime::System::block_number(); +pub fn initialize_rococo_block(target_block: BlockNumber, target_slot: Slot) { + use sp_consensus_babe::digests::PreDigest; + + let authority_index: u32 = 0; + + rococo_runtime::System::set_block_number(target_block); + println!("Set Rococo block number to {}", target_block); + + println!("Current BABE slot {:?}", rococo_runtime::Babe::current_slot()); + println!("Babe initialized {:?}", rococo_runtime::Babe::initialized()); + + rococo_runtime::System::initialize( + &target_block, + &Default::default(), + &Digest { + logs: vec![DigestItem::PreRuntime( + BABE_ENGINE_ID, + PreDigest::SecondaryPlain( + (SecondaryPlainPreDigest { + authority_index, + slot: target_slot, + }), + ) + .encode(), + )], + }, + ); + rococo_runtime::System::on_initialize(target_block); + println!("initialized System for Rococo"); - basilisk_runtime::System::on_finalize(b); - basilisk_runtime::EmaOracle::on_finalize(b); - basilisk_runtime::MultiTransactionPayment::on_finalize(b); + rococo_runtime::Scheduler::on_initialize(target_block); + println!("initialized Scheduler for Rococo"); - basilisk_runtime::System::on_initialize(b + 1); - basilisk_runtime::EmaOracle::on_initialize(b + 1); - basilisk_runtime::MultiTransactionPayment::on_initialize(b + 1); + rococo_runtime::Preimage::on_initialize(target_block); + println!("initialized Preimage for Rococo"); - basilisk_runtime::System::set_block_number(b + 1); -} + rococo_runtime::Babe::on_initialize(target_block); + println!("initialized Babe for Rococo"); + + rococo_runtime::Timestamp::on_initialize(target_block); + println!("initialized and set Timestamp for Rococo"); + + rococo_runtime::Session::on_initialize(target_block); + println!("initialized Session for Rococo"); + + rococo_runtime::Grandpa::on_initialize(target_block); + println!("initialized Grandpa for Rococo"); + + rococo_runtime::ParachainsOrigin::on_initialize(target_block); + println!("initialized ParachainsOrigin for Rococo"); + + rococo_runtime::ParasShared::on_initialize(target_block); + println!("initialized ParasShared for Rococo"); + + rococo_runtime::ParaInclusion::on_initialize(target_block); + println!("initialized ParaInclusion for Rococo"); + + // rococo_runtime::ParaInherent::on_initialize(target_block); + // println!("initialized ParaInherent for Rococo"); + + rococo_runtime::ParaScheduler::on_initialize(target_block); + println!("initialized ParaScheduler for Rococo"); + + rococo_runtime::Paras::on_initialize(target_block); + println!("initialized Paras for Rococo"); + + rococo_runtime::Initializer::on_initialize(target_block); + println!("initialized Initializer for Rococo"); + + rococo_runtime::Dmp::on_initialize(target_block); + println!("initialized DmpQueue for Rococo"); + + rococo_runtime::Hrmp::on_initialize(target_block); + println!("initialized Hrmp for Rococo"); + + rococo_runtime::ParaSessionInfo::on_initialize(target_block); + println!("initialized ParaSessionInfo for Rococo"); + + rococo_runtime::Slots::on_initialize(target_block); + println!("initialized Slots for Rococo"); + + rococo_runtime::XcmPallet::on_initialize(target_block); + println!("initialized Xcm for Rococo"); + + rococo_runtime::MessageQueue::on_initialize(target_block); + println!("initialized MessageQueue for Rococo"); -pub fn set_slot_info(number: u64) { - sp_io::storage::clear(&frame_support::storage::storage_prefix( - b"ParachainSystem", - b"UnincludedSegment", + rococo_runtime::Beefy::on_initialize(target_block); + println!("initialized Beefy for Rococo"); + + assert_ok!(rococo_runtime::Timestamp::set( + rococo_runtime::RuntimeOrigin::none(), + SLOT_DURATION * *target_slot )); - frame_support::storage::unhashed::put( - &frame_support::storage::storage_prefix(b"AuraExt", b"SlotInfo"), - &((Slot::from(number), 0)) - ); + // rococo_runtime::AllPalletsWithSystem::on_initialize(target_block); + // println!("initialized all pallets for Rococo"); } -fn set_timestamp() { - assert_ok!(rococo_runtime::Timestamp::set( - rococo_runtime::RuntimeOrigin::none(), - pallet_timestamp::Now::::get() + primitives::constants::time::SLOT_DURATION - )); +pub fn initialize_basilisk_block(target_block: BlockNumber, target_slot: Slot) { + // Force a new Basilisk block to be created + println!( + "Initializing. Current block number: {:?}", + basilisk_runtime::System::block_number() + ); + + basilisk_runtime::System::set_block_number(target_block); + println!("Set Basilisk block number to {}", target_block); + + basilisk_runtime::System::initialize( + &target_block, + &Default::default(), + &Digest { + logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, target_slot.encode())], + }, + ); + + basilisk_runtime::System::on_initialize(target_block); + println!("Initialized System for Basilisk"); + + // basilisk_runtime::Timestamp::on_initialize(target_block); + // println!("Initialized Timestamp for Basilisk"); + + basilisk_runtime::Session::on_initialize(target_block); + println!("Initialized Session for Basilisk"); + + basilisk_runtime::Aura::on_initialize(target_block); + println!("Initialized Aura for Basilisk"); + + basilisk_runtime::AuraExt::on_initialize(target_block); + println!("Initialized AuraExt for Basilisk"); + + basilisk_runtime::RelayChainInfo::on_initialize(target_block); + println!("Initialized RelayChainInfo for Basilisk"); + + basilisk_runtime::Scheduler::on_initialize(target_block); + println!("Initialized Scheduler for Basilisk"); + + basilisk_runtime::ParachainSystem::on_initialize(target_block); + println!("Initialized ParachainSystem for Basilisk"); + + basilisk_runtime::ParachainInfo::on_initialize(target_block); + println!("Initialized ParachainInfo for Basilisk"); + + basilisk_runtime::PolkadotXcm::on_initialize(target_block); + println!("Initialized PolkadotXcm for Basilisk"); + + basilisk_runtime::CumulusXcm::on_initialize(target_block); + println!("Initialized CumulusXcm for Basilisk"); + + basilisk_runtime::XcmpQueue::on_initialize(target_block); + println!("Initialized XcmpQueue for Basilisk"); + + basilisk_runtime::MessageQueue::on_initialize(target_block); + println!("Initialized MessageQueue for Basilisk"); + + basilisk_runtime::MultiTransactionPayment::on_initialize(target_block); + println!("Initialized MultiTransactionPayment for Basilisk"); + + basilisk_runtime::EmaOracle::on_initialize(target_block); + println!("Initialized EmaOracle for Basilisk"); + + // assert_ok!(basilisk_runtime::Timestamp::set( + // basilisk_runtime::RuntimeOrigin::none(), + // SLOT_DURATION * *target_slot + // )); + + // basilisk_runtime::AllPalletsWithSystem::on_initialize(target_block); + // println!("Initialized all pallets for Basilisk"); + + set_validation_data(target_block, target_slot); + println!("Set validation data for block {}", target_block); } -fn set_timestamp2(number: u64) { - assert_ok!(rococo_runtime::Timestamp::set( - rococo_runtime::RuntimeOrigin::none(), - pallet_timestamp::Now::::get() + (primitives::constants::time::SLOT_DURATION * number) - )); +pub fn finalize_basilisk_block(target_block: BlockNumber) { + use frame_support::traits::OnFinalize; + + basilisk_runtime::System::on_finalize(target_block); + println!("finalized System for Basilisk"); + + // basilisk_runtime::Timestamp::on_finalize(target_block); + // println!("finalized Timestamp for Basilisk"); + + basilisk_runtime::Session::on_finalize(target_block); + println!("finalized Session for Basilisk"); + + basilisk_runtime::Aura::on_finalize(target_block); + println!("finalized Aura for Basilisk"); + + basilisk_runtime::AuraExt::on_finalize(target_block); + println!("finalized AuraExt for Basilisk"); + + basilisk_runtime::RelayChainInfo::on_finalize(target_block); + println!("finalized RelayChainInfo for Basilisk"); + + basilisk_runtime::Scheduler::on_finalize(target_block); + println!("finalized Scheduler for Basilisk"); + + basilisk_runtime::ParachainSystem::on_finalize(target_block); + println!("finalized ParachainSystem for Basilisk"); + + basilisk_runtime::ParachainInfo::on_finalize(target_block); + println!("finalized ParachainInfo for Basilisk"); + + basilisk_runtime::PolkadotXcm::on_finalize(target_block); + println!("finalized PolkadotXcm for Basilisk"); + + basilisk_runtime::CumulusXcm::on_finalize(target_block); + println!("finalized CumulusXcm for Basilisk"); + + basilisk_runtime::XcmpQueue::on_finalize(target_block); + println!("finalized XcmpQueue for Basilisk"); + + basilisk_runtime::MessageQueue::on_finalize(target_block); + println!("finalized MessageQueue for Basilisk"); + + basilisk_runtime::MultiTransactionPayment::on_finalize(target_block); + println!("finalized MultiTransactionPayment for Basilisk"); + + basilisk_runtime::EmaOracle::on_finalize(target_block); + println!("finalized EmaOracle for Basilisk"); + + basilisk_runtime::System::finalize(); } -pub fn go_to_relaychain_block(number: BlockNumber) { +pub fn finalize_rococo_block(target_block: BlockNumber) { use frame_support::traits::OnFinalize; + rococo_runtime::System::on_finalize(target_block); + println!("Finalized System for Rococo"); + + rococo_runtime::Scheduler::on_finalize(target_block); + println!("Finalized Scheduler for Rococo"); + + rococo_runtime::Preimage::on_finalize(target_block); + println!("Finalized Preimage for Rococo"); + + rococo_runtime::Babe::on_finalize(target_block); + println!("Finalized Babe for Rococo"); + + rococo_runtime::Timestamp::on_finalize(target_block); + println!("Finalized Timestamp for Rococo"); + + rococo_runtime::Session::on_finalize(target_block); + println!("Finalized Session for Rococo"); + + rococo_runtime::Grandpa::on_finalize(target_block); + println!("Finalized Grandpa for Rococo"); + + rococo_runtime::ParachainsOrigin::on_finalize(target_block); + println!("Finalized ParachainsOrigin for Rococo"); + + rococo_runtime::ParasShared::on_finalize(target_block); + println!("Finalized ParasShared for Rococo"); + + rococo_runtime::ParaInclusion::on_finalize(target_block); + println!("Finalized ParaInclusion for Rococo"); + + // rococo_runtime::ParaInherent::on_finalize(target_block); + // println!("Finalized ParaInherent for Rococo"); - while rococo_runtime::System::block_number() < number { - let current_block = rococo_runtime::System::block_number(); - let next_block = current_block + 1; - rococo_runtime::System::on_finalize(current_block); - - let slot = Slot::from_timestamp( - (pallet_timestamp::Now::::get() + SLOT_DURATION).into(), - SlotDuration::from_millis(SLOT_DURATION), - ); - rococo_runtime::System::on_initialize(next_block); - rococo_runtime::System::initialize( - &(next_block), - &Default::default(), - &Digest { - logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, slot.encode())], - }, - ); - - rococo_runtime::System::set_block_number(next_block); - - basilisk_run_to_next_block(); - - // ParachainSystem::on_initialize(next_block); - // set_slot_info((next_block).into()); - set_timestamp(); - set_validation_data(next_block); + rococo_runtime::ParaScheduler::on_finalize(target_block); + println!("Finalized ParaScheduler for Rococo"); + + rococo_runtime::Paras::on_finalize(target_block); + println!("Finalized Paras for Rococo"); + + rococo_runtime::Initializer::on_finalize(target_block); + println!("Finalized Initializer for Rococo"); + + rococo_runtime::Dmp::on_finalize(target_block); + println!("Finalized DmpQueue for Rococo"); + + rococo_runtime::Hrmp::on_finalize(target_block); + println!("Finalized Hrmp for Rococo"); + + rococo_runtime::ParaSessionInfo::on_finalize(target_block); + println!("Finalized ParaSessionInfo for Rococo"); + + rococo_runtime::Slots::on_finalize(target_block); + println!("Finalized Slots for Rococo"); + + rococo_runtime::XcmPallet::on_finalize(target_block); + println!("Finalized Xcm for Rococo"); + + rococo_runtime::MessageQueue::on_finalize(target_block); + println!("Finalized MessageQueue for Rococo"); + + rococo_runtime::Beefy::on_finalize(target_block); + println!("Finalized Beefy for Rococo"); + + // rococo_runtime::System::finalize(); + + // rococo_runtime::AllPalletsWithSystem::on_finalize(target_block); + // println!("Finalized all pallets for Rococo"); +} + +pub fn go_to_next_block(initialize: bool, finalize: bool) { + let current_block = rococo_runtime::System::block_number(); + let current_para_block = basilisk_runtime::System::block_number(); + let target_relay_block = current_block + 1; + let target_para_block = current_para_block + 1; + + // Advance the relaychain block + + let slot = Slot::from_timestamp( + (pallet_timestamp::Now::::get() + SLOT_DURATION).into(), + SlotDuration::from_millis(SLOT_DURATION), + ); + + println!("Current BABE slot {:?}", rococo_runtime::Babe::current_slot()); + println!("Babe initialized {:?}", rococo_runtime::Babe::initialized()); + if initialize { + initialize_rococo_block(target_relay_block, slot); + initialize_basilisk_block(target_para_block, slot); + } + println!("RelayBlock {:?}", rococo_runtime::System::block_number()); + println!( + "LastRelayBlockPara {:?}", + basilisk_runtime::ParachainSystem::last_relay_block_number() + ); + + if finalize { + finalize_basilisk_block(target_para_block); + finalize_rococo_block(target_relay_block); } } -fn set_validation_data(next_block: u32) { +pub fn set_validation_data(next_block: u32, slot: Slot) { use basilisk_runtime::RuntimeOrigin; + use frame_support::storage::storage_prefix; use polkadot_primitives::HeadData; let parent_head = HeadData(b"deadbeef".into()); let sproof_builder = RelayStateSproofBuilder { - para_id: BASILISK_PARA_ID.into(), + para_id: basilisk_runtime::ParachainInfo::parachain_id(), included_para_head: Some(parent_head.clone()), - current_slot: Slot::from_timestamp( - pallet_timestamp::Now::::get().into(), - SlotDuration::from_millis(6_000), - ), + current_slot: slot, ..Default::default() }; - + let (relay_storage_root, proof) = sproof_builder.into_state_root_and_proof(); - assert_ok!(ParachainSystem::set_validation_data( + assert_ok!(basilisk_runtime::ParachainSystem::set_validation_data( RuntimeOrigin::none(), cumulus_primitives_parachain_inherent::ParachainInherentData { validation_data: cumulus_primitives_core::PersistedValidationData { - parent_head: Default::default(), + parent_head, relay_parent_number: next_block, relay_parent_storage_root: relay_storage_root, max_pov_size: Default::default(), @@ -656,47 +874,18 @@ fn set_validation_data(next_block: u32) { } )); + sp_io::storage::clear(&storage_prefix(b"ParachainSystem", b"UnincludedSegment")); } -// pub fn set_relaychain_block_number(number: BlockNumber) { -// use basilisk_runtime::ParachainSystem; -// use basilisk_runtime::RuntimeOrigin; - -// rococo_run_to_block(number); //We need to set block number this way as well because tarpaulin code coverage tool does not like the way how we set the block number with `cumulus-test-relay-sproof-builder` package -// set_slot_info(number.into()); - -// ParachainSystem::on_initialize(number); - -// set_timestamp2((number-2).into()); - -// let (relay_storage_root, proof) = RelayStateSproofBuilder::default().into_state_root_and_proof(); -// assert_ok!(ParachainSystem::set_validation_data( -// RuntimeOrigin::none(), -// cumulus_primitives_parachain_inherent::ParachainInherentData { -// validation_data: cumulus_primitives_core::PersistedValidationData { -// parent_head: Default::default(), -// relay_parent_number: number, -// relay_parent_storage_root: relay_storage_root, -// max_pov_size: Default::default(), -// }, -// relay_chain_state: proof, -// downward_messages: Default::default(), -// horizontal_messages: Default::default(), -// } -// )); -// // set_slot_info(number.into()); -// } - -pub fn rococo_run_to_block(to: BlockNumber) { - use frame_support::traits::OnFinalize; - - while rococo_runtime::System::block_number() < to { - let b = rococo_runtime::System::block_number(); - rococo_runtime::System::on_finalize(b); - rococo_runtime::System::on_initialize(b + 1); - rococo_runtime::System::set_block_number(b + 1); - // set_slot_info((b + 1).into()); - } +pub fn set_para_slot_info(number: u64) { + // sp_io::storage::clear(&frame_support::storage::storage_prefix( + // b"ParachainSystem", + // b"UnincludedSegment", + // )); + frame_support::storage::unhashed::put( + &frame_support::storage::storage_prefix(b"AuraExt", b"SlotInfo"), + &((Slot::from(number), 0)), + ); } use xcm_emulator::pallet_message_queue; diff --git a/integration-tests/src/non_native_fee.rs b/integration-tests/src/non_native_fee.rs index 885f83f753..e1a8cbaf80 100644 --- a/integration-tests/src/non_native_fee.rs +++ b/integration-tests/src/non_native_fee.rs @@ -139,7 +139,8 @@ fn non_native_fee_payment_works_with_oracle_price_based_on_onchain_route() { false, )); - basilisk_run_to_next_block(); + go_to_next_block(true, true); + go_to_next_block(true, false); // pay with the new token assert_ok!( diff --git a/integration-tests/src/oracle.rs b/integration-tests/src/oracle.rs index 6b6a5beeba..78d536b380 100644 --- a/integration-tests/src/oracle.rs +++ b/integration-tests/src/oracle.rs @@ -17,7 +17,8 @@ fn xyk_trades_are_ingested_into_oracle() { Basilisk::execute_with(|| { // arrange - basilisk_run_to_next_block(); + go_to_next_block(true, true); + go_to_next_block(true, false); assert_ok!(XYK::create_pool( RuntimeOrigin::signed(ALICE.into()), @@ -37,7 +38,7 @@ fn xyk_trades_are_ingested_into_oracle() { // act // will store the data received in the sell as oracle values - basilisk_run_to_next_block(); + go_to_next_block(false, true); // assert let expected = ((105000000000000, 190504761904760).into(), 0); diff --git a/integration-tests/src/router.rs b/integration-tests/src/router.rs index e7733a5557..ab612b41f7 100644 --- a/integration-tests/src/router.rs +++ b/integration-tests/src/router.rs @@ -1399,7 +1399,7 @@ fn get_lbp_pair_account_id(asset_a: AssetId, asset_b: AssetId) -> AccountId { } fn start_lbp_campaign() { - go_to_relaychain_block(SALE_START.unwrap() + 1); + go_to_block(SALE_START.unwrap() + 1); } #[macro_export] diff --git a/rust-toolchain b/rust-toolchain index 47a114dc5e..8cf8846114 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,5 +1,5 @@ [toolchain] -channel = "1.77.0" +channel = "1.82.0" components = [ "rustfmt", "clippy", "rust-src" ] targets = [ "wasm32-unknown-unknown" ] profile = "minimal" From 867804ba4494ce2c83a3f6f66acc4a3402d8f67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20P=C3=A1nik?= Date: Wed, 23 Oct 2024 02:58:33 +0200 Subject: [PATCH 16/24] remove logging --- integration-tests/src/kusama_test_net.rs | 179 +---------------------- 1 file changed, 7 insertions(+), 172 deletions(-) diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index 5e5ad0692d..e7834b7031 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -511,7 +511,6 @@ pub fn vesting_account() -> AccountId { } pub fn go_to_block(target_block: BlockNumber) { - println!("Going to block {}", target_block); while rococo_runtime::System::block_number() < target_block { let stop = rococo_runtime::System::block_number() == target_block - 1; go_to_next_block(true, !stop); @@ -524,10 +523,6 @@ pub fn initialize_rococo_block(target_block: BlockNumber, target_slot: Slot) { let authority_index: u32 = 0; rococo_runtime::System::set_block_number(target_block); - println!("Set Rococo block number to {}", target_block); - - println!("Current BABE slot {:?}", rococo_runtime::Babe::current_slot()); - println!("Babe initialized {:?}", rococo_runtime::Babe::initialized()); rococo_runtime::System::initialize( &target_block, @@ -546,86 +541,38 @@ pub fn initialize_rococo_block(target_block: BlockNumber, target_slot: Slot) { }, ); rococo_runtime::System::on_initialize(target_block); - println!("initialized System for Rococo"); - rococo_runtime::Scheduler::on_initialize(target_block); - println!("initialized Scheduler for Rococo"); - rococo_runtime::Preimage::on_initialize(target_block); - println!("initialized Preimage for Rococo"); - rococo_runtime::Babe::on_initialize(target_block); - println!("initialized Babe for Rococo"); - rococo_runtime::Timestamp::on_initialize(target_block); - println!("initialized and set Timestamp for Rococo"); - rococo_runtime::Session::on_initialize(target_block); - println!("initialized Session for Rococo"); - rococo_runtime::Grandpa::on_initialize(target_block); - println!("initialized Grandpa for Rococo"); - rococo_runtime::ParachainsOrigin::on_initialize(target_block); - println!("initialized ParachainsOrigin for Rococo"); - rococo_runtime::ParasShared::on_initialize(target_block); - println!("initialized ParasShared for Rococo"); - rococo_runtime::ParaInclusion::on_initialize(target_block); - println!("initialized ParaInclusion for Rococo"); - // rococo_runtime::ParaInherent::on_initialize(target_block); - // println!("initialized ParaInherent for Rococo"); - - rococo_runtime::ParaScheduler::on_initialize(target_block); - println!("initialized ParaScheduler for Rococo"); - + // rococo_runtime::ParaScheduler::on_initialize(target_block); rococo_runtime::Paras::on_initialize(target_block); - println!("initialized Paras for Rococo"); - rococo_runtime::Initializer::on_initialize(target_block); - println!("initialized Initializer for Rococo"); - rococo_runtime::Dmp::on_initialize(target_block); - println!("initialized DmpQueue for Rococo"); - rococo_runtime::Hrmp::on_initialize(target_block); - println!("initialized Hrmp for Rococo"); - rococo_runtime::ParaSessionInfo::on_initialize(target_block); - println!("initialized ParaSessionInfo for Rococo"); - rococo_runtime::Slots::on_initialize(target_block); - println!("initialized Slots for Rococo"); - rococo_runtime::XcmPallet::on_initialize(target_block); - println!("initialized Xcm for Rococo"); - rococo_runtime::MessageQueue::on_initialize(target_block); - println!("initialized MessageQueue for Rococo"); - rococo_runtime::Beefy::on_initialize(target_block); - println!("initialized Beefy for Rococo"); - assert_ok!(rococo_runtime::Timestamp::set( rococo_runtime::RuntimeOrigin::none(), SLOT_DURATION * *target_slot )); // rococo_runtime::AllPalletsWithSystem::on_initialize(target_block); - // println!("initialized all pallets for Rococo"); + // } pub fn initialize_basilisk_block(target_block: BlockNumber, target_slot: Slot) { // Force a new Basilisk block to be created - println!( - "Initializing. Current block number: {:?}", - basilisk_runtime::System::block_number() - ); basilisk_runtime::System::set_block_number(target_block); - println!("Set Basilisk block number to {}", target_block); - basilisk_runtime::System::initialize( &target_block, &Default::default(), @@ -635,182 +582,77 @@ pub fn initialize_basilisk_block(target_block: BlockNumber, target_slot: Slot) { ); basilisk_runtime::System::on_initialize(target_block); - println!("Initialized System for Basilisk"); - // basilisk_runtime::Timestamp::on_initialize(target_block); - // println!("Initialized Timestamp for Basilisk"); - - basilisk_runtime::Session::on_initialize(target_block); - println!("Initialized Session for Basilisk"); - + // basilisk_runtime::Session::on_initialize(target_block); basilisk_runtime::Aura::on_initialize(target_block); - println!("Initialized Aura for Basilisk"); - basilisk_runtime::AuraExt::on_initialize(target_block); - println!("Initialized AuraExt for Basilisk"); - basilisk_runtime::RelayChainInfo::on_initialize(target_block); - println!("Initialized RelayChainInfo for Basilisk"); - basilisk_runtime::Scheduler::on_initialize(target_block); - println!("Initialized Scheduler for Basilisk"); - basilisk_runtime::ParachainSystem::on_initialize(target_block); - println!("Initialized ParachainSystem for Basilisk"); - basilisk_runtime::ParachainInfo::on_initialize(target_block); - println!("Initialized ParachainInfo for Basilisk"); - basilisk_runtime::PolkadotXcm::on_initialize(target_block); - println!("Initialized PolkadotXcm for Basilisk"); - basilisk_runtime::CumulusXcm::on_initialize(target_block); - println!("Initialized CumulusXcm for Basilisk"); - basilisk_runtime::XcmpQueue::on_initialize(target_block); - println!("Initialized XcmpQueue for Basilisk"); - basilisk_runtime::MessageQueue::on_initialize(target_block); - println!("Initialized MessageQueue for Basilisk"); - basilisk_runtime::MultiTransactionPayment::on_initialize(target_block); - println!("Initialized MultiTransactionPayment for Basilisk"); - basilisk_runtime::EmaOracle::on_initialize(target_block); - println!("Initialized EmaOracle for Basilisk"); - // assert_ok!(basilisk_runtime::Timestamp::set( // basilisk_runtime::RuntimeOrigin::none(), // SLOT_DURATION * *target_slot // )); // basilisk_runtime::AllPalletsWithSystem::on_initialize(target_block); - // println!("Initialized all pallets for Basilisk"); - - set_validation_data(target_block, target_slot); - println!("Set validation data for block {}", target_block); + // set_validation_data(target_block, target_slot); } pub fn finalize_basilisk_block(target_block: BlockNumber) { use frame_support::traits::OnFinalize; basilisk_runtime::System::on_finalize(target_block); - println!("finalized System for Basilisk"); - // basilisk_runtime::Timestamp::on_finalize(target_block); - // println!("finalized Timestamp for Basilisk"); - - basilisk_runtime::Session::on_finalize(target_block); - println!("finalized Session for Basilisk"); - + // basilisk_runtime::Session::on_finalize(target_block); basilisk_runtime::Aura::on_finalize(target_block); - println!("finalized Aura for Basilisk"); - basilisk_runtime::AuraExt::on_finalize(target_block); - println!("finalized AuraExt for Basilisk"); - basilisk_runtime::RelayChainInfo::on_finalize(target_block); - println!("finalized RelayChainInfo for Basilisk"); - basilisk_runtime::Scheduler::on_finalize(target_block); - println!("finalized Scheduler for Basilisk"); - basilisk_runtime::ParachainSystem::on_finalize(target_block); - println!("finalized ParachainSystem for Basilisk"); - basilisk_runtime::ParachainInfo::on_finalize(target_block); - println!("finalized ParachainInfo for Basilisk"); - basilisk_runtime::PolkadotXcm::on_finalize(target_block); - println!("finalized PolkadotXcm for Basilisk"); - basilisk_runtime::CumulusXcm::on_finalize(target_block); - println!("finalized CumulusXcm for Basilisk"); - basilisk_runtime::XcmpQueue::on_finalize(target_block); - println!("finalized XcmpQueue for Basilisk"); - basilisk_runtime::MessageQueue::on_finalize(target_block); - println!("finalized MessageQueue for Basilisk"); - basilisk_runtime::MultiTransactionPayment::on_finalize(target_block); - println!("finalized MultiTransactionPayment for Basilisk"); - basilisk_runtime::EmaOracle::on_finalize(target_block); - println!("finalized EmaOracle for Basilisk"); - basilisk_runtime::System::finalize(); } pub fn finalize_rococo_block(target_block: BlockNumber) { use frame_support::traits::OnFinalize; rococo_runtime::System::on_finalize(target_block); - println!("Finalized System for Rococo"); - rococo_runtime::Scheduler::on_finalize(target_block); - println!("Finalized Scheduler for Rococo"); - rococo_runtime::Preimage::on_finalize(target_block); - println!("Finalized Preimage for Rococo"); - rococo_runtime::Babe::on_finalize(target_block); - println!("Finalized Babe for Rococo"); - rococo_runtime::Timestamp::on_finalize(target_block); - println!("Finalized Timestamp for Rococo"); - rococo_runtime::Session::on_finalize(target_block); - println!("Finalized Session for Rococo"); - rococo_runtime::Grandpa::on_finalize(target_block); - println!("Finalized Grandpa for Rococo"); - rococo_runtime::ParachainsOrigin::on_finalize(target_block); - println!("Finalized ParachainsOrigin for Rococo"); - rococo_runtime::ParasShared::on_finalize(target_block); - println!("Finalized ParasShared for Rococo"); - rococo_runtime::ParaInclusion::on_finalize(target_block); - println!("Finalized ParaInclusion for Rococo"); - // rococo_runtime::ParaInherent::on_finalize(target_block); - // println!("Finalized ParaInherent for Rococo"); - - rococo_runtime::ParaScheduler::on_finalize(target_block); - println!("Finalized ParaScheduler for Rococo"); - + // rococo_runtime::ParaScheduler::on_finalize(target_block); rococo_runtime::Paras::on_finalize(target_block); - println!("Finalized Paras for Rococo"); - rococo_runtime::Initializer::on_finalize(target_block); - println!("Finalized Initializer for Rococo"); - rococo_runtime::Dmp::on_finalize(target_block); - println!("Finalized DmpQueue for Rococo"); - rococo_runtime::Hrmp::on_finalize(target_block); - println!("Finalized Hrmp for Rococo"); - rococo_runtime::ParaSessionInfo::on_finalize(target_block); - println!("Finalized ParaSessionInfo for Rococo"); - rococo_runtime::Slots::on_finalize(target_block); - println!("Finalized Slots for Rococo"); - rococo_runtime::XcmPallet::on_finalize(target_block); - println!("Finalized Xcm for Rococo"); - rococo_runtime::MessageQueue::on_finalize(target_block); - println!("Finalized MessageQueue for Rococo"); - rococo_runtime::Beefy::on_finalize(target_block); - println!("Finalized Beefy for Rococo"); - // rococo_runtime::System::finalize(); // rococo_runtime::AllPalletsWithSystem::on_finalize(target_block); - // println!("Finalized all pallets for Rococo"); + // } pub fn go_to_next_block(initialize: bool, finalize: bool) { @@ -826,17 +668,10 @@ pub fn go_to_next_block(initialize: bool, finalize: bool) { SlotDuration::from_millis(SLOT_DURATION), ); - println!("Current BABE slot {:?}", rococo_runtime::Babe::current_slot()); - println!("Babe initialized {:?}", rococo_runtime::Babe::initialized()); if initialize { initialize_rococo_block(target_relay_block, slot); initialize_basilisk_block(target_para_block, slot); } - println!("RelayBlock {:?}", rococo_runtime::System::block_number()); - println!( - "LastRelayBlockPara {:?}", - basilisk_runtime::ParachainSystem::last_relay_block_number() - ); if finalize { finalize_basilisk_block(target_para_block); From 1918d6bbca332f52657c71094bd7970a961a2bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20P=C3=A1nik?= Date: Wed, 23 Oct 2024 03:07:47 +0200 Subject: [PATCH 17/24] too much comments --- integration-tests/src/kusama_test_net.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index e7834b7031..1fce0f33e5 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -551,7 +551,7 @@ pub fn initialize_rococo_block(target_block: BlockNumber, target_slot: Slot) { rococo_runtime::ParasShared::on_initialize(target_block); rococo_runtime::ParaInclusion::on_initialize(target_block); // rococo_runtime::ParaInherent::on_initialize(target_block); - // rococo_runtime::ParaScheduler::on_initialize(target_block); + rococo_runtime::ParaScheduler::on_initialize(target_block); rococo_runtime::Paras::on_initialize(target_block); rococo_runtime::Initializer::on_initialize(target_block); rococo_runtime::Dmp::on_initialize(target_block); @@ -566,7 +566,6 @@ pub fn initialize_rococo_block(target_block: BlockNumber, target_slot: Slot) { SLOT_DURATION * *target_slot )); // rococo_runtime::AllPalletsWithSystem::on_initialize(target_block); - // } pub fn initialize_basilisk_block(target_block: BlockNumber, target_slot: Slot) { @@ -583,7 +582,7 @@ pub fn initialize_basilisk_block(target_block: BlockNumber, target_slot: Slot) { basilisk_runtime::System::on_initialize(target_block); // basilisk_runtime::Timestamp::on_initialize(target_block); - // basilisk_runtime::Session::on_initialize(target_block); + basilisk_runtime::Session::on_initialize(target_block); basilisk_runtime::Aura::on_initialize(target_block); basilisk_runtime::AuraExt::on_initialize(target_block); basilisk_runtime::RelayChainInfo::on_initialize(target_block); @@ -602,7 +601,7 @@ pub fn initialize_basilisk_block(target_block: BlockNumber, target_slot: Slot) { // )); // basilisk_runtime::AllPalletsWithSystem::on_initialize(target_block); - // set_validation_data(target_block, target_slot); + set_validation_data(target_block, target_slot); } pub fn finalize_basilisk_block(target_block: BlockNumber) { @@ -610,7 +609,7 @@ pub fn finalize_basilisk_block(target_block: BlockNumber) { basilisk_runtime::System::on_finalize(target_block); // basilisk_runtime::Timestamp::on_finalize(target_block); - // basilisk_runtime::Session::on_finalize(target_block); + basilisk_runtime::Session::on_finalize(target_block); basilisk_runtime::Aura::on_finalize(target_block); basilisk_runtime::AuraExt::on_finalize(target_block); basilisk_runtime::RelayChainInfo::on_finalize(target_block); @@ -639,7 +638,7 @@ pub fn finalize_rococo_block(target_block: BlockNumber) { rococo_runtime::ParasShared::on_finalize(target_block); rococo_runtime::ParaInclusion::on_finalize(target_block); // rococo_runtime::ParaInherent::on_finalize(target_block); - // rococo_runtime::ParaScheduler::on_finalize(target_block); + rococo_runtime::ParaScheduler::on_finalize(target_block); rococo_runtime::Paras::on_finalize(target_block); rococo_runtime::Initializer::on_finalize(target_block); rococo_runtime::Dmp::on_finalize(target_block); From 4318938c289b07be22e35ee4933fdc2dd12b47da Mon Sep 17 00:00:00 2001 From: vgantchev Date: Thu, 24 Oct 2024 20:23:32 +0200 Subject: [PATCH 18/24] remove xcm tests --- Cargo.lock | 2 +- integration-tests/Cargo.toml | 2 +- integration-tests/src/cross_chain_transfer.rs | 635 ------------------ integration-tests/src/exchange_asset.rs | 117 ---- integration-tests/src/kusama_test_net.rs | 6 +- integration-tests/src/lib.rs | 1 - 6 files changed, 5 insertions(+), 758 deletions(-) delete mode 100644 integration-tests/src/cross_chain_transfer.rs diff --git a/Cargo.lock b/Cargo.lock index 27751dbf86..ef83566a3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11179,7 +11179,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.0.4" +version = "1.0.5" dependencies = [ "basilisk-runtime", "cumulus-pallet-aura-ext", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index ee2919c536..ae74465358 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.0.4" +version = "1.0.5" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/integration-tests/src/cross_chain_transfer.rs b/integration-tests/src/cross_chain_transfer.rs deleted file mode 100644 index 81c47a8788..0000000000 --- a/integration-tests/src/cross_chain_transfer.rs +++ /dev/null @@ -1,635 +0,0 @@ -#![cfg(test)] -use crate::kusama_test_net::Rococo; -use crate::kusama_test_net::*; - -use frame_support::{assert_noop, assert_ok}; - -use polkadot_xcm::{v4::prelude::*, VersionedAssets, VersionedXcm}; - -use cumulus_primitives_core::ParaId; -use orml_traits::currency::MultiCurrency; -use polkadot_xcm::opaque::v3::{ - Junction, - Junctions::{X1, X2}, - MultiLocation, -}; -use sp_core::H256; -use sp_runtime::traits::{AccountIdConversion, BlakeTwo256, Hash}; -use xcm_emulator::TestExt; - -use sp_std::sync::Arc; - -// Determine the hash for assets expected to be have been trapped. -fn determine_hash(origin: &MultiLocation, assets: Vec) -> H256 { - let versioned = VersionedAssets::from(Assets::from(assets)); - BlakeTwo256::hash_of(&(origin, &versioned)) -} - -#[test] -fn basilisk_should_receive_asset_when_transferred_from_relaychain() { - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::parent()) - )); - }); - Rococo::execute_with(|| { - assert_ok!(rococo_runtime::XcmPallet::limited_reserve_transfer_assets( - rococo_runtime::RuntimeOrigin::signed(ALICE.into()), - Box::new(Parachain(BASILISK_PARA_ID).into_versioned()), - Box::new(Junction::AccountId32 { id: BOB, network: None }.into_versioned()), - Box::new((Here, 300 * UNITS).into()), - 0, - WeightLimit::Unlimited, - )); - - assert_eq!( - rococo_runtime::Balances::free_balance(AccountIdConversion::::into_account_truncating( - &ParaId::from(BASILISK_PARA_ID) - )), - 310 * UNITS - ); - }); - - Basilisk::execute_with(|| { - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), - 1_299_999_987_268_519 - ); - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()), - 12_731_481 - ); - }); -} - -#[test] -fn relaychain_should_receive_asset_when_transferred_from_basilisk() { - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::parent()) - )); - - let dest = MultiLocation::new(1, X1(Junction::AccountId32 { id: BOB, network: None })).into_versioned(); - - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 1, - 3 * UNITS, - Box::new(dest), - WeightLimit::Limited(Weight::from_parts(4_600_000_000, 10_000)) - )); - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(ALICE)), - ALICE_INITIAL_AUSD_BALANCE - 3 * UNITS - ); - }); - - Rococo::execute_with(|| { - assert_eq!( - rococo_runtime::Balances::free_balance(AccountId::from(BOB)), - 2999989698923 // 3 * BSX - fee - ); - }); -} - -#[test] -fn basilisk_should_receive_asset_when_sent_from_other_parachain() { - TestNet::reset(); - - let amount_to_send = 30 * UNITS; - - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::new( - 1, - X2(Junction::Parachain(OTHER_PARA_ID), Junction::GeneralIndex(0)) - )) - )); - }); - - OtherParachain::execute_with(|| { - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 0, - amount_to_send, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(BASILISK_PARA_ID), - Junction::AccountId32 { id: BOB, network: None } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - )); - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - amount_to_send - ); - }); - - let fee = 10_185_185; - Basilisk::execute_with(|| { - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), - 1000 * UNITS + amount_to_send - fee - ); - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()), - fee // fees should go to treasury - ); - }); -} - -#[test] -fn other_parachain_should_receive_asset_when_sent_from_basilisk() { - TestNet::reset(); - - let amount_to_send = 30 * UNITS; - - OtherParachain::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::new( - 1, - X2(Junction::Parachain(BASILISK_PARA_ID), Junction::GeneralIndex(0)) - )) - )); - }); - - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::MultiTransactionPayment::set_currency( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 1, - )); - - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 0, - amount_to_send, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(OTHER_PARA_ID), - Junction::AccountId32 { id: BOB, network: None } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - )); - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_BSX_BALANCE - amount_to_send - ); - }); - - OtherParachain::execute_with(|| { - let fee = 10185185; - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), - BOB_INITIAL_AUSD_BALANCE_ON_OTHER_PARACHAIN + amount_to_send - fee - ); - - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::TreasuryAccount::get()), - fee - ); - }); -} - -#[test] -fn transfer_from_other_parachain_and_back() { - TestNet::reset(); - - let amount_to_send = 30 * UNITS; - - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::new( - 1, - X2(Junction::Parachain(OTHER_PARA_ID), Junction::GeneralIndex(0)) - )) - )); - }); - - OtherParachain::execute_with(|| { - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 0, - amount_to_send, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(BASILISK_PARA_ID), - Junction::AccountId32 { id: BOB, network: None } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - )); - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - amount_to_send - ); - }); - - let fee = 10_185_185; - Basilisk::execute_with(|| { - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), - 1000 * UNITS + amount_to_send - fee - ); - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()), - fee // fees should go to treasury - ); - - //transfer back - assert_ok!(basilisk_runtime::MultiTransactionPayment::set_currency( - basilisk_runtime::RuntimeOrigin::signed(BOB.into()), - 1, - )); - - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(BOB.into()), - 0, - amount_to_send, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(OTHER_PARA_ID), - Junction::AccountId32 { - id: ALICE, - network: None, - } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - )); - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(BOB)), - 1000 * UNITS - amount_to_send - ); - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()), - 10_185_185 // fees should go to treasury - ); - }); - - OtherParachain::execute_with(|| { - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(ALICE)), - ALICE_INITIAL_AUSD_BALANCE_ON_OTHER_PARACHAIN - ); - }); -} - -#[test] -fn other_parachain_should_fail_to_send_asset_to_basilisk_when_insufficient_amount_is_used() { - TestNet::reset(); - - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::new( - 1, - X2(Junction::Parachain(OTHER_PARA_ID), Junction::GeneralIndex(0)) - )) - )); - }); - - OtherParachain::execute_with(|| { - let insufficient_amount = 55; - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - ); - - assert_noop!( - basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 0, - insufficient_amount, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(BASILISK_PARA_ID), - Junction::AccountId32 { id: BOB, network: None } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - ), - orml_xtokens::Error::::XcmExecutionFailed - ); - - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - ); - }); - - Basilisk::execute_with(|| { - // Xcm should fail therefore nothing should be deposit into beneficiary account - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), - 1000 * UNITS - ); - }); -} -#[test] -fn fee_currency_set_on_xcm_transfer() { - TestNet::reset(); - - const HITCHHIKER: [u8; 32] = [42u8; 32]; - - let transfer_amount = 100 * UNITS; - - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::new( - 1, - X2(Junction::Parachain(OTHER_PARA_ID), Junction::GeneralIndex(0)) - )) - )); - - // fee currency is not set before XCM transfer - assert_eq!( - basilisk_runtime::MultiTransactionPayment::get_currency(AccountId::from(HITCHHIKER)), - None - ); - }); - - OtherParachain::execute_with(|| { - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 0, - transfer_amount, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(BASILISK_PARA_ID), - Junction::AccountId32 { - id: HITCHHIKER, - network: None, - } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - )); - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - transfer_amount - ); - }); - - Basilisk::execute_with(|| { - let fee_amount = 10_185_185; - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(HITCHHIKER)), - transfer_amount - fee_amount - ); - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()), - fee_amount // fees should go to treasury - ); - // fee currency is set after XCM transfer - assert_eq!( - basilisk_runtime::MultiTransactionPayment::get_currency(AccountId::from(HITCHHIKER)), - Some(1) - ); - }); -} - -#[test] -fn assets_should_be_trapped_when_assets_are_unknown() { - TestNet::reset(); - - OtherParachain::execute_with(|| { - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 0, - 30 * UNITS, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(BASILISK_PARA_ID), - Junction::AccountId32 { id: BOB, network: None } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - )); - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - 30 * UNITS - ); - }); - - Basilisk::execute_with(|| { - assert_xcm_message_processing_failed(); - let origin = MultiLocation::new(1, X1(Junction::Parachain(OTHER_PARA_ID))); - let asset: Asset = Asset { - id: cumulus_primitives_core::AssetId(Location::new( - 1, - cumulus_primitives_core::Junctions::X2(Arc::new( - vec![ - cumulus_primitives_core::Junction::Parachain(OTHER_PARA_ID), - cumulus_primitives_core::Junction::GeneralIndex(0), - ] - .try_into() - .unwrap(), - )), - )), - fun: Fungible(30 * UNITS), - }; - let hash = determine_hash(&origin, vec![asset.clone()]); - assert_eq!(basilisk_runtime::PolkadotXcm::asset_trap(hash), 1); - - expect_basilisk_event(basilisk_runtime::RuntimeEvent::PolkadotXcm( - pallet_xcm::Event::AssetsTrapped { - hash, - origin: origin.try_into().unwrap(), - assets: vec![asset].into(), - }, - )) - }); -} - -#[test] -fn claim_trapped_asset_should_work() { - TestNet::reset(); - - // traps asset when asset is not registered yet - let asset = trap_asset(); - - // register the asset - Basilisk::execute_with(|| { - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - 1, - basilisk_runtime::AssetLocation(MultiLocation::new( - 1, - X2(Junction::Parachain(OTHER_PARA_ID), Junction::GeneralIndex(0)) - )) - )); - }); - - let bob_loc = Location::new( - 0, - cumulus_primitives_core::Junctions::X1(Arc::new( - vec![cumulus_primitives_core::Junction::AccountId32 { id: BOB, network: None }] - .try_into() - .unwrap(), - )), - ); - - claim_asset(asset.clone(), bob_loc); - - Basilisk::execute_with(|| { - assert_eq!( - basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), - 1000 * UNITS + 29_999_992_361_112u128 - ); - - let origin = MultiLocation::new(1, X1(Junction::Parachain(OTHER_PARA_ID))); - let hash = determine_hash(&origin, vec![asset]); - assert_eq!(basilisk_runtime::PolkadotXcm::asset_trap(hash), 0); - }); -} - -fn trap_asset() -> Asset { - OtherParachain::execute_with(|| { - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - ); - assert_ok!(basilisk_runtime::XTokens::transfer( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - 0, - 30 * UNITS, - Box::new( - MultiLocation::new( - 1, - X2( - Junction::Parachain(BASILISK_PARA_ID), - Junction::AccountId32 { id: BOB, network: None } - ) - ) - .into_versioned() - ), - WeightLimit::Limited(Weight::from_parts(399_600_000_000, 0)) - )); - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - 200 * UNITS - 30 * UNITS - ); - }); - - let asset: Asset = Asset { - id: cumulus_primitives_core::AssetId(Location::new( - 1, - cumulus_primitives_core::Junctions::X2(Arc::new( - vec![ - cumulus_primitives_core::Junction::Parachain(OTHER_PARA_ID), - cumulus_primitives_core::Junction::GeneralIndex(0), - ] - .try_into() - .unwrap(), - )), - )), - fun: Fungible(30 * UNITS), - }; - - Basilisk::execute_with(|| { - assert_xcm_message_processing_failed(); - let origin = MultiLocation::new(1, X1(Junction::Parachain(OTHER_PARA_ID))); - let hash = determine_hash(&origin, vec![asset.clone()]); - assert_eq!(basilisk_runtime::PolkadotXcm::asset_trap(hash), 1); - }); - - asset -} - -fn claim_asset(asset: Asset, recipient: Location) { - OtherParachain::execute_with(|| { - let xcm_msg = Xcm(vec![ - ClaimAsset { - assets: vec![asset.clone()].into(), - ticket: Here.into(), - }, - BuyExecution { - fees: asset, - weight_limit: Unlimited, - }, - DepositAsset { - assets: All.into(), - beneficiary: recipient, - }, - ]); - assert_ok!(basilisk_runtime::PolkadotXcm::send( - basilisk_runtime::RuntimeOrigin::root(), - Box::new(MultiLocation::new(1, X1(Junction::Parachain(BASILISK_PARA_ID))).into_versioned()), - Box::new(VersionedXcm::from(xcm_msg)) - )); - }); -} - -#[test] -fn polkadot_xcm_execute_extrinsic_should_not_be_allowed() { - TestNet::reset(); - - Basilisk::execute_with(|| { - let xcm_msg = Xcm(vec![ - WithdrawAsset((Here, 410000000000u128).into()), - BuyExecution { - fees: (Here, 400000000000u128).into(), - weight_limit: Unlimited, - }, - ClearError, - ]); - - assert_noop!( - basilisk_runtime::PolkadotXcm::execute( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - Box::new(VersionedXcm::from(xcm_msg)), - Weight::from_parts(400_000_000_000, 0) - ), - sp_runtime::DispatchErrorWithPostInfo { - post_info: frame_support::dispatch::PostDispatchInfo { - actual_weight: Some(Weight::from_parts(10355000, 0)), - pays_fee: frame_support::dispatch::Pays::Yes, - }, - error: pallet_xcm::Error::::Filtered.into() - } - ); - }); -} diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 29d2d2ce1c..3e25289f9e 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -145,123 +145,6 @@ fn basilisk_should_swap_assets_when_receiving_from_otherchain_with_buy() { }); } -#[test] -fn basilisk_should_swap_assets_coming_from_karura_when_onchain_route_present() { - //Arrange - TestNet::reset(); - - Basilisk::execute_with(|| { - register_kar(); - assert_ok!(basilisk_runtime::Tokens::deposit(KAR, &CHARLIE.into(), 3000 * UNITS)); - create_xyk_pool_with_amounts(KAR, 100000 * UNITS, BSX, 100000 * UNITS); - create_xyk_pool_with_amounts(BSX, 100000 * UNITS, KSM, 100000 * UNITS); - - //Register KSM location - assert_ok!(basilisk_runtime::AssetRegistry::set_location( - basilisk_runtime::RuntimeOrigin::root(), - KSM, - basilisk_runtime::AssetLocation(MultiLocation::new( - 0, - polkadot_xcm::opaque::v3::Junctions::X1(polkadot_xcm::opaque::v3::Junction::GeneralIndex(3)) - )) - )); - - assert_ok!(basilisk_runtime::Tokens::set_balance( - frame_system::RawOrigin::Root.into(), - ALICE.into(), - KAR, - 100 * UNITS, - 0, - )); - assert_ok!(basilisk_runtime::Router::sell( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - KAR, - KSM, - 10_000, // make a small swap to not move the price a lot - 0, - vec![ - Trade { - pool: PoolType::XYK, - asset_in: KAR, - asset_out: BSX, - }, - Trade { - pool: PoolType::XYK, - asset_in: BSX, - asset_out: KSM, - } - ] - )); - - go_to_next_block(true, false); - - //Register onchain route from KAR to KSM - assert_ok!(basilisk_runtime::Router::set_route( - RuntimeOrigin::signed(CHARLIE.into()), - AssetPair::new(KAR, KSM), - vec![ - Trade { - pool: PoolType::XYK, - asset_in: KAR, - asset_out: BSX, - }, - Trade { - pool: PoolType::XYK, - asset_in: BSX, - asset_out: KSM, - }, - ], - )); - - add_currency_price(KAR, FixedU128::from(1)); - }); - - OtherParachain::execute_with(|| { - let amount_in: Asset = Asset::from((cumulus_primitives_core::Junction::GeneralIndex(0), 5 * UNITS)); - let min_amount_out: Asset = - Asset::from((cumulus_primitives_core::Junction::GeneralIndex(KSM.into()), 2 * UNITS)); - - let xcm = craft_exchange_asset_xcm::<_, basilisk_runtime::RuntimeCall>(amount_in, min_amount_out, SELL); - //Act - let res = basilisk_runtime::PolkadotXcm::execute( - basilisk_runtime::RuntimeOrigin::signed(ALICE.into()), - Box::new(xcm), - Weight::from_parts(399_600_000_000, 0), - ); - assert_ok!(res); - - //Assert - assert_eq!( - basilisk_runtime::Balances::free_balance(AccountId::from(ALICE)), - ALICE_INITIAL_NATIVE_BALANCE_ON_OTHER_PARACHAIN - 100 * UNITS - ); - - assert!(matches!( - last_other_para_events(2).first(), - Some(basilisk_runtime::RuntimeEvent::XcmpQueue( - cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. } - )) - )); - }); - - let fees = 27_500_000_000_005; - Basilisk::execute_with(|| { - assert_eq!( - basilisk_runtime::Tokens::free_balance(KAR, &AccountId::from(BOB)), - 95000000000000 - fees - ); - let received = 4969548790553; - assert_eq!( - basilisk_runtime::Tokens::free_balance(KSM, &AccountId::from(BOB)), - received - ); - assert_eq!( - basilisk_runtime::Tokens::free_balance(KAR, &basilisk_runtime::Treasury::account_id()), - fees - ); - }); -} - fn register_kar() { assert_ok!(basilisk_runtime::AssetRegistry::register( basilisk_runtime::RuntimeOrigin::root(), diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index 1fce0f33e5..cdbcdaeb85 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -61,7 +61,7 @@ use sp_runtime::{traits::AccountIdConversion, BuildStorage, Digest, DigestItem}; use primitives::constants::chain::CORE_ASSET_ID; pub use xcm_emulator::Network; -use xcm_emulator::{decl_test_networks, decl_test_parachains, decl_test_relay_chains, Parachain, TestExt}; +use xcm_emulator::{decl_test_networks, decl_test_parachains, decl_test_relay_chains}; pub type Rococo = RococoRelayChain; pub type Basilisk = BasiliskParachain; @@ -531,10 +531,10 @@ pub fn initialize_rococo_block(target_block: BlockNumber, target_slot: Slot) { logs: vec![DigestItem::PreRuntime( BABE_ENGINE_ID, PreDigest::SecondaryPlain( - (SecondaryPlainPreDigest { + SecondaryPlainPreDigest { authority_index, slot: target_slot, - }), + }, ) .encode(), )], diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 1a05d15f31..7ae33ebae0 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -2,7 +2,6 @@ // Disable the integration tests when this feature is enabled. #![cfg(not(feature = "runtime-benchmarks"))] mod call_filter; -mod cross_chain_transfer; mod exchange_asset; mod fees; mod kusama_test_net; From 47668727512ae3975b46412571a3c7b88a2fda2a Mon Sep 17 00:00:00 2001 From: vgantchev Date: Thu, 24 Oct 2024 20:26:22 +0200 Subject: [PATCH 19/24] fmt --- integration-tests/src/kusama_test_net.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index cdbcdaeb85..f1ca79dfaf 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -530,12 +530,10 @@ pub fn initialize_rococo_block(target_block: BlockNumber, target_slot: Slot) { &Digest { logs: vec![DigestItem::PreRuntime( BABE_ENGINE_ID, - PreDigest::SecondaryPlain( - SecondaryPlainPreDigest { - authority_index, - slot: target_slot, - }, - ) + PreDigest::SecondaryPlain(SecondaryPlainPreDigest { + authority_index, + slot: target_slot, + }) .encode(), )], }, From ce92f885849c69ae320aae72b2e456af50837d82 Mon Sep 17 00:00:00 2001 From: vgantchev Date: Fri, 25 Oct 2024 12:30:02 +0200 Subject: [PATCH 20/24] clippy --- Cargo.lock | 8 ++++---- pallets/asset-registry/Cargo.toml | 2 +- pallets/asset-registry/src/lib.rs | 3 ++- pallets/asset-registry/src/migration.rs | 1 - 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef83566a3c..04b678e4f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1004,7 +1004,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", - "pallet-asset-registry 2.3.4", + "pallet-asset-registry 2.3.5", "pallet-aura", "pallet-authorship", "pallet-balances", @@ -6938,7 +6938,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" -version = "2.3.4" +version = "2.3.5" dependencies = [ "frame-benchmarking", "frame-support", @@ -8599,7 +8599,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "pallet-asset-registry 2.3.4", + "pallet-asset-registry 2.3.5", "pallet-balances", "pallet-duster", "pallet-liquidity-mining", @@ -11207,7 +11207,7 @@ dependencies = [ "orml-xcm", "orml-xcm-support", "orml-xtokens", - "pallet-asset-registry 2.3.4", + "pallet-asset-registry 2.3.5", "pallet-aura", "pallet-authorship", "pallet-balances", diff --git a/pallets/asset-registry/Cargo.toml b/pallets/asset-registry/Cargo.toml index 129291b88f..0978d899a8 100644 --- a/pallets/asset-registry/Cargo.toml +++ b/pallets/asset-registry/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-asset-registry" -version = "2.3.4" +version = "2.3.5" description = "Pallet for asset registry management" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index 5a1b644593..cd9a75bbf8 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -108,7 +108,8 @@ pub mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); - #[pallet::hooks] + #[allow(clippy::manual_inspect)] + #[pallet::hooks] impl Hooks> for Pallet {} #[pallet::error] diff --git a/pallets/asset-registry/src/migration.rs b/pallets/asset-registry/src/migration.rs index 26fc5986d5..458eef1de4 100644 --- a/pallets/asset-registry/src/migration.rs +++ b/pallets/asset-registry/src/migration.rs @@ -21,7 +21,6 @@ use frame_support::{ weights::Weight, }; -/// pub mod v1 { use super::*; use codec::{Decode, Encode}; From a8b7c07007cfcd133ec5694750570228ab3cdd12 Mon Sep 17 00:00:00 2001 From: vgantchev Date: Fri, 25 Oct 2024 12:31:36 +0200 Subject: [PATCH 21/24] fmt --- pallets/asset-registry/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index cd9a75bbf8..21efec04a4 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -109,7 +109,7 @@ pub mod pallet { pub struct Pallet(_); #[allow(clippy::manual_inspect)] - #[pallet::hooks] + #[pallet::hooks] impl Hooks> for Pallet {} #[pallet::error] From fd87fe9545a8244e1b93f0bef0f055360b93d0ff Mon Sep 17 00:00:00 2001 From: vgantchev Date: Fri, 25 Oct 2024 13:14:03 +0200 Subject: [PATCH 22/24] fix zombienet RC chainspec --- launch-configs/zombienet/local.json | 9 +++--- node/src/chain_spec/mod.rs | 47 ++++++++++++----------------- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/launch-configs/zombienet/local.json b/launch-configs/zombienet/local.json index 71567ca663..e6888f2985 100644 --- a/launch-configs/zombienet/local.json +++ b/launch-configs/zombienet/local.json @@ -15,11 +15,10 @@ "patch": { "configuration": { "config": { - "scheduling_lookahead": 2, - "async_backing_params": { - "max_candidate_depth": 3, - "allowed_ancestry_len": 2 - } + "async_backing_params": { + "max_candidate_depth": 3, + "allowed_ancestry_len": 2 + } } } } diff --git a/node/src/chain_spec/mod.rs b/node/src/chain_spec/mod.rs index f68794a008..6db1dedbab 100644 --- a/node/src/chain_spec/mod.rs +++ b/node/src/chain_spec/mod.rs @@ -106,7 +106,7 @@ pub fn parachain_genesis( }) .collect::>(), }, - "assetRegistry": { + "assetRegistry": { "registeredAssets": registered_assets.clone(), "nativeAssetName": TOKEN_SYMBOL.as_bytes().to_vec(), "nativeExistentialDeposit": NATIVE_EXISTENTIAL_DEPOSIT, @@ -114,36 +114,34 @@ pub fn parachain_genesis( "aura": { "authorities": Vec::::new() }, - "auraExt": { + "auraExt": {}, + "balances": { + "balances": endowed_accounts + .iter() + .cloned() + .map(|k| (k.0.clone(), k.1 * UNITS)) + .collect::>(), }, - "balances": { - "balances": endowed_accounts - .iter() - .cloned() - .map(|k| (k.0.clone(), k.1 * UNITS)) - .collect::>(), - }, "collatorSelection": { "invulnerables": initial_authorities.0.iter().cloned().map(|(acc, _)| acc).collect::>(), "candidacyBond": initial_authorities.1, "desiredCandidates": 0u32, }, - "duster": { - "accountBlacklist": vec![get_account_id_from_seed::("Duster")], + "duster": { + "accountBlacklist": vec![get_account_id_from_seed::("Duster")], "rewardAccount": Some(get_account_id_from_seed::("Duster")), "dustAccount": Some(get_account_id_from_seed::("Duster")) }, - "emaOracle": { + "emaOracle": { }, - "multiTransactionPayment": { + "multiTransactionPayment": { "currencies": accepted_assets, "accountCurrencies": Vec::<(AccountId, AssetId)>::new(), }, - "parachainInfo": { - "parachainId": parachain_id, - }, - "polkadotXcm": { + "parachainInfo": { + "parachainId": parachain_id, }, + "polkadotXcm": {}, "technicalCommittee": { "members": tech_committee_members, }, @@ -161,14 +159,9 @@ pub fn parachain_genesis( .collect::>() }, }, - "treasury": { - }, - "vesting": { - }, - "xykWarehouseLm": { - }, - "xykLiquidityMining": { - }, - } - ) + "treasury": {}, + "vesting": {}, + "xykWarehouseLm": {}, + "xykLiquidityMining": {}, + }) } From 8cde540e07d6079f514e89ad49c61256c1fd3e02 Mon Sep 17 00:00:00 2001 From: vgantchev Date: Fri, 25 Oct 2024 15:52:30 +0200 Subject: [PATCH 23/24] clippy --- integration-tests/src/exchange_asset.rs | 27 ------------------------ integration-tests/src/kusama_test_net.rs | 15 +------------ pallets/asset-registry/src/mock.rs | 2 -- runtime/basilisk/src/governance/mod.rs | 2 +- 4 files changed, 2 insertions(+), 44 deletions(-) diff --git a/integration-tests/src/exchange_asset.rs b/integration-tests/src/exchange_asset.rs index 3e25289f9e..762fa3aa44 100644 --- a/integration-tests/src/exchange_asset.rs +++ b/integration-tests/src/exchange_asset.rs @@ -1,14 +1,10 @@ #![cfg(test)] use crate::kusama_test_net::*; -use basilisk_runtime::Currencies; use basilisk_runtime::RuntimeOrigin; use basilisk_runtime::XYK; use frame_support::dispatch::GetDispatchInfo; use frame_support::{assert_ok, pallet_prelude::*}; -use hydradx_traits::router::AssetPair; -use hydradx_traits::router::PoolType; -use hydradx_traits::router::Trade; use orml_traits::currency::MultiCurrency; use polkadot_xcm::{ opaque::v3::{Junction, Junctions::X2, MultiLocation}, @@ -288,26 +284,3 @@ fn create_xyk_pool(asset_a: u32, asset_b: u32) { 50 * UNITS, )); } - -fn create_xyk_pool_with_amounts(asset_a: u32, amount_a: u128, asset_b: u32, amount_b: u128) { - assert_ok!(Currencies::update_balance( - RuntimeOrigin::root(), - DAVE.into(), - asset_a, - amount_a as i128, - )); - - assert_ok!(Currencies::update_balance( - RuntimeOrigin::root(), - DAVE.into(), - asset_b, - amount_b as i128, - )); - assert_ok!(XYK::create_pool( - RuntimeOrigin::signed(DAVE.into()), - asset_a, - amount_a, - asset_b, - amount_b, - )); -} diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index f1ca79dfaf..35111d42b0 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -63,7 +63,6 @@ use primitives::constants::chain::CORE_ASSET_ID; pub use xcm_emulator::Network; use xcm_emulator::{decl_test_networks, decl_test_parachains, decl_test_relay_chains}; -pub type Rococo = RococoRelayChain; pub type Basilisk = BasiliskParachain; pub type OtherParachain = OtherPara; @@ -483,18 +482,6 @@ pub fn expect_basilisk_events(e: Vec) { assert_eq!(last_basilisk_events(e.len()), e); } -pub fn expect_basilisk_event(e: basilisk_runtime::RuntimeEvent) { - let last_10_events = last_basilisk_events(10); - let mut found = false; - for event in last_10_events { - if event == e { - found = true; - break; - } - } - assert!(found, "Event not found in the last 10 basilisk events"); -} - #[allow(dead_code)] pub fn last_parachain_events(n: usize) -> Vec { frame_system::Pallet::::events() @@ -716,7 +703,7 @@ pub fn set_para_slot_info(number: u64) { // )); frame_support::storage::unhashed::put( &frame_support::storage::storage_prefix(b"AuraExt", b"SlotInfo"), - &((Slot::from(number), 0)), + &(Slot::from(number), 0), ); } diff --git a/pallets/asset-registry/src/mock.rs b/pallets/asset-registry/src/mock.rs index 72974e840f..6b914c501f 100644 --- a/pallets/asset-registry/src/mock.rs +++ b/pallets/asset-registry/src/mock.rs @@ -15,8 +15,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![cfg(test)] - use frame_support::parameter_types; use frame_system as system; use sp_core::H256; diff --git a/runtime/basilisk/src/governance/mod.rs b/runtime/basilisk/src/governance/mod.rs index 4ab8562145..5e3ecb8570 100644 --- a/runtime/basilisk/src/governance/mod.rs +++ b/runtime/basilisk/src/governance/mod.rs @@ -77,7 +77,7 @@ impl pallet_conviction_voting::Config for Runtime { } parameter_types! { - pub const MaxBalance: Balance = Balance::max_value(); + pub const MaxBalance: Balance = Balance::MAX; } pub type TreasurySpender = EitherOf, Spender>; From da8ca579f2a300e2fc2e5945579d645672f7dbc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20P=C3=A1nik?= Date: Sat, 26 Oct 2024 16:23:36 +0200 Subject: [PATCH 24/24] revert rust version increse --- pallets/asset-registry/src/lib.rs | 1 - rust-toolchain | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index 21efec04a4..5a1b644593 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -108,7 +108,6 @@ pub mod pallet { #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); - #[allow(clippy::manual_inspect)] #[pallet::hooks] impl Hooks> for Pallet {} diff --git a/rust-toolchain b/rust-toolchain index 8cf8846114..47a114dc5e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,5 +1,5 @@ [toolchain] -channel = "1.82.0" +channel = "1.77.0" components = [ "rustfmt", "clippy", "rust-src" ] targets = [ "wasm32-unknown-unknown" ] profile = "minimal"