Remove Recommit and Fix Parent Actual Time track on Prepare#1938
Remove Recommit and Fix Parent Actual Time track on Prepare#1938
Conversation
There was a problem hiding this comment.
Pull request overview
This PR disables the recommit mechanism in the miner and fixes how parent block ActualTime is tracked in the Bor consensus engine. The recommit feature was disabled because current block production time already consumes most of the block interval, making reprocessing wasteful. The parent ActualTime tracking was improved to use a hash-based cache lookup instead of relying on the assumption that the last locally processed block was always the parent, fixing timestamp progression issues especially during multiple Prepare invocations for the same block.
Key Changes:
- Disables the recommit timer mechanism in the miner's work loop by adding a continue statement
- Replaces
lastMinedBlockTimefield withparentActualTimeCache(LRU cache) in Bor consensus engine - Updates
Prepare()to look up parent ActualTime by ParentHash from the cache instead of using a single shared timestamp - Updates
FinalizeAndAssemble()to store the block's ActualTime in the cache keyed by block hash
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| miner/worker.go | Disables the recommit mechanism in the work loop by replacing the timer case logic with a continue statement and commenting out the original recommit code |
| consensus/bor/bor.go | Replaces the lastMinedBlockTime field with a hash-based LRU cache (parentActualTimeCache) to properly track parent block ActualTime, updating both Prepare() to retrieve from cache and FinalizeAndAssemble() to store to cache |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
There seems to be some compilation errors for tests due to these changes. Other than that - and the suggestions from @kamuikatsurgi - LGTM, thanks |
|
* Revert recorded write operations when tx fails * Revert selfdestruct on failure * Added test for selfdestruct revert write * Add HasSelfDestructed check when applying to final db * p2p: added functionality to temporarily ban peers to prevent connections (#1922) * p2p: added functionality to temporarily ban peers to prevent connections * p2p: cleanup * chore: bump kurtosis-pos (#1923) * chore: bump kurtosis-pos * chore: nits * chore: install go * fix(miner): delete pending task after successful block sealing to prevent node stall (#1929) * fix(miner): delete pending task after successful block sealing to prevent node stall * chore: nits * chore: set staleThreshold to 0 * chore: update comment * Remove Recommit and Fix Parent Actual Time track on Prepare (#1938) * remove recommit and track parent actual time * applying pr comments * fix actual time cache store place * chore: update deps (#1939) chore: update deps * bump version * bump version * stable version --------- Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com>
* bump version * stable version * V2.5.6 candidate (#1941) * Revert recorded write operations when tx fails * Revert selfdestruct on failure * Added test for selfdestruct revert write * Add HasSelfDestructed check when applying to final db * p2p: added functionality to temporarily ban peers to prevent connections (#1922) * p2p: added functionality to temporarily ban peers to prevent connections * p2p: cleanup * chore: bump kurtosis-pos (#1923) * chore: bump kurtosis-pos * chore: nits * chore: install go * fix(miner): delete pending task after successful block sealing to prevent node stall (#1929) * fix(miner): delete pending task after successful block sealing to prevent node stall * chore: nits * chore: set staleThreshold to 0 * chore: update comment * Remove Recommit and Fix Parent Actual Time track on Prepare (#1938) * remove recommit and track parent actual time * applying pr comments * fix actual time cache store place * chore: update deps (#1939) chore: update deps * bump version * bump version * stable version --------- Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com> * Unstuck * Added block range check * bump version 2.5.7 * bump to 2.5.6-beta3 --------- Co-authored-by: Lucca Martins <lucca_martins30@yahoo.com.br> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com>
…block building work (#1943) * bump version * stable version * V2.5.6 candidate (#1941) * Revert recorded write operations when tx fails * Revert selfdestruct on failure * Added test for selfdestruct revert write * Add HasSelfDestructed check when applying to final db * p2p: added functionality to temporarily ban peers to prevent connections (#1922) * p2p: added functionality to temporarily ban peers to prevent connections * p2p: cleanup * chore: bump kurtosis-pos (#1923) * chore: bump kurtosis-pos * chore: nits * chore: install go * fix(miner): delete pending task after successful block sealing to prevent node stall (#1929) * fix(miner): delete pending task after successful block sealing to prevent node stall * chore: nits * chore: set staleThreshold to 0 * chore: update comment * Remove Recommit and Fix Parent Actual Time track on Prepare (#1938) * remove recommit and track parent actual time * applying pr comments * fix actual time cache store place * chore: update deps (#1939) chore: update deps * bump version * bump version * stable version --------- Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com> * fix: add pendingWorkBlock to prevent duplicate work * fix: if check * nit: comment * chore: bump version * chore: add pending work check in new head event as well * chore: read veblop timeout --------- Co-authored-by: Lucca Martins <lucca_martins30@yahoo.com.br> Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com>
* bump version * Revert "V2.5.6 candidate (#1941)" This reverts commit 85b5ef7. * fix: ignore invalid signer error for specific block range (#1944) * bump version * stable version * V2.5.6 candidate (#1941) * Revert recorded write operations when tx fails * Revert selfdestruct on failure * Added test for selfdestruct revert write * Add HasSelfDestructed check when applying to final db * p2p: added functionality to temporarily ban peers to prevent connections (#1922) * p2p: added functionality to temporarily ban peers to prevent connections * p2p: cleanup * chore: bump kurtosis-pos (#1923) * chore: bump kurtosis-pos * chore: nits * chore: install go * fix(miner): delete pending task after successful block sealing to prevent node stall (#1929) * fix(miner): delete pending task after successful block sealing to prevent node stall * chore: nits * chore: set staleThreshold to 0 * chore: update comment * Remove Recommit and Fix Parent Actual Time track on Prepare (#1938) * remove recommit and track parent actual time * applying pr comments * fix actual time cache store place * chore: update deps (#1939) chore: update deps * bump version * bump version * stable version --------- Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com> * Unstuck * Added block range check * bump version 2.5.7 * bump to 2.5.6-beta3 --------- Co-authored-by: Lucca Martins <lucca_martins30@yahoo.com.br> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com> * fix(miner): track pending work using block number to avoid duplicate block building work (#1943) * bump version * stable version * V2.5.6 candidate (#1941) * Revert recorded write operations when tx fails * Revert selfdestruct on failure * Added test for selfdestruct revert write * Add HasSelfDestructed check when applying to final db * p2p: added functionality to temporarily ban peers to prevent connections (#1922) * p2p: added functionality to temporarily ban peers to prevent connections * p2p: cleanup * chore: bump kurtosis-pos (#1923) * chore: bump kurtosis-pos * chore: nits * chore: install go * fix(miner): delete pending task after successful block sealing to prevent node stall (#1929) * fix(miner): delete pending task after successful block sealing to prevent node stall * chore: nits * chore: set staleThreshold to 0 * chore: update comment * Remove Recommit and Fix Parent Actual Time track on Prepare (#1938) * remove recommit and track parent actual time * applying pr comments * fix actual time cache store place * chore: update deps (#1939) chore: update deps * bump version * bump version * stable version --------- Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com> * fix: add pendingWorkBlock to prevent duplicate work * fix: if check * nit: comment * chore: bump version * chore: add pending work check in new head event as well * chore: read veblop timeout --------- Co-authored-by: Lucca Martins <lucca_martins30@yahoo.com.br> Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> * chore: bump version to v2.5.6-beta4 * fix(rpc): maxFeePerGas and maxPriorityFeePerGas for StateSyncTx type (#1952) * Fix missing chain validator service setup (#1957) * eth/protocols/wit: made protocol version consistent (#1940) * eth: add missing checker initialization * core: add log when verifyPendingHeaders is skipped * Revert "eth/protocols/wit: made protocol version consistent (#1940)" This reverts commit c98a00e. --------- Co-authored-by: Pratik Patil <pratikspatil024@gmail.com> * fix(api): traceBlock (#1959) * Revert "Merge branch 'master' into v2.5.6-candidate" This reverts commit 809b189, reversing changes made to 1dbae9d. * version bump to v2.5.6-beta5 * Dandeli HF: modify block gas target calculations (#1968) * remove baseFee validation after hf * remove logs * params, consensus: use target gas percentage for base fee calculations * cleanup * add comments * consensus/misc/eip1559: add tests for untitled HF * typo * test fixes * update HF name to dandeli * simplify * update gas target to 65%, fix tests * update comment * fix tests * fix tests * fix tests * schedule dandeli HF for amoy at block 31890000 * fix lint * add missing madhugiripro HF in amoy genesis --------- Co-authored-by: Lucca Martins <lucca_martins30@yahoo.com.br> * params: bump version to v2.5.6-beta6 * Update DandeliBlock HF for mainnet and bump version --------- Co-authored-by: Lucca Martins <lucca_martins30@yahoo.com.br> Co-authored-by: Angel Valkov <avalkov@polygon.technology> Co-authored-by: Marcello Ardizzone <marcelloardizzone@hotmail.it> Co-authored-by: Krishang <109511742+kamuikatsurgi@users.noreply.github.com> Co-authored-by: kamuikatsurgi <shahkrishang11@gmail.com> Co-authored-by: Raneet Debnath <35629432+Raneet10@users.noreply.github.com> Co-authored-by: Manav Darji <manavdarji.india@gmail.com> Co-authored-by: Jerry <jerrycgh@gmail.com>



Description
This PR disables the recommit mechanism and improves how the parent header ActualTime is tracked. Recommit was removed because our current block production/plotting time already consumes most of the block interval, making reprocessing the same block wasteful and counter-productive, as those resources are better reserved for the next block. In addition, the parent ActualTime is now derived from the correct parent block (by hash) when available, instead of assuming the last locally processed block was always the parent. This fixes incorrect timestamp progression and avoids longer-than-expected waiting slots, especially when Prepare is invoked multiple times for the same block (e.g. during recommits).
Changes