-
Notifications
You must be signed in to change notification settings - Fork 357
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
Custom proof specs in config #1574
Changes from 17 commits
d15f6a2
bd9ff26
6750982
ee32e66
f0fd102
67c8991
623e766
d55f57c
f98cf85
2c109ed
3873c11
c7aaa03
e4b8ea3
4ab7308
0822feb
1803828
9347949
0b9a709
a72ab39
12a46a4
a229708
450992f
9ab79a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Allow custom proof-specs in chain config | ||
([#1561](https://github.com/informalsystems/ibc-rs/issues/1561)) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
use crate::prelude::*; | ||
use ibc_proto::ics23::ProofSpec as ProtoProofSpec; | ||
use ics23::ProofSpec; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just FYI, with regard to #853 - this file (i.e. |
||
use serde::{Deserialize, Serialize}; | ||
|
||
/// An array of proof specifications. | ||
/// | ||
|
@@ -9,19 +10,23 @@ use ics23::ProofSpec; | |
/// Additionally, this type also aids in the conversion from `ProofSpec` types from crate `ics23` | ||
/// into proof specifications as represented in the `ibc_proto` type; see the | ||
/// `From` trait(s) below. | ||
pub struct ProofSpecs { | ||
specs: Vec<ProofSpec>, | ||
} | ||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct ProofSpecs(Vec<ProtoProofSpec>); | ||
|
||
impl ProofSpecs { | ||
/// Returns the specification for Cosmos-SDK proofs | ||
pub fn cosmos() -> Self { | ||
Self { | ||
specs: vec![ | ||
ics23::iavl_spec(), // Format of proofs-iavl (iavl merkle proofs) | ||
ics23::tendermint_spec(), // Format of proofs-tendermint (crypto/ merkle SimpleProof) | ||
], | ||
} | ||
vec![ | ||
ics23::iavl_spec(), // Format of proofs-iavl (iavl merkle proofs) | ||
ics23::tendermint_spec(), // Format of proofs-tendermint (crypto/ merkle SimpleProof) | ||
] | ||
.into() | ||
} | ||
} | ||
|
||
impl Default for ProofSpecs { | ||
fn default() -> Self { | ||
Self::cosmos() | ||
} | ||
} | ||
|
||
|
@@ -31,7 +36,7 @@ impl ProofSpecs { | |
impl From<ProofSpecs> for Vec<ProtoProofSpec> { | ||
fn from(domain_specs: ProofSpecs) -> Self { | ||
let mut raw_specs = Vec::new(); | ||
for ds in domain_specs.specs.iter() { | ||
for ds in domain_specs.0.iter() { | ||
// Both `ProofSpec` types implement trait `prost::Message`. Convert by encoding, then | ||
// decoding into the destination type. | ||
// Safety note: the source and target data structures are identical, hence the | ||
|
@@ -44,3 +49,26 @@ impl From<ProofSpecs> for Vec<ProtoProofSpec> { | |
raw_specs | ||
} | ||
} | ||
|
||
impl From<Vec<ProofSpec>> for ProofSpecs { | ||
fn from(proto_specs: Vec<ProofSpec>) -> Self { | ||
let mut specs = Vec::new(); | ||
for ds in proto_specs { | ||
// Both `ProofSpec` types implement trait `prost::Message`. Convert by encoding, then | ||
romac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// decoding into the destination type. | ||
// Safety note: the source and target data structures are identical, hence the | ||
// encode/decode conversion here should be infallible. | ||
let mut encoded = Vec::new(); | ||
prost::Message::encode(&ds, &mut encoded).unwrap(); | ||
let decoded: ProtoProofSpec = prost::Message::decode(&*encoded).unwrap(); | ||
specs.push(decoded); | ||
} | ||
Self(specs) | ||
} | ||
} | ||
|
||
impl From<Vec<ProtoProofSpec>> for ProofSpecs { | ||
fn from(specs: Vec<ProtoProofSpec>) -> Self { | ||
Self(specs) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,4 +173,4 @@ fn checkout_tag(repo: &Repository, tag_name: &str) -> Result<(), git2::Error> { | |
} | ||
|
||
Ok(()) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more operator-friendly manner to specify this? I tried to give an alternative suggestion in #1630 .