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

Remove AnyClientState from the modules #2559

Conversation

hu55a1n1
Copy link
Member

@hu55a1n1 hu55a1n1 commented Aug 15, 2022

Partially addresses: #2335


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@hu55a1n1 hu55a1n1 changed the title Remove AnyClientState Remove AnyClientState from the modules Aug 16, 2022
@hu55a1n1 hu55a1n1 mentioned this pull request Aug 16, 2022
20 tasks
@hu55a1n1 hu55a1n1 marked this pull request as ready for review August 16, 2022 10:55
@plafer plafer self-assigned this Aug 16, 2022
@@ -16,17 +15,13 @@ pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient";
/// A type of message that triggers the creation of a new on-chain (IBC) client.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MsgCreateAnyClient {
pub client_state: AnyClientState,
pub client_state: Any,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust is giving me the following error here:

the trait bound ibc_proto::google::protobuf::Any: core::cmp::Eq is not satisfied
the trait core::cmp::Eq is not implemented for ibc_proto::google::protobuf::Any

I'm not sure why?

Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hu55a1n1 hu55a1n1 merged commit a87cf8e into hu55a1n1/light-client-extraction Aug 16, 2022
@hu55a1n1 hu55a1n1 deleted the hu55a1n1/adr011-impl-remove-any-client-state branch August 16, 2022 15:25
romac added a commit that referenced this pull request Aug 26, 2022
* 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]>
hu55a1n1 added a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants