-
Notifications
You must be signed in to change notification settings - Fork 352
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
Remove all occurences of Any* enums from light-clients #2332
Remove all occurences of Any* enums from light-clients #2332
Conversation
ff09e88
to
ea0876e
Compare
ea0876e
to
a27c1bb
Compare
fn block_delay(&self, delay_period_time: Duration) -> u64; | ||
} | ||
|
||
impl<T: ChannelReader> ChannelMetaReader for T { |
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.
Instead of duplicating the methods of ChannelMetaReader
in ChannelReader
, and providing a blanket implementation, why not have ChannelMetaReader
a supertrait of ChannelReader
, and remove the duplicated methods from ChannelReader
?
It would also simplify everywhere that we have the trait bound ChannelReader + ChannelMetaReader
down to just ChannelReader
.
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.
This is definitely something we should do once we remove the Any*
enums. I didn't do it in this PR because some of the trait methods have default impls that depend on other trait methods that use the Any*
enums. (e.g. host_timestamp()
and pending_host_consensus_state()
)
/// Type of client associated with this consensus state (eg. Tendermint) | ||
fn client_type(&self) -> ClientType; | ||
|
||
/// Commitment root of the consensus state, which is used for key-value pair verification. | ||
fn root(&self) -> &CommitmentRoot; | ||
|
||
/// Wrap into an `AnyConsensusState` | ||
fn wrap_any(self) -> AnyConsensusState; | ||
fn encode_vec(&self) -> Result<Vec<u8>, Error>; |
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.
I think we decided against including encode_vec()
directly in the traits, and instead using a trait object safe version of Protobuf
, right? We can address this in another PR, perhaps #2412; let's just not forget to do it!
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.
Great job!
* Remove all occurences of Any* enums from light-clients (#2332) * Make ConsensusState object-safe * Make ClientState trait object safe * Extract ConsensusReader * Fix clippy errors * Remove all Any* usages from clients * Remove client specific errors from Ics02Error * Extract ChannelMetaReader * Fix Ci * Remove unnecessary Clone supertrait from Header & Misbehaviour * Fix bad std import * Remove redundant Clone supertrait from ClientDef * Rename ConsensusReader -> LightClientReader * Add docstring for LightClientReader * Add docstring for ChannelMetaReader * Remove unused LightClientReader trait bound * AnyTrait -> CoreAny * Remove ClientReader::maybe_consensus_state() * Rename LightClientReader -> ClientReaderLightClient and ChannelReaderLightClient Co-authored-by: Philippe Laferriere <[email protected]> * Object safe Protobuf (#2412) * Define protobuf error * Implement object safe Protobuf trait * Add test for object safety * Provide blanket impls for ToBoxed and TryFromIfSized * Add blanket impl test * Use more specific bounds * Seal Protobuf supertraits * Add mod erased * Rename erased traits * Doc comments for Protobuf * Update code to use ibc_proto::protobuf::Protobuf * Fix no_std check * Address review feedback * Rename Protobuf<T> to Protobuf<Raw> * Remove Sealed mod * Rename Into -> CloneInto and return T instead of Box<T> * Remove `AnyHeader` from the modules (#2524) * Define protobuf error * Implement object safe Protobuf trait * Add test for object safety * Provide blanket impls for ToBoxed and TryFromIfSized * Add blanket impl test * Use more specific bounds * Seal Protobuf supertraits * Add mod erased * Rename erased traits * Doc comments for Protobuf * Update code to use ibc_proto::protobuf::Protobuf * Fix no_std check * Address review feedback * Rename Protobuf<T> to Protobuf<Raw> * commit before dealing with Serialize * Implement erased_serde Serialize on Header * comment redacted * Made `Header` trait object safe * error * Impl Protobuf<Any> for TmHeader * Impl Protobuf<Any> for MockHeader * Change Header supertrait to `Protobuf<Any>`` instead of `Protobuf<RawHeader>` * ErasedProtobuf * Fix encode_to_string compile error * implement downcast_header * Move AsAny to dynamic_typing module * fix 1 more compile error: clone * Make UpdateClient `PartialEq` again by making `dyn Header` PartialEq * Add `Header::into_box` * Use `Any` in place of `MsgUpdateAnyClient.header` * Update relayer for MsgUpdateAnyClient `Any` header changes * Avoid using `Header` methods in update_client handler * Remove AnyHeader from ClientDef * Update tests for ClientDef changes * Remove redundant clone * Remove AnyHeader usage from mock * MsgUpdateClient -> RawMsgUpdateClient * MsgUpdateAnyClient -> MsgUpdateClient * Remove use of AnyHeader * Move MisbehaviourEvidence to the relayer * Remove use of AnyHeader in mock * Remove AnyHeader from modelator * Fix MockHeader test * Move AnyHeader into the relayer * use alloc String in protobuf * fix no-std issue * Cleanup SyntheticTmBlock impl * Rename EqualsHeader and move to sealed module * Remove unused Error=Error * Remove Deref impl for SyntheticTmBlock * Fix default `trusted_height` in `HostBlock::generate_tm_block()` * fix test * fix errors Co-authored-by: hu55a1n1 <[email protected]> * Remove `AnyMisbehaviour` from modules (#2527) * Implement PartialEq for dyn Misbehaviour * Add DynClone to Misbehaviour * MsgSubmitMisbehaviour now uses Any * Move AnyMisbehaviour to the relayer * Header: move sealed module at the end of file * Rename misbehavior -> misbehaviour * Misbehaviour: mark Mock stuff cfg(test) * Header: put Mock stuff behind cfg(test) * Remove `AnyConsensusState` from modules (#2528) * Update Cargo.lock * Fix header comment * Implement Erased traits for ConsensusState * Implement supertraits for concrete `ConsensusState`s * Remove AnyConsensusState from ClientDef * Remove check for matching ClientTypes in MsgCreateAnyClient domain type conv * Remove AnyConsensusState from client handlers * Fix tests compile * Fix typo in comment * Add ConsensusState::timestamp() * Remove `AnyConsensusState` from readers & keepers * Remove `AnyConsensusState` from mock context * Fix tests * Impl conversions for Host block to dyn ConsensusState * Treat Tm light client as first class citizen and allow Mock impl to depend on it's data structures * Fix no-std check * Replace AnyConsensusState in Messages with Box<dyn ConsensusState> * Modify `verify_upgrade_and_update_state()` to accept `Any` consensus state * Remove redundant conversion from MockHeader to AnyConsensusState * Remove any remnants of AnyConsensusState from tests * Move `AnyConsensusState` to the relayer crate * Move type url consts to the light client mods * Extract mock::consensus_state mod * Rename client_consensus.rs to consensus_state.rs * Move header type url consts to the light client mods * Minor refactoring and doc comments * Move misbehaviour type url consts to the light client mods * Rename Clientdef::validate_consensus_state -> initialise * Remove `AnyClientState` from the modules (#2559) * dyn UpgradeOptions * Object safe ClientState * Add PartialEq for ClientState * Remove AnyClientState * Update remaining handlers and relayer code * Fix tests * Remove AnyClientState from ICS03 * Remove AnyClientState from mock * Fix typos * Fix CI * Move AnyClientState to relayer crate * Move client state type URLs to light clients * Remove ClientReaderLightClient * Fix comment * Avoid decoding expected client state on counterparty (#2569) * Merge `Clientdef` into `Clientstate` (#2570) * add verification functions to ClientState * Implement tendermint clientstate * Implemented verification functions for MockClientState * Remove ClientDef * MsgCreateAnyClient -> MsgCreateClient * MsgUpgradeAnyClient -> MsgUpgradeClient * fix test * Cleanup fully qualified imports * Rename TmClientState * Remove ChannelReaderLightClient (#2572) Co-authored-by: hu55a1n1 <[email protected]> * Re-add Deserialize on Any enums in relayer crate where possible * Impl From<&dyn> for AnyClientState and AnyConsensusState * Remove redundant line Co-authored-by: Philippe Laferriere <[email protected]> Co-authored-by: Romain Ruetschi <[email protected]>
* Remove all occurences of Any* enums from light-clients (informalsystems#2332) * Make ConsensusState object-safe * Make ClientState trait object safe * Extract ConsensusReader * Fix clippy errors * Remove all Any* usages from clients * Remove client specific errors from Ics02Error * Extract ChannelMetaReader * Fix Ci * Remove unnecessary Clone supertrait from Header & Misbehaviour * Fix bad std import * Remove redundant Clone supertrait from ClientDef * Rename ConsensusReader -> LightClientReader * Add docstring for LightClientReader * Add docstring for ChannelMetaReader * Remove unused LightClientReader trait bound * AnyTrait -> CoreAny * Remove ClientReader::maybe_consensus_state() * Rename LightClientReader -> ClientReaderLightClient and ChannelReaderLightClient Co-authored-by: Philippe Laferriere <[email protected]> * Object safe Protobuf (informalsystems#2412) * Define protobuf error * Implement object safe Protobuf trait * Add test for object safety * Provide blanket impls for ToBoxed and TryFromIfSized * Add blanket impl test * Use more specific bounds * Seal Protobuf supertraits * Add mod erased * Rename erased traits * Doc comments for Protobuf * Update code to use ibc_proto::protobuf::Protobuf * Fix no_std check * Address review feedback * Rename Protobuf<T> to Protobuf<Raw> * Remove Sealed mod * Rename Into -> CloneInto and return T instead of Box<T> * Remove `AnyHeader` from the modules (informalsystems#2524) * Define protobuf error * Implement object safe Protobuf trait * Add test for object safety * Provide blanket impls for ToBoxed and TryFromIfSized * Add blanket impl test * Use more specific bounds * Seal Protobuf supertraits * Add mod erased * Rename erased traits * Doc comments for Protobuf * Update code to use ibc_proto::protobuf::Protobuf * Fix no_std check * Address review feedback * Rename Protobuf<T> to Protobuf<Raw> * commit before dealing with Serialize * Implement erased_serde Serialize on Header * comment redacted * Made `Header` trait object safe * error * Impl Protobuf<Any> for TmHeader * Impl Protobuf<Any> for MockHeader * Change Header supertrait to `Protobuf<Any>`` instead of `Protobuf<RawHeader>` * ErasedProtobuf * Fix encode_to_string compile error * implement downcast_header * Move AsAny to dynamic_typing module * fix 1 more compile error: clone * Make UpdateClient `PartialEq` again by making `dyn Header` PartialEq * Add `Header::into_box` * Use `Any` in place of `MsgUpdateAnyClient.header` * Update relayer for MsgUpdateAnyClient `Any` header changes * Avoid using `Header` methods in update_client handler * Remove AnyHeader from ClientDef * Update tests for ClientDef changes * Remove redundant clone * Remove AnyHeader usage from mock * MsgUpdateClient -> RawMsgUpdateClient * MsgUpdateAnyClient -> MsgUpdateClient * Remove use of AnyHeader * Move MisbehaviourEvidence to the relayer * Remove use of AnyHeader in mock * Remove AnyHeader from modelator * Fix MockHeader test * Move AnyHeader into the relayer * use alloc String in protobuf * fix no-std issue * Cleanup SyntheticTmBlock impl * Rename EqualsHeader and move to sealed module * Remove unused Error=Error * Remove Deref impl for SyntheticTmBlock * Fix default `trusted_height` in `HostBlock::generate_tm_block()` * fix test * fix errors Co-authored-by: hu55a1n1 <[email protected]> * Remove `AnyMisbehaviour` from modules (informalsystems#2527) * Implement PartialEq for dyn Misbehaviour * Add DynClone to Misbehaviour * MsgSubmitMisbehaviour now uses Any * Move AnyMisbehaviour to the relayer * Header: move sealed module at the end of file * Rename misbehavior -> misbehaviour * Misbehaviour: mark Mock stuff cfg(test) * Header: put Mock stuff behind cfg(test) * Remove `AnyConsensusState` from modules (informalsystems#2528) * Update Cargo.lock * Fix header comment * Implement Erased traits for ConsensusState * Implement supertraits for concrete `ConsensusState`s * Remove AnyConsensusState from ClientDef * Remove check for matching ClientTypes in MsgCreateAnyClient domain type conv * Remove AnyConsensusState from client handlers * Fix tests compile * Fix typo in comment * Add ConsensusState::timestamp() * Remove `AnyConsensusState` from readers & keepers * Remove `AnyConsensusState` from mock context * Fix tests * Impl conversions for Host block to dyn ConsensusState * Treat Tm light client as first class citizen and allow Mock impl to depend on it's data structures * Fix no-std check * Replace AnyConsensusState in Messages with Box<dyn ConsensusState> * Modify `verify_upgrade_and_update_state()` to accept `Any` consensus state * Remove redundant conversion from MockHeader to AnyConsensusState * Remove any remnants of AnyConsensusState from tests * Move `AnyConsensusState` to the relayer crate * Move type url consts to the light client mods * Extract mock::consensus_state mod * Rename client_consensus.rs to consensus_state.rs * Move header type url consts to the light client mods * Minor refactoring and doc comments * Move misbehaviour type url consts to the light client mods * Rename Clientdef::validate_consensus_state -> initialise * Remove `AnyClientState` from the modules (informalsystems#2559) * dyn UpgradeOptions * Object safe ClientState * Add PartialEq for ClientState * Remove AnyClientState * Update remaining handlers and relayer code * Fix tests * Remove AnyClientState from ICS03 * Remove AnyClientState from mock * Fix typos * Fix CI * Move AnyClientState to relayer crate * Move client state type URLs to light clients * Remove ClientReaderLightClient * Fix comment * Avoid decoding expected client state on counterparty (informalsystems#2569) * Merge `Clientdef` into `Clientstate` (informalsystems#2570) * add verification functions to ClientState * Implement tendermint clientstate * Implemented verification functions for MockClientState * Remove ClientDef * MsgCreateAnyClient -> MsgCreateClient * MsgUpgradeAnyClient -> MsgUpgradeClient * fix test * Cleanup fully qualified imports * Rename TmClientState * Remove ChannelReaderLightClient (informalsystems#2572) Co-authored-by: hu55a1n1 <[email protected]> * Re-add Deserialize on Any enums in relayer crate where possible * Impl From<&dyn> for AnyClientState and AnyConsensusState * Remove redundant line Co-authored-by: Philippe Laferriere <[email protected]> Co-authored-by: Romain Ruetschi <[email protected]>
Partially addresses: #2335
Description
Implements phase-1 of #2335:
Any*
enums from light-client code.Note: The target branch is a long-lived branch hu55a1n1/light-client-extraction. The plan is to merge PRs (addressing #2335) such as this into hu55a1n1/light-client-extraction and ultimately merge that into master.
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.