Skip to content

Commit 49862b3

Browse files
authored
ConsensusId configurable in pallet config (#311)
* ConsensusId configurable in pallet config * fix compilation
1 parent 7426070 commit 49862b3

8 files changed

Lines changed: 27 additions & 7 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/market/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ polkadot-sdk = { workspace = true, features = [
3737
"pallet-balances",
3838
], default-features = true }
3939
ismp = { workspace = true, default-features = false }
40+
ismp-parachain = { workspace = true, default-features = false }
4041
ismp-testsuite = { workspace = true }
4142

4243
[features]
@@ -50,6 +51,7 @@ std = [
5051
"scale-info/std",
5152
"pallet-regions/std",
5253
"ismp/std",
54+
"ismp-parachain/std",
5355
"polkadot-sdk/std",
5456
]
5557
try-runtime = [ "polkadot-sdk/try-runtime" ]

pallets/market/src/mock.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ use ismp::{
2222
host::StateMachine,
2323
router::PostResponse,
2424
};
25+
use ismp_parachain::PASEO_CONSENSUS_ID;
2526
use ismp_testsuite::mocks::Host;
2627
use pallet_regions::primitives::StateMachineHeightProvider;
2728
use polkadot_sdk::*;
2829
use sp_core::{ConstU64, H256};
2930
use sp_runtime::{
3031
traits::{BlakeTwo256, BlockNumberProvider, IdentityLookup},
31-
BuildStorage,
32+
BuildStorage, ConsensusEngineId,
3233
};
3334
use std::sync::Arc;
3435

@@ -125,6 +126,7 @@ impl<T: crate::Config> IsmpDispatcher for MockDispatcher<T> {
125126
parameter_types! {
126127
pub const CoretimeChain: StateMachine = StateMachine::Kusama(1005); // coretime-kusama
127128
pub const RegionsUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
129+
pub const ConsensusId: ConsensusEngineId = PASEO_CONSENSUS_ID;
128130
}
129131

130132
impl pallet_regions::Config for Test {
@@ -137,6 +139,7 @@ impl pallet_regions::Config for Test {
137139
type RCBlockNumberProvider = RelayBlockNumberProvider;
138140
type TimeslicePeriod = ConstU64<80>;
139141
type UnsignedPriority = RegionsUnsignedPriority;
142+
type ConsensusId = ConsensusId;
140143
type WeightInfo = ();
141144
}
142145

pallets/processor/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pallet-regions = { workspace = true, default-features = true }
4646
pallet-orders = { workspace = true, default-features = true }
4747

4848
ismp = { workspace = true, default-features = true }
49+
ismp-parachain = { workspace = true, default-features = false }
4950
ismp-testsuite = { workspace = true, default-features = true }
5051

5152
[features]
@@ -64,6 +65,7 @@ std = [
6465
"order-primitives/std",
6566
"region-primitives/std",
6667
"ismp/std",
68+
"ismp-parachain/std",
6769
"polkadot-sdk/std",
6870
]
6971
try-runtime = ["polkadot-sdk/try-runtime"]

pallets/processor/src/mock.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use ismp::{
3131
host::StateMachine,
3232
router::PostResponse,
3333
};
34+
use ismp_parachain::PASEO_CONSENSUS_ID;
3435
use ismp_testsuite::mocks::Host;
3536
use order_primitives::{OrderId, ParaId};
3637
use pallet_broker::RegionId;
@@ -41,7 +42,7 @@ use smallvec::smallvec;
4142
use sp_core::{ConstU64, H256};
4243
use sp_runtime::{
4344
traits::{BlakeTwo256, BlockNumberProvider, Convert, IdentityLookup},
44-
BuildStorage, DispatchResult, Perbill,
45+
BuildStorage, ConsensusEngineId, DispatchResult, Perbill,
4546
};
4647
use staging_xcm as xcm;
4748
use std::sync::Arc;
@@ -165,6 +166,7 @@ parameter_types! {
165166

166167
parameter_types! {
167168
pub static RelayBlockNumber: u64 = 0;
169+
pub const ConsensusId: ConsensusEngineId = PASEO_CONSENSUS_ID;
168170
}
169171

170172
pub struct RelayBlockNumberProvider;
@@ -185,6 +187,7 @@ impl pallet_regions::Config for Test {
185187
type UnsignedPriority = RegionsUnsignedPriority;
186188
type RCBlockNumberProvider = RelayBlockNumberProvider;
187189
type TimeslicePeriod = ConstU64<80>;
190+
type ConsensusId = ConsensusId;
188191
type WeightInfo = ();
189192
}
190193

pallets/regions/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use ismp::{
2626
module::IsmpModule,
2727
router::{PostRequest, Request, Response, StorageValue, Timeout},
2828
};
29-
use ismp_parachain::PASEO_CONSENSUS_ID;
3029
pub use pallet::*;
3130
use pallet_broker::{RegionId, Timeslice};
3231
use pallet_ismp::{weights::IsmpModuleWeight, ModuleId};
@@ -37,7 +36,7 @@ use scale_info::prelude::{format, vec, vec::Vec};
3736
use sp_core::H256;
3837
use sp_runtime::{
3938
traits::{BlockNumberProvider, Zero},
40-
SaturatedConversion,
39+
ConsensusEngineId, SaturatedConversion,
4140
};
4241

4342
#[cfg(test)]
@@ -137,6 +136,9 @@ pub mod pallet {
137136
#[pallet::constant]
138137
type UnsignedPriority: Get<TransactionPriority>;
139138

139+
#[pallet::constant]
140+
type ConsensusId: Get<ConsensusEngineId>;
141+
140142
/// Weight Info
141143
type WeightInfo: WeightInfo;
142144
}
@@ -345,7 +347,7 @@ pub mod pallet {
345347
let coretime_chain_height =
346348
T::StateMachineHeightProvider::latest_state_machine_height(StateMachineId {
347349
state_id: T::CoretimeChain::get(),
348-
consensus_state_id: PASEO_CONSENSUS_ID, // Is this used on Kusama?
350+
consensus_state_id: T::ConsensusId::get(),
349351
})
350352
.ok_or(Error::<T>::LatestHeightInaccessible)?;
351353

pallets/regions/src/mock.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
// You should have received a copy of the GNU General Public License
1414
// along with RegionX. If not, see <https://www.gnu.org/licenses/>.
1515

16-
use crate::{ismp_mock::MockDispatcher, StateMachineHeightProvider};
16+
use crate::{ismp_mock::MockDispatcher, ConsensusEngineId, StateMachineHeightProvider};
1717
use frame_support::{derive_impl, pallet_prelude::*, parameter_types, traits::Everything};
1818
use frame_system::{config_preludes::TestDefaultConfig, DefaultConfig};
1919
use ismp::{consensus::StateMachineId, host::StateMachine};
20+
use ismp_parachain::PASEO_CONSENSUS_ID;
2021
use polkadot_sdk::*;
2122
use sp_core::{ConstU64, H256};
2223
use sp_runtime::{
@@ -92,6 +93,7 @@ impl StateMachineHeightProvider for MockStateMachineHeightProvider {
9293

9394
parameter_types! {
9495
pub static RelayBlockNumber: u64 = 0;
96+
pub const ConsensusId: ConsensusEngineId = PASEO_CONSENSUS_ID;
9597
}
9698

9799
pub struct RelayBlockNumberProvider;
@@ -112,6 +114,7 @@ impl crate::Config for Test {
112114
type UnsignedPriority = RegionsUnsignedPriority;
113115
type RCBlockNumberProvider = RelayBlockNumberProvider;
114116
type TimeslicePeriod = ConstU64<80>;
117+
type ConsensusId = ConsensusId;
115118
type WeightInfo = ();
116119
}
117120

runtime/kusama/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ use frame_system::{
9393
limits::{BlockLength, BlockWeights},
9494
EnsureRoot,
9595
};
96+
use ismp_parachain::PASEO_CONSENSUS_ID;
9697
use pallet_ismp::offchain::{Leaf, Proof, ProofKeys};
9798
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
9899
use sp_core::H256;
99100
use sp_mmr_primitives::INDEXING_PREFIX;
100-
pub use sp_runtime::{MultiAddress, Perbill, Permill};
101+
pub use sp_runtime::{ConsensusEngineId, MultiAddress, Perbill, Permill};
101102
use xcm_config::XcmOriginToTransactDispatchOrigin;
102103

103104
#[cfg(any(feature = "std", test))]
@@ -541,6 +542,7 @@ impl StateMachineHeightProviderT for StateMachineHeightProvider {
541542
parameter_types! {
542543
pub const CoretimeChain: StateMachine = StateMachine::Kusama(CORETIME_CHAIN_PARA_ID); // coretime-kusama
543544
pub const RegionsUnsignedPriority: TransactionPriority = TransactionPriority::MAX;
545+
pub const ConsensusId: ConsensusEngineId = PASEO_CONSENSUS_ID;
544546
}
545547

546548
impl pallet_regions::Config for Runtime {
@@ -553,6 +555,7 @@ impl pallet_regions::Config for Runtime {
553555
type RCBlockNumberProvider = RelaychainDataProvider<Self>;
554556
type TimeslicePeriod = ConstU32<80>;
555557
type UnsignedPriority = RegionsUnsignedPriority;
558+
type ConsensusId = ConsensusId;
556559
type WeightInfo = weights::pallet_regions::WeightInfo<Runtime>;
557560
}
558561

0 commit comments

Comments
 (0)