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

Quickly skip invalid transactions during block authorship. #9789

Merged
9 commits merged into from
Oct 1, 2021
Merged

Conversation

tomusdrw
Copy link
Contributor

Before this PR, basic authorship crate was trying to push to the block each and every ready transaction received from the transaction pool.

This might be costly, cause it involves multiple calls into the runtime. It's especially inefficient for transactions that are well known to be invalid before even attempting to execute them, because they depend (i.e. require) some other transaction that was found to be invalid.

Same logic applies to transactions that are skipped due to resource exhaustion (i.e. they are unable to fit the block, cause it contains a few transactions already that consumed much of the available weight or block length size).

After the PR, the authorship task reports invalidity of transactions back to the iterator, which keeps track of invalid transactions and is able to skip the dependent ones efficiently (i.e. does not even return them to the authorship task).

This should speed up block authorship in the edge case of block being partially full already or in case there is a long chain of transactions that depend on a invalid one.

Note that the authorship task does not ask the transaction pool to remove the transactions that were skipped - this is desired, the pool itself should re-validate transactions that depend on a first-in-chain transaction reported as invalid.

@tomusdrw tomusdrw added A0-please_review Pull request needs code review. B5-clientnoteworthy C1-low PR touches the given topic and has a low impact on builders. labels Sep 15, 2021
@tomusdrw tomusdrw requested a review from bkchr September 15, 2021 15:42
Cargo.lock Outdated Show resolved Hide resolved
@tomusdrw
Copy link
Contributor Author

tomusdrw commented Oct 1, 2021

bot merge

@ghost
Copy link

ghost commented Oct 1, 2021

Trying merge.

@ghost
Copy link

ghost commented Oct 1, 2021

Bot will approve on the behalf of @tomusdrw, since they are a team lead, in an attempt to reach the minimum approval count

@ghost ghost merged commit c60ccc0 into master Oct 1, 2021
@ghost ghost deleted the td-invalid-skip branch October 1, 2021 14:25
ordian added a commit that referenced this pull request Oct 2, 2021
* master: (67 commits)
  Downstream `node-template` pull (#9915)
  Implement core::fmt::Debug for BoundedVec (#9914)
  Quickly skip invalid transactions during block authorship. (#9789)
  Add SS58 prefix for Automata (#9805)
  Clean up sc-peerset (#9806)
  Test each benchmark case in own #[test] (#9860)
  Add build with docker section to README (#9792)
  Simple Trait to Inspect Metadata (#9893)
  Pallet Assets: Create new asset classes from genesis config (#9742)
  doc: subkey usage (#9905)
  Silence alert about large-statement-fetcher (#9882)
  Fix democracy on-initialize weight (#9890)
  Fix basic authorship flaky test (#9906)
  contracts: Add event field names (#9896)
  subkey readme update on install (#9900)
  add feature wasmtime-jitdump (#9871)
  Return `target_hash` for finality_target instead of an Option (#9867)
  Update wasmtime to 0.29.0 (#9552)
  Less sleeps (#9848)
  remove unidiomatic (#9895)
  ...
ordian added a commit that referenced this pull request Oct 5, 2021
* master: (125 commits)
  Update multiple dependencies (#9936)
  Speed up timestamp generation when logging (#9933)
  First word should be Substrate not Polkadot (#9935)
  Improved file not found error message (#9931)
  don't read events in elections anymore. (#9898)
  Remove incorrect sanity check (#9924)
  Require crypto scheme for `insert-key` (#9909)
  chore: refresh of the substrate_builder image (#9808)
  Introduce block authorship soft deadline (#9663)
  Rework Transaction Priority calculation (#9834)
  Do not propagate host RUSTFLAGS when checking for WASM toolchain (#9926)
  Small quoting comment fix (#9927)
  add clippy to CI (#9694)
  Ensure BeforeBestBlockBy voting rule accounts for base (#9920)
  rm `.maintain` lock (#9919)
  Downstream `node-template` pull (#9915)
  Implement core::fmt::Debug for BoundedVec (#9914)
  Quickly skip invalid transactions during block authorship. (#9789)
  Add SS58 prefix for Automata (#9805)
  Clean up sc-peerset (#9806)
  ...
niklasad1 added a commit that referenced this pull request Oct 8, 2021
bkchr added a commit that referenced this pull request Apr 13, 2023
The check was intially added by: #5121

But a later pr fixed it properly: #9789

TLDR: We don't need to check for skipped anymore, as we already remove all transactions that are
being unlocked by an invalid transactions and thus, we will not tag them as invalid directly because
the nonce for example is incorrect.

Fixes: #13911
bkchr added a commit that referenced this pull request Apr 14, 2023
The check was intially added by: #5121

But a later pr fixed it properly: #9789

TLDR: We don't need to check for skipped anymore, as we already remove all transactions that are
being unlocked by an invalid transactions and thus, we will not tag them as invalid directly because
the nonce for example is incorrect.

Fixes: #13911
nathanwhit pushed a commit to nathanwhit/substrate that referenced this pull request Jul 19, 2023
The check was intially added by: paritytech#5121

But a later pr fixed it properly: paritytech#9789

TLDR: We don't need to check for skipped anymore, as we already remove all transactions that are
being unlocked by an invalid transactions and thus, we will not tag them as invalid directly because
the nonce for example is incorrect.

Fixes: paritytech#13911
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants