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

Remove engine to client circular reference #9114

Closed
sorpaas opened this issue Jul 13, 2018 · 1 comment
Closed

Remove engine to client circular reference #9114

sorpaas opened this issue Jul 13, 2018 · 1 comment
Assignees
Labels
F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. P5-sometimesoon 🌲 Issue is worth doing soon.
Milestone

Comments

@sorpaas
Copy link
Collaborator

sorpaas commented Jul 13, 2018

In ethcore, the Engine trait is usually invoked by Client. However, in some cases, an Engine would also need to query additional state, and requires a reference back to Client. We have Engine::register_client and Error::RequiresClient. Because this is circular, it may be better if we can remove it.

Currently we only use this feature for Aura engine in two places:

  • In on_close_block, where we need to calculate how many empty steps have passed.
  • In EpochManager::zoom_to function, where we need to get the epoch transition for the parent block.

The first one can be easily fixed by using the new AncestryIterator, possibly combined with set_metadata.

The second one is a little bit more complicated -- we would need to add an extra field to BlockDetails, recording the current epoch transition directly, and then use the same method we allowed engine to fetch finalized info to fetch current epoch transition. The complication arises because this time we cannot avoid a DB migration. But it indeed has its benefits -- the epoch_transition_for function can now be always O(1).

@sorpaas sorpaas added F6-refactor 📚 Code needs refactoring. P5-sometimesoon 🌲 Issue is worth doing soon. M4-core ⛓ Core client code / Rust. labels Jul 13, 2018
@sorpaas sorpaas self-assigned this Jul 13, 2018
@sorpaas sorpaas changed the title Remove engine to client circular dependency Remove engine to client circular reference Jul 13, 2018
@Tbaut Tbaut added this to the 2.1 milestone Aug 3, 2018
@5chdn 5chdn modified the milestones: 2.1, 2.2 Sep 11, 2018
@5chdn 5chdn modified the milestones: 2.2, 2.3 Oct 29, 2018
@5chdn 5chdn modified the milestones: 2.3, 2.4 Jan 10, 2019
@5chdn 5chdn modified the milestones: 2.4, 2.5 Feb 21, 2019
@soc1c soc1c modified the milestones: 2.5, 2.6 Apr 2, 2019
@ordian ordian modified the milestones: 2.6, 2.7 Jul 12, 2019
@adria0
Copy link

adria0 commented Jul 27, 2020

Closing the issue due to its stale state

@adria0 adria0 closed this as completed Jul 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. P5-sometimesoon 🌲 Issue is worth doing soon.
Projects
None yet
Development

No branches or pull requests

6 participants