Skip to content

Commit

Permalink
ignore unknown parachains in ismp-parachain
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Sep 4, 2023
1 parent 5d0650d commit e5fc847
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions parachain/modules/consensus/parachain/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ where
let id = codec::Decode::decode(&mut &key[(key.len() - 4)..]).map_err(|e| {
Error::ImplementationSpecific(format!("Error decoding parachain header: {e}"))
})?;

if matches!(super::Parachains::<T>::get(id), None) {
Err(Error::ImplementationSpecific(format!("Unknown parachain with Id({id})")))?
}

let header = header.ok_or_else(|| {
Error::ImplementationSpecific(format!(
"Cannot find parachain header for ParaId({id})",
Expand All @@ -146,7 +151,7 @@ where
Error::ImplementationSpecific(format!("Cannot slot: {e:?}"))
})?;
timestamp = Duration::from_millis(*slot * SLOT_DURATION).as_secs();
}
},
DigestItem::Consensus(consensus_engine_id, value)
if *consensus_engine_id == ISMP_ID =>
{
Expand All @@ -157,9 +162,9 @@ where
}

overlay_root = H256::from_slice(&value);
}
},
// don't really care about the rest
_ => {}
_ => {},
};
}

Expand Down
2 changes: 2 additions & 0 deletions parachain/modules/consensus/parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ pub mod pallet {
}
}

pub use pallet::*;

impl<T: Config> Pallet<T> {
/// Returns the list of parachains who's consensus updates will be inserted by the inherent
/// data provider
Expand Down
1 change: 1 addition & 0 deletions parachain/modules/consensus/sync-committee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// Implementation of the ethereum beacon consensus client for ISMP
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(unused_variables)]

extern crate alloc;

Expand Down
6 changes: 3 additions & 3 deletions parachain/modules/state-machine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ where
let request = Request::Post(post);
let commitment = hash_request::<Host<T>>(&request);
keys.push(pallet_ismp::RequestReceipts::<T>::hashed_key_for(commitment));
}
},
Request::Get(_) => continue,
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ where
Ok((key, value))
})
.collect::<Result<BTreeMap<_, _>, _>>()?
}
},
HashAlgorithm::Blake2 => {
let db =
StorageProof::new(state_proof.storage_proof).into_memory_db::<BlakeTwo256>();
Expand All @@ -154,7 +154,7 @@ where
Ok((key, value))
})
.collect::<Result<BTreeMap<_, _>, _>>()?
}
},
};

Ok(data)
Expand Down

0 comments on commit e5fc847

Please sign in to comment.