-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: validate transactions in parallel (#12654)
In the old flow, validation (including signature checks) happened inside `verify_and_charge_transaction()`. In the new flow, we first run `parallel_validate_transactions()` to validate and compute the transaction cost (including signature checks) in parallel. Only after a transaction passes validation do we call `verify_and_charge_transaction()` with the known `cost`. ```mermaid graph TD; subgraph Old_Flow A[Runtime::apply] A-->B[self.process_transactions] B-->C[process_transaction] C-->D[verify_and_charge_transaction] D-->E[validate_transaction incl. signature] E-->|Valid|F[charge fees & finalize] E-->|Invalid|G[reject tx] end subgraph New_Flow A2[Runtime::apply] A2-->H[self.process_transactions] H-->|parallel|I[parallel_validate_transactions incl. signature] I-->|Valid, get cost|J[process_transaction] J-->K[verify_and_charge_transaction] K-->L[charge fees & finalize] I-->|Invalid|M[reject tx early] classDef threaded fill:#3240a8,stroke:#333,stroke-width:2px; class I threaded; end ``` (blue = running in parallel) ## Testing The change brings ~20% throughput improvement on `n2d-standard-16` ```sh 1006/1006 blocks applied in 2m at a rate of 7.5129/s. 0s remaining. Skipped 0 blocks. Over last 100 blocks to height 1073: 0 empty blocks, averaging 413.00 Tgas per non-empty block ``` ```sh 1007/1007 blocks applied in 2m at a rate of 8.9972/s. 0s remaining. Skipped 0 blocks. Over last 100 blocks to height 1073: 0 empty blocks, averaging 413.00 Tgas per non-empty block ``` Additionally, profiles before and after the change are available: [before](https://share.firefox.dev/4a5W9tO), [after](https://share.firefox.dev/40pd4oe)
- Loading branch information
1 parent
cf45cc5
commit abe4a60
Showing
4 changed files
with
445 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.