Skip to content

Conversation

wemeetagain
Copy link
Member

Motivation

Description

  • Add condition to blockInput.hasAllData to trigger if the number of columns is enough to reconstruct (gte NUMBER_OF_COLUMNS / 2)
  • Add consumer-driven delay of reconstruction (allows for easier setting the delay relative to the slot)
  • Set reconstruction delay to be after the 4 second mark during a slot

matthewkeil and others added 30 commits August 14, 2025 04:40
…hainSafe/lodestar into mkeil/refactor-block-input-on-unstable
wemeetagain and others added 8 commits September 12, 2025 11:48
**Motivation**

- clean up of block-input branch

**Description**

- bix build and unit test issues (many tests no longer relevant)
**Motivation**

- make e2e CI green for #8200

**Description**

- fix e2e for unknownBlockSync
- support fulu for other e2e tests

---------

Co-authored-by: Tuyen Nguyen <[email protected]>
@wemeetagain wemeetagain requested a review from a team as a code owner September 16, 2025 12:04
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @wemeetagain, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the block processing mechanism by allowing blocks to be considered 'complete' and imported earlier, specifically once half of the required data columns are received. It also introduces a more flexible, consumer-driven approach to managing reconstruction delays, which is then leveraged to strategically delay reconstruction until after the 4-second mark in a slot. This change aims to optimize network load, improve block propagation efficiency, and align reconstruction efforts with critical protocol timings, ultimately contributing to a more robust and performant beacon node.

Highlights

  • Reconstruction Trigger Condition: The blockInput.hasAllData condition now triggers if at least NUMBER_OF_COLUMNS / 2 are available, enabling earlier block processing and import once sufficient data is present.
  • Consumer-Driven Reconstruction Delay: The ColumnReconstructionTracker has been refactored to accept a delay parameter, allowing external callers to precisely specify the base delay before reconstruction occurs, enhancing control over timing.
  • Delayed Reconstruction in Gossip Handler: Reconstruction is now explicitly delayed until after the 4-second mark within a slot in the gossip handler, aligning with the head vote timing, and includes a small random component to desynchronize nodes and reduce peak load.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a feature to allow block import to proceed when at least half of the data columns are available, which is enough for reconstruction. It also makes the reconstruction delay configurable. The changes are a good step forward. My review focuses on a potential bug in determining data availability for reconstruction and a minor code redundancy that could be improved for clarity.

chain.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
chain.columnReconstructionTracker.triggerColumnReconstruction(
// wait to reconstruct until after head vote
getCutoffTimeMs(chain, dataColumnSlot, 4000),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be hard coding 4000 here, either SECONDS_PER_SLOT / INTERVALS_PER_SLOT or something similar to what we do in validator client

wemeetagain and others added 2 commits September 16, 2025 08:15
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 38.46154% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.35%. Comparing base (a6dd9e7) to head (22ee657).
⚠️ Report is 22 commits behind head on mkeil/refactor-block-input-on-unstable.

Additional details and impacted files
@@                            Coverage Diff                             @@
##           mkeil/refactor-block-input-on-unstable    #8408      +/-   ##
==========================================================================
- Coverage                                   54.42%   54.35%   -0.07%     
==========================================================================
  Files                                         853      853              
  Lines                                       63935    64085     +150     
  Branches                                     4787     4789       +2     
==========================================================================
+ Hits                                        34794    34833      +39     
- Misses                                      29070    29181     +111     
  Partials                                       71       71              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wemeetagain
Copy link
Member Author

Discussion from voice chat:

  • This PR needs to ensure that when we're "saving to db" that all custodied columns exist. Current logic here doesn't ensure this.

@wemeetagain
Copy link
Member Author

wemeetagain commented Sep 16, 2025

Notes related to having all custodied columns before persisting everything to db:

  • Basically, "allow block import after NUMBER_OF_COLUMNS / 2" feature motivation is to prevent outlier late received columns from delaying block processing and affecting head votes of attached validators.
  • We currently have eagerPersistBlock set to true, which attempts to persist the block to db concurrently with other validation like state transition - feature introduced in feat: batch io operations when verifying & importing block #5473
  • As it it currently implemented, eagerPersistBlock: true prevents this feature from easily fulfilling its purpose. (Persist step is awaited before block import)
  • We could set eagerPersistBlock to false always, update importBlock impl to not await writeBlockInputToDb (before updating the head), and trigger reconstruction in writeBlockInputDb if all columns aren't available.

// gossip block is validated, we want to process it asap
eagerPersistBlock: true,
// however, due to other optimizations, we don't eagerly persist the block
eagerPersistBlock: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do this for postfulu only? need to update comments as well if we do

// if we've received at least half of the columns, trigger reconstruction of the rest
if (blockInput.columnCount >= NUMBER_OF_COLUMNS / 2) {
chain.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
chain.columnReconstructionTracker.triggerColumnReconstruction(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing triggerColumnReconstruction in writeBlockInputToDeb.ts could be enough because data columns could be from different sources, not just gossip

// block is validated with correct root, we want to process it as soon as possible
eagerPersistBlock: true,
// however, due to other optimizations, we don't eagerly persist the block
eagerPersistBlock: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same to above, if we do this postfulu only, we don't have to worry about the current validator performance of electra

}

// Await writeBlockInputToDb if it was started above
await writeBlockInputPromise;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you move this to after "Imported block" log but before "Block processed" log
that's give us more detail about timing

const delay =
RECONSTRUCTION_DELAY_MIN_MS + Math.random() * (RECONSTRUCTION_DELAY_MAX_MS - RECONSTRUCTION_DELAY_MIN_MS);
sleep(delay).then(() => {
sleep(delay + Math.random() * RECONSTRUCTION_RANDOM_DELAY_MAX_MS).then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of having a mechanism to delay more based on number of columns arrived instead of a random()
similar to lighthouse
may want to revisit this later

Base automatically changed from mkeil/refactor-block-input-on-unstable to unstable September 18, 2025 11:49
@nflaig
Copy link
Member

nflaig commented Oct 3, 2025

needs to be rebased onto unstable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants