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

Update sealing just once when externally importing many blocks #1541

Merged
merged 1 commit into from
Jul 6, 2016

Conversation

nipunn1313
Copy link
Contributor

Fixes Issue #1372

The change factors out an "add_transactions_to_queue" private function on the miner which queues transactions without updating sealing. The externally visible "import_transactions" function will add transactions and seal (with the throttling from @5d3ff3d). The externally visible "chain_new_blocks" function chains all the new transactions and updates sealing once.

};
self.miner.import_transactions(self, transactions, fetch_account)
fn import_external_transactions(&self, transactions: Vec<SignedTransaction>) -> Vec<Result<TransactionImportResult, Error>> {
self.miner.import_external_transactions(self, transactions)
Copy link
Contributor Author

@nipunn1313 nipunn1313 Jul 4, 2016

Choose a reason for hiding this comment

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

I'm not sure this function provides any value any more. It may be used for testing, but I don't think it's particularly useful for even that since we could just call "import_queued_transactions"

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 get rid of it if it's not used.

@rphmeier rphmeier added the A0-pleasereview 🤓 Pull request needs code review. label Jul 5, 2016
// lets assume that all txs are valid
self.imported_transactions.lock().unwrap().extend_from_slice(&transactions);

for sender in transactions.iter().filter_map(|t| t.sender().ok()) {
let nonce = self.last_nonce(&sender).unwrap_or(fetch_account(&sender).nonce);
let nonce = self.last_nonce(&sender).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why it's removed? If there are no other transactions from this sender in queue self.last_nonce/1 may return None

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, ok - it's only used for tests (and there doesn't seem to be any tests using that.

I would change it to expect("..") with some nice description that last_nonce should be populated for tests.

@tomusdrw tomusdrw added A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 5, 2016
@tomusdrw
Copy link
Collaborator

tomusdrw commented Jul 5, 2016

Besides the comments that I left it looks good 👍 - it minimizes calls to update_sealing indeed.

@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. and removed A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. labels Jul 6, 2016
Vec<Result<TransactionImportResult, Error>> {

let mut transaction_queue = self.transaction_queue.lock().unwrap();
let results = self.add_transactions_to_queue(chain, transactions, TransactionOrigin::External,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We use a bit different indentation style. I think I would write something like this here:

let results = self.add_transactions_to_queue(
    chain, transactions, TransactionOrigin::External, &mut transaction_queue
);

Or would just keep it single line.

(Same in L693)

@tomusdrw tomusdrw added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 6, 2016
@tomusdrw
Copy link
Collaborator

tomusdrw commented Jul 6, 2016

LGTM except for indentation grumble. 👍

@gavofyork gavofyork added A0-pleasereview 🤓 Pull request needs code review. A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. A0-pleasereview 🤓 Pull request needs code review. labels Jul 6, 2016
@gavofyork gavofyork merged commit 4a9b9dc into openethereum:master Jul 6, 2016
@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Jul 6, 2016
@gavofyork
Copy link
Contributor

will fix this on merge myself.

gavofyork added a commit that referenced this pull request Jul 6, 2016
gavofyork added a commit that referenced this pull request Jul 6, 2016
gavofyork pushed a commit that referenced this pull request Jul 12, 2016
* Update sealing just once when  externally importing many blocks (#1541)

Fixes Issue #1372

* Fixing deadlock in miner (#1569)

* Fixing deadlock in miner
* Adding more comments
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants