Skip to content

fix(fork-choice): preserve exact Gwei weights - #9821

Draft
GrapeBaBa wants to merge 1 commit into
ChainSafe:unstablefrom
GrapeBaBa:grapebaba/forkchoice-bigint-weight
Draft

fix(fork-choice): preserve exact Gwei weights#9821
GrapeBaBa wants to merge 1 commit into
ChainSafe:unstablefrom
GrapeBaBa:grapebaba/forkchoice-bigint-weight

Conversation

@GrapeBaBa

@GrapeBaBa GrapeBaBa commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Motivation

Fork choice stores validator balances in effective-balance increments, while the consensus specification computes proposer boost and reorg thresholds in Gwei. Flooring these values in whole increments can change fork-choice weights near the decision boundary.

Issue #9694 identifies Gwei bigint ProtoArray weights as the option that fully closes this precision gap and asks for its performance cost to be measured.

Closes #9694.

Description

  • Keep validator balances and computeDeltas() in number effective-balance increments.
  • Convert attestation deltas to Gwei bigint at the lower-cardinality ProtoArray update boundary.
  • Store ProtoArray weight, attestation score, proposer boost, and reorg thresholds as exact Gwei bigint values.
  • Preserve the specification division order in getCommitteeFraction().
  • Expose debug fork-choice weights as Gwei through ssz.Gwei. This intentionally changes the TypeScript API weight type from number to bigint.
  • Remove the compliance-test proposer-boost normalization and compare exact Gwei weights directly.

Benchmark

Node.js 24.15.0, 897,032 validators, active proposer boost, and 1,200 or 7,200 ProtoArray nodes. Fixture construction and GC run outside the timed updateHead() call. Each value is the median of three independent process-level averages with five samples per process.

Blocks Changed votes Base BigInt Difference
1,200 28,032 9.560 ms 9.829 ms +2.82%
1,200 89,703 9.871 ms 9.889 ms +0.19%
1,200 897,032 13.207 ms 13.175 ms -0.24%
7,200 28,032 11.491 ms 11.990 ms +4.34%
7,200 89,703 11.810 ms 12.263 ms +3.83%
7,200 897,032 15.254 ms 15.583 ms +2.16%

The validator count and total balance are mainnet-derived, but vote distribution and per-validator balances are synthetic rather than a replay of live mainnet traces.

This PR was written primarily by Codex.

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.59%. Comparing base (25a4a1c) to head (eb910bc).
⚠️ Report is 1 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #9821      +/-   ##
============================================
- Coverage     52.60%   52.59%   -0.01%     
============================================
  Files           848      848              
  Lines         59969    59959      -10     
  Branches       4414     4414              
============================================
- Hits          31545    31535      -10     
  Misses        28365    28365              
  Partials         59       59              
🚀 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.

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Compute proposer boost score using Gwei instead of ETH

1 participant