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

Extract the Engine trait #10958

Merged
merged 49 commits into from
Aug 15, 2019
Merged

Extract the Engine trait #10958

merged 49 commits into from
Aug 15, 2019

Conversation

dvdplm
Copy link
Collaborator

@dvdplm dvdplm commented Aug 10, 2019

Another big, noisy PR. This time the Engine trait and associated types are extracted to an engine crate. Along with this many of the client traits have been moved from ethcore/client/traits.rs into the client_traits crate.

To some degree the PR makes arbitrary decisions on which types/traits to move. The criteria used is not so much about what belongs where, but rather given that we want a free standing Engine, what else has to move? One example of such unclean division is how the engine crate now hosts two traits related to snapshotting.

The only relevant logic change is in Ethash: the epoch_verifier() method requires a type that implements EpochVerifier that can be stuck inside a ConstructedVerifier enum and before this PR this was achieved by an impl on Arc<Ethash>. When the Engine trait is no longer local, this is not possible. Instead there is now a local EpochVerifier struct that impls the EpochVerifier trait, much like the other engines do. This leads to somewhat convoluted code but otoh it saves us the doubly-arc-wrapped setup we had before.

Based on #10949

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
@dvdplm dvdplm requested review from debris and tomusdrw August 10, 2019 14:09
@dvdplm dvdplm self-assigned this Aug 10, 2019
@dvdplm dvdplm added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Aug 10, 2019
Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

🎉 Awesome work! A bunch of tiny grumbles.

ethcore/Cargo.toml Outdated Show resolved Hide resolved
vm = { path = "../vm" }
trace = { path = "../trace" }
ethcore-miner = { path = "../../miner" }
kvdb = "0.1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

sort?

ethcore/engine/Cargo.toml Outdated Show resolved Hide resolved
ethcore/engine/src/snapshot.rs Show resolved Hide resolved
use block::*;
use client::EngineClient;
use engines::{Engine, Seal, ConstructedVerifier};
use client_traits::EngineClient;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the next step would be to move specific engines implementations into it's own crates? ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You nailed it. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

We're actually already doing that with our WIP Honey Badger engine:
https://github.com/poanetwork/parity-ethereum/tree/hbbft/ethcore/hbbft_engine
Saves a lot of compile time!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@afck See #10966 – once you get rid of the ethcore dependency compilation times are pretty great.

ethcore/src/engines/ethash.rs Outdated Show resolved Hide resolved
@@ -207,17 +241,18 @@ impl Ethash {
// for any block in the chain.
// in the future, we might move the Ethash epoch
// caching onto this mechanism as well.
// NOTE[dvdplm]: the reason we impl this for Arc<Ethash> and not plain Ethash is the
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉

ethcore/src/engines/ethash.rs Outdated Show resolved Hide resolved
ethcore/src/engines/mod.rs Show resolved Hide resolved
* master:
  Extract Machine from ethcore (#10949)
  removed redundant state_root function from spec, improve spec error types (#10955)
  Add support for Energy Web Foundation's new chains (#10957)
  [evmbin] add more tests to main.rs (#10956)
* master:
  Verify transaction against its block during import (#10954)
  [evmbin] fix compilation (#10976)
  Update to latest trie version. (#10972)
  [blooms-db] Fix benchmarks (#10974)
  Fix ethcore/benches build. (#10964)
  tx-pool: accept local tx with higher gas price when pool full (#10901)
  Disable unsyncable expanse chain (#10926)
Copy link
Collaborator

@debris debris left a comment

Choose a reason for hiding this comment

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

lgtm!

@dvdplm dvdplm merged commit 6a9de9b into master Aug 15, 2019
@dvdplm dvdplm deleted the dp/chore/extract-engine-trait branch August 15, 2019 15:59
dvdplm added a commit that referenced this pull request Aug 15, 2019
* master:
  Extract the Engine trait (#10958)
  Better error message for rpc gas price errors (#10931)
  [.gitlab.yml] cargo check ethcore benches (#10965)
  Verify transaction against its block during import (#10954)
  [evmbin] fix compilation (#10976)
  Update to latest trie version. (#10972)
  [blooms-db] Fix benchmarks (#10974)
  Fix ethcore/benches build. (#10964)
  tx-pool: accept local tx with higher gas price when pool full (#10901)
  Disable unsyncable expanse chain (#10926)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants