@lodestar/state-transition 1.43.0 → 1.44.0-dev.552cdce8d0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/block/processDepositRequest.d.ts +3 -11
- package/lib/block/processDepositRequest.d.ts.map +1 -1
- package/lib/block/processDepositRequest.js +27 -35
- package/lib/block/processDepositRequest.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
- package/lib/block/processParentExecutionPayload.js +4 -3
- package/lib/block/processParentExecutionPayload.js.map +1 -1
- package/lib/lightClient/spec/index.d.ts +22 -0
- package/lib/lightClient/spec/index.d.ts.map +1 -0
- package/lib/lightClient/spec/index.js +58 -0
- package/lib/lightClient/spec/index.js.map +1 -0
- package/lib/lightClient/spec/isBetterUpdate.d.ts +23 -0
- package/lib/lightClient/spec/isBetterUpdate.d.ts.map +1 -0
- package/lib/lightClient/spec/isBetterUpdate.js +66 -0
- package/lib/lightClient/spec/isBetterUpdate.js.map +1 -0
- package/lib/lightClient/spec/processLightClientUpdate.d.ts +12 -0
- package/lib/lightClient/spec/processLightClientUpdate.d.ts.map +1 -0
- package/lib/lightClient/spec/processLightClientUpdate.js +80 -0
- package/lib/lightClient/spec/processLightClientUpdate.js.map +1 -0
- package/lib/lightClient/spec/store.d.ts +45 -0
- package/lib/lightClient/spec/store.d.ts.map +1 -0
- package/lib/lightClient/spec/store.js +56 -0
- package/lib/lightClient/spec/store.js.map +1 -0
- package/lib/lightClient/spec/utils.d.ts +47 -0
- package/lib/lightClient/spec/utils.d.ts.map +1 -0
- package/lib/lightClient/spec/utils.js +197 -0
- package/lib/lightClient/spec/utils.js.map +1 -0
- package/lib/lightClient/spec/validateLightClientBootstrap.d.ts +4 -0
- package/lib/lightClient/spec/validateLightClientBootstrap.d.ts.map +1 -0
- package/lib/lightClient/spec/validateLightClientBootstrap.js +22 -0
- package/lib/lightClient/spec/validateLightClientBootstrap.js.map +1 -0
- package/lib/lightClient/spec/validateLightClientUpdate.d.ts +5 -0
- package/lib/lightClient/spec/validateLightClientUpdate.d.ts.map +1 -0
- package/lib/lightClient/spec/validateLightClientUpdate.js +88 -0
- package/lib/lightClient/spec/validateLightClientUpdate.js.map +1 -0
- package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
- package/lib/slot/upgradeStateToGloas.js +33 -28
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +8 -3
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +15 -4
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +1 -1
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/pendingDepositsLookup.d.ts +40 -0
- package/lib/util/pendingDepositsLookup.d.ts.map +1 -0
- package/lib/util/pendingDepositsLookup.js +84 -0
- package/lib/util/pendingDepositsLookup.js.map +1 -0
- package/lib/util/shuffling.d.ts +6 -5
- package/lib/util/shuffling.d.ts.map +1 -1
- package/lib/util/shuffling.js +13 -15
- package/lib/util/shuffling.js.map +1 -1
- package/package.json +12 -7
- package/src/block/processDepositRequest.ts +29 -47
- package/src/block/processParentExecutionPayload.ts +4 -3
- package/src/lightClient/spec/index.ts +101 -0
- package/src/lightClient/spec/isBetterUpdate.ts +94 -0
- package/src/lightClient/spec/processLightClientUpdate.ts +119 -0
- package/src/lightClient/spec/store.ts +106 -0
- package/src/lightClient/spec/utils.ts +317 -0
- package/src/lightClient/spec/validateLightClientBootstrap.ts +39 -0
- package/src/lightClient/spec/validateLightClientUpdate.ts +145 -0
- package/src/slot/upgradeStateToGloas.ts +41 -44
- package/src/stateView/beaconStateView.ts +15 -4
- package/src/stateView/interface.ts +1 -1
- package/src/util/index.ts +1 -0
- package/src/util/pendingDepositsLookup.ts +105 -0
- package/src/util/shuffling.ts +17 -15
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { computeSyncPeriodAtSlot } from "../../util/epoch.js";
|
|
2
|
+
import { deserializeSyncCommittee } from "./utils.js";
|
|
3
|
+
export const MAX_SYNC_PERIODS_CACHE = 2;
|
|
4
|
+
export class LightClientStore {
|
|
5
|
+
config;
|
|
6
|
+
events;
|
|
7
|
+
syncCommittees = new Map();
|
|
8
|
+
bestValidUpdates = new Map();
|
|
9
|
+
finalizedHeaderValue;
|
|
10
|
+
optimisticHeaderValue;
|
|
11
|
+
maxActiveParticipants = new Map();
|
|
12
|
+
constructor(config, bootstrap, events) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.events = events;
|
|
15
|
+
const bootstrapPeriod = computeSyncPeriodAtSlot(bootstrap.header.beacon.slot);
|
|
16
|
+
this.syncCommittees.set(bootstrapPeriod, deserializeSyncCommittee(bootstrap.currentSyncCommittee));
|
|
17
|
+
this.finalizedHeaderValue = bootstrap.header;
|
|
18
|
+
this.optimisticHeaderValue = bootstrap.header;
|
|
19
|
+
}
|
|
20
|
+
get finalizedHeader() {
|
|
21
|
+
return this.finalizedHeaderValue;
|
|
22
|
+
}
|
|
23
|
+
set finalizedHeader(value) {
|
|
24
|
+
this.finalizedHeaderValue = value;
|
|
25
|
+
this.events.onSetFinalizedHeader?.(value);
|
|
26
|
+
}
|
|
27
|
+
get optimisticHeader() {
|
|
28
|
+
return this.optimisticHeaderValue;
|
|
29
|
+
}
|
|
30
|
+
set optimisticHeader(value) {
|
|
31
|
+
this.optimisticHeaderValue = value;
|
|
32
|
+
this.events.onSetOptimisticHeader?.(value);
|
|
33
|
+
}
|
|
34
|
+
getMaxActiveParticipants(period) {
|
|
35
|
+
const currMaxParticipants = this.maxActiveParticipants.get(period) ?? 0;
|
|
36
|
+
const prevMaxParticipants = this.maxActiveParticipants.get(period - 1) ?? 0;
|
|
37
|
+
return Math.max(currMaxParticipants, prevMaxParticipants);
|
|
38
|
+
}
|
|
39
|
+
setActiveParticipants(period, activeParticipants) {
|
|
40
|
+
const maxActiveParticipants = this.maxActiveParticipants.get(period) ?? 0;
|
|
41
|
+
if (activeParticipants > maxActiveParticipants) {
|
|
42
|
+
this.maxActiveParticipants.set(period, activeParticipants);
|
|
43
|
+
}
|
|
44
|
+
// Prune old entries
|
|
45
|
+
for (const key of this.maxActiveParticipants.keys()) {
|
|
46
|
+
if (key < period - MAX_SYNC_PERIODS_CACHE) {
|
|
47
|
+
this.maxActiveParticipants.delete(key);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// === storePeriod ? store.currentSyncCommittee : store.nextSyncCommittee;
|
|
53
|
+
// if (!syncCommittee) {
|
|
54
|
+
// throw Error(`syncCommittee not available for signature period ${updateSignaturePeriod}`);
|
|
55
|
+
// }
|
|
56
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/lightClient/spec/store.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,uBAAuB,EAAC,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAC,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAEpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAyBxC,MAAM,OAAO,gBAAgB;IAUhB,MAAM;IAEE,MAAM;IAXhB,cAAc,GAAG,IAAI,GAAG,EAAiC,CAAC;IAC1D,gBAAgB,GAAG,IAAI,GAAG,EAA4C,CAAC;IAExE,oBAAoB,CAAoB;IACxC,qBAAqB,CAAoB;IAEhC,qBAAqB,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEvE,YACW,MAAoB,EAC7B,SAA+B,EACd,MAA8B,EAC/C;sBAHS,MAAM;sBAEE,MAAM;QAEvB,MAAM,eAAe,GAAG,uBAAuB,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9E,IA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,CAAC,qBAAqB,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;QAC7D,CAAC;QAED,oBAAoB;QACpB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC;YACpD,IAAI,GAAG,GAAG,MAAM,GAAG,sBAAsB,EAAE,CAAC;gBAC1C,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;IAAA,CACF;CACF;AAYD,0EAA0E;AAC1E,wBAAwB;AACxB,8FAA8F;AAC9F,IAAI"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BitArray } from "@chainsafe/ssz";
|
|
2
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
3
|
+
import { ForkName } from "@lodestar/params";
|
|
4
|
+
import { BeaconBlockHeader, LightClientFinalityUpdate, LightClientHeader, LightClientOptimisticUpdate, LightClientUpdate, Slot, SyncCommittee } from "@lodestar/types";
|
|
5
|
+
import type { LightClientStore, SyncCommitteeFast } from "./store.js";
|
|
6
|
+
export declare const GENESIS_SLOT = 0;
|
|
7
|
+
export declare const ZERO_HASH: Uint8Array<ArrayBuffer>;
|
|
8
|
+
export declare const ZERO_PUBKEY: Uint8Array<ArrayBuffer>;
|
|
9
|
+
export declare const ZERO_SYNC_COMMITTEE: import("@chainsafe/ssz").ValueOfFields<{
|
|
10
|
+
pubkeys: import("@chainsafe/ssz").VectorCompositeType<import("@chainsafe/ssz").ByteVectorType>;
|
|
11
|
+
aggregatePubkey: import("@chainsafe/ssz").ByteVectorType;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const ZERO_HEADER: import("@chainsafe/ssz").ValueOfFields<{
|
|
14
|
+
slot: import("@chainsafe/ssz").UintNumberType;
|
|
15
|
+
proposerIndex: import("@chainsafe/ssz").UintNumberType;
|
|
16
|
+
parentRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
17
|
+
stateRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
18
|
+
bodyRoot: import("@chainsafe/ssz").ByteVectorType;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function sumBits(bits: BitArray): number;
|
|
21
|
+
/**
|
|
22
|
+
* Util to guarantee that all bits have a corresponding pubkey.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getParticipantPubkeys<T>(pubkeys: T[], bits: BitArray): T[];
|
|
25
|
+
export declare function deserializeSyncCommittee(syncCommittee: SyncCommittee): SyncCommitteeFast;
|
|
26
|
+
export declare function serializeSyncCommittee(syncCommittee: SyncCommitteeFast): SyncCommittee;
|
|
27
|
+
export declare function getSafetyThreshold(maxActiveParticipants: number): number;
|
|
28
|
+
export declare function getZeroSyncCommitteeBranch(fork: ForkName): Uint8Array[];
|
|
29
|
+
export declare function getZeroFinalityBranch(fork: ForkName): Uint8Array[];
|
|
30
|
+
export declare function isSyncCommitteeUpdate(update: LightClientUpdate): boolean;
|
|
31
|
+
export declare function isFinalityUpdate(update: LightClientUpdate): boolean;
|
|
32
|
+
export declare function isZeroedHeader(header: BeaconBlockHeader): boolean;
|
|
33
|
+
export declare function isZeroedSyncCommittee(syncCommittee: SyncCommittee): boolean;
|
|
34
|
+
export declare function isValidMerkleBranch(leaf: Uint8Array, branch: Uint8Array[], depth: number, index: number, root: Uint8Array): boolean;
|
|
35
|
+
export declare function normalizeMerkleBranch(branch: Uint8Array[], depth: number): Uint8Array[];
|
|
36
|
+
export declare function upgradeLightClientHeader(config: ChainForkConfig, targetFork: ForkName, header: LightClientHeader): LightClientHeader;
|
|
37
|
+
export declare function isValidLightClientHeader(config: ChainForkConfig, header: LightClientHeader): boolean;
|
|
38
|
+
export declare function upgradeLightClientUpdate(config: ChainForkConfig, targetFork: ForkName, update: LightClientUpdate): LightClientUpdate;
|
|
39
|
+
export declare function upgradeLightClientFinalityUpdate(config: ChainForkConfig, targetFork: ForkName, finalityUpdate: LightClientFinalityUpdate): LightClientFinalityUpdate;
|
|
40
|
+
export declare function upgradeLightClientOptimisticUpdate(config: ChainForkConfig, targetFork: ForkName, optimisticUpdate: LightClientOptimisticUpdate): LightClientOptimisticUpdate;
|
|
41
|
+
/**
|
|
42
|
+
* Currently this upgradation is not required because all processing is done based on the
|
|
43
|
+
* summary that the store generates and maintains. In case store needs to be saved to disk,
|
|
44
|
+
* this could be required depending on the format the store is saved to the disk
|
|
45
|
+
*/
|
|
46
|
+
export declare function upgradeLightClientStore(config: ChainForkConfig, targetFork: ForkName, store: LightClientStore, signatureSlot: Slot): LightClientStore;
|
|
47
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lightClient/spec/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAKL,QAAQ,EAKT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,2BAA2B,EAC3B,iBAAiB,EACjB,IAAI,EACJ,aAAa,EAGd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAEpE,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,SAAS,yBAAqB,CAAC;AAC5C,eAAO,MAAM,WAAW,yBAAqB,CAAC;AAC9C,eAAO,MAAM,mBAAmB;;;EAA0C,CAAC;AAC3E,eAAO,MAAM,WAAW;;;;;;EAA8C,CAAC;AAIvE,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,GAAG,CAAC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,gCAAgC,CAC9C,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,QAAQ,EACpB,cAAc,EAAE,yBAAyB,GACxC,yBAAyB,CAS3B;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,QAAQ,EACpB,gBAAgB,EAAE,2BAA2B,GAC5C,2BAA2B,CAI7B;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,QAAQ,EACpB,KAAK,EAAE,gBAAgB,EACvB,aAAa,EAAE,IAAI,GAClB,gBAAgB,CAelB"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { PublicKey } from "@chainsafe/blst";
|
|
2
|
+
import { BLOCK_BODY_EXECUTION_PAYLOAD_DEPTH as EXECUTION_PAYLOAD_DEPTH, BLOCK_BODY_EXECUTION_PAYLOAD_INDEX as EXECUTION_PAYLOAD_INDEX, FINALIZED_ROOT_DEPTH, FINALIZED_ROOT_DEPTH_ELECTRA, ForkName, ForkSeq, NEXT_SYNC_COMMITTEE_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, isForkPostElectra, } from "@lodestar/params";
|
|
3
|
+
import { isElectraLightClientUpdate, ssz, } from "@lodestar/types";
|
|
4
|
+
import { byteArrayEquals, verifyMerkleBranch } from "@lodestar/utils";
|
|
5
|
+
import { computeEpochAtSlot, computeSyncPeriodAtSlot } from "../../util/epoch.js";
|
|
6
|
+
export const GENESIS_SLOT = 0;
|
|
7
|
+
export const ZERO_HASH = new Uint8Array(32);
|
|
8
|
+
export const ZERO_PUBKEY = new Uint8Array(48);
|
|
9
|
+
export const ZERO_SYNC_COMMITTEE = ssz.altair.SyncCommittee.defaultValue();
|
|
10
|
+
export const ZERO_HEADER = ssz.phase0.BeaconBlockHeader.defaultValue();
|
|
11
|
+
/** From https://notes.ethereum.org/@vbuterin/extended_light_client_protocol#Optimistic-head-determining-function */
|
|
12
|
+
const SAFETY_THRESHOLD_FACTOR = 2;
|
|
13
|
+
export function sumBits(bits) {
|
|
14
|
+
return bits.getTrueBitIndexes().length;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Util to guarantee that all bits have a corresponding pubkey.
|
|
18
|
+
*/
|
|
19
|
+
export function getParticipantPubkeys(pubkeys, bits) {
|
|
20
|
+
// BitArray.intersectValues() checks the length is correct.
|
|
21
|
+
return bits.intersectValues(pubkeys);
|
|
22
|
+
}
|
|
23
|
+
function deserializePubkeys(pubkeys) {
|
|
24
|
+
return pubkeys.map((pk) => PublicKey.fromBytes(pk, true));
|
|
25
|
+
}
|
|
26
|
+
function serializePubkeys(pubkeys) {
|
|
27
|
+
return pubkeys.map((pk) => pk.toBytes());
|
|
28
|
+
}
|
|
29
|
+
export function deserializeSyncCommittee(syncCommittee) {
|
|
30
|
+
return {
|
|
31
|
+
pubkeys: deserializePubkeys(syncCommittee.pubkeys),
|
|
32
|
+
aggregatePubkey: PublicKey.fromBytes(syncCommittee.aggregatePubkey, true),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function serializeSyncCommittee(syncCommittee) {
|
|
36
|
+
return {
|
|
37
|
+
pubkeys: serializePubkeys(syncCommittee.pubkeys),
|
|
38
|
+
aggregatePubkey: syncCommittee.aggregatePubkey.toBytes(),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function getSafetyThreshold(maxActiveParticipants) {
|
|
42
|
+
return Math.floor(maxActiveParticipants / SAFETY_THRESHOLD_FACTOR);
|
|
43
|
+
}
|
|
44
|
+
export function getZeroSyncCommitteeBranch(fork) {
|
|
45
|
+
const nextSyncCommitteeDepth = isForkPostElectra(fork)
|
|
46
|
+
? NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA
|
|
47
|
+
: NEXT_SYNC_COMMITTEE_DEPTH;
|
|
48
|
+
return Array.from({ length: nextSyncCommitteeDepth }, () => ZERO_HASH);
|
|
49
|
+
}
|
|
50
|
+
export function getZeroFinalityBranch(fork) {
|
|
51
|
+
const finalizedRootDepth = isForkPostElectra(fork) ? FINALIZED_ROOT_DEPTH_ELECTRA : FINALIZED_ROOT_DEPTH;
|
|
52
|
+
return Array.from({ length: finalizedRootDepth }, () => ZERO_HASH);
|
|
53
|
+
}
|
|
54
|
+
export function isSyncCommitteeUpdate(update) {
|
|
55
|
+
return (
|
|
56
|
+
// Fast return for when constructing full LightClientUpdate from partial updates
|
|
57
|
+
update.nextSyncCommitteeBranch !==
|
|
58
|
+
getZeroSyncCommitteeBranch(isElectraLightClientUpdate(update) ? ForkName.electra : ForkName.altair) &&
|
|
59
|
+
update.nextSyncCommitteeBranch.some((branch) => !byteArrayEquals(branch, ZERO_HASH)));
|
|
60
|
+
}
|
|
61
|
+
export function isFinalityUpdate(update) {
|
|
62
|
+
return (
|
|
63
|
+
// Fast return for when constructing full LightClientUpdate from partial updates
|
|
64
|
+
update.finalityBranch !==
|
|
65
|
+
getZeroFinalityBranch(isElectraLightClientUpdate(update) ? ForkName.electra : ForkName.altair) &&
|
|
66
|
+
update.finalityBranch.some((branch) => !byteArrayEquals(branch, ZERO_HASH)));
|
|
67
|
+
}
|
|
68
|
+
export function isZeroedHeader(header) {
|
|
69
|
+
// Fast return for when constructing full LightClientUpdate from partial updates
|
|
70
|
+
return header === ZERO_HEADER || byteArrayEquals(header.bodyRoot, ZERO_HASH);
|
|
71
|
+
}
|
|
72
|
+
export function isZeroedSyncCommittee(syncCommittee) {
|
|
73
|
+
// Fast return for when constructing full LightClientUpdate from partial updates
|
|
74
|
+
return syncCommittee === ZERO_SYNC_COMMITTEE || byteArrayEquals(syncCommittee.pubkeys[0], ZERO_PUBKEY);
|
|
75
|
+
}
|
|
76
|
+
export function isValidMerkleBranch(leaf, branch, depth, index, root) {
|
|
77
|
+
if (branch.length !== depth) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return verifyMerkleBranch(leaf, branch, depth, index, root);
|
|
81
|
+
}
|
|
82
|
+
export function normalizeMerkleBranch(branch, depth) {
|
|
83
|
+
const numExtraDepth = depth - branch.length;
|
|
84
|
+
return [...Array.from({ length: numExtraDepth }, () => ZERO_HASH), ...branch];
|
|
85
|
+
}
|
|
86
|
+
export function upgradeLightClientHeader(config, targetFork, header) {
|
|
87
|
+
const headerFork = config.getForkName(header.beacon.slot);
|
|
88
|
+
if (ForkSeq[headerFork] >= ForkSeq[targetFork]) {
|
|
89
|
+
throw Error(`Invalid upgrade request from headerFork=${headerFork} to targetFork=${targetFork}`);
|
|
90
|
+
}
|
|
91
|
+
// We are modifying the same header object, may be we could create a copy, but its
|
|
92
|
+
// not required as of now
|
|
93
|
+
const upgradedHeader = header;
|
|
94
|
+
const startUpgradeFromFork = Object.values(ForkName)[ForkSeq[headerFork] + 1];
|
|
95
|
+
switch (startUpgradeFromFork) {
|
|
96
|
+
// biome-ignore lint/suspicious/useDefaultSwitchClauseLast: We want default to evaluate at first to throw error early
|
|
97
|
+
default:
|
|
98
|
+
throw Error(`Invalid startUpgradeFromFork=${startUpgradeFromFork} for headerFork=${headerFork} in upgradeLightClientHeader to targetFork=${targetFork}`);
|
|
99
|
+
case ForkName.altair:
|
|
100
|
+
// biome-ignore lint/suspicious/noFallthroughSwitchClause: We need fall-through behavior here
|
|
101
|
+
case ForkName.bellatrix:
|
|
102
|
+
// Break if no further upgradation is required else fall through
|
|
103
|
+
if (ForkSeq[targetFork] <= ForkSeq.bellatrix)
|
|
104
|
+
break;
|
|
105
|
+
// biome-ignore lint/suspicious/noFallthroughSwitchClause: We need fall-through behavior here
|
|
106
|
+
case ForkName.capella:
|
|
107
|
+
upgradedHeader.execution =
|
|
108
|
+
ssz.capella.LightClientHeader.fields.execution.defaultValue();
|
|
109
|
+
upgradedHeader.executionBranch =
|
|
110
|
+
ssz.capella.LightClientHeader.fields.executionBranch.defaultValue();
|
|
111
|
+
// Break if no further upgradation is required else fall through
|
|
112
|
+
if (ForkSeq[targetFork] <= ForkSeq.capella)
|
|
113
|
+
break;
|
|
114
|
+
// biome-ignore lint/suspicious/noFallthroughSwitchClause: We need fall-through behavior here
|
|
115
|
+
case ForkName.deneb:
|
|
116
|
+
upgradedHeader.execution.blobGasUsed =
|
|
117
|
+
ssz.deneb.LightClientHeader.fields.execution.fields.blobGasUsed.defaultValue();
|
|
118
|
+
upgradedHeader.execution.excessBlobGas =
|
|
119
|
+
ssz.deneb.LightClientHeader.fields.execution.fields.excessBlobGas.defaultValue();
|
|
120
|
+
// Break if no further upgradation is required else fall through
|
|
121
|
+
if (ForkSeq[targetFork] <= ForkSeq.deneb)
|
|
122
|
+
break;
|
|
123
|
+
// biome-ignore lint/suspicious/noFallthroughSwitchClause: We need fall-through behavior here
|
|
124
|
+
case ForkName.electra:
|
|
125
|
+
// No changes to LightClientHeader in Electra
|
|
126
|
+
// Break if no further upgrades is required else fall through
|
|
127
|
+
if (ForkSeq[targetFork] <= ForkSeq.electra)
|
|
128
|
+
break;
|
|
129
|
+
// biome-ignore lint/suspicious/noFallthroughSwitchClause: We need fall-through behavior here
|
|
130
|
+
case ForkName.fulu:
|
|
131
|
+
// No changes to LightClientHeader in Fulu
|
|
132
|
+
// Break if no further upgrades is required else fall through
|
|
133
|
+
if (ForkSeq[targetFork] <= ForkSeq.fulu)
|
|
134
|
+
break;
|
|
135
|
+
case ForkName.gloas:
|
|
136
|
+
// No changes to LightClientHeader in Gloas
|
|
137
|
+
// Break if no further upgrades is required else fall through
|
|
138
|
+
if (ForkSeq[targetFork] <= ForkSeq.gloas)
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
return upgradedHeader;
|
|
142
|
+
}
|
|
143
|
+
export function isValidLightClientHeader(config, header) {
|
|
144
|
+
const epoch = computeEpochAtSlot(header.beacon.slot);
|
|
145
|
+
if (epoch < config.CAPELLA_FORK_EPOCH) {
|
|
146
|
+
return ((header.execution === undefined ||
|
|
147
|
+
ssz.capella.ExecutionPayloadHeader.equals(header.execution, ssz.capella.LightClientHeader.fields.execution.defaultValue())) &&
|
|
148
|
+
(header.executionBranch === undefined ||
|
|
149
|
+
ssz.capella.LightClientHeader.fields.executionBranch.equals(ssz.capella.LightClientHeader.fields.executionBranch.defaultValue(), header.executionBranch)));
|
|
150
|
+
}
|
|
151
|
+
if (epoch < config.DENEB_FORK_EPOCH &&
|
|
152
|
+
((header.execution.blobGasUsed &&
|
|
153
|
+
header.execution.blobGasUsed !== BigInt(0)) ||
|
|
154
|
+
(header.execution.excessBlobGas &&
|
|
155
|
+
header.execution.excessBlobGas !== BigInt(0)))) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return isValidMerkleBranch(config
|
|
159
|
+
.getPostBellatrixForkTypes(header.beacon.slot)
|
|
160
|
+
.ExecutionPayloadHeader.hashTreeRoot(header.execution), header.executionBranch, EXECUTION_PAYLOAD_DEPTH, EXECUTION_PAYLOAD_INDEX, header.beacon.bodyRoot);
|
|
161
|
+
}
|
|
162
|
+
export function upgradeLightClientUpdate(config, targetFork, update) {
|
|
163
|
+
update.attestedHeader = upgradeLightClientHeader(config, targetFork, update.attestedHeader);
|
|
164
|
+
update.finalizedHeader = upgradeLightClientHeader(config, targetFork, update.finalizedHeader);
|
|
165
|
+
update.nextSyncCommitteeBranch = normalizeMerkleBranch(update.nextSyncCommitteeBranch, isForkPostElectra(targetFork) ? NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA : NEXT_SYNC_COMMITTEE_DEPTH);
|
|
166
|
+
update.finalityBranch = normalizeMerkleBranch(update.finalityBranch, isForkPostElectra(targetFork) ? FINALIZED_ROOT_DEPTH_ELECTRA : FINALIZED_ROOT_DEPTH);
|
|
167
|
+
return update;
|
|
168
|
+
}
|
|
169
|
+
export function upgradeLightClientFinalityUpdate(config, targetFork, finalityUpdate) {
|
|
170
|
+
finalityUpdate.attestedHeader = upgradeLightClientHeader(config, targetFork, finalityUpdate.attestedHeader);
|
|
171
|
+
finalityUpdate.finalizedHeader = upgradeLightClientHeader(config, targetFork, finalityUpdate.finalizedHeader);
|
|
172
|
+
finalityUpdate.finalityBranch = normalizeMerkleBranch(finalityUpdate.finalityBranch, isForkPostElectra(targetFork) ? FINALIZED_ROOT_DEPTH_ELECTRA : FINALIZED_ROOT_DEPTH);
|
|
173
|
+
return finalityUpdate;
|
|
174
|
+
}
|
|
175
|
+
export function upgradeLightClientOptimisticUpdate(config, targetFork, optimisticUpdate) {
|
|
176
|
+
optimisticUpdate.attestedHeader = upgradeLightClientHeader(config, targetFork, optimisticUpdate.attestedHeader);
|
|
177
|
+
return optimisticUpdate;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Currently this upgradation is not required because all processing is done based on the
|
|
181
|
+
* summary that the store generates and maintains. In case store needs to be saved to disk,
|
|
182
|
+
* this could be required depending on the format the store is saved to the disk
|
|
183
|
+
*/
|
|
184
|
+
export function upgradeLightClientStore(config, targetFork, store, signatureSlot) {
|
|
185
|
+
const updateSignaturePeriod = computeSyncPeriodAtSlot(signatureSlot);
|
|
186
|
+
const bestValidUpdate = store.bestValidUpdates.get(updateSignaturePeriod);
|
|
187
|
+
if (bestValidUpdate) {
|
|
188
|
+
store.bestValidUpdates.set(updateSignaturePeriod, {
|
|
189
|
+
update: upgradeLightClientUpdate(config, targetFork, bestValidUpdate.update),
|
|
190
|
+
summary: bestValidUpdate.summary,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
store.finalizedHeader = upgradeLightClientHeader(config, targetFork, store.finalizedHeader);
|
|
194
|
+
store.optimisticHeader = upgradeLightClientHeader(config, targetFork, store.optimisticHeader);
|
|
195
|
+
return store;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lightClient/spec/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EACL,kCAAkC,IAAI,uBAAuB,EAC7D,kCAAkC,I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CAChD,MAAuB,EACvB,UAAoB,EACpB,gBAA6C,EAChB;IAC7B,gBAAgB,CAAC,cAAc,GAAG,wBAAwB,CAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAEhH,OAAO,gBAAgB,CAAC;AAAA,CACzB;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAuB,EACvB,UAAoB,EACpB,KAAuB,EACvB,aAAmB,EACD;IAClB,MAAM,qBAAqB,GAAG,uBAAuB,CAAC,aAAa,CAAC,CAAC;IACrE,MAAM,eAAe,GAAG,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAE1E,IAAI,eAAe,EAAE,CAAC;QACpB,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,qBAAqB,EAAE;YAChD,MAAM,EAAE,wBAAwB,CAAC,MAAM,EAAE,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC;YAC5E,OAAO,EAAE,eAAe,CAAC,OAAO;SACjC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,eAAe,GAAG,wBAAwB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC5F,KAAK,CAAC,gBAAgB,GAAG,wBAAwB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAE9F,OAAO,KAAK,CAAC;AAAA,CACd"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
+
import { LightClientBootstrap, Root } from "@lodestar/types";
|
|
3
|
+
export declare function validateLightClientBootstrap(config: ChainForkConfig, trustedBlockRoot: Root, bootstrap: LightClientBootstrap): void;
|
|
4
|
+
//# sourceMappingURL=validateLightClientBootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateLightClientBootstrap.d.ts","sourceRoot":"","sources":["../../../src/lightClient/spec/validateLightClientBootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,oBAAoB,EAAE,IAAI,EAAM,MAAM,iBAAiB,CAAC;AAShE,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,eAAe,EACvB,gBAAgB,EAAE,IAAI,EACtB,SAAS,EAAE,oBAAoB,GAC9B,IAAI,CAuBN"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isForkPostElectra } from "@lodestar/params";
|
|
2
|
+
import { ssz } from "@lodestar/types";
|
|
3
|
+
import { byteArrayEquals, toHex } from "@lodestar/utils";
|
|
4
|
+
import { isValidLightClientHeader, isValidMerkleBranch } from "./utils.js";
|
|
5
|
+
const CURRENT_SYNC_COMMITTEE_INDEX = 22;
|
|
6
|
+
const CURRENT_SYNC_COMMITTEE_DEPTH = 5;
|
|
7
|
+
const CURRENT_SYNC_COMMITTEE_INDEX_ELECTRA = 22;
|
|
8
|
+
const CURRENT_SYNC_COMMITTEE_DEPTH_ELECTRA = 6;
|
|
9
|
+
export function validateLightClientBootstrap(config, trustedBlockRoot, bootstrap) {
|
|
10
|
+
const headerRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(bootstrap.header.beacon);
|
|
11
|
+
const fork = config.getForkName(bootstrap.header.beacon.slot);
|
|
12
|
+
if (!isValidLightClientHeader(config, bootstrap.header)) {
|
|
13
|
+
throw Error("Bootstrap Header is not Valid Light Client Header");
|
|
14
|
+
}
|
|
15
|
+
if (!byteArrayEquals(headerRoot, trustedBlockRoot)) {
|
|
16
|
+
throw Error(`bootstrap header root ${toHex(headerRoot)} != trusted root ${toHex(trustedBlockRoot)}`);
|
|
17
|
+
}
|
|
18
|
+
if (!isValidMerkleBranch(ssz.altair.SyncCommittee.hashTreeRoot(bootstrap.currentSyncCommittee), bootstrap.currentSyncCommitteeBranch, isForkPostElectra(fork) ? CURRENT_SYNC_COMMITTEE_DEPTH_ELECTRA : CURRENT_SYNC_COMMITTEE_DEPTH, isForkPostElectra(fork) ? CURRENT_SYNC_COMMITTEE_INDEX_ELECTRA : CURRENT_SYNC_COMMITTEE_INDEX, bootstrap.header.beacon.stateRoot)) {
|
|
19
|
+
throw Error("Invalid currentSyncCommittee merkle branch");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=validateLightClientBootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateLightClientBootstrap.js","sourceRoot":"","sources":["../../../src/lightClient/spec/validateLightClientBootstrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAA6B,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAC,eAAe,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAC,wBAAwB,EAAE,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAEzE,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AACvC,MAAM,oCAAoC,GAAG,EAAE,CAAC;AAChD,MAAM,oCAAoC,GAAG,CAAC,CAAC;AAE/C,MAAM,UAAU,4BAA4B,CAC1C,MAAuB,EACvB,gBAAsB,EACtB,SAA+B,EACzB;IACN,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtF,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAE9D,IAAI,CAAC,wBAAwB,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAAE,CAAC;QACnD,MAAM,KAAK,CAAC,yBAAyB,KAAK,CAAC,UAAU,CAAC,oBAAoB,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACvG,CAAC;IAED,IACE,CAAC,mBAAmB,CAClB,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,SAAS,CAAC,oBAAoB,CAAC,EACrE,SAAS,CAAC,0BAA0B,EACpC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,4BAA4B,EAC7F,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,4BAA4B,EAC7F,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAClC,EACD,CAAC;QACD,MAAM,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;AAAA,CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
+
import { LightClientUpdate } from "@lodestar/types";
|
|
3
|
+
import type { ILightClientStore, SyncCommitteeFast } from "./store.js";
|
|
4
|
+
export declare function validateLightClientUpdate(config: ChainForkConfig, store: ILightClientStore, update: LightClientUpdate, syncCommittee: SyncCommitteeFast): void;
|
|
5
|
+
//# sourceMappingURL=validateLightClientUpdate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateLightClientUpdate.d.ts","sourceRoot":"","sources":["../../../src/lightClient/spec/validateLightClientUpdate.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAcjD,OAAO,EAAC,iBAAiB,EAAwC,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAarE,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,iBAAiB,GAC/B,IAAI,CA0FN"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Signature, fastAggregateVerify } from "@chainsafe/blst";
|
|
2
|
+
import { DOMAIN_SYNC_COMMITTEE, FINALIZED_ROOT_DEPTH, FINALIZED_ROOT_DEPTH_ELECTRA, FINALIZED_ROOT_INDEX, FINALIZED_ROOT_INDEX_ELECTRA, GENESIS_SLOT, MIN_SYNC_COMMITTEE_PARTICIPANTS, NEXT_SYNC_COMMITTEE_DEPTH, NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA, NEXT_SYNC_COMMITTEE_INDEX, NEXT_SYNC_COMMITTEE_INDEX_ELECTRA, } from "@lodestar/params";
|
|
3
|
+
import { isElectraLightClientUpdate, ssz } from "@lodestar/types";
|
|
4
|
+
import { ZERO_HASH, getParticipantPubkeys, isFinalityUpdate, isSyncCommitteeUpdate, isValidLightClientHeader, isValidMerkleBranch, isZeroedHeader, isZeroedSyncCommittee, sumBits, } from "./utils.js";
|
|
5
|
+
export function validateLightClientUpdate(config, store, update, syncCommittee) {
|
|
6
|
+
// Verify sync committee has sufficient participants
|
|
7
|
+
if (sumBits(update.syncAggregate.syncCommitteeBits) < MIN_SYNC_COMMITTEE_PARTICIPANTS) {
|
|
8
|
+
throw Error("Sync committee has not sufficient participants");
|
|
9
|
+
}
|
|
10
|
+
if (!isValidLightClientHeader(config, update.attestedHeader)) {
|
|
11
|
+
throw Error("Attested Header is not Valid Light Client Header");
|
|
12
|
+
}
|
|
13
|
+
// Sanity check that slots are in correct order
|
|
14
|
+
if (update.signatureSlot <= update.attestedHeader.beacon.slot) {
|
|
15
|
+
throw Error(`signature slot ${update.signatureSlot} must be after attested header slot ${update.attestedHeader.beacon.slot}`);
|
|
16
|
+
}
|
|
17
|
+
if (update.attestedHeader.beacon.slot < update.finalizedHeader.beacon.slot) {
|
|
18
|
+
throw Error(`attested header slot ${update.signatureSlot} must be after finalized header slot ${update.finalizedHeader.beacon.slot}`);
|
|
19
|
+
}
|
|
20
|
+
// Verify that the `finality_branch`, if present, confirms `finalized_header`
|
|
21
|
+
// to match the finalized checkpoint root saved in the state of `attested_header`.
|
|
22
|
+
// Note that the genesis finalized checkpoint root is represented as a zero hash.
|
|
23
|
+
if (!isFinalityUpdate(update)) {
|
|
24
|
+
if (!isZeroedHeader(update.finalizedHeader.beacon)) {
|
|
25
|
+
throw Error("finalizedHeader must be zero for non-finality update");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
let finalizedRoot;
|
|
30
|
+
if (update.finalizedHeader.beacon.slot === GENESIS_SLOT) {
|
|
31
|
+
if (!isZeroedHeader(update.finalizedHeader.beacon)) {
|
|
32
|
+
throw Error("finalizedHeader must be zero for not finality update");
|
|
33
|
+
}
|
|
34
|
+
finalizedRoot = ZERO_HASH;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (!isValidLightClientHeader(config, update.finalizedHeader)) {
|
|
38
|
+
throw Error("Finalized Header is not valid Light Client Header");
|
|
39
|
+
}
|
|
40
|
+
finalizedRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(update.finalizedHeader.beacon);
|
|
41
|
+
}
|
|
42
|
+
if (!isValidMerkleBranch(finalizedRoot, update.finalityBranch, isElectraLightClientUpdate(update) ? FINALIZED_ROOT_DEPTH_ELECTRA : FINALIZED_ROOT_DEPTH, isElectraLightClientUpdate(update) ? FINALIZED_ROOT_INDEX_ELECTRA : FINALIZED_ROOT_INDEX, update.attestedHeader.beacon.stateRoot)) {
|
|
43
|
+
throw Error("Invalid finality header merkle branch");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Verify that the `next_sync_committee`, if present, actually is the next sync committee saved in the
|
|
47
|
+
// state of the `attested_header`
|
|
48
|
+
if (!isSyncCommitteeUpdate(update)) {
|
|
49
|
+
if (!isZeroedSyncCommittee(update.nextSyncCommittee)) {
|
|
50
|
+
throw Error("nextSyncCommittee must be zero for non sync committee update");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (!isValidMerkleBranch(ssz.altair.SyncCommittee.hashTreeRoot(update.nextSyncCommittee), update.nextSyncCommitteeBranch, isElectraLightClientUpdate(update) ? NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA : NEXT_SYNC_COMMITTEE_DEPTH, isElectraLightClientUpdate(update) ? NEXT_SYNC_COMMITTEE_INDEX_ELECTRA : NEXT_SYNC_COMMITTEE_INDEX, update.attestedHeader.beacon.stateRoot)) {
|
|
55
|
+
throw Error("Invalid next sync committee merkle branch");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Verify sync committee aggregate signature
|
|
59
|
+
const participantPubkeys = getParticipantPubkeys(syncCommittee.pubkeys, update.syncAggregate.syncCommitteeBits);
|
|
60
|
+
const signingRoot = ssz.phase0.SigningData.hashTreeRoot({
|
|
61
|
+
objectRoot: ssz.phase0.BeaconBlockHeader.hashTreeRoot(update.attestedHeader.beacon),
|
|
62
|
+
domain: store.config.getDomain(update.signatureSlot - 1, DOMAIN_SYNC_COMMITTEE),
|
|
63
|
+
});
|
|
64
|
+
if (!isValidBlsAggregate(participantPubkeys, signingRoot, update.syncAggregate.syncCommitteeSignature)) {
|
|
65
|
+
throw Error("Invalid aggregate signature");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Same as BLS.verifyAggregate but with detailed error messages
|
|
70
|
+
*/
|
|
71
|
+
function isValidBlsAggregate(publicKeys, message, signature) {
|
|
72
|
+
let sig;
|
|
73
|
+
try {
|
|
74
|
+
sig = Signature.fromBytes(signature, true);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
e.message = `Error deserializing signature: ${e.message}`;
|
|
78
|
+
throw e;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
return fastAggregateVerify(message, publicKeys, sig);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
e.message = `Error verifying signature: ${e.message}`;
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=validateLightClientUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateLightClientUpdate.js","sourceRoot":"","sources":["../../../src/lightClient/spec/validateLightClientUpdate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,4BAA4B,EAC5B,oBAAoB,EACpB,4BAA4B,EAC5B,YAAY,EACZ,+BAA+B,EAC/B,yBAAyB,EACzB,iCAAiC,EACjC,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA0B,0BAA0B,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,MAAM,UAAU,yBAAyB,CACvC,MAAuB,EACvB,KAAwB,EACxB,MAAyB,EACzB,aAAgC,EAC1B;IACN,oDAAoD;IACpD,IAAI,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,+BAA+B,EAAE,CAAC;QACtF,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7D,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAClE,CAAC;IAED,+CAA+C;IAC/C,IA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MAAM,CAAC,WAAW,CAAC,YAAY,CAAC;QACtD,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;QACnF,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,EAAE,qBAAqB,CAAC;KAChF,CAAC,CAAC;IAEH,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACvG,MAAM,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC7C,CAAC;AAAA,CACF;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,UAAuB,EAAE,OAAmB,EAAE,SAAqB,EAAW;IACzG,IAAI,GAAc,CAAC;IACnB,IAAI,CAAC;QACH,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACV,CAAW,CAAC,OAAO,GAAG,kCAAmC,CAAW,CAAC,OAAO,EAAE,CAAC;QAChF,MAAM,CAAC,CAAC;IACV,CAAC;IAED,IAAI,CAAC;QACH,OAAO,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACV,CAAW,CAAC,OAAO,GAAG,8BAA+B,CAAW,CAAC,OAAO,EAAE,CAAC;QAC5E,MAAM,CAAC,CAAC;IACV,CAAC;AAAA,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeStateToGloas.d.ts","sourceRoot":"","sources":["../../src/slot/upgradeStateToGloas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upgradeStateToGloas.d.ts","sourceRoot":"","sources":["../../src/slot/upgradeStateToGloas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,qBAAqB,EAAE,sBAAsB,EAAC,MAAM,aAAa,CAAC;AAK1E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,qBAAqB,GAAG,sBAAsB,CAuE5F"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SLOTS_PER_HISTORICAL_ROOT } from "@lodestar/params";
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
|
-
import {
|
|
4
|
-
import { isValidDepositSignature } from "../block/processDeposit.js";
|
|
3
|
+
import { toPubkeyHex } from "@lodestar/utils";
|
|
5
4
|
import { applyDepositForBuilder } from "../block/processDepositRequest.js";
|
|
6
5
|
import { getCachedBeaconState } from "../cache/stateCache.js";
|
|
7
6
|
import { initializePtcWindow, isBuilderWithdrawalCredential } from "../util/gloas.js";
|
|
8
7
|
import { isValidatorKnown } from "../util/index.js";
|
|
8
|
+
import { PendingDepositsLookup } from "../util/pendingDepositsLookup.js";
|
|
9
9
|
/**
|
|
10
10
|
* Upgrade a state from Fulu to Gloas.
|
|
11
11
|
*/
|
|
@@ -76,42 +76,47 @@ export function upgradeStateToGloas(stateFulu) {
|
|
|
76
76
|
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.2/specs/gloas/fork.md#new-onboard_builders_from_pending_deposits
|
|
77
77
|
*/
|
|
78
78
|
function onboardBuildersFromPendingDeposits(state) {
|
|
79
|
-
// Track pubkeys of new validators to keep their deposits pending
|
|
80
|
-
const validatorPubkeys = new Set();
|
|
81
79
|
// Track pubkeys of new builders added when applying deposits
|
|
82
80
|
const builderPubkeys = new Set();
|
|
83
|
-
const
|
|
81
|
+
const pendingDeposits = ssz.electra.PendingDeposits.defaultViewDU();
|
|
82
|
+
const pendingDepositsLookup = PendingDepositsLookup.buildEmpty();
|
|
84
83
|
for (let i = 0; i < state.pendingDeposits.length; i++) {
|
|
85
84
|
const deposit = state.pendingDeposits.getReadonly(i);
|
|
86
85
|
const validatorIndex = state.epochCtx.getValidatorIndex(deposit.pubkey);
|
|
87
|
-
const pubkeyHex =
|
|
88
|
-
// Deposits for existing validators stay in pending queue
|
|
89
|
-
if (isValidatorKnown(state, validatorIndex)
|
|
90
|
-
|
|
86
|
+
const pubkeyHex = toPubkeyHex(deposit.pubkey);
|
|
87
|
+
// Deposits for existing validators stay in the pending queue
|
|
88
|
+
if (isValidatorKnown(state, validatorIndex)) {
|
|
89
|
+
pendingDeposits.push(deposit);
|
|
90
|
+
pendingDepositsLookup.add(deposit, pubkeyHex);
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
//
|
|
101
|
-
if (!
|
|
102
|
-
|
|
93
|
+
// `applyDepositForBuilder` can mutate the state and add a builder to the registry, so
|
|
94
|
+
// the set of builder pubkeys must be recomputed each iteration. `builderPubkeys` stands
|
|
95
|
+
// in for the spec's `[b.pubkey for b in state.builders]`: `state.builders` starts empty
|
|
96
|
+
// at the fork, so every builder is one added in a previous iteration of this loop.
|
|
97
|
+
if (!builderPubkeys.has(pubkeyHex)) {
|
|
98
|
+
// Deposits for non-builders stay in the pending queue. If there is a valid pending
|
|
99
|
+
// deposit for a new validator with this pubkey, keep this deposit in the pending
|
|
100
|
+
// queue to be applied to that validator later.
|
|
101
|
+
if (!isBuilderWithdrawalCredential(deposit.withdrawalCredentials)) {
|
|
102
|
+
pendingDeposits.push(deposit);
|
|
103
|
+
pendingDepositsLookup.add(deposit, pubkeyHex);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (pendingDepositsLookup.hasPendingValidator(state.config, pubkeyHex)) {
|
|
107
|
+
pendingDeposits.push(deposit);
|
|
108
|
+
pendingDepositsLookup.add(deposit, pubkeyHex);
|
|
109
|
+
continue;
|
|
103
110
|
}
|
|
104
|
-
continue;
|
|
105
111
|
}
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
remainingPendingDeposits.push(deposit);
|
|
112
|
+
const buildersLenBefore = state.builders.length;
|
|
113
|
+
// TODO GLOAS: handle 20k 1ETH deposits on time
|
|
114
|
+
// there is a note in the spec https://github.com/ethereum/consensus-specs/pull/5227
|
|
115
|
+
applyDepositForBuilder(state, deposit.pubkey, deposit.withdrawalCredentials, deposit.amount, deposit.signature, deposit.slot);
|
|
116
|
+
if (state.builders.length > buildersLenBefore) {
|
|
117
|
+
builderPubkeys.add(pubkeyHex);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
state.pendingDeposits =
|
|
120
|
+
state.pendingDeposits = pendingDeposits;
|
|
116
121
|
}
|
|
117
122
|
//# sourceMappingURL=upgradeStateToGloas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeStateToGloas.js","sourceRoot":"","sources":["../../src/slot/upgradeStateToGloas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"upgradeStateToGloas.js","sourceRoot":"","sources":["../../src/slot/upgradeStateToGloas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,sBAAsB,EAAC,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAC,mBAAmB,EAAE,6BAA6B,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAC,gBAAgB,EAAC,MAAM,kB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