-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Produce block always on updated transaction pool state #5227
Conversation
bkchr
left a comment
There was a problem hiding this 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?
There are multiple tests altered and unaltered to show this should work I'll add dedicated one to specify behaviour though, yes |
tomusdrw
left a comment
There was a problem hiding this 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)()), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to warning & continue
Co-Authored-By: Tomasz Drwięga <[email protected]>
@bkchr added! |
| 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
Co-Authored-By: Bastian Köcher <[email protected]>
Co-Authored-By: Bastian Köcher <[email protected]>
Co-Authored-By: Bastian Köcher <[email protected]>
Co-Authored-By: Bastian Köcher <[email protected]>
Co-Authored-By: Bastian Köcher <[email protected]>
Co-Authored-By: Bastian Köcher <[email protected]>
* 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]>
* 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]>
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:
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.