Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(ibc-clients/tendermint): sanity check for proof_specs are skipped #1100

Closed
rnbguy opened this issue Feb 26, 2024 · 3 comments · Fixed by #1104
Closed

bug(ibc-clients/tendermint): sanity check for proof_specs are skipped #1100

rnbguy opened this issue Feb 26, 2024 · 3 comments · Fixed by #1104
Milestone

Comments

@rnbguy
Copy link
Collaborator

rnbguy commented Feb 26, 2024

Bug Summary

The proof_specs for tendermint client state should validate if they have min_depth <= max_depth.

Details

This is the current proof_specs validation.

if self.proof_specs.is_empty() {
return Err(Error::Validation {
reason: "ClientState proof-specs cannot be empty".to_string(),
});
}

There should be one more check that validates the above inequality. It is best to implement a validate method for ProofSpecs that includes all these checks and use it here.

pub fn validate(&self) -> bool {
  !self.0.is_empty() &&
  self.0.iter().all(|proof_spec| proof_spec.min_depth <= proof_spec.max_depth) 
}

Version

<= 0.50.0

@gr4yha7
Copy link
Contributor

gr4yha7 commented Feb 28, 2024

@rnbguy i can take this. One question though: what will be the new validation error reason?

@rnbguy
Copy link
Collaborator Author

rnbguy commented Feb 28, 2024

Thanks @gr4yha7 ! you can use

format!("Depth range in proof-specs cannot be empty: ({}, {})", proof_spec.min_depth, proof_spec.max_depth)

Note that my validate impl was a reference. Please implement it as following

fn validate(&self) -> Result<(), Error> {
  if self.0.is_empty() { return Err(...); }
  for proof_spec in &self.0 {
    if proof_spec.min_depth >  proof_spec.max_depth { return Err(...); } 
  }
  Ok(())
}

@gr4yha7
Copy link
Contributor

gr4yha7 commented Feb 29, 2024

@rnbguy I added a PR.

@github-project-automation github-project-automation bot moved this to 📥 To Do in ibc-rs Mar 12, 2024
@Farhad-Shabani Farhad-Shabani added this to the 0.51.0 milestone Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📥 To Do
3 participants