Skip to content

Commit 9617c1c

Browse files
committed
assethub separate runtime
1 parent 69e93e6 commit 9617c1c

File tree

12 files changed

+471
-656
lines changed

12 files changed

+471
-656
lines changed

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.

Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,4 @@ features = ["derive"]
366366

367367
[workspace.dependencies.reconnecting-jsonrpsee-ws-client]
368368
version = "0.5.0"
369-
default-features = false
370-
371-
372-
[patch.crates-io]
373-
staging-xcm-builder = { path = "vendor/staging-xcm-builder" }
369+
default-features = false

modules/pallets/testsuite/src/asset_hub_runtime.rs

Lines changed: 60 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,31 @@
1616

1717
extern crate alloc;
1818
use polkadot_sdk::{frame_support::traits::WithdrawReasons, sp_runtime::traits::ConvertInto, *};
19-
use polkadot_sdk::sp_runtime::traits::AccountIdConversion;
2019

21-
use alloc::collections::BTreeMap;
2220
use cumulus_pallet_parachain_system::ParachainSetCode;
2321
use frame_support::{
24-
derive_impl, parameter_types,
25-
traits::{ConstU32, ConstU64, Get},
26-
PalletId,
22+
derive_impl, parameter_types,
23+
traits::{ConstU32, ConstU64, Get},
24+
PalletId,
2725
};
2826
use frame_system::{EnsureRoot, EnsureSigned, EventRecord};
29-
use ismp::{
30-
consensus::{
31-
ConsensusClient, ConsensusClientId, StateCommitment, StateMachineClient,
32-
StateMachineHeight, StateMachineId, VerifiedCommitments,
33-
},
34-
error::Error as IsmpError,
35-
handlers,
36-
host::{IsmpHost, StateMachine},
37-
messaging::{CreateConsensusState, Proof, StateCommitmentHeight},
38-
module::IsmpModule,
39-
router::{IsmpRouter, PostRequest, RequestResponse, Response, Timeout},
40-
Error,
41-
};
42-
use ismp_sync_committee::constants::sepolia::Sepolia;
43-
use pallet_ismp::{offchain::Leaf, ModuleId};
44-
use pallet_token_governor::GatewayParams;
4527
use polkadot_sdk::{
46-
pallet_session::{disabling::UpToLimitDisablingStrategy, SessionHandler},
47-
sp_runtime::{app_crypto::AppCrypto, traits::OpaqueKeys},
48-
xcm_simulator::{GeneralIndex, Junctions::X3, Location, PalletInstance, Parachain},
28+
pallet_session::{disabling::UpToLimitDisablingStrategy, SessionHandler},
29+
sp_runtime::{app_crypto::AppCrypto, traits::OpaqueKeys},
30+
xcm_simulator::{GeneralIndex, Junctions::X3, Location, PalletInstance, Parachain},
4931
};
5032
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
5133
use sp_core::{
52-
offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWorkerExt},
53-
H160, H256, U256,
34+
offchain::{testing::TestOffchainExt, OffchainDbExt, OffchainWorkerExt},
35+
H160, H256, U256,
5436
};
5537
use sp_runtime::{
56-
traits::{IdentityLookup, Keccak256},
57-
AccountId32, BuildStorage,
38+
traits::{IdentityLookup, Keccak256},
39+
AccountId32, BuildStorage,
5840
};
5941

6042
use crate::asset_hub_runtime::sp_runtime::DispatchError;
61-
use hyperbridge_client_machine::HyperbridgeClientMachine;
62-
use pallet_messaging_fees::types::PriceOracle;
6343
use pallet_xcm_gateway::xcm_utilities::ASSET_HUB_PARA_ID;
64-
use substrate_state_machine::SubstrateStateMachine;
6544
use xcm_simulator::mock_message_queue;
6645
pub const ALICE: AccountId32 = AccountId32::new([1; 32]);
6746
pub const BOB: AccountId32 = AccountId32::new([2; 32]);
@@ -78,36 +57,25 @@ frame_support::construct_runtime!(
7857
System: frame_system,
7958
ParachainSystem: cumulus_pallet_parachain_system,
8059
ParachainInfo: staging_parachain_info,
81-
Timestamp: pallet_timestamp,
8260
Balances: pallet_balances,
8361
XcmpQueue: cumulus_pallet_xcmp_queue,
8462
MessageQueue: pallet_message_queue,
8563
PalletXcm: pallet_xcm,
8664
Assets: pallet_assets,
87-
Sudo: pallet_sudo,
88-
Vesting: pallet_vesting,
8965
MsgQueue: mock_message_queue
9066
}
9167
);
9268

9369
/// Verify the the last event emitted
9470
pub fn assert_last_event<T: frame_system::Config>(generic_event: T::RuntimeEvent) {
95-
assert_eq!(last_event::<T>(), generic_event);
71+
assert_eq!(last_event::<T>(), generic_event);
9672
}
9773

9874
/// Verify the the last event emitted
9975
pub fn last_event<T: frame_system::Config>() -> T::RuntimeEvent {
100-
let events = frame_system::Pallet::<T>::events();
101-
let EventRecord { event, .. } = &events[events.len() - 1];
102-
event.clone()
103-
}
104-
105-
pub struct StateMachineProvider;
106-
107-
impl Get<StateMachine> for StateMachineProvider {
108-
fn get() -> StateMachine {
109-
StateMachine::Kusama(100)
110-
}
76+
let events = frame_system::Pallet::<T>::events();
77+
let EventRecord { event, .. } = &events[events.len() - 1];
78+
event.clone()
11179
}
11280

11381
/// Balance of an account.
@@ -125,166 +93,72 @@ parameter_types! {
12593
}
12694

12795
impl pallet_balances::Config for AssetHubTest {
128-
/// The ubiquitous event type.
129-
type RuntimeEvent = RuntimeEvent;
130-
type RuntimeHoldReason = RuntimeHoldReason;
131-
type RuntimeFreezeReason = RuntimeFreezeReason;
132-
type WeightInfo = pallet_balances::weights::SubstrateWeight<AssetHubTest>;
133-
/// The type for recording an account's balance.
134-
type Balance = Balance;
135-
type DustRemoval = ();
136-
type ExistentialDeposit = ExistentialDeposit;
137-
type AccountStore = System;
138-
type ReserveIdentifier = [u8; 8];
139-
type FreezeIdentifier = ();
140-
type MaxLocks = ConstU32<50>;
141-
type MaxReserves = ConstU32<50>;
142-
type MaxFreezes = ();
143-
type DoneSlashHandler = ();
144-
}
145-
146-
147-
148-
impl pallet_sudo::Config for AssetHubTest {
149-
type RuntimeEvent = RuntimeEvent;
150-
type RuntimeCall = RuntimeCall;
151-
type WeightInfo = ();
96+
/// The ubiquitous event type.
97+
type RuntimeEvent = RuntimeEvent;
98+
type RuntimeHoldReason = RuntimeHoldReason;
99+
type RuntimeFreezeReason = RuntimeFreezeReason;
100+
type WeightInfo = pallet_balances::weights::SubstrateWeight<AssetHubTest>;
101+
/// The type for recording an account's balance.
102+
type Balance = Balance;
103+
type DustRemoval = ();
104+
type ExistentialDeposit = ExistentialDeposit;
105+
type AccountStore = System;
106+
type ReserveIdentifier = [u8; 8];
107+
type FreezeIdentifier = ();
108+
type MaxLocks = ConstU32<50>;
109+
type MaxReserves = ConstU32<50>;
110+
type MaxFreezes = ();
111+
type DoneSlashHandler = ();
152112
}
153113

154114
#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)]
155115
impl frame_system::Config for AssetHubTest {
156-
type BaseCallFilter = frame_support::traits::Everything;
157-
type RuntimeOrigin = RuntimeOrigin;
158-
type RuntimeCall = RuntimeCall;
159-
type Hash = H256;
160-
type Hashing = Keccak256;
161-
type AccountId = AccountId32;
162-
type Lookup = IdentityLookup<Self::AccountId>;
163-
type RuntimeEvent = RuntimeEvent;
164-
type BlockHashCount = ConstU64<250>;
165-
type DbWeight = ();
166-
type BlockWeights = ();
167-
type RuntimeTask = ();
168-
type BlockLength = ();
169-
type Version = ();
170-
type Nonce = u64;
171-
type Block = Block;
172-
type PalletInfo = PalletInfo;
173-
type AccountData = pallet_balances::AccountData<Balance>;
174-
type OnNewAccount = ();
175-
type OnKilledAccount = ();
176-
type SystemWeightInfo = ();
177-
type SS58Prefix = ();
178-
type OnSetCode = ParachainSetCode<AssetHubTest>;
179-
type MaxConsumers = ConstU32<16>;
180-
}
181-
182-
impl pallet_timestamp::Config for AssetHubTest {
183-
type Moment = u64;
184-
type OnTimestampSet = ();
185-
type MinimumPeriod = ConstU64<1>;
186-
type WeightInfo = ();
116+
type BaseCallFilter = frame_support::traits::Everything;
117+
type RuntimeOrigin = RuntimeOrigin;
118+
type RuntimeCall = RuntimeCall;
119+
type Hash = H256;
120+
type Hashing = Keccak256;
121+
type AccountId = AccountId32;
122+
type Lookup = IdentityLookup<Self::AccountId>;
123+
type RuntimeEvent = RuntimeEvent;
124+
type BlockHashCount = ConstU64<250>;
125+
type DbWeight = ();
126+
type BlockWeights = ();
127+
type RuntimeTask = ();
128+
type BlockLength = ();
129+
type Version = ();
130+
type Nonce = u64;
131+
type Block = Block;
132+
type PalletInfo = PalletInfo;
133+
type AccountData = pallet_balances::AccountData<Balance>;
134+
type OnNewAccount = ();
135+
type OnKilledAccount = ();
136+
type SystemWeightInfo = ();
137+
type SS58Prefix = ();
138+
type OnSetCode = ParachainSetCode<AssetHubTest>;
139+
type MaxConsumers = ConstU32<16>;
187140
}
188141

189-
parameter_types! {
190-
pub const Coprocessor: Option<StateMachine> = Some(StateMachine::Polkadot(3367));
191-
}
192-
193-
194-
195142
parameter_types! {
196143
pub const Decimals: u8 = 10;
197144
}
198145

199146
pub struct NativeAssetId;
200147

201148
impl Get<H256> for NativeAssetId {
202-
fn get() -> H256 {
203-
sp_io::hashing::keccak_256(b"BRIDGE").into()
204-
}
149+
fn get() -> H256 {
150+
sp_io::hashing::keccak_256(b"BRIDGE").into()
151+
}
205152
}
206153

207-
208-
209154
sp_runtime::impl_opaque_keys! {
210155
pub struct SessionKeys {
211156
pub aura: AuraId,
212157
}
213158
}
214159

215-
pub struct TestSessionHandler;
216-
impl SessionHandler<AccountId32> for TestSessionHandler {
217-
const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[AuraId::ID];
218-
219-
fn on_genesis_session<T: OpaqueKeys>(_validators: &[(AccountId32, T)]) {}
220-
221-
fn on_new_session<T: OpaqueKeys>(
222-
_changed: bool,
223-
_validators: &[(AccountId32, T)],
224-
_queued_validators: &[(AccountId32, T)],
225-
) {
226-
}
227-
228-
fn on_disabled(_validator_index: u32) {}
229-
230-
fn on_before_session_ending() {}
231-
}
232-
233-
234-
parameter_types! {
235-
pub const PotId: PalletId = PalletId(*b"PotStake");
236-
pub const MaxCandidates: u32 = 100;
237-
pub const MaxInvulnerables: u32 = 20;
238-
pub const DesiredCollators: u32 = 2;
239-
}
240-
241-
242-
243-
244-
245-
246-
parameter_types! {
247-
pub const TreasuryAccount: PalletId = PalletId(*b"treasury");
248-
}
249-
250-
pub struct MockPriceOracle;
251-
252-
impl PriceOracle for MockPriceOracle {
253-
fn get_bridge_price() -> Result<U256, DispatchError> {
254-
// return 0.05 with 18 decimals: 0.05 * 10^18
255-
Ok(U256::from(50_000_000_000_000_000u128))
256-
}
257-
}
258-
259-
parameter_types! {
260-
pub const MinVestedTransfer: u64 = 256 * 2;
261-
pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
262-
WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
263-
}
264-
265-
impl pallet_vesting::Config for AssetHubTest {
266-
type BlockNumberToBalance = ConvertInto;
267-
type Currency = Balances;
268-
type RuntimeEvent = RuntimeEvent;
269-
const MAX_VESTING_SCHEDULES: u32 = 3;
270-
type MinVestedTransfer = MinVestedTransfer;
271-
type WeightInfo = ();
272-
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
273-
type BlockNumberProvider = System;
274-
}
275-
276-
277-
pub fn set_timestamp<T: pallet_timestamp::Config>(value: u64)
278-
where
279-
<T as pallet_timestamp::Config>::Moment: From<u64>,
280-
{
281-
pallet_timestamp::Pallet::<T>::set_timestamp(value.into());
282-
}
283-
284-
285160
pub fn register_offchain_ext(ext: &mut sp_io::TestExternalities) {
286-
let (offchain, _offchain_state) = TestOffchainExt::with_offchain_db(ext.offchain_db());
287-
ext.register_extension(OffchainDbExt::new(offchain.clone()));
288-
ext.register_extension(OffchainWorkerExt::new(offchain));
161+
let (offchain, _offchain_state) = TestOffchainExt::with_offchain_db(ext.offchain_db());
162+
ext.register_extension(OffchainDbExt::new(offchain.clone()));
163+
ext.register_extension(OffchainWorkerExt::new(offchain));
289164
}
290-

0 commit comments

Comments
 (0)