Repository navigation
feat: cache builder deposit signatures for gloas fork transition #9727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,110
−73
Merged
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aa035b0
feat: cache builder deposit signatures for gloas fork transition
twoeths 457e9cd
fix: handle error thrown per verify()
twoeths cb473cf
fix: simplify metric buckets
twoeths 2d90027
chore: add upgradeStateToGloasCacheHit.test.ts unit test
twoeths 6d249a7
fix: linting
twoeths 9489a34
Merge branch 'unstable' into te/gloas_onboard_builders_at_fork
nflaig a37f5d3
feat: time box preverify step
twoeths b352417
feat: preverify validator deposits with same builder pubkey
twoeths 625fe33
fix: specrefs
twoeths ea2360e
fix: only pre-verify validator deposits until a valid signature found
twoeths a6297dd
Merge branch 'unstable' into te/gloas_onboard_builders_at_fork
nflaig 221a4ff
Merge branch 'unstable' into te/gloas_onboard_builders_at_fork
nflaig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/state-transition/src/cache/builderDepositSignatureCache.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import {electra} from "@lodestar/types"; | ||
|
|
||
| /** | ||
| * Caches builder-deposit signature-verification results — passes (`true`) and failures (`false`) | ||
| * — so the Fulu → Gloas fork transition can skip the bulk verification cost AND skip re-verifying | ||
| * deposits already proven invalid. | ||
| * | ||
| * Keyed by the deposit's struct **value object** — `electra.PendingDeposit` is a | ||
| * `ContainerNodeStructType`, so its `node.value` is a stable object reused across | ||
| * prepareNextSlot-derived states and carried by reference through the gloas pendingDeposits | ||
| * migration. No merkle-root computation, no slot bucketing. | ||
| * | ||
| * Lifecycle owned by `prepareNextSlot`: filled during the pre-fork window, then `clear()`ed once the | ||
| * Gloas fork is finalized. `onboardBuildersFromPendingDeposits()` only reads it. A plain `Map` (not a | ||
| * `WeakMap`) is used so the drop is deterministic and the contents are inspectable for logging. | ||
| * | ||
| * Single instance across the application (created in `EpochCache.createFromState`, shared | ||
| * by-reference through `clone()`). | ||
| */ | ||
| export class BuilderDepositSignatureCache { | ||
| private validityByDeposit = new Map<electra.PendingDeposit, boolean>(); | ||
|
|
||
| setSignatureValidity(deposit: electra.PendingDeposit, isValid: boolean): void { | ||
| this.validityByDeposit.set(deposit, isValid); | ||
| } | ||
|
|
||
| getSignatureValidity(deposit: electra.PendingDeposit): boolean | null { | ||
| return this.validityByDeposit.get(deposit) ?? null; | ||
| } | ||
|
|
||
| isVerified(deposit: electra.PendingDeposit): boolean { | ||
| return this.validityByDeposit.has(deposit); | ||
| } | ||
|
|
||
| /** Cumulative builder deposits verified & cached this window (pass + fail). */ | ||
| get size(): number { | ||
| return this.validityByDeposit.size; | ||
| } | ||
|
|
||
| clear(): void { | ||
| this.validityByDeposit.clear(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there can be attackers that submit a bunch of deposits with invalid signature that force us to fall back to verify one by one which makes lodestar hard to keep up.
They only need 1 bad deposit per batch (32 deposits) to nullify all the optimizations here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a valid concern but also the attacker would burn the eth, so it's basically a trade-off here, we want the batch sizes to be large enough to get benefits from batching but not too large so an invalid signature can't waste too much time/compute