Skip to content

Commit

Permalink
oak-audit: issue 1
Browse files Browse the repository at this point in the history
  • Loading branch information
kkast committed Mar 12, 2024
1 parent a276ead commit f34da1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions light-clients/ics10-grandpa/src/client_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ where
))
.into())
}
if header.finality_proof.unknown_headers.len() >= client_state.session_length() {
return Err(Error::Custom(format!(
"Number of unknown headers submitted exceeds max number of blocks in a session: max {}, got {}",
client_state.session_length(), header.finality_proof.unknown_headers.len()
))
.into())
}
let headers_with_finality_proof = ParachainHeadersWithFinalityProof {
finality_proof: header.finality_proof,
parachain_header: header.parachain_header,
Expand Down
8 changes: 8 additions & 0 deletions light-clients/ics10-grandpa/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ impl<H> ClientState<H> {
elapsed > self.relay_chain.trusting_period()
}

pub fn session_length(&self) -> usize {
match self.relay_chain {
RelayChain::Polkadot => 2400,
RelayChain::Kusama => 600,
RelayChain::Rococo => 600,
}
}

pub fn with_frozen_height(self, h: Height) -> Result<Self, Error> {
if h == Height::zero() {
return Err(Error::Custom(
Expand Down

0 comments on commit f34da1a

Please sign in to comment.