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

Light client extraction #2483

Merged
merged 22 commits into from
Aug 26, 2022
Merged

Light client extraction #2483

merged 22 commits into from
Aug 26, 2022

Conversation

hu55a1n1
Copy link
Member

@hu55a1n1 hu55a1n1 commented Jul 29, 2022

Closes: #2335

Description

This is the PR for merging the long-lived branch for ADR011 impl.

Make sure the following points are addressed before merging ->

Component PRs

Follow-up work (improvements)

  • Use the downcast-rs crate - This will allow us to remove the AsAny and AsAnyMut code we currently have. It also provides a way for going from boxed trait objects to boxed concrete types without cloning, something that isn't possible with the current API. eg. Box<dyn ClientState> -> Box<TmClientState>.
  • Use macros for ErasedPartialEq defs and impls.
  • Separate trait for into_box(). (downcast-rs might already have a solution for this)

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).

* 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]>
hu55a1n1 and others added 15 commits July 29, 2022 18:40
* 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>
* 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]>
* 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)
* 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
* 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
* 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]>
@hu55a1n1 hu55a1n1 mentioned this pull request Aug 17, 2022
6 tasks
@hu55a1n1 hu55a1n1 marked this pull request as ready for review August 17, 2022 15:14
@romac romac marked this pull request as draft August 18, 2022 15:12
@romac romac added this to the v1.1 milestone Aug 22, 2022
@romac romac marked this pull request as ready for review August 24, 2022 07:27
@romac romac changed the title Light client extraction (long-lived branch) Light client extraction Aug 25, 2022
@hu55a1n1 hu55a1n1 mentioned this pull request Aug 25, 2022
6 tasks
Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

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

Amazing work @hu55a1n1 and @plafer, and thanks for the sync review 🙏

@romac romac merged commit a413375 into master Aug 26, 2022
@romac romac deleted the hu55a1n1/light-client-extraction branch August 26, 2022 10:13
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.

Extract light client implementations into separate crates
3 participants