-
Notifications
You must be signed in to change notification settings - Fork 577
Prefetch Transactions from Pool & PIP-66 Back #2031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Code ReviewBug found in consensus/bor/bor.go at line 1080 The delay calculation delay = time.Until(parentTime) computes time until the PARENT block timestamp. Since the parent block has already been mined, its timestamp is in the past, making this a negative duration. When time.After(delay) is called with a negative duration at line 1102 ( Lines 1101 to 1103 in 0077186
The old Seal logic correctly waited until header.GetActualTime() (the new block target time, which is in the future): Lines 1367 to 1370 in 0077186
Suggested fix at line 1080 ( Lines 1078 to 1082 in 0077186
Note: The test at line 1741 passes because it sets genesis time 3 seconds in the future, which makes parentTime positive. In production, the parent block is always in the past. Checked for bugs and CLAUDE.md compliance. |
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (83.64%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #2031 +/- ##
===========================================
+ Coverage 49.59% 49.78% +0.18%
===========================================
Files 874 873 -1
Lines 150517 150788 +271
===========================================
+ Hits 74652 75069 +417
+ Misses 70837 70648 -189
- Partials 5028 5071 +43
... and 24 files with indirect coverage changes
🚀 New features to boost your workflow:
|
The delay calculation Design IntentThe Rio fork allows early block announcement to improve block propagation speed. The primary producer (succession == 0) can produce and announce blocks as soon as Key timing relationships:
Why negative delays are correctIn production, when the parent block is in the past:
|
cffls
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.
This PR is quite large to review, and it essentially contains two features. If possible, could you split it into two, one is about PIP-66 and the other is txns prefetch?
Yeah, I do also agree it got big. But is important to point that the Transaction Prefetching benefits and partially depends on PIP-66. So it would be a bit hard trying to split those changes now. What I'll try to do is provided a summary of snippets related to the PIP-66 below. 1. Early Announcement CheckThis section introduces a new and more flexible way to check early announcements too early because of the introduced Lines 405 to 438 in 6acb9e1
2. Accounting the Announcement Time into timeout for span checkAs we discussed on a chat, this address the original issue we got when introduction PIP-66. Which were considering the announcement time on the TTL instead of block time itself. Lines 496 to 508 in 6acb9e1
3. Wait on
|
| func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header, waitOnPrepare bool) error { |
|



Description
SealtoPreparephaseKey Changes
1. State Prefetching from Transaction Pool
miner/worker.go,core/state_prefetcher.go2. Configuration Flags
--miner.prefetch: Enable/disable transaction pool prefetching (default: disabled)--miner.prefetch.gaslimit.percent: Percentage of block gas limit to be used as internal limit of prefetched transactions.3. Enhanced Metrics
miner/worker.go,core/state/reader.go,core/blockchain.goworker/chain/...)hit_from_prefetch: Cache hits attributed to prefetchprefetch_used_unique: Unique accounts loaded by prefetch and used during processingTechnical Details
Prefetch Flow
commitWorkis called, two parallel operations start:preparephase)Results
From a local test with
polyclirunning bothrandomandUniswapmode we observed that many storages that never were prefetched are now being prefetched and also a slightly increase on accounts being early prefetchedPS: The second instance is the one with prefetchFromPool activated
Changes
Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it
Nodes audience
In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)
Checklist
Cross repository changes
Testing
Manual tests
Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it
Additional comments
Please post additional comments in this section if you have them, otherwise delete it