-
-
Notifications
You must be signed in to change notification settings - Fork 478
feat: backfill sync v2 #9238
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
base: unstable
Are you sure you want to change the base?
feat: backfill sync v2 #9238
Changes from all commits
279d9a7
ccb53a5
2461dcf
2a20b91
8de52ce
82ac45f
c31d365
6c15473
a94df82
c04375b
cd7a327
8a122a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,7 @@ export enum Bucket { | |
| // altair_lightClientSyncCommitteeProof = 35, // DEPRECATED on v0.32.0 | ||
| // index_lightClientInitProof = 36, // DEPRECATED on v0.32.0 | ||
|
|
||
| backfilled_ranges = 42, // Backfilled From to To, inclusive of both From, To | ||
| backfill_state = 42, // Epoch -> EpochBackfillState | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repurposing bucket ID
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed — verified by diffing
Same ID, different schema. Any existing node DB has entries at bucket 42 in the old |
||
|
|
||
| // Buckets to support LightClient server v2 | ||
| lightClient_syncCommitteeWitness = 51, // BlockRoot -> SyncCommitteeWitness | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import {ContainerType, ListBasicType, OptionalType, ValueOf} from "@chainsafe/ssz"; | ||
| import {ChainForkConfig} from "@lodestar/config"; | ||
| import {DatabaseController, Repository} from "@lodestar/db"; | ||
| import {NUMBER_OF_COLUMNS} from "@lodestar/params"; | ||
| import {ssz} from "@lodestar/types"; | ||
| import {bytesToInt} from "@lodestar/utils"; | ||
| import {Bucket, getBucketNameByValue} from "../buckets.js"; | ||
| import {BACKFILLED_RANGE_KEY} from "../single/backfilledRange.js"; | ||
|
|
||
| export const backfillStateWrapperSsz = new ContainerType( | ||
| { | ||
| hasBlock: ssz.Boolean, | ||
| hasBlobs: new OptionalType(ssz.Boolean), | ||
| columnIndices: new OptionalType(new ListBasicType(ssz.ColumnIndex, NUMBER_OF_COLUMNS)), | ||
| }, | ||
| {typeName: "BackfillStateWrapper", jsonCase: "eth2"} | ||
| ); | ||
| export type BackfillStateWrapper = ValueOf<typeof backfillStateWrapperSsz>; | ||
|
|
||
| export class BackfillStateRepository extends Repository<number, BackfillStateWrapper> { | ||
| constructor(config: ChainForkConfig, db: DatabaseController<Uint8Array, Uint8Array>) { | ||
| const bucket = Bucket.backfill_state; | ||
| super(config, db, bucket, backfillStateWrapperSsz, getBucketNameByValue(bucket)); | ||
| } | ||
|
|
||
| encodeKey(key: number): Uint8Array { | ||
| if (key === BACKFILLED_RANGE_KEY) { | ||
| throw new Error("Reserved key for backfill range singleton object"); | ||
| } | ||
| return super.encodeKey(key); | ||
| } | ||
|
|
||
| decodeKey(data: Uint8Array): number { | ||
| return bytesToInt(super.decodeKey(data) as unknown as Uint8Array, "be"); | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import {ContainerType, ValueOf} from "@chainsafe/ssz"; | ||
| import {ChainForkConfig} from "@lodestar/config"; | ||
| import {Db, DbReqOpts, encodeKey} from "@lodestar/db"; | ||
| import {ssz} from "@lodestar/types"; | ||
| import {Bucket, getBucketNameByValue} from "../buckets.js"; | ||
|
|
||
| export const backfilledRangeWrapperSsz = new ContainerType( | ||
| {beginningEpoch: ssz.Epoch, endingEpoch: ssz.Epoch}, | ||
| {typeName: "BackfilledRange", jsonCase: "eth2"} | ||
| ); | ||
| export type BackfilledRangeWrapper = ValueOf<typeof backfilledRangeWrapperSsz>; | ||
| export const BACKFILLED_RANGE_KEY = -1; | ||
|
|
||
| export class BackfilledRange { | ||
| private readonly db: Db; | ||
| private readonly key: Uint8Array; | ||
| private readonly dbReqOpts: DbReqOpts; | ||
|
|
||
| constructor(_config: ChainForkConfig, db: Db) { | ||
| this.db = db; | ||
| this.key = encodeKey(Bucket.backfill_state, BACKFILLED_RANGE_KEY); | ||
| this.dbReqOpts = {bucketId: getBucketNameByValue(Bucket.backfill_state)}; | ||
| } | ||
|
|
||
| async put(value: BackfilledRangeWrapper): Promise<void> { | ||
| await this.db.put(this.key, backfilledRangeWrapperSsz.serialize(value), this.dbReqOpts); | ||
| } | ||
|
|
||
| async get(): Promise<BackfilledRangeWrapper | null> { | ||
| const value = await this.db.get(this.key, this.dbReqOpts); | ||
| return value ? backfilledRangeWrapperSsz.deserialize(value) : null; | ||
| } | ||
|
|
||
| async delete(): Promise<void> { | ||
| await this.db.delete(this.key, this.dbReqOpts); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export {BACKFILLED_RANGE_KEY, BackfilledRange} from "./backfilledRange.js"; |
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.
The logic for updating the backfill range during finalization has been commented out. This effectively disables progress tracking for backfill sync during normal node operation. If this logic is being replaced by the new
backfillStateandbackfilledRangesingleton, it should be updated to use them instead of being left as commented-out code.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.
Confirmed — the entire
updateBackfillRangebody is now commented out (lines ~17-43 ofpackages/beacon-node/src/chain/archiveStore/utils/updateBackfillRange.ts). The function is still called from the finalization path but is a no-op. Same scope question asdiscussion_r3109761377— either restore it pointing at the new singletonbackfilledRange+ per-epochbackfillState, or delete the call site and the helper entirely as part of the legacy-removal change.