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

Move more types out of ethcore #10880

Merged
merged 124 commits into from
Jul 18, 2019
Merged

Conversation

dvdplm
Copy link
Collaborator

@dvdplm dvdplm commented Jul 12, 2019

This PR is a small step on the way to be able to extract the Engine trait from ethcore. The next step after this is probably to remove Machine from the trait but there are several tricky types that need moving/deep thought too:

  • ExecutedBlock: embeds State<StateDB> which means it can't be moved to common-types (circular ref.)
  • Proof: has a troublesome WithState variant which implies a dependency on Machine.
  • ConstructedVerifier: uses a trait that needs to be extracted somewhere sensible.
  • ClientIoMessage: this one is probably the trickiest to move outside of ethcore because of how the Execute variant is used.

…and probably others.

Reviewers guide

  • common-types now has plenty more dependencies
  • common-types now owns PreverifiedBlock and several machine related types: AuxiliaryData, AuxiliaryRequest, Call, CommonParams (here the crate gained way more code than I'd like: something we can perhaps fix with a trait), all error types
  • having independent errors simplifies error handling in account-state (and potentially others down the line)
  • the params() function in the Engine trait does not provide a default implementation anymore: the idea is that future PRs will remove the dependency on Machine all-together.
  • despite the high SNR here there are no changes to logic or other "dangerous" changes.

dvdplm added 30 commits July 3, 2019 15:57
Remove botched ethcore-error crate
* master:
  Extricate PodAccount and state Account to own crates (#10838)
  logs (#10817)
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
…hore/extricate-state-backend

* dp/chore/extricate-account-db-into-own-crate:
  third time's the charm
  test failure 2
  test failure
  Extricate PodAccount and state Account to own crates (#10838)
  logs (#10817)
  refactor: whisper: Add type aliases and update rustdocs in message.rs (#10812)
  Break circular dependency between Client and Engine (part 1) (#10833)
  tests: Relates to #10655: Test instructions for Readme (#10835)
  refactor: Related #9459 - evmbin: replace untyped json! macro with fully typed serde serialization using Rust structs (#10657)
* master:
  Extract AccountDB to account-db (#10839)
  test: Update Whisper test for invalid pool size (#10811)
* master:
  Improve logging and cleanup in miner around block sealing (#10745)
* master:
  whisper is no longer a part of parity-ethereum repo (#10855)
  [ethash] remove mem::uninitialized (#10861)
  Docker images renaming (#10863)
  Move the substate module into ethcore/executive (#10867)
@dvdplm dvdplm self-assigned this Jul 12, 2019
@dvdplm dvdplm added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jul 12, 2019
@dvdplm dvdplm marked this pull request as ready for review July 12, 2019 14:47
@dvdplm dvdplm requested review from debris and ordian July 12, 2019 17:48
@ordian ordian added this to the 2.7 milestone Jul 12, 2019
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.

There are several things that I like and don't like about this pr. I definitely like unification of error types and cleanup possibilities that it brings. I don't like putting more modules into types/ crate which imo should be kept as small as possible. But all in all I believe that pros of this pr significantly out-wage cons and we can modularize types crate more after we finish our work with ethcore.

great work!

/// Auxiliary data fetcher for an Ethereum machine. In Ethereum-like machines
/// there are two kinds of auxiliary data: bodies and receipts.
#[derive(Default, Clone)]
pub struct AuxiliaryData<'a> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep those data structures together with Machine? I don't think that putting all plain data structures in the same crate is a good idea. imo this crate should define only the basic few (header, block, blockid..) and nothing else

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 are right and I agree that with this pr the common-types crate becomes a bit too “heavy”. We need to move some types out of the way on the path to disentangle machine from engine though but that’s not done in this pr so maybe best to undo this change here and redo it in the next pr (or do it better).


/// Ethash-specific extensions.
#[derive(Debug, Clone)]
pub struct EthashExtensions {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

ethcore/src/ethereum/ethash_eng.rs Outdated Show resolved Hide resolved
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.

a bunch of grumbles

use executive::Executed;
use account_state::state::StateInfo;
use trace::LocalizedTrace;
use verification::queue::QueueInfo as BlockQueueInfo;
use verification::queue::kind::blocks::Unverified;
use verification::queue::kind::blocks::Unverified; // todo this is reexported from common_types
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you want to resolve the TODO in this PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's do it in a separate one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It’s fine to do in separate pr: it’s a matter of checking what uses the type outside ethcore.

ethcore/src/verification/queue/mod.rs Outdated Show resolved Hide resolved
ethcore/types/Cargo.toml Outdated Show resolved Hide resolved
ethcore/types/Cargo.toml Show resolved Hide resolved
ethcore/src/lib.rs Outdated Show resolved Hide resolved
ethcore/types/src/engines/mod.rs Outdated Show resolved Hide resolved
ethcore/types/src/errors/block_error.rs Show resolved Hide resolved
@debris
Copy link
Collaborator

debris commented Jul 16, 2019

I'll rebase this pr and fix review suggestions to get it in soon ;)

@debris debris added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 17, 2019
ethcore/src/ethereum/denominations.rs Show resolved Hide resolved
"Engine error"
}
}

/// Seal type.
#[derive(Debug, PartialEq, Eq)]
pub enum Seal {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels like Seal and SealingState should go together, no?


[dev-dependencies]
rustc-hex= "1.0"
rustc-hex= "1.0" # todo: only needed for CommonParams to do from_hex on a const. Remove?
Copy link
Collaborator

Choose a reason for hiding this comment

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

that's fine for tests

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, yes, I should've removed the comment

@debris debris merged commit 1ef9d5b into master Jul 18, 2019
@debris debris deleted the dp/chore/move-more-types-out-of-ethcore branch July 18, 2019 10:27
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