Open NachoPal opened 10 months ago
Picking this up
@0xmovses Ok, I had something in mind already.
The idea is to expand decl_test_relay_chains
and decl_test_parachains
adding on_initialize
and on_finalize
attributes. And probably to rename on_init
to on_genesis
as it could now be confused with on_initialize
. Something like this:
decl_test_parachains! {
pub struct AssetHub {
genesis = genesis(),
on_genesis = {
asset_hub_kusama_runtime::AuraExt::on_initialize(1);
},
runtime = asset_hub_kusama_runtime,
core = {
XcmpMessageHandler: asset_hub_kusama_runtime::XcmpQueue,
DmpMessageHandler: asset_hub_kusama_runtime::DmpQueue,
LocationToAccountId: asset_hub_kusama_runtime::xcm_config::LocationToAccountId,
ParachainInfo: asset_hub_kusama_runtime::ParachainInfo,
},
pallets = {
PolkadotXcm: asset_hub_kusama_runtime::PolkadotXcm,
Assets: asset_hub_kusama_runtime::Assets,
ForeignAssets: asset_hub_kusama_runtime::ForeignAssets,
PoolAssets: asset_hub_kusama_runtime::PoolAssets,
AssetConversion: asset_hub_kusama_runtime::AssetConversion,
Balances: asset_hub_kusama_runtime::Balances,
},
on_initialize = // Accepts a function that is expecting `BlockNumber` as argument
on_finalize = // Accepts a function that is expecting `BlockNumber` as argument,
},
}
Maybe just init
instead of on_genesis
. I am not fully convinced about the naming.
Actually on_initialize
and on_finalize
should be a function that is expecting a BlockNumber
only an argument.
Inside the function, individual calls to each selected pallets on_initialize/on_finalize
calls would be added.
For Parachains BlockNumber
is coming from:
parachains_common::BlockNumber;
For RelayChains BlockNumber
is coming from:cumulus_primitives_core::relay_chain::{BlockNumber as RelayBlockNumber}
The block numbers can be queried in xcm-emulator
. It would be something like:
<Self as $crate::Chain>::System::block_number();
(for Parachain)N::relay_block_number()
(for RelayChain)Hey, I would like to pick up on this issue for a reason:
For Parachains BlockNumber is coming from: parachains_common::BlockNumber;
This represents a problem for parachains that use a different type for block numbers, e.g. a u64
. We cannot update to Polkadot SDK 1.1 because of this issue that leads to compilation errors for XCM Emulator. BlockNumber
should be taken from the implementation of the frame_system
pallet rather. Should I open a different issue for it?
More info here: https://github.com/paritytech/cumulus/issues/2734