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

Move DatabaseExtras back to trace #10868

Merged
merged 10 commits into from
Jul 14, 2019
Merged

Conversation

dvdplm
Copy link
Collaborator

@dvdplm dvdplm commented Jul 8, 2019

Move DatabaseExtras back to trace and remove the impl for BlockChain. Instead add a BlockChainWithExtras type to ethcore and impl DatabaseExtras for it.

ref. #10840 (comment)

Add a new BlockChainWithExtras newtype to ethcore
Impl DatabaseExtras for BlockChainWithExtras
Impl From for BlockChainWithExtras for convenient instantiation
Change TraceDB::new to take a T: DatabaseExtras (instead of an Arc)
@dvdplm dvdplm self-assigned this Jul 8, 2019
@dvdplm dvdplm added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jul 8, 2019
@dvdplm dvdplm requested review from tomusdrw and debris July 8, 2019 21:29
ethcore/src/client/client.rs Outdated Show resolved Hide resolved
ethcore/src/client/client.rs Outdated Show resolved Hide resolved
ethcore/src/client/client.rs Outdated Show resolved Hide resolved
@@ -6,7 +6,6 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
common-types = { path = "../types"}
ethcore-blockchain = { path = "../blockchain" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, so we still can't get rid of the blockchain depenency? Then I don't think it makes much sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

dyn BlockChainWithExtras? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

dyn BlockChainWithExtrasAndExtraMayo ;)

Sure, we can work on disentangling things further, but I think we can get more bang for our effort elsewhere at this time. I'm fine adding an issue to make trace independent of blockchain but for the time being I think we should pick the lesser of two evils, so the question is: which is worst, this PR or the current master? Personally I think they both smell a little so I don't really care which it is. @tomusdrw seem to feel this PR is worse. What is your opinion @debris, merge or close?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we depend on blockchain the wrapper type is unecessary since we can write the implementation right next to the DatabaseExtras definition. I'd just add this in traces:

impl<T: BlockProvider> trace::DatabaseExtras for T {
	fn block_hash(&self, block_number: BlockNumber) -> Option<H256> {
		BlockProvider::block_hash(&self, block_number)
	}

	fn transaction_hash(&self, block_number: BlockNumber, tx_position: usize) -> Option<H256> {
		self.block_hash(block_number)
			.and_then(|block_hash| {
				let tx_address = TransactionAddress {
					block_hash,
					index: tx_position
				};
				self.transaction(&tx_address)
			})
			.map(|tx| tx.hash())
	}
}

and be done with it.

@@ -57,6 +57,16 @@ impl Key<FlatBlockTraces> for H256 {
}
}

/// `DatabaseExtras` provides an interface to query extra data which is not stored in TraceDB,
/// but necessary to work correctly.
pub trait DatabaseExtras {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we still need the blockchain dependenccy we can probably just implement DatabaseExtras for any BlockProvider here easily. There is no need for a wrapper struct afaict.

@ordian ordian added this to the 2.7 milestone Jul 9, 2019
dvdplm and others added 4 commits July 9, 2019 14:02
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* master:
  Docker images renaming (#10863)
  Move the substate module into ethcore/executive (#10867)
  Run cargo fix on a few of the worst offenders (#10854)
  removed redundant fork choice abstraction (#10849)
  Extract state-db from ethcore (#10858)
@dvdplm
Copy link
Collaborator Author

dvdplm commented Jul 11, 2019

Updated as per @tomusdrw's grumble here: #10868 (comment)

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

I think that DatabaseExtras interface should be redesigned in future, but let's merge it for now

@debris debris merged commit 14e7641 into master Jul 14, 2019
@debris debris deleted the dp/chore/extract-state-followup branch July 14, 2019 16:35
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