-
Notifications
You must be signed in to change notification settings - Fork 87
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
Proposal for redesigning parts of the ibc-rs modules' API #25
Comments
pub enum Proofs {
ChannelOpenTry(ChannelOpenTryProof),
// ...
} Bikeshedding: // 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 |
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 Implement proof verification functions for Tendermint client informalsystems/hermes#1583 (comment))ics24_host::Path
variants as types - Since Rust doesn't treat enum variants as types, it might be a good idea to extract these variants as distinct types and use those types as the actual enum variants. This will allow us to enforce that certain functions accept only a certain type of path. eg.verify_client_consensus_state()
should only accept aPath::ClientConsensusState
. (ICS24 Path variants as types informalsystems/hermes#1760)ibc::core::ics04_channel::msgs::MsgChannelCloseConfirm
toibc::core::ics04_channel::msgs::ChannelCloseConfirm
, and either re-export it asMsgChannelCloseConfirm
inmsgs.rs
or add it to the prelude.struct
s should either have public fields or setters/getters (if required), but not both. e.g.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.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. (Disallow emptyCommitmentPrefix
andCommitmentProofBytes
informalsystems/hermes#1761)Capability{Reader,Keeper}
traits #58unwrap()
s.ClientState
metadata (https://github.com/cosmos/ibc-go/blob/main/modules/light-clients/07-tendermint/types/client_state.go#L187). (Initialize consensus metadata during client create informalsystems/hermes#1763)ChannelId
by value since it implsCopy
. ModelChannelId
as newtype u64 and improve validation informalsystems/hermes#2071 (comment)PS: Thanks to @romac for his valuable insights and suggestions!
For Admin Use
The text was updated successfully, but these errors were encountered: