perf(app): parallelize per-tx gas classification in checkTotalBlockGas#3399
Open
amir-deris wants to merge 3 commits intomainfrom
Open
perf(app): parallelize per-tx gas classification in checkTotalBlockGas#3399amir-deris wants to merge 3 commits intomainfrom
amir-deris wants to merge 3 commits intomainfrom
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3399 +/- ##
=======================================
Coverage 59.03% 59.04%
=======================================
Files 2102 2102
Lines 173237 173256 +19
=======================================
+ Hits 102277 102291 +14
- Misses 62083 62086 +3
- Partials 8877 8879 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
checkTotalBlockGasiterates every tx in a proposed block to compute total gas. Each tx's classification (EVM check, gasless check, gas extraction) is independent, making the loop a natural fan-out target.Changes
checkTotalBlockGas— replaced the serial loop with a two-phase design:classifyTxForGas. Results are written into a pre-allocated[]txGasResultslice indexed by position (no lock needed on the slice).MaxGasWanted/MaxGaslimit enforcement.classifyTxForGas— extracted helper that owns all per-tx logic. EVM txs (the vast majority) run fully unlocked. The non-EVMIsTxGaslesspath takes actxMumutex becausesdk.Contextwraps aCacheMultiStorethat is not goroutine-safe.txGasResult— small struct (gasWanted,gasContrib,skip,malicious) that carries each tx's outcome between phases.nonzeroTxsCnt— it was declared and incremented but never read.Safety
results[i]slot;ctxMuserializes the only shared-state reader (IsTxGasless).ctxMuis uncontested — oracle-vote txs are the only non-EVM path that acquires it.