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

--reseal-on-uncle #5940

Merged
merged 4 commits into from
Jul 10, 2017
Merged

--reseal-on-uncle #5940

merged 4 commits into from
Jul 10, 2017

Conversation

arkpar
Copy link
Collaborator

@arkpar arkpar commented Jun 27, 2017

Closes #4785

@arkpar arkpar requested a review from tomusdrw June 27, 2017 12:18
@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jun 27, 2017
@arkpar arkpar force-pushed the reseal-on-uncles branch from f186c40 to c6e3d40 Compare June 27, 2017 12:28
@@ -1652,6 +1652,32 @@ impl MiningBlockChainClient for Client {
open_block
}

fn reopen_block(&self, block: ClosedBlock) -> OpenBlock {
Copy link
Contributor

Choose a reason for hiding this comment

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

this logic is specifically for the miner, so couldn't it be kept completely within there? client is bloated enough already

rather than fetching all valid uncles again, the miner could just check if any of the new headers in imported is a valid uncle.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is MiningBlockChainClient so it does indeed contain some mining-specific logic. See prepare_open_block above for example.

As for fetching all valid uncles - a chain ancestry iteration is required to check if an uncle is valid. It is actually faster to iterate once and check if uncle is already in the block.
I've added a small change to avoid reading headers unnecessarily though.

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.

LGTM, small grumbles though.

.find_uncle_hashes(&h, engine.maximum_uncle_age())
.unwrap_or_else(Vec::new);

for h in uncles {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the uncle-adding code in prepare_open_block more. Seems that the only difference is a check that uncle is already in the block, can't we use filter to get rid of such uncles in the list returned by find_uncle_hashes and re-use the same code in both methods?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

prepare_open_block uses find_uncle_headers and not find_uncle_hashes. Borrow checker won't allow using a single iterator sequence here because blocks would need to be used in two closures.

@@ -1189,7 +1191,7 @@ impl MinerService for Miner {
transaction_queue.remove_old(&fetch_account, time);
}

if enacted.len() > 0 {
if enacted.len() > 0 || (imported.len() > 0 && self.options.reseal_on_uncle) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it cause spurious re-seals if the imported block cannot be a valid uncle?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Such cases are extremely rare

@@ -1150,7 +1152,7 @@ impl MinerService for Miner {
})
}

fn chain_new_blocks(&self, chain: &MiningBlockChainClient, _imported: &[H256], _invalid: &[H256], enacted: &[H256], retracted: &[H256]) {
fn chain_new_blocks(&self, chain: &MiningBlockChainClient, imported: &[H256], _invalid: &[H256], enacted: &[H256], retracted: &[H256]) {
trace!(target: "miner", "chain_new_blocks");

// 1. We ignore blocks that were `imported` (because it means that they are not in canon-chain, and transactions
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment is no longer valid.

@arkpar arkpar force-pushed the reseal-on-uncles branch from 7db607f to d94053e Compare July 3, 2017 09:56
@arkpar arkpar closed this Jul 5, 2017
@arkpar arkpar reopened this Jul 5, 2017
@jesuscript jesuscript closed this Jul 5, 2017
@jesuscript jesuscript reopened this Jul 5, 2017
@gavofyork gavofyork merged commit 15aebac into master Jul 10, 2017
@gavofyork gavofyork deleted the reseal-on-uncles branch July 10, 2017 11:36
@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 10, 2017
arkpar added a commit that referenced this pull request Jul 14, 2017
* --reseal-on-uncle

* Optimized uncle check

* Additional uncle check

* Updated comment
arkpar added a commit that referenced this pull request Jul 14, 2017
* --reseal-on-uncle (#5940)

* --reseal-on-uncle

* Optimized uncle check

* Additional uncle check

* Updated comment

* v1.6.9

* CLI: Export error message and less verbose peer counter. (#5870)

* Removed numbed of active connections from informant

* Print error message when fatdb is required

* Remove peers from UI
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.

5 participants