ismp-parachain

ismp-parachain contains an implementation of the parachain consensus client for ISMP. Since parachains get their consensus from the relay chain, ismp-parachain simply uses the relay chain as consensus oracle for other parachain headers. By reading the relay chain state, it is able obtain finality guarantees of parachain headers, due to the availability & backing subsystems of the parachain protocol.
The pallet itself stores a whitelist of parachains whose headers that should be read from the relay chain by it’s inherent provider, Allowing easier interoperability with those parachains. Worth noting is that ut’s entirely possible to still relay headers for parachain that are not in this whitelist through an external relayer.

Adding it to your runtime

To add ismp-parachain to the runtime, add the following code snippet to your runtime’s lib.rs
rust
impl ismp_parachain::Config for Runtime { type RuntimeEvent = RuntimeEvent; } // For A Sample runtime construct_runtime!( pub enum Runtime where Block = Block, NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic, { /* --snip-- */ IsmpParachain: ismp_parachain, } );

Adding it to your ConsensusClientProvider

Now that you have added the pallet to your runtime, it’s time to integrate it with pallet-ismp's ConsensusClientProvider. This allows your parachain to communicate with other parachains by verifying the consensus proofs for parachain headers.
rust
use ismp::{ consensus::{ConsensusClient, ConsensusClientId, StateMachineId}, error::Error, host::StateMachine, router::{Request, Response}, }; use ismp_parachain::consensus::ParachainConsensusClient; pub struct ConsensusProvider; impl ConsensusClientProvider for ConsensusProvider { fn consensus_client(id: ConsensusClientId) -> Result<Box<dyn ConsensusClient>, Error> { let client = match id { ismp_parachain::consensus::PARACHAIN_CONSENSUS_ID => { Box::new(ParachainConsensusClient::<Runtime, IsmpParachain>::default()) } _ => Err(Error::ImplementationSpecific("Unknown consensus client".into()))?, }; Ok(client) } }

ismp-parachain-inherent

The inherent provider is responsible for automatically including consensus proofs for the whitelisted parachains at every block. This removes the need for a dedicated relayer for parachain consensus proofs.
Find the build_consensus function in your collator’s service.rs file and add the following code to the create_inherent_data_providers closure of the BuildAuraConsensusParams struct.
rust
create_inherent_data_providers: move |_, (relay_parent, validation_data)| { let relay_chain_interface = relay_chain_interface.clone(); let client = client_clone.clone(); async move { /* --snip-- */ let consensus_inherent = ismp_parachain_inherent::ConsensusInherentProvider::create( client.clone(), relay_parent, &relay_chain_interface, validation_data, ) .await?; Ok((slot, timestamp, parachain_inherent, consensus_inherent)) } },

Runtime Api

The pallet provides a runtime api that is required by the inherent provider. Find the impl_runtime_apis! line in your runtime’s lib.rs file and add the following code:
rust
impl ismp_parachain_runtime_api::IsmpParachainApi<Block> for Runtime { fn para_ids() -> Vec<u32> { IsmpParachain::para_ids() } }
And that’s it, you are all set.

Calls

To make changes to the parachain whitelist , the pallet provides two calls:
add_parachains(para_ids: Vec<u32>) :
This call adds the new parachains to the whitelist. This requires the admin origin that was configured in pallet-ismp
remove_parachains(para_ids: Vec<u32>) :
This call removes the parachains from the whitelist. This requires the admin origin that was configured in pallet-ismp