Skip to content

perf: speed up builder onboarding at the Gloas fork transition#9397

Draft
twoeths wants to merge 16 commits into
ChainSafe:unstablefrom
twoeths:te/improve_onboard_builders
Draft

perf: speed up builder onboarding at the Gloas fork transition#9397
twoeths wants to merge 16 commits into
ChainSafe:unstablefrom
twoeths:te/improve_onboard_builders

Conversation

@twoeths
Copy link
Copy Markdown
Contributor

@twoeths twoeths commented May 22, 2026

Motivation

Improve the performance of builder onboarding at the Gloas fork transition.
upgradeStateToGloasonboardBuildersFromPendingDeposits onboards builders from the pending deposit queue, which was prohibitively slow for a large number of builders.
See #9395 for the benchmark before this improvement.

Description

  • add a perf benchmark for upgradeStateToGloas builder onboarding, sweeping builder counts (5k / 10k / 20k / 30k)
  • track the index of each builder pubkey in a map to avoid looping through the registry per deposit
  • append new builders directly, since the registry is empty at the fork — this avoids another loop (the slot-reuse scan)
  • verify deposit signatures lazily in batches of 32 via verifyMultipleAggregateSignatures instead of one at a time
  • onboarding 20k builders at the fork drops from >100s to ~2.7s in my local benchmark
upgradeStateToGloas - onboard builders
  ✔ upgradeStateToGloas - onboard 5000 builders                         1.401911 ops/s    713.3120 ms/op        -          3 runs   2.99 s
  ✔ upgradeStateToGloas - onboard 10000 builders                       0.7338705 ops/s    1.362638  s/op        -          3 runs   5.62 s
  ✔ upgradeStateToGloas - onboard 20000 builders                       0.3715238 ops/s    2.691618  s/op        -          3 runs   11.1 s
  ✔ upgradeStateToGloas - onboard 30000 builders                       0.2475123 ops/s    4.040203  s/op        -          3 runs   16.8 s

AI Assistance Disclosure

Used Claude Code.

Copy link
Copy Markdown
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 optimizes the builder onboarding process during the Gloas fork transition by implementing lazy batch signature verification for builder deposits. Key changes include the introduction of verifyDepositSignatures for batched BLS verification, a refactored onboardBuildersFromPendingDeposits function that processes deposits in batches of 32, and the addition of performance benchmarks and unit tests to ensure correctness and efficiency. Feedback suggests further optimizing verifyDepositSignatures by moving signature deserialization into the initial loop to avoid redundant work and simplify the batch verification call.

Comment thread packages/state-transition/src/block/processDepositRequest.ts Outdated
@twoeths twoeths marked this pull request as ready for review May 22, 2026 10:36
@twoeths twoeths requested a review from a team as a code owner May 22, 2026 10:36
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.55%. Comparing base (6c85077) to head (3a60596).

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #9397      +/-   ##
============================================
- Coverage     52.55%   52.55%   -0.01%     
============================================
  Files           848      848              
  Lines         60947    60946       -1     
  Branches       4486     4486              
============================================
- Hits          32032    32031       -1     
  Misses        28853    28853              
  Partials         62       62              
🚀 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.

@twoeths
Copy link
Copy Markdown
Contributor Author

twoeths commented May 22, 2026

this is still not fast enough in a typical server

packages/state-transition/test/perf/slot/upgradeStateToGloas.test.ts
  upgradeStateToGloas - onboard builders
    ✔ upgradeStateToGloas - onboard 5000 builders                        0.5386571 ops/s    1.856469  s/op        -          3 runs   7.74 s
    ✔ upgradeStateToGloas - onboard 10000 builders                       0.2828542 ops/s    3.535391  s/op        -          3 runs   14.6 s
    ✔ upgradeStateToGloas - onboard 20000 builders                       0.1450163 ops/s    6.895774  s/op        -          3 runs   28.6 s
    ✔ upgradeStateToGloas - onboard 30000 builders                      0.09686719 ops/s    10.32341  s/op        -          3 runs   42.6 s

update after f755870

upgradeStateToGloas - onboard builders
    ✔ upgradeStateToGloas - onboard 5000 builders                        0.7375614 ops/s    1.355819  s/op        -          3 runs   6.11 s
    ✔ upgradeStateToGloas - onboard 10000 builders                       0.3690238 ops/s    2.709852  s/op        -          3 runs   11.2 s
    ✔ upgradeStateToGloas - onboard 20000 builders                       0.1785821 ops/s    5.599667  s/op        -          3 runs   22.7 s
    ✔ upgradeStateToGloas - onboard 30000 builders                       0.1297449 ops/s    7.707432  s/op        -          3 runs   31.7 s

@twoeths twoeths marked this pull request as draft May 23, 2026 07:33
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.

1 participant