Skip to content

perf(state-transition): avoid per-validator pubkey lookups in epoch updated#3130

Draft
fridrik01 wants to merge 2 commits into
mainfrom
imporove-perf-epoch-deposit
Draft

perf(state-transition): avoid per-validator pubkey lookups in epoch updated#3130
fridrik01 wants to merge 2 commits into
mainfrom
imporove-perf-epoch-deposit

Conversation

@fridrik01

@fridrik01 fridrik01 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

I noticed that on our devnet-core after running load testing for a few hours that block times became unstable after several hours. Looking at the logs it seems that we hit timeouts in process_proposal always at epoch boundaries.

When running our load testing harness, it injects thousands of deposits, and each creates a validator entry. Then at every epoch boundary processEpoch iterates the whole registry, and processEffectiveBalanceUpdates did a per-validator pubkey->index lookup plus a single-key balance read. That is ~2N small reads against disk-backed IAVL on Longhorn. With a bloated registry that makes many random I/O reads, and having Longhorn's high latency spikes we are often exceeding the consensus timeouts at epoch boundaries.

To address this, this PR:

  • Bulk loads balances via GetBalances() instead of per-validator GetBalance (validators and balances are index-keyed and dense, so balances[i] == validator i).
  • Drop the redundant ValidatorIndexByPubkey lookups in processEffectiveBalanceUpdates and processRegistryUpdates, since the loop index already is the validator index.
  • Adds temporary per-step timing logs in processEpoch to confirm which step dominates (we can remove this devnet-core testing).

Going to push a tag from this PR and deploy it to devnet-core and monitor

@fridrik01 fridrik01 self-assigned this Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch imporove-perf-epoch-deposit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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