@lodestar/native 0.0.0-stage → 1.51.0-dev.8d8efcbf5f
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/LICENSE +202 -0
- package/README.md +44 -2
- package/package.json +93 -3
- package/src/bindings.js +6 -0
- package/src/bls-verifier.d.ts +62 -0
- package/src/bls-verifier.js +12 -0
- package/src/blst.d.ts +183 -0
- package/src/blst.js +15 -0
- package/src/execution-proof-verifier.d.ts +46 -0
- package/src/execution-proof-verifier.js +17 -0
- package/src/index.d.ts +513 -0
- package/src/index.js +2 -0
- package/src/metrics.d.ts +18 -0
- package/src/metrics.js +8 -0
- package/src/pubkeys.d.ts +59 -0
- package/src/pubkeys.js +72 -0
- package/src/shuffle.d.ts +77 -0
- package/src/shuffle.js +12 -0
- package/src/state-transition.d.ts +11 -0
- package/src/state-transition.js +5 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import bindings from "./bindings.js";
|
|
2
|
+
|
|
3
|
+
const executionProofVerifier = bindings.executionProofVerifier;
|
|
4
|
+
|
|
5
|
+
/** @type {typeof import("./execution-proof-verifier.d.ts").ZKVM_KIND} */
|
|
6
|
+
export const ZKVM_KIND = executionProofVerifier.ZkvmKind;
|
|
7
|
+
|
|
8
|
+
export const EXECUTION_PROOF_VERIFIER_AVAILABLE = executionProofVerifier.available;
|
|
9
|
+
export const EXECUTION_PROOF_MAX_SIZE = executionProofVerifier.MAX_PROOF_SIZE;
|
|
10
|
+
|
|
11
|
+
export const registerExecutionProofVerifier = executionProofVerifier.register;
|
|
12
|
+
export const hasExecutionProofVerifier = executionProofVerifier.has;
|
|
13
|
+
|
|
14
|
+
/** @type {typeof import("./execution-proof-verifier.d.ts").verifyExecutionProof} */
|
|
15
|
+
export async function verifyExecutionProof(proofType, proofData) {
|
|
16
|
+
return executionProofVerifier.verify(proofType, proofData);
|
|
17
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
// biome-ignore-all lint/style/useNamingConvention: spec-canonical fork names in `ForkName`
|
|
2
|
+
|
|
3
|
+
interface BeaconBlockHeader {
|
|
4
|
+
slot: number;
|
|
5
|
+
proposerIndex: number;
|
|
6
|
+
parentRoot: Uint8Array;
|
|
7
|
+
stateRoot: Uint8Array;
|
|
8
|
+
bodyRoot: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface Checkpoint {
|
|
12
|
+
epoch: number;
|
|
13
|
+
root: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface VoluntaryExit {
|
|
17
|
+
epoch: number;
|
|
18
|
+
validatorIndex: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SignedVoluntaryExit {
|
|
22
|
+
message: VoluntaryExit;
|
|
23
|
+
signature: Uint8Array;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface Eth1Data {
|
|
27
|
+
depositRoot: Uint8Array;
|
|
28
|
+
depositCount: bigint;
|
|
29
|
+
blockHash: Uint8Array;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface ExecutionPayloadHeader {
|
|
33
|
+
parentHash: Uint8Array;
|
|
34
|
+
feeRecipient: Uint8Array;
|
|
35
|
+
stateRoot: Uint8Array;
|
|
36
|
+
receiptsRoot: Uint8Array;
|
|
37
|
+
logsBloom: Uint8Array;
|
|
38
|
+
prevRandao: Uint8Array;
|
|
39
|
+
blockNumber: number;
|
|
40
|
+
gasLimit: number;
|
|
41
|
+
gasUsed: number;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
extraData: Uint8Array;
|
|
44
|
+
baseFeePerGas: bigint;
|
|
45
|
+
blockHash: Uint8Array;
|
|
46
|
+
transactionsRoot: Uint8Array;
|
|
47
|
+
withdrawalsRoot?: Uint8Array; // capella+
|
|
48
|
+
blobGasUsed?: bigint; // deneb+
|
|
49
|
+
excessBlobGas?: bigint; // deneb+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ExecutionPayloadBid {
|
|
53
|
+
parentBlockHash: Uint8Array;
|
|
54
|
+
parentBlockRoot: Uint8Array;
|
|
55
|
+
blockHash: Uint8Array;
|
|
56
|
+
prevRandao: Uint8Array;
|
|
57
|
+
feeRecipient: Uint8Array;
|
|
58
|
+
gasLimit: bigint;
|
|
59
|
+
builderIndex: number;
|
|
60
|
+
slot: number;
|
|
61
|
+
value: number;
|
|
62
|
+
executionPayment: bigint;
|
|
63
|
+
blobKzgCommitments: Uint8Array[];
|
|
64
|
+
executionRequestsRoot: Uint8Array;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface HezeExecutionPayloadBid extends ExecutionPayloadBid {
|
|
68
|
+
inclusionListBits: {uint8Array: Uint8Array; bitLen: number};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface Builder {
|
|
72
|
+
pubkey: Uint8Array;
|
|
73
|
+
version: number;
|
|
74
|
+
executionAddress: Uint8Array;
|
|
75
|
+
balance: number;
|
|
76
|
+
depositEpoch: number;
|
|
77
|
+
withdrawableEpoch: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface BuilderPendingWithdrawal {
|
|
81
|
+
feeRecipient: Uint8Array;
|
|
82
|
+
amount: number;
|
|
83
|
+
builderIndex: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface BuilderPendingPayment {
|
|
87
|
+
weight: number;
|
|
88
|
+
withdrawal: BuilderPendingWithdrawal;
|
|
89
|
+
proposerIndex: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface Withdrawal {
|
|
93
|
+
index: number;
|
|
94
|
+
validatorIndex: number;
|
|
95
|
+
address: Uint8Array;
|
|
96
|
+
amount: bigint;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
* We don't need *all* the fields to check if a block
|
|
101
|
+
* is a pre-merge or a merge transition block, so we just
|
|
102
|
+
* have a minimum interface that is like a `BeaconBlock`.
|
|
103
|
+
*/
|
|
104
|
+
interface BeaconBlockLike {
|
|
105
|
+
body: {
|
|
106
|
+
randaoReveal: Uint8Array;
|
|
107
|
+
executionPayload?: {
|
|
108
|
+
parentHash: Uint8Array;
|
|
109
|
+
feeRecipient: Uint8Array;
|
|
110
|
+
stateRoot: Uint8Array;
|
|
111
|
+
receiptsRoot: Uint8Array;
|
|
112
|
+
logsBloom: Uint8Array;
|
|
113
|
+
prevRandao: Uint8Array;
|
|
114
|
+
blockNumber: number;
|
|
115
|
+
gasLimit: number;
|
|
116
|
+
gasUsed: number;
|
|
117
|
+
timestamp: number;
|
|
118
|
+
extraData: Uint8Array;
|
|
119
|
+
baseFeePerGas: bigint;
|
|
120
|
+
blockHash: Uint8Array;
|
|
121
|
+
transactions: {readonly length: number};
|
|
122
|
+
};
|
|
123
|
+
executionPayloadHeader?: ExecutionPayloadHeader;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface Fork {
|
|
128
|
+
previousVersion: Uint8Array;
|
|
129
|
+
currentVersion: Uint8Array;
|
|
130
|
+
epoch: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export enum ForkName {
|
|
134
|
+
phase0 = "phase0",
|
|
135
|
+
altair = "altair",
|
|
136
|
+
bellatrix = "bellatrix",
|
|
137
|
+
capella = "capella",
|
|
138
|
+
deneb = "deneb",
|
|
139
|
+
electra = "electra",
|
|
140
|
+
fulu = "fulu",
|
|
141
|
+
gloas = "gloas",
|
|
142
|
+
heze = "heze",
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export enum ForkSeq {
|
|
146
|
+
phase0 = 0,
|
|
147
|
+
altair = 1,
|
|
148
|
+
bellatrix = 2,
|
|
149
|
+
capella = 3,
|
|
150
|
+
deneb = 4,
|
|
151
|
+
electra = 5,
|
|
152
|
+
fulu = 6,
|
|
153
|
+
gloas = 7,
|
|
154
|
+
heze = 8,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface SyncCommittee {
|
|
158
|
+
pubkeys: Uint8Array[];
|
|
159
|
+
aggregatePubkey: Uint8Array;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface ProcessSlotsOpts {
|
|
163
|
+
/** Default: false (cache is transferred). Set to true to opt out of cache transfer. */
|
|
164
|
+
dontTransferCache?: boolean;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface CompactMultiProof {
|
|
168
|
+
// biome-ignore lint/suspicious/noExplicitAny: native returns string literal "compactMulti", IBeaconStateView uses @chainsafe/persistent-merkle-tree's ProofType
|
|
169
|
+
// TODO(bing): align types?
|
|
170
|
+
type: any;
|
|
171
|
+
leaves: Uint8Array[];
|
|
172
|
+
descriptor: Uint8Array;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Options to control how state transition is run.
|
|
177
|
+
*/
|
|
178
|
+
export interface TransitionOpts {
|
|
179
|
+
/** Verify the post-state root matches the block's state root. Default: true. */
|
|
180
|
+
verifyStateRoot?: boolean;
|
|
181
|
+
/** Verify the proposer signature on the signed block. Default: true. */
|
|
182
|
+
verifyProposer?: boolean;
|
|
183
|
+
/** Verify BLS signatures during block processing. Default: true. */
|
|
184
|
+
verifySignatures?: boolean;
|
|
185
|
+
/** Default: false (cache is transferred). Set to true to opt out of cache transfer. */
|
|
186
|
+
dontTransferCache?: boolean;
|
|
187
|
+
/** Execution engine result for payload validation. Default: "valid". */
|
|
188
|
+
executionPayloadStatus?: "valid" | "invalid" | "preMerge";
|
|
189
|
+
/** Data availability result; Gloas beacon blocks use "NotRequired". Default: "Available". */
|
|
190
|
+
dataAvailabilityStatus?: "Available" | "PreData" | "OutOfRange" | "NotRequired";
|
|
191
|
+
/** Source of block processing for the process-block timing metric. Default: "block". */
|
|
192
|
+
source?: "block" | "regen" | "get_historical_state";
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface ProposerRewards {
|
|
196
|
+
attestations: number;
|
|
197
|
+
syncAggregate: number;
|
|
198
|
+
slashing: number;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
interface BlockRewards {
|
|
202
|
+
proposerIndex: number;
|
|
203
|
+
total: number;
|
|
204
|
+
attestations: number;
|
|
205
|
+
syncAggregate: number;
|
|
206
|
+
proposerSlashings: number;
|
|
207
|
+
attesterSlashings: number;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface SyncCommitteeCache {
|
|
211
|
+
validatorIndices: Uint32Array;
|
|
212
|
+
validatorIndexMap: Map<number, number[]>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
interface EpochShuffling {
|
|
216
|
+
epoch: number;
|
|
217
|
+
activeIndices: Uint32Array;
|
|
218
|
+
shuffling: Uint32Array;
|
|
219
|
+
/** committees[slotInEpoch][committeeIndex] -> validator indices */
|
|
220
|
+
committees: Uint32Array[][];
|
|
221
|
+
committeesPerSlot: number;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface HistoricalSummary {
|
|
225
|
+
blockSummaryRoot: Uint8Array;
|
|
226
|
+
stateSummaryRoot: Uint8Array;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
interface Validator {
|
|
230
|
+
pubkey: Uint8Array;
|
|
231
|
+
withdrawalCredentials: Uint8Array;
|
|
232
|
+
effectiveBalance: number;
|
|
233
|
+
slashed: boolean;
|
|
234
|
+
activationEligibilityEpoch: number;
|
|
235
|
+
activationEpoch: number;
|
|
236
|
+
exitEpoch: number;
|
|
237
|
+
withdrawableEpoch: number;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
type ValidatorStatus =
|
|
241
|
+
| "pending_initialized"
|
|
242
|
+
| "pending_queued"
|
|
243
|
+
| "active_ongoing"
|
|
244
|
+
| "active_exiting"
|
|
245
|
+
| "active_slashed"
|
|
246
|
+
| "exited_unslashed"
|
|
247
|
+
| "exited_slashed"
|
|
248
|
+
| "withdrawal_possible"
|
|
249
|
+
| "withdrawal_done";
|
|
250
|
+
|
|
251
|
+
export type VoluntaryExitValidity =
|
|
252
|
+
| "valid"
|
|
253
|
+
| "inactive"
|
|
254
|
+
| "already_exited"
|
|
255
|
+
| "early_epoch"
|
|
256
|
+
| "short_time_active"
|
|
257
|
+
| "pending_withdrawals"
|
|
258
|
+
| "invalid_signature";
|
|
259
|
+
|
|
260
|
+
export declare class BeaconStateView {
|
|
261
|
+
/** Requires state bytes with trusted provenance; SSZ decoding does not authenticate them. */
|
|
262
|
+
static createFromBytes(bytes: Uint8Array, config: BeaconConfig): BeaconStateView;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Idempotently release this view. Subsequent state access throws InvalidState.
|
|
266
|
+
* An already-running native call retains its resources until that call returns.
|
|
267
|
+
*/
|
|
268
|
+
release(): void;
|
|
269
|
+
slot: number;
|
|
270
|
+
fork: Fork;
|
|
271
|
+
forkName: ForkName;
|
|
272
|
+
forkSeq: ForkSeq;
|
|
273
|
+
epoch: number;
|
|
274
|
+
genesisTime: number;
|
|
275
|
+
genesisValidatorsRoot: Uint8Array;
|
|
276
|
+
/** Throws on Heze and later, where legacy deposit fields are removed. */
|
|
277
|
+
eth1Data: Eth1Data;
|
|
278
|
+
latestBlockHeader: BeaconBlockHeader;
|
|
279
|
+
previousJustifiedCheckpoint: Checkpoint;
|
|
280
|
+
currentJustifiedCheckpoint: Checkpoint;
|
|
281
|
+
finalizedCheckpoint: Checkpoint;
|
|
282
|
+
getBlockRoot(epoch: number): Uint8Array;
|
|
283
|
+
getBlockRootAtSlot(slot: number): Uint8Array;
|
|
284
|
+
getBlockRootAtEpoch(epoch: number): Uint8Array;
|
|
285
|
+
getStateRootAtSlot(slot: number): Uint8Array;
|
|
286
|
+
getRandaoMix(epoch: number): Uint8Array;
|
|
287
|
+
previousEpochParticipation: Uint8Array;
|
|
288
|
+
currentEpochParticipation: Uint8Array;
|
|
289
|
+
getPreviousEpochParticipation(index: number): number;
|
|
290
|
+
getCurrentEpochParticipation(index: number): number;
|
|
291
|
+
latestExecutionPayloadHeader: ExecutionPayloadHeader;
|
|
292
|
+
payloadBlockNumber: number;
|
|
293
|
+
historicalSummaries: HistoricalSummary[];
|
|
294
|
+
pendingDeposits: Uint8Array;
|
|
295
|
+
pendingDepositsCount: number;
|
|
296
|
+
pendingPartialWithdrawals: Uint8Array;
|
|
297
|
+
pendingPartialWithdrawalsCount: number;
|
|
298
|
+
pendingConsolidations: Uint8Array;
|
|
299
|
+
pendingConsolidationsCount: number;
|
|
300
|
+
proposerLookahead: Uint32Array;
|
|
301
|
+
// Gloas fields throw when called on an earlier fork.
|
|
302
|
+
latestBlockHash: Uint8Array;
|
|
303
|
+
executionPayloadAvailability: {uint8Array: Uint8Array; bitLen: number};
|
|
304
|
+
latestExecutionPayloadBid: ExecutionPayloadBid | HezeExecutionPayloadBid;
|
|
305
|
+
payloadExpectedWithdrawals: Withdrawal[];
|
|
306
|
+
builderPendingPayments: BuilderPendingPayment[];
|
|
307
|
+
builderPendingWithdrawals: BuilderPendingWithdrawal[];
|
|
308
|
+
getBuilder(index: number): Builder;
|
|
309
|
+
canBuilderCoverBid(builderIndex: number, bidAmount: number): boolean;
|
|
310
|
+
getEpochPTCs(epoch: number): Uint32Array[];
|
|
311
|
+
getPayloadTimelinessCommittee(slot: number): Uint32Array;
|
|
312
|
+
getInclusionListCommittee(slot: number): Uint32Array;
|
|
313
|
+
getIndicesInPayloadTimelinessCommittee(validatorIndex: number, slot: number): number[];
|
|
314
|
+
/** Clone this view and apply serialized Gloas ExecutionRequests from the full parent. */
|
|
315
|
+
withParentPayloadApplied(executionRequestsBytes: Uint8Array): BeaconStateView;
|
|
316
|
+
|
|
317
|
+
getShufflingAtEpoch(epoch: number): EpochShuffling;
|
|
318
|
+
getPreviousShuffling(): EpochShuffling;
|
|
319
|
+
getCurrentShuffling(): EpochShuffling;
|
|
320
|
+
getNextShuffling(): EpochShuffling;
|
|
321
|
+
getBeaconCommittee(slot: number, index: number): Uint32Array;
|
|
322
|
+
getBeaconCommitteeCountPerSlot(epoch: number): number;
|
|
323
|
+
previousDecisionRoot: string;
|
|
324
|
+
currentDecisionRoot: string;
|
|
325
|
+
nextDecisionRoot: string;
|
|
326
|
+
getShufflingDecisionRoot(epoch: number): string;
|
|
327
|
+
previousProposers: number[] | null;
|
|
328
|
+
currentProposers: number[];
|
|
329
|
+
nextProposers: number[];
|
|
330
|
+
getBeaconProposer(slot: number): number;
|
|
331
|
+
getBeaconProposerOrNull(slot: number): number | null;
|
|
332
|
+
currentSyncCommittee: SyncCommittee;
|
|
333
|
+
nextSyncCommittee: SyncCommittee;
|
|
334
|
+
currentSyncCommitteeIndexed: SyncCommitteeCache;
|
|
335
|
+
/** Returns an owned copy in committee order, including repeated validators. */
|
|
336
|
+
readonly currentSyncCommitteeValidatorIndices: Uint32Array;
|
|
337
|
+
syncProposerReward: number;
|
|
338
|
+
getIndexedSyncCommitteeAtEpoch(epoch: number): SyncCommitteeCache;
|
|
339
|
+
getIndexedSyncCommittee(slot: number): SyncCommitteeCache;
|
|
340
|
+
|
|
341
|
+
effectiveBalanceIncrements: Uint16Array;
|
|
342
|
+
getEffectiveBalanceIncrementsZeroInactive(): Uint16Array;
|
|
343
|
+
getBalance(index: number): number;
|
|
344
|
+
getValidator(index: number): Validator;
|
|
345
|
+
getAllValidators(): Validator[];
|
|
346
|
+
getBuildersLength(): number;
|
|
347
|
+
getAllBalances(): number[];
|
|
348
|
+
getValidatorsByStatus(statuses: Set<string>, currentEpoch: number): Validator[];
|
|
349
|
+
// TODO wrong function
|
|
350
|
+
getValidatorStatus(index: number): ValidatorStatus;
|
|
351
|
+
validatorCount: number;
|
|
352
|
+
activeValidatorCount: number;
|
|
353
|
+
|
|
354
|
+
isExecutionStateType: boolean;
|
|
355
|
+
isMergeTransitionComplete: boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Check whether execution is enabled for the given block at this state.
|
|
358
|
+
*
|
|
359
|
+
* For normal post-merge operation this short-circuits from state alone and does
|
|
360
|
+
* not inspect `block`. The block object is only read for the historical pre-merge
|
|
361
|
+
* Bellatrix case, where execution is enabled iff the block carries the first
|
|
362
|
+
* non-default execution payload.
|
|
363
|
+
*/
|
|
364
|
+
isExecutionEnabled(block: BeaconBlockLike): boolean;
|
|
365
|
+
|
|
366
|
+
proposerRewards: ProposerRewards;
|
|
367
|
+
computeBlockRewards(
|
|
368
|
+
signedBlockBytes: Uint8Array,
|
|
369
|
+
isBlinded: boolean,
|
|
370
|
+
proposerRewards?: ProposerRewards
|
|
371
|
+
): BlockRewards;
|
|
372
|
+
computeAttestationsRewards(validatorIds?: (number | string)[]): AttestationsRewards;
|
|
373
|
+
computeSyncCommitteeRewards(
|
|
374
|
+
block: SyncCommitteeRewardsBlock,
|
|
375
|
+
validatorIds?: (number | string)[]
|
|
376
|
+
): SyncCommitteeReward[];
|
|
377
|
+
getLatestWeakSubjectivityCheckpointEpoch(): number;
|
|
378
|
+
|
|
379
|
+
getVoluntaryExitValidity(signedVoluntaryExit: SignedVoluntaryExit, verifySignature: boolean): VoluntaryExitValidity;
|
|
380
|
+
isValidVoluntaryExit(signedVoluntaryExit: SignedVoluntaryExit, verifySignature: boolean): boolean;
|
|
381
|
+
|
|
382
|
+
getFinalizedRootProof(): Uint8Array[];
|
|
383
|
+
getSyncCommitteesWitness(): {
|
|
384
|
+
/** Shared witness before Gloas; empty when separate committee branches are returned. */
|
|
385
|
+
witness: Uint8Array[];
|
|
386
|
+
currentSyncCommitteeRoot: Uint8Array;
|
|
387
|
+
nextSyncCommitteeRoot: Uint8Array;
|
|
388
|
+
currentSyncCommitteeBranch?: Uint8Array[];
|
|
389
|
+
nextSyncCommitteeBranch?: Uint8Array[];
|
|
390
|
+
};
|
|
391
|
+
getSingleProof(gindex: bigint): Uint8Array[];
|
|
392
|
+
/**
|
|
393
|
+
* Compute expected withdrawals for the next payload (capella+).
|
|
394
|
+
*
|
|
395
|
+
* processedBuilderWithdrawalsCount is withdrawals coming from builder payment since gloas
|
|
396
|
+
* processedPartialWithdrawalsCount is withdrawals coming from EL since electra (EIP-7002)
|
|
397
|
+
* processedBuildersSweepCount is withdrawals from builder sweep since gloas
|
|
398
|
+
* processedValidatorSweepCount is withdrawals coming from validator sweep
|
|
399
|
+
|
|
400
|
+
*/
|
|
401
|
+
getExpectedWithdrawals(): {
|
|
402
|
+
expectedWithdrawals: Withdrawal[];
|
|
403
|
+
processedBuilderWithdrawalsCount: number;
|
|
404
|
+
processedPartialWithdrawalsCount: number;
|
|
405
|
+
processedBuildersSweepCount: number;
|
|
406
|
+
processedValidatorSweepCount: number;
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
/** On phase0, serialize this call with other STF operations and cache teardown within this thread. */
|
|
410
|
+
computeUnrealizedCheckpoints(): {
|
|
411
|
+
justifiedCheckpoint: Checkpoint;
|
|
412
|
+
finalizedCheckpoint: Checkpoint;
|
|
413
|
+
};
|
|
414
|
+
computeAnchorCheckpoint(): {
|
|
415
|
+
checkpoint: Checkpoint;
|
|
416
|
+
blockHeader: BeaconBlockHeader;
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
clonedCount: number;
|
|
420
|
+
clonedCountWithTransferCache: number;
|
|
421
|
+
createdWithTransferCache: boolean;
|
|
422
|
+
isStateValidatorsNodesPopulated(): boolean;
|
|
423
|
+
|
|
424
|
+
loadOtherState(
|
|
425
|
+
stateBytes: Uint8Array,
|
|
426
|
+
seedValidatorsBytes?: Uint8Array,
|
|
427
|
+
opts?: {preloadValidatorsAndBalances?: boolean}
|
|
428
|
+
): BeaconStateView;
|
|
429
|
+
loadOtherStateBench(stateBytes: Uint8Array, seedValidatorsBytes?: Uint8Array): void;
|
|
430
|
+
// biome-ignore lint/suspicious/noExplicitAny: structurally a BeaconState (fork-narrowed),
|
|
431
|
+
// but typing the union here would duplicate types from @lodestar/types. Caller narrows by forkName.
|
|
432
|
+
toValue(): any;
|
|
433
|
+
|
|
434
|
+
serialize(): Uint8Array;
|
|
435
|
+
serializedSize(): number;
|
|
436
|
+
/** Takes a `@chainsafe/ssz` ByteViews `{uint8Array, dataView}`; native uses `uint8Array` only. */
|
|
437
|
+
serializeToBytes(output: {uint8Array: Uint8Array; dataView: DataView}, offset: number): number;
|
|
438
|
+
serializeValidators(): Uint8Array;
|
|
439
|
+
serializedValidatorsSize(): number;
|
|
440
|
+
serializeValidatorsToBytes(output: {uint8Array: Uint8Array; dataView: DataView}, offset: number): number;
|
|
441
|
+
hashTreeRoot(): Uint8Array;
|
|
442
|
+
createMultiProof(descriptor: Uint8Array): CompactMultiProof;
|
|
443
|
+
|
|
444
|
+
/** Serialize this call with other STF operations and cache teardown within this thread. */
|
|
445
|
+
processSlots(slot: number, options?: ProcessSlotsOpts): BeaconStateView;
|
|
446
|
+
/**
|
|
447
|
+
* Serialize this call with other STF operations and cache teardown within this thread.
|
|
448
|
+
* Throws an Error with the native error name in `code` and available diagnostic details in `message`.
|
|
449
|
+
*/
|
|
450
|
+
stateTransition(signedBlockBytes: Uint8Array, isBlinded: boolean, options?: TransitionOpts): BeaconStateView;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Owns a copy of the configuration inputs; states retain it for their lifetime.
|
|
455
|
+
* Numeric u64 fields accept safe unsigned integers or Infinity as the maximum u64 sentinel.
|
|
456
|
+
*/
|
|
457
|
+
export declare class BeaconConfig {
|
|
458
|
+
private readonly _brand: void;
|
|
459
|
+
constructor(chainConfig: object, genesisValidatorsRoot: Uint8Array);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
declare const bindings: {
|
|
463
|
+
stateTransition: {
|
|
464
|
+
/** Callers must exclude STF operations in this thread until teardown returns. */
|
|
465
|
+
deinitReusedEpochTransitionCache: () => void;
|
|
466
|
+
};
|
|
467
|
+
metrics: {
|
|
468
|
+
init: (options?: {historical?: boolean}) => void;
|
|
469
|
+
scrapeMetrics: () => string;
|
|
470
|
+
registerLocalValidator: (index: number) => void;
|
|
471
|
+
unregisterLocalValidator: (index: number) => void;
|
|
472
|
+
};
|
|
473
|
+
BeaconStateView: typeof BeaconStateView;
|
|
474
|
+
BeaconConfig: typeof BeaconConfig;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
export default bindings;
|
|
478
|
+
|
|
479
|
+
export interface SyncCommitteeRewardsBlock {
|
|
480
|
+
slot: number;
|
|
481
|
+
body: {
|
|
482
|
+
randaoReveal: Uint8Array;
|
|
483
|
+
syncAggregate?: {
|
|
484
|
+
syncCommitteeBits: {uint8Array: Uint8Array; bitLen: number};
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export interface SyncCommitteeReward {
|
|
490
|
+
validatorIndex: number;
|
|
491
|
+
reward: number;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export interface AttestationReward {
|
|
495
|
+
head: number;
|
|
496
|
+
target: number;
|
|
497
|
+
source: number;
|
|
498
|
+
inclusionDelay: number;
|
|
499
|
+
inactivity: number;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export interface IdealAttestationsReward extends AttestationReward {
|
|
503
|
+
effectiveBalance: number;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export interface TotalAttestationsReward extends AttestationReward {
|
|
507
|
+
validatorIndex: number;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export interface AttestationsRewards {
|
|
511
|
+
idealRewards: IdealAttestationsReward[];
|
|
512
|
+
totalRewards: TotalAttestationsReward[];
|
|
513
|
+
}
|
package/src/index.js
ADDED
package/src/metrics.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Initialize this environment's native state-transition metrics. */
|
|
2
|
+
export declare function init(options?: {historical?: boolean}): void;
|
|
3
|
+
|
|
4
|
+
/** Scrape native state-transition metrics in Prometheus text format. */
|
|
5
|
+
export declare function scrapeMetrics(): string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Register a validator index with the native validator monitor. Metrics
|
|
9
|
+
* are recorded for registered validators on every epoch transition.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerLocalValidator(index: number): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Remove a validator index from the native validator monitor, so its
|
|
15
|
+
* `validator_monitor_*` status metrics stop being recorded. Mirrors the pruning
|
|
16
|
+
* of stale registrations in lodestar's validator monitor.
|
|
17
|
+
*/
|
|
18
|
+
export declare function unregisterLocalValidator(index: number): void;
|
package/src/metrics.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import bindings from "./bindings.js";
|
|
2
|
+
|
|
3
|
+
const native = bindings.metrics;
|
|
4
|
+
|
|
5
|
+
export const init = native.init;
|
|
6
|
+
export const scrapeMetrics = native.scrapeMetrics;
|
|
7
|
+
export const registerLocalValidator = native.registerLocalValidator;
|
|
8
|
+
export const unregisterLocalValidator = native.unregisterLocalValidator;
|
package/src/pubkeys.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type {PublicKey} from "./blst.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Append-only validator public-key cache.
|
|
5
|
+
*
|
|
6
|
+
* Throws when encountering:
|
|
7
|
+
* - An existing index with a different public key.
|
|
8
|
+
* - An existing public key at a different index.
|
|
9
|
+
*
|
|
10
|
+
* No-op for an exact index and public-key replay.
|
|
11
|
+
*/
|
|
12
|
+
export interface PubkeyCache {
|
|
13
|
+
/** Get a cached, deserialized PublicKey. */
|
|
14
|
+
get(index: number): PublicKey | undefined;
|
|
15
|
+
/** Same as get(), but throws if the index is not in the cache */
|
|
16
|
+
getOrThrow(index: number): PublicKey;
|
|
17
|
+
/** Get the cached 48-byte compressed pubkey bytes without materializing a PublicKey wrapper. */
|
|
18
|
+
getPubkeyBytes(index: number): Uint8Array | undefined;
|
|
19
|
+
/** Same as getPubkeyBytes(), but throws if the index is not in the cache. */
|
|
20
|
+
getPubkeyBytesOrThrow(index: number): Uint8Array;
|
|
21
|
+
/** Aggregate cached public keys by validator index */
|
|
22
|
+
aggregate(indices: number[]): PublicKey;
|
|
23
|
+
/** Get validator index by pubkey bytes */
|
|
24
|
+
getIndex(pubkey: Uint8Array): number | null;
|
|
25
|
+
/**
|
|
26
|
+
* Append a trusted public key at the next index. Before calling this method,
|
|
27
|
+
* the caller must cryptographically validate the public key.
|
|
28
|
+
*
|
|
29
|
+
* The method throws if:
|
|
30
|
+
*
|
|
31
|
+
* - Encodings are malformed.
|
|
32
|
+
* - Entries are sparse.
|
|
33
|
+
*/
|
|
34
|
+
append(index: number, pubkey: Uint8Array): void;
|
|
35
|
+
/**
|
|
36
|
+
* Populate the cache from the missing suffix of a trusted validator list.
|
|
37
|
+
* This method decodes public keys but does not validate.
|
|
38
|
+
*/
|
|
39
|
+
syncPubkeys(validators: {pubkey: Uint8Array}[]): void;
|
|
40
|
+
/** Current number of cached entries. */
|
|
41
|
+
readonly size: number;
|
|
42
|
+
/** Number of entries the current native allocation can hold without growing. */
|
|
43
|
+
readonly capacity: number;
|
|
44
|
+
/**
|
|
45
|
+
* Load a compatible, trusted PKIX file from the control environment while no workers are using the cache.
|
|
46
|
+
* Does not revalidate public keys. The explicit capacity
|
|
47
|
+
* limit bounds both the entry count and native allocation; spare capacity
|
|
48
|
+
* recorded in the file is discarded above this limit.
|
|
49
|
+
*/
|
|
50
|
+
load(filepath: string, maxCapacity: number): void;
|
|
51
|
+
/** Testing-only reset from the control environment while no workers are using the cache. */
|
|
52
|
+
reset(): void;
|
|
53
|
+
/** Save from the control environment. */
|
|
54
|
+
save(filepath: string): void;
|
|
55
|
+
/** Reserve exact native capacity when growing; existing larger capacity is retained. */
|
|
56
|
+
ensureCapacity(capacity: number): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export declare const pubkeyCache: PubkeyCache;
|
package/src/pubkeys.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import bindings from "./bindings.js";
|
|
2
|
+
|
|
3
|
+
const native = bindings.pubkeys;
|
|
4
|
+
|
|
5
|
+
/** @type {import("./pubkeys.d.ts").PubkeyCache} */
|
|
6
|
+
export const pubkeyCache = {
|
|
7
|
+
get(index) {
|
|
8
|
+
return native.get(index);
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
getOrThrow(index) {
|
|
12
|
+
const pk = pubkeyCache.get(index);
|
|
13
|
+
if (pk === undefined) {
|
|
14
|
+
throw Error(`pubkeyCache: index ${index} not found`);
|
|
15
|
+
}
|
|
16
|
+
return pk;
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
getPubkeyBytes(index) {
|
|
20
|
+
return native.getPubkeyBytes(index);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
getPubkeyBytesOrThrow(index) {
|
|
24
|
+
const pubkey = native.getPubkeyBytes(index);
|
|
25
|
+
if (pubkey === undefined) {
|
|
26
|
+
throw new Error(`pubkeyCache: index ${index} not found`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return pubkey;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
aggregate(indices) {
|
|
33
|
+
if (indices.length === 1) return pubkeyCache.getOrThrow(indices[0]);
|
|
34
|
+
return native.aggregate(indices);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
getIndex(pubkey) {
|
|
38
|
+
return native.getIndex(pubkey);
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
append(index, pubkey) {
|
|
42
|
+
native.append(index, pubkey);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
syncPubkeys(validators) {
|
|
46
|
+
native.syncPubkeys(validators);
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
get size() {
|
|
50
|
+
return native.size();
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
get capacity() {
|
|
54
|
+
return native.capacity();
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
load(filepath, maxCapacity) {
|
|
58
|
+
native.load(filepath, maxCapacity);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
reset() {
|
|
62
|
+
native.reset();
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
save(filepath) {
|
|
66
|
+
native.save(filepath);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
ensureCapacity(capacity) {
|
|
70
|
+
native.ensureCapacity(capacity);
|
|
71
|
+
},
|
|
72
|
+
};
|