Closed hu55a1n1 closed 1 year ago
pub enum Proofs {
ChannelOpenTry(ChannelOpenTryProof),
// ...
}
Bikeshedding:
Does this type mean "all proofs supplied with (necessary for?) this request"?
The variant names suggest that each case can be thought of a singular "proof", and in this case the enum should probably be named Proof
.
// or maybe this ->
pub struct SimpleProof(CommitmentProofBytes);
pub struct ComplexProof {
pub proof: CommitmentProofBytes,
pub consensus_proof: ConsensusProof,
// ...
}
pub enum Proofs {
ConnectionOpenTry(ComplexProof),
ChannelOpenTry(SimpleProof),
// ...
}
Could be, but then a convenience accessor may be needed to get at the commitment proof in all variants where it's available:
impl Proofs {
pub fn commitment(&self) -> Option<&CommitmentProofBytes> {
todo!()
}
}
If there may be benefit in type-checking the proof variants in particular places where only such a variant is meaningful, they each should get their own dedicated type, to be used instead of matching a dynamically multiplexed Proofs
value and asserting. This is similar to @hu55a1n1's suggestion for ics24_host::Path
For the remained tasks in this ticket, issues that still make sense are opened (#532, #534, #537). This is done as a pre-work before preparing the "Road to IBC-rs V1". @plafer Can you please recheck the list to make sure I didn't miss anything before closing the issue?
LGTM
Crate
ibc
Proposal
Following is a list of ideas for redesigning parts of our ibc-rs modules' API accompanied with some reasoning for why these changes are required. (Some of these have already been implemented in PR informalsystems/hermes#1583.) This is meant to serve as a meta issue for tracking these design changes. Might make sense to defer this until we start implementing another client (i.e.
substrate
, etc.) ->Proofs
struct into an enum. (See https://github.com/informalsystems/ibc-rs/pull/1583#discussion_r766923695)// to something like this -> pub enum Proofs { ChannelOpenTry(ChannelOpenTryProof), // ... }
// or maybe this -> pub struct SimpleProof(CommitmentProofBytes); pub struct ComplexProof { pub proof: CommitmentProofBytes, pub consensus_proof: ConsensusProof, // ... }
pub enum Proofs { ConnectionOpenTry(ComplexProof), ChannelOpenTry(SimpleProof), // ... }
ParamsReader
trait to allow users to get host genesis params likeMaxExpectedTimePerBlock
. Prefer composition over inheritance (where possible) ->&dyn
in trait methods.*Reader
trait methods must match API. e.g.ChannelReader::client_state()
is usually just a proxy toClientReader::client_state()
, so it doesn't make sense for it to return aChannelError
->*Reader
trait methods, so it might make sense to use inheritance here ->*Reader
contexts. (this may not be feasible due to methods likecheck_header_and_update_state()
requiring access toctx.next_consensus_state()
) The other extreme is to only give verification functions such contexts and allow them to extract everything they need them.[x]
ChannelReader::hash()
accepts input as (and returns) aString
.The method should ideally take a
Vec<u8>
as input and return aDigest
type that is fixed per client. So maybe something like ->Or maybe this should be part of
ClientReader
?CommitmentPrefix
andCommitmentProofBytes
, i.e. empty values for these types should not be constructible. (https://github.com/informalsystems/ibc-rs/pull/1761)unwrap()
s.ClientState
metadata (https://github.com/cosmos/ibc-go/blob/main/modules/light-clients/07-tendermint/types/client_state.go#L187). (https://github.com/informalsystems/ibc-rs/pull/1763)ChannelId
by value since it implsCopy
. https://github.com/informalsystems/ibc-rs/pull/2071#discussion_r845063824PS: Thanks to @romac for his valuable insights and suggestions!
For Admin Use