Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@NikVolf
Copy link
Contributor

@NikVolf NikVolf commented Mar 11, 2020

This mostly fixes pipeline problems we experience during block production (#5211, partially #5139, but the latter may require small follow-up) and makes so we always produce block with updated transaction pool state.

The idea is that pending set iterator returned only when transaction pool has processed previous block update.

This will:

  • avoid validating transactions that are included in previous block
  • avoid marking invalid transactions that made it to the previous block and reimported
  • avoid sending invalid rpc updates associated with above behaviour
  • generally make block import-production more correct

This might induce small blocking before starting block production, but generally should increase speed, since we won't validate something that is known to be invalid.

@NikVolf NikVolf added A3-in_progress Pull request is in progress. No review needed at this stage. B1-apinoteworthy labels Mar 11, 2020
@NikVolf NikVolf requested a review from tomusdrw as a code owner March 11, 2020 16:35
Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Can we get a test?

@NikVolf
Copy link
Contributor Author

NikVolf commented Mar 12, 2020

Can we get a test?

There are multiple tests altered and unaltered to show this should work

I'll add dedicated one to specify behaviour though, yes

@NikVolf NikVolf added this to the 2.0 milestone Mar 12, 2020
Copy link
Contributor

@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.

Looks good! Although I'd prefer to proceed with (empty) block production even though the transaction pool is not ready yet. Unless I can be proven that returning an error from block production will cause immediate restart or is just simply more desirable.

let pending_iterator = self.transaction_pool.ready();
let pending_iterator = match executor::block_on(future::select(
self.transaction_pool.ready_at(Some(self.parent_number)),
futures_timer::Delay::new(deadline - (self.now)()),
Copy link
Contributor

Choose a reason for hiding this comment

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

That might not give us enough time to produce anything. I think it should be half of the remaining time to at least produce an empty block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I somewhat agree

But also there is an argument that we must just fail here instead of trying to recover from some invalid system state (transaction pool does not receive new block notifications or cannot handle them fast for some reason). Timeout is therefore here (for now) just for avoiding thread hanging forever, not for some logic after it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to warning & continue

@NikVolf NikVolf added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Mar 12, 2020
@NikVolf
Copy link
Contributor Author

NikVolf commented Mar 12, 2020

Can we get a test?

@bkchr added!

@gavofyork gavofyork requested review from bkchr and tomusdrw March 15, 2020 19:22
let tx_remaining = 0;
let block = propose_block(&client, 1, 2, tx_remaining);
// now let's make sure that we can still make some progress
let block = propose_block(&client, 1, 2, 5);
Copy link
Member

Choose a reason for hiding this comment

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

Why did we had before 0 remaining and now 5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were 7 initially, and 2 was included in previous block
(see deleted comment above that outlines that 0 was an incorrect observation caused by the bug this pr aims to fix among other things)

@NikVolf NikVolf added A8-looksgood and removed A0-please_review Pull request needs code review. A5-grumble labels Mar 17, 2020
@gnunicorn gnunicorn merged commit abd00b1 into master Mar 17, 2020
@gnunicorn gnunicorn deleted the nv-txpool-poll branch March 17, 2020 15:24
General-Beck pushed a commit to General-Beck/substrate that referenced this pull request Mar 17, 2020
* make sure return ready iterator once state is updated

* update sc_basic_authorship tests

* update node tests

* fix manual seal

* actually fix service test

* add tests

* Update client/basic-authorship/src/basic_authorship.rs

Co-Authored-By: Tomasz Drwięga <[email protected]>

* helper function

* review suggestions

* warning and continue

* add debug log

* use futures::chennel::oneshot

* use declaration bound

* no option for updated_at

* no allocation

* ready_at / ready

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

Co-authored-by: Tomasz Drwięga <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
bkchr added a commit that referenced this pull request Mar 24, 2020
* make sure return ready iterator once state is updated

* update sc_basic_authorship tests

* update node tests

* fix manual seal

* actually fix service test

* add tests

* Update client/basic-authorship/src/basic_authorship.rs

Co-Authored-By: Tomasz Drwięga <[email protected]>

* helper function

* review suggestions

* warning and continue

* add debug log

* use futures::chennel::oneshot

* use declaration bound

* no option for updated_at

* no allocation

* ready_at / ready

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

* Update client/transaction-pool/src/lib.rs

Co-Authored-By: Bastian Köcher <[email protected]>

Co-authored-by: Tomasz Drwięga <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants