Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Make ClientIoMessage generic over the Client #10981

Merged
merged 106 commits into from
Aug 28, 2019

Conversation

dvdplm
Copy link
Collaborator

@dvdplm dvdplm commented Aug 19, 2019

The one big remaining issue in ethcore is the ClientIoMessage type which has an Execute variant that embeds a Client. This is a blocker for several things, e.g. making a freestanding ethcore/light, extracting verification etc.
This PR attempts to disentangle this type by making it generic and extracts verification from ethcore.

There are some questionable changes made here, in particular wrt to the traits used/modified. Careful review of these areas is much appreciated.

  1. the ImportBlock trait gains a method despite the FIXME that seems to indicate that the trait should not even exist
  2. the new Tick trait
  3. hijacking the SnapshotClient trait (maybe the SnapshotWriter trait should be combined with this?)
  4. making the light client's fetcher type param 'static – better way?

After this PR we can build the eth light client without depending on Client.

Based on #10978.

I have synced mainnet with this branch.

dvdplm added 30 commits August 6, 2019 18:33
Move the BlockInfo trait to new crate
Contains code extracted from ethcore that defines `Machine`, `Externalities` and other execution related code.
* master:
  Allow default block parameter to be blockHash (#10932)
  Enable sealing when engine is ready (#10938)
  Fix some warnings and typos. (#10941)
* master:
  unify loading spec && further spec cleanups (#10948)
  refactor: Refactor evmbin CLI (#10742)
  journaldb changes (#10929)
* master:
  Fix compiler warnings in util/io and upgrade to edition 2018 Upgrade mio to latest (#10953)
Cleanup Executed as exported from machine crate
Sort out default impls for EpochVerifier
Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

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

This introduces some changes that need to be reverted later, but the ability to build the light client w/o ethcore is cool!

ethcore/verification/src/lib.rs Show resolved Hide resolved
@ordian ordian added this to the 2.7 milestone Aug 26, 2019
@dvdplm dvdplm requested a review from sorpaas August 26, 2019 18:04
@dvdplm dvdplm requested a review from niklasad1 August 27, 2019 16:02
client: Arc<Client<T>>,
io_service: IoService<ClientIoMessage>,
io_service: IoService<ClientIoMessage<()>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this ()?

does it work because we only care about ClientIoMessage::BlockVerified for the light client?

Copy link
Collaborator Author

@dvdplm dvdplm Aug 27, 2019

Choose a reason for hiding this comment

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

Great question. So before this PR light depends on ethcore essentially only for ClientIoMessage, and then only because it has a Execute variant that embeds a Callback which is a Fn that takes an ethcore::Client as a param… So the dependency was actually not "real" but merely ceremonial, to satisfy the types as they were set up.
Once I made the Callback generic over the Client (and all the other types using it) @ordian spotted that it's actually not necessary to use anything other than () in light.

Now, we all agree that ClientIoMessage<()> looks plenty odd and hopefully someone will come along and refactor this further. ;)
In particular I know that @ngotchac is working on changes to the IO code that may, as a desired side-effect, result in a better message passing infrastructure, one that does not need a Client (or whatever stand-in we use).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I see.

In particular I know that @ngotchac is working on changes to the IO code that may, as a desired side-effect, result in a better message passing infrastructure, one that does not need a Client (or whatever stand-in we use).

Cool 👍

Copy link
Collaborator

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

nice work.

I have one remaining question regarding the light-client when that is answered you'll get my final approval!

Copy link
Collaborator

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

LGTM

@niklasad1 niklasad1 added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Aug 28, 2019
@dvdplm dvdplm merged commit cd26526 into master Aug 28, 2019
dvdplm added a commit that referenced this pull request Aug 28, 2019
* master:
  Make ClientIoMessage generic over the Client (#10981)
  bump spin to 0.5.2 (#10996)
  fix compile warnings (#10993)
  Fix compilation on recent nightlies (#10991)
  [ipfs] Convert to edition 2018 (#10979)
@niklasad1 niklasad1 deleted the dp/chore/sort-out-ClientIoMessage branch August 28, 2019 08:29
dvdplm added a commit that referenced this pull request Aug 28, 2019
…/eip-1884-reprice-trie-size-dependent-ops

* dp/feature/eip-1344-add-ChainID-opcode:
  more merge fallout
  Update ethcore/vm/src/schedule.rs
  Fix a few warnings
  merge conflict error
  Make ClientIoMessage generic over the Client (#10981)
  bump spin to 0.5.2 (#10996)
  fix compile warnings (#10993)
  Fix compilation on recent nightlies (#10991)
  [ipfs] Convert to edition 2018 (#10979)
ordian added a commit to ordian/parity that referenced this pull request Aug 29, 2019
* master:
  EIP 1884 Re-pricing of trie-size dependent operations (openethereum#10992)
  xDai chain support and nodes list update (openethereum#10989)
  [trace] check mem diff within range (openethereum#11002)
  EIP-1344 Add CHAINID op-code (openethereum#10983)
  Make ClientIoMessage generic over the Client (openethereum#10981)
  bump spin to 0.5.2 (openethereum#10996)
  fix compile warnings (openethereum#10993)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants