ismp-grandpa

In order to facilitate interoperability with so-called “standalone” substrate-based chains with their own consensus. We’ve built a consensus client for the GRANDPA algorithm. This means that solochains are not just fully interoperable with each other, but also parachains as well.

Adding it to your runtime

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

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 solochain to communicate with other solochains or parachains.
rust
use ismp::{ consensus::{ConsensusClient, ConsensusClientId, StateMachineId}, error::Error, host::StateMachine, router::{Request, Response}, }; use ismp_grandpa::consensus::GrandpaConsensusClient; pub struct ConsensusProvider; impl ConsensusClientProvider for ConsensusProvider { fn consensus_client(id: ConsensusClientId) -> Result<Box<dyn ConsensusClient>, Error> { let client = match id { ismp_grandpa::consensus::GRANDPA_CONSENSUS_ID => { Box::new(GrandpaConsensusClient::<Runtime>::default()) } _ => Err(Error::ImplementationSpecific("Unknown consensus client".into()))?, }; Ok(client) } }

Calls

Since ismp-granpda can be used to track the consensus proofs of a relay chain, eg Polkadot or Kusama, We allow for configuring the parachain headers you’re interested in on this relay chain through a set of calls.
add_parachains(consensus_state_id: Vec<u8>, 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(consensus_state_id: Vec<u8>, para_ids: Vec<u32>) :
This call removes the parachains from the whitelist. This requires the admin origin that was configured in pallet-ismp