@lodestar/state-transition 1.42.0 → 1.43.0-dev.07452fe3b7
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/index.d.ts +2 -2
- package/lib/block/index.d.ts.map +1 -1
- package/lib/block/index.js +11 -4
- package/lib/block/index.js.map +1 -1
- package/lib/block/processDepositRequest.d.ts +11 -2
- package/lib/block/processDepositRequest.d.ts.map +1 -1
- package/lib/block/processDepositRequest.js +34 -4
- package/lib/block/processDepositRequest.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts +20 -0
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -0
- package/lib/block/processParentExecutionPayload.js +100 -0
- package/lib/block/processParentExecutionPayload.js.map +1 -0
- package/lib/block/processWithdrawals.d.ts.map +1 -1
- package/lib/block/processWithdrawals.js +10 -4
- package/lib/block/processWithdrawals.js.map +1 -1
- package/lib/cache/epochCache.d.ts +3 -1
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +31 -13
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/epochTransitionCache.d.ts +5 -0
- package/lib/cache/epochTransitionCache.d.ts.map +1 -1
- package/lib/cache/epochTransitionCache.js +1 -0
- package/lib/cache/epochTransitionCache.js.map +1 -1
- package/lib/epoch/index.d.ts +3 -1
- package/lib/epoch/index.d.ts.map +1 -1
- package/lib/epoch/index.js +8 -1
- package/lib/epoch/index.js.map +1 -1
- package/lib/epoch/processPtcWindow.d.ts +11 -0
- package/lib/epoch/processPtcWindow.d.ts.map +1 -0
- package/lib/epoch/processPtcWindow.js +28 -0
- package/lib/epoch/processPtcWindow.js.map +1 -0
- package/lib/index.d.ts +4 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.js +5 -1
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
- package/lib/signatureSets/index.d.ts +1 -0
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +1 -0
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/proposerPreferences.d.ts +4 -0
- package/lib/signatureSets/proposerPreferences.d.ts.map +1 -0
- package/lib/signatureSets/proposerPreferences.js +8 -0
- package/lib/signatureSets/proposerPreferences.js.map +1 -0
- package/lib/signatureSets/voluntaryExits.d.ts +2 -2
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +4 -0
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
- package/lib/slot/upgradeStateToGloas.js +3 -1
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/stateTransition.d.ts +1 -2
- package/lib/stateTransition.d.ts.map +1 -1
- package/lib/stateTransition.js +1 -2
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +18 -12
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +69 -42
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +111 -54
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js +22 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/util/attestation.d.ts +12 -1
- package/lib/util/attestation.d.ts.map +1 -1
- package/lib/util/attestation.js +23 -8
- package/lib/util/attestation.js.map +1 -1
- package/lib/util/computeAnchorCheckpoint.d.ts +1 -1
- package/lib/util/computeAnchorCheckpoint.d.ts.map +1 -1
- package/lib/util/computeAnchorCheckpoint.js +6 -19
- package/lib/util/computeAnchorCheckpoint.js.map +1 -1
- package/lib/util/execution.d.ts +4 -2
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +7 -0
- package/lib/util/execution.js.map +1 -1
- package/lib/util/gloas.d.ts +7 -2
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +25 -3
- package/lib/util/gloas.js.map +1 -1
- package/package.json +8 -8
- package/src/block/index.ts +12 -4
- package/src/block/processDepositRequest.ts +50 -5
- package/src/block/processParentExecutionPayload.ts +116 -0
- package/src/block/processWithdrawals.ts +12 -4
- package/src/cache/epochCache.ts +32 -30
- package/src/cache/epochTransitionCache.ts +7 -0
- package/src/epoch/index.ts +9 -0
- package/src/epoch/processPtcWindow.ts +38 -0
- package/src/index.ts +20 -2
- package/src/signatureSets/executionPayloadEnvelope.ts +6 -2
- package/src/signatureSets/index.ts +1 -0
- package/src/signatureSets/proposerPreferences.ts +12 -0
- package/src/signatureSets/voluntaryExits.ts +5 -2
- package/src/slot/upgradeStateToGloas.ts +5 -1
- package/src/stateTransition.ts +1 -2
- package/src/stateView/beaconStateView.ts +91 -56
- package/src/stateView/interface.ts +163 -79
- package/src/util/attestation.ts +37 -8
- package/src/util/computeAnchorCheckpoint.ts +6 -19
- package/src/util/execution.ts +11 -1
- package/src/util/gloas.ts +46 -3
- package/lib/block/processExecutionPayloadEnvelope.d.ts +0 -9
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +0 -1
- package/lib/block/processExecutionPayloadEnvelope.js +0 -102
- package/lib/block/processExecutionPayloadEnvelope.js.map +0 -1
- package/src/block/processExecutionPayloadEnvelope.ts +0 -170
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import {CompactMultiProof} from "@chainsafe/persistent-merkle-tree";
|
|
2
2
|
import {BitArray, ByteViews} from "@chainsafe/ssz";
|
|
3
|
+
import {
|
|
4
|
+
ForkName,
|
|
5
|
+
ForkPostAltair,
|
|
6
|
+
ForkPostBellatrix,
|
|
7
|
+
ForkPostCapella,
|
|
8
|
+
ForkPostDeneb,
|
|
9
|
+
ForkPostElectra,
|
|
10
|
+
ForkPostFulu,
|
|
11
|
+
ForkPostGloas,
|
|
12
|
+
isForkPostAltair,
|
|
13
|
+
isForkPostBellatrix,
|
|
14
|
+
isForkPostCapella,
|
|
15
|
+
isForkPostDeneb,
|
|
16
|
+
isForkPostElectra,
|
|
17
|
+
isForkPostFulu,
|
|
18
|
+
isForkPostGloas,
|
|
19
|
+
} from "@lodestar/params";
|
|
3
20
|
import {
|
|
4
21
|
BeaconBlock,
|
|
5
22
|
BeaconState,
|
|
@@ -24,7 +41,6 @@ import {
|
|
|
24
41
|
rewards,
|
|
25
42
|
} from "@lodestar/types";
|
|
26
43
|
import {Checkpoint, Fork} from "@lodestar/types/phase0";
|
|
27
|
-
import {ProcessExecutionPayloadEnvelopeOpts} from "../block/processExecutionPayloadEnvelope.js";
|
|
28
44
|
import {VoluntaryExitValidity} from "../block/processVoluntaryExit.js";
|
|
29
45
|
import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js";
|
|
30
46
|
import {EpochTransitionCacheOpts} from "../cache/epochTransitionCache.js";
|
|
@@ -41,6 +57,7 @@ export interface IBeaconStateView {
|
|
|
41
57
|
// State access
|
|
42
58
|
|
|
43
59
|
// phase0
|
|
60
|
+
forkName: ForkName;
|
|
44
61
|
slot: Slot;
|
|
45
62
|
fork: Fork;
|
|
46
63
|
epoch: Epoch;
|
|
@@ -56,50 +73,6 @@ export interface IBeaconStateView {
|
|
|
56
73
|
getStateRootAtSlot(slot: Slot): Root;
|
|
57
74
|
getRandaoMix(epoch: Epoch): Bytes32;
|
|
58
75
|
|
|
59
|
-
// altair
|
|
60
|
-
previousEpochParticipation: Uint8Array;
|
|
61
|
-
currentEpochParticipation: Uint8Array;
|
|
62
|
-
getPreviousEpochParticipation(validatorIndex: ValidatorIndex): number;
|
|
63
|
-
getCurrentEpochParticipation(validatorIndex: ValidatorIndex): number;
|
|
64
|
-
|
|
65
|
-
// bellatrix
|
|
66
|
-
latestExecutionPayloadHeader: ExecutionPayloadHeader;
|
|
67
|
-
/**
|
|
68
|
-
* Cross-fork accessor for the execution block hash of the most recently included payload.
|
|
69
|
-
* Pre-gloas: returns latestExecutionPayloadHeader.blockHash (bellatrix–fulu).
|
|
70
|
-
* Gloas+: returns the dedicated latestBlockHash state field (EIP-7732).
|
|
71
|
-
* Throws before bellatrix.
|
|
72
|
-
*/
|
|
73
|
-
latestBlockHash: Bytes32;
|
|
74
|
-
/**
|
|
75
|
-
* The execution block number of the most recently included payload.
|
|
76
|
-
* Named payloadBlockNumber (not latestBlockNumber) to mirror ExecutionPayloadHeader.blockNumber pre-gloas.
|
|
77
|
-
* Only available from bellatrix through fulu — not tracked on BeaconState in gloas+ (EIP-7732).
|
|
78
|
-
* Throws before bellatrix and from gloas onwards.
|
|
79
|
-
*/
|
|
80
|
-
payloadBlockNumber: number;
|
|
81
|
-
|
|
82
|
-
// capella
|
|
83
|
-
historicalSummaries: capella.HistoricalSummaries;
|
|
84
|
-
|
|
85
|
-
// electra
|
|
86
|
-
pendingDeposits: electra.PendingDeposits;
|
|
87
|
-
pendingDepositsCount: number;
|
|
88
|
-
pendingPartialWithdrawals: electra.PendingPartialWithdrawals;
|
|
89
|
-
pendingPartialWithdrawalsCount: number;
|
|
90
|
-
pendingConsolidations: electra.PendingConsolidations;
|
|
91
|
-
pendingConsolidationsCount: number;
|
|
92
|
-
|
|
93
|
-
// fulu
|
|
94
|
-
proposerLookahead: fulu.ProposerLookahead;
|
|
95
|
-
|
|
96
|
-
// gloas
|
|
97
|
-
executionPayloadAvailability: BitArray;
|
|
98
|
-
latestExecutionPayloadBid: ExecutionPayloadBid;
|
|
99
|
-
getBuilder(index: BuilderIndex): gloas.Builder;
|
|
100
|
-
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
|
|
101
|
-
getIndexInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number;
|
|
102
|
-
|
|
103
76
|
// Shuffling and committees
|
|
104
77
|
getShufflingAtEpoch(epoch: Epoch): EpochShuffling;
|
|
105
78
|
// Decision roots
|
|
@@ -117,15 +90,6 @@ export interface IBeaconStateView {
|
|
|
117
90
|
nextProposers: ValidatorIndex[];
|
|
118
91
|
getBeaconProposer(slot: Slot): ValidatorIndex;
|
|
119
92
|
|
|
120
|
-
// Sync committees
|
|
121
|
-
currentSyncCommittee: altair.SyncCommittee;
|
|
122
|
-
nextSyncCommittee: altair.SyncCommittee;
|
|
123
|
-
currentSyncCommitteeIndexed: SyncCommitteeCache;
|
|
124
|
-
syncProposerReward: number;
|
|
125
|
-
getIndexedSyncCommitteeAtEpoch(epoch: Epoch): SyncCommitteeCache;
|
|
126
|
-
/** Get indexed sync committee with slot+1 offset for duty lookups */
|
|
127
|
-
getIndexedSyncCommittee(slot: Slot): SyncCommitteeCache;
|
|
128
|
-
|
|
129
93
|
// Validators and balances
|
|
130
94
|
effectiveBalanceIncrements: EffectiveBalanceIncrements;
|
|
131
95
|
getEffectiveBalanceIncrementsZeroInactive(): EffectiveBalanceIncrements;
|
|
@@ -140,29 +104,10 @@ export interface IBeaconStateView {
|
|
|
140
104
|
getAllValidators(): phase0.Validator[];
|
|
141
105
|
getAllBalances(): number[];
|
|
142
106
|
|
|
143
|
-
// Merge
|
|
144
|
-
isExecutionStateType: boolean;
|
|
145
|
-
isMergeTransitionComplete: boolean;
|
|
146
|
-
// TODO this should go away (or rather only need block)
|
|
147
|
-
isExecutionEnabled(block: BeaconBlock | BlindedBeaconBlock): boolean;
|
|
148
|
-
|
|
149
|
-
// Block production
|
|
150
|
-
getExpectedWithdrawals(): {
|
|
151
|
-
expectedWithdrawals: capella.Withdrawal[];
|
|
152
|
-
processedBuilderWithdrawalsCount: number;
|
|
153
|
-
processedPartialWithdrawalsCount: number;
|
|
154
|
-
processedBuildersSweepCount: number;
|
|
155
|
-
processedValidatorSweepCount: number;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
107
|
// API
|
|
159
108
|
proposerRewards: RewardCache;
|
|
160
109
|
computeBlockRewards(block: BeaconBlock, proposerRewards?: RewardCache): Promise<rewards.BlockRewards>;
|
|
161
110
|
computeAttestationsRewards(validatorIds?: (ValidatorIndex | string)[]): Promise<rewards.AttestationsRewards>;
|
|
162
|
-
computeSyncCommitteeRewards(
|
|
163
|
-
block: BeaconBlock,
|
|
164
|
-
validatorIds: (ValidatorIndex | string)[]
|
|
165
|
-
): Promise<rewards.SyncCommitteeRewards>;
|
|
166
111
|
getLatestWeakSubjectivityCheckpointEpoch(): Epoch;
|
|
167
112
|
|
|
168
113
|
// Validation
|
|
@@ -174,7 +119,6 @@ export interface IBeaconStateView {
|
|
|
174
119
|
|
|
175
120
|
// Proofs
|
|
176
121
|
getFinalizedRootProof(): Uint8Array[];
|
|
177
|
-
getSyncCommitteesWitness(): SyncCommitteeWitness;
|
|
178
122
|
getSingleProof(gindex: bigint): Uint8Array[];
|
|
179
123
|
createMultiProof(descriptor: Uint8Array): CompactMultiProof;
|
|
180
124
|
|
|
@@ -193,7 +137,13 @@ export interface IBeaconStateView {
|
|
|
193
137
|
isStateValidatorsNodesPopulated(): boolean;
|
|
194
138
|
|
|
195
139
|
// Serialization
|
|
196
|
-
|
|
140
|
+
/** Set `preloadValidatorsAndBalances` only when the whole state will be consumed
|
|
141
|
+
* immediately (e.g. CP reload before block replay). */
|
|
142
|
+
loadOtherState(
|
|
143
|
+
stateBytes: Uint8Array,
|
|
144
|
+
seedValidatorsBytes?: Uint8Array,
|
|
145
|
+
opts?: {preloadValidatorsAndBalances?: boolean}
|
|
146
|
+
): IBeaconStateView;
|
|
197
147
|
toValue(): BeaconState;
|
|
198
148
|
serialize(): Uint8Array;
|
|
199
149
|
serializedSize(): number;
|
|
@@ -215,8 +165,142 @@ export interface IBeaconStateView {
|
|
|
215
165
|
epochTransitionCacheOpts?: EpochTransitionCacheOpts & {dontTransferCache?: boolean},
|
|
216
166
|
modules?: StateTransitionModules
|
|
217
167
|
): IBeaconStateView;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Altair+ state fields — use isStatePostAltair() guard */
|
|
171
|
+
export interface IBeaconStateViewAltair extends IBeaconStateView {
|
|
172
|
+
forkName: ForkPostAltair;
|
|
173
|
+
previousEpochParticipation: Uint8Array;
|
|
174
|
+
currentEpochParticipation: Uint8Array;
|
|
175
|
+
getPreviousEpochParticipation(validatorIndex: ValidatorIndex): number;
|
|
176
|
+
getCurrentEpochParticipation(validatorIndex: ValidatorIndex): number;
|
|
177
|
+
currentSyncCommittee: altair.SyncCommittee;
|
|
178
|
+
nextSyncCommittee: altair.SyncCommittee;
|
|
179
|
+
currentSyncCommitteeIndexed: SyncCommitteeCache;
|
|
180
|
+
syncProposerReward: number;
|
|
181
|
+
getIndexedSyncCommitteeAtEpoch(epoch: Epoch): SyncCommitteeCache;
|
|
182
|
+
/** Get indexed sync committee with slot+1 offset for duty lookups */
|
|
183
|
+
getIndexedSyncCommittee(slot: Slot): SyncCommitteeCache;
|
|
184
|
+
computeSyncCommitteeRewards(
|
|
185
|
+
block: BeaconBlock,
|
|
186
|
+
validatorIds: (ValidatorIndex | string)[]
|
|
187
|
+
): Promise<rewards.SyncCommitteeRewards>;
|
|
188
|
+
getSyncCommitteesWitness(): SyncCommitteeWitness;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Bellatrix+ state fields — use isStatePostBellatrix() guard */
|
|
192
|
+
export interface IBeaconStateViewBellatrix extends IBeaconStateViewAltair {
|
|
193
|
+
forkName: ForkPostBellatrix;
|
|
194
|
+
latestExecutionPayloadHeader: ExecutionPayloadHeader;
|
|
195
|
+
/**
|
|
196
|
+
* The execution block number of the most recently included payload.
|
|
197
|
+
* Named payloadBlockNumber (not latestBlockNumber) to mirror ExecutionPayloadHeader.blockNumber pre-gloas.
|
|
198
|
+
* Only available from bellatrix through fulu — not tracked on BeaconState in gloas+ (EIP-7732).
|
|
199
|
+
* Throws before bellatrix and from gloas onwards.
|
|
200
|
+
*/
|
|
201
|
+
payloadBlockNumber: number;
|
|
202
|
+
isExecutionStateType: boolean;
|
|
203
|
+
isMergeTransitionComplete: boolean;
|
|
204
|
+
isExecutionEnabled(block: BeaconBlock | BlindedBeaconBlock): boolean;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Capella+ state fields — use isStatePostCapella() guard */
|
|
208
|
+
export interface IBeaconStateViewCapella extends IBeaconStateViewBellatrix {
|
|
209
|
+
forkName: ForkPostCapella;
|
|
210
|
+
historicalSummaries: capella.HistoricalSummaries;
|
|
211
|
+
getExpectedWithdrawals(): {
|
|
212
|
+
expectedWithdrawals: capella.Withdrawal[];
|
|
213
|
+
processedBuilderWithdrawalsCount: number;
|
|
214
|
+
processedPartialWithdrawalsCount: number;
|
|
215
|
+
processedBuildersSweepCount: number;
|
|
216
|
+
processedValidatorSweepCount: number;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Deneb+ state — no new state-view fields; placeholder for fork completeness and isStatePostDeneb() narrowing */
|
|
221
|
+
export interface IBeaconStateViewDeneb extends IBeaconStateViewCapella {
|
|
222
|
+
forkName: ForkPostDeneb;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Electra+ state fields — use isStatePostElectra() guard */
|
|
226
|
+
export interface IBeaconStateViewElectra extends IBeaconStateViewDeneb {
|
|
227
|
+
forkName: ForkPostElectra;
|
|
228
|
+
pendingDeposits: electra.PendingDeposits;
|
|
229
|
+
pendingDepositsCount: number;
|
|
230
|
+
pendingPartialWithdrawals: electra.PendingPartialWithdrawals;
|
|
231
|
+
pendingPartialWithdrawalsCount: number;
|
|
232
|
+
pendingConsolidations: electra.PendingConsolidations;
|
|
233
|
+
pendingConsolidationsCount: number;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Fulu+ state fields — use isStatePostFulu() guard */
|
|
237
|
+
export interface IBeaconStateViewFulu extends IBeaconStateViewElectra {
|
|
238
|
+
forkName: ForkPostFulu;
|
|
239
|
+
proposerLookahead: fulu.ProposerLookahead;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Gloas+ state fields — use isStatePostGloas() guard */
|
|
243
|
+
export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
|
|
244
|
+
forkName: ForkPostGloas;
|
|
245
|
+
/** Removed from BeaconState in gloas. Use `latestBlockHash` instead. */
|
|
246
|
+
latestExecutionPayloadHeader: never;
|
|
247
|
+
/** Removed from BeaconState in gloas. */
|
|
248
|
+
payloadBlockNumber: never;
|
|
249
|
+
latestBlockHash: Bytes32;
|
|
250
|
+
executionPayloadAvailability: BitArray;
|
|
251
|
+
latestExecutionPayloadBid: ExecutionPayloadBid;
|
|
252
|
+
payloadExpectedWithdrawals: capella.Withdrawal[];
|
|
253
|
+
getBuilder(index: BuilderIndex): gloas.Builder;
|
|
254
|
+
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
|
|
255
|
+
getEpochPTCs(epoch: Epoch): Uint32Array[];
|
|
256
|
+
getIndexInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number;
|
|
257
|
+
/**
|
|
258
|
+
* Clone the state and apply parent execution payload effects.
|
|
259
|
+
* Used during block production and prepareNextSlot so that withdrawals and
|
|
260
|
+
* operation selection (e.g. voluntary exits) see the same post-apply state that the block
|
|
261
|
+
* processor will see at import.
|
|
262
|
+
*/
|
|
263
|
+
withParentPayloadApplied(executionRequests: electra.ExecutionRequests): IBeaconStateViewGloas;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Type constraint for the concrete BeaconStateView class.
|
|
268
|
+
* Requires all fields from the latest fork interface (IBeaconStateViewGloas) but keeps
|
|
269
|
+
* forkName as ForkName since the class wraps any fork's state.
|
|
270
|
+
* Sub-interfaces retain their narrowed forkName discriminants for caller-side type guards.
|
|
271
|
+
*/
|
|
272
|
+
export type IBeaconStateViewLatestFork = Omit<
|
|
273
|
+
IBeaconStateViewGloas,
|
|
274
|
+
"forkName" | "latestExecutionPayloadHeader" | "payloadBlockNumber"
|
|
275
|
+
> & {
|
|
276
|
+
forkName: ForkName;
|
|
277
|
+
latestExecutionPayloadHeader: ExecutionPayloadHeader;
|
|
278
|
+
payloadBlockNumber: number;
|
|
279
|
+
};
|
|
280
|
+
export function isStatePostAltair(state: IBeaconStateView): state is IBeaconStateViewAltair {
|
|
281
|
+
return isForkPostAltair(state.forkName);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function isStatePostBellatrix(state: IBeaconStateView): state is IBeaconStateViewBellatrix {
|
|
285
|
+
return isForkPostBellatrix(state.forkName);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function isStatePostCapella(state: IBeaconStateView): state is IBeaconStateViewCapella {
|
|
289
|
+
return isForkPostCapella(state.forkName);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function isStatePostDeneb(state: IBeaconStateView): state is IBeaconStateViewDeneb {
|
|
293
|
+
return isForkPostDeneb(state.forkName);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function isStatePostElectra(state: IBeaconStateView): state is IBeaconStateViewElectra {
|
|
297
|
+
return isForkPostElectra(state.forkName);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function isStatePostFulu(state: IBeaconStateView): state is IBeaconStateViewFulu {
|
|
301
|
+
return isForkPostFulu(state.forkName);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function isStatePostGloas(state: IBeaconStateView): state is IBeaconStateViewGloas {
|
|
305
|
+
return isForkPostGloas(state.forkName);
|
|
222
306
|
}
|
package/src/util/attestation.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
|
-
import {
|
|
1
|
+
import {ForkSeq, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
|
+
import {
|
|
3
|
+
AttesterSlashing,
|
|
4
|
+
IndexedAttestation,
|
|
5
|
+
IndexedAttestationBigint,
|
|
6
|
+
Slot,
|
|
7
|
+
ValidatorIndex,
|
|
8
|
+
phase0,
|
|
9
|
+
ssz,
|
|
10
|
+
} from "@lodestar/types";
|
|
3
11
|
|
|
4
12
|
/**
|
|
5
13
|
* Check if [[data1]] and [[data2]] are slashable according to Casper FFG rules.
|
|
@@ -22,15 +30,36 @@ export function isValidAttestationSlot(attestationSlot: Slot, currentSlot: Slot)
|
|
|
22
30
|
);
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Compute the intersection of two sorted validator index lists.
|
|
35
|
+
* Both inputs must be sorted in ascending order (per spec).
|
|
36
|
+
*/
|
|
37
|
+
export function getIntersectingIndices(indices1: ValidatorIndex[], indices2: ValidatorIndex[]): ValidatorIndex[] {
|
|
26
38
|
const indices: ValidatorIndex[] = [];
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (attSet1.has(index)) {
|
|
39
|
+
const alreadyPresent = new Set(indices1);
|
|
40
|
+
for (let i = 0, len = indices2.length; i < len; i++) {
|
|
41
|
+
const index = indices2[i];
|
|
42
|
+
if (alreadyPresent.has(index)) {
|
|
32
43
|
indices.push(index);
|
|
33
44
|
}
|
|
34
45
|
}
|
|
35
46
|
return indices;
|
|
36
47
|
}
|
|
48
|
+
|
|
49
|
+
export function getAttesterSlashableIndices(attesterSlashing: AttesterSlashing): ValidatorIndex[] {
|
|
50
|
+
return getIntersectingIndices(
|
|
51
|
+
attesterSlashing.attestation1.attestingIndices,
|
|
52
|
+
attesterSlashing.attestation2.attestingIndices
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Convert IndexedAttestation to IndexedAttestationBigint via SSZ roundtrip.
|
|
58
|
+
* Both types share the same binary layout — only the JS numeric representation differs.
|
|
59
|
+
*/
|
|
60
|
+
export function toIndexedAttestationBigint(att: IndexedAttestation, fork: ForkSeq): IndexedAttestationBigint {
|
|
61
|
+
const sszType = fork >= ForkSeq.electra ? ssz.electra.IndexedAttestation : ssz.phase0.IndexedAttestation;
|
|
62
|
+
const sszTypeBigint =
|
|
63
|
+
fork >= ForkSeq.electra ? ssz.electra.IndexedAttestationBigint : ssz.phase0.IndexedAttestationBigint;
|
|
64
|
+
return sszTypeBigint.deserialize(sszType.serialize(att));
|
|
65
|
+
}
|
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {
|
|
2
|
+
import {ZERO_HASH} from "@lodestar/params";
|
|
3
3
|
import {phase0, ssz} from "@lodestar/types";
|
|
4
4
|
import {BeaconStateAllForks} from "../types.js";
|
|
5
|
-
import {blockToHeader} from "./blockRoot.js";
|
|
6
5
|
import {computeCheckpointEpochAtStateSlot} from "./epoch.js";
|
|
7
6
|
|
|
8
7
|
export function computeAnchorCheckpoint(
|
|
9
|
-
|
|
8
|
+
_config: ChainForkConfig,
|
|
10
9
|
anchorState: BeaconStateAllForks
|
|
11
10
|
): {checkpoint: phase0.Checkpoint; blockHeader: phase0.BeaconBlockHeader} {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (anchorState.latestBlockHeader.slot === GENESIS_SLOT) {
|
|
17
|
-
const block = blockTypes.BeaconBlock.defaultValue();
|
|
18
|
-
block.stateRoot = anchorState.hashTreeRoot();
|
|
19
|
-
blockHeader = blockToHeader(config, block);
|
|
20
|
-
root = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader);
|
|
21
|
-
} else {
|
|
22
|
-
blockHeader = ssz.phase0.BeaconBlockHeader.clone(anchorState.latestBlockHeader);
|
|
23
|
-
if (ssz.Root.equals(blockHeader.stateRoot, ZERO_HASH)) {
|
|
24
|
-
blockHeader.stateRoot = anchorState.hashTreeRoot();
|
|
25
|
-
}
|
|
26
|
-
root = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader);
|
|
11
|
+
const blockHeader = ssz.phase0.BeaconBlockHeader.clone(anchorState.latestBlockHeader);
|
|
12
|
+
if (ssz.Root.equals(blockHeader.stateRoot, ZERO_HASH)) {
|
|
13
|
+
blockHeader.stateRoot = anchorState.hashTreeRoot();
|
|
27
14
|
}
|
|
28
15
|
|
|
29
16
|
return {
|
|
30
17
|
checkpoint: {
|
|
31
|
-
root,
|
|
18
|
+
root: ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader),
|
|
32
19
|
// the checkpoint epoch = computeEpochAtSlot(anchorState.slot) + 1 if slot is not at epoch boundary
|
|
33
20
|
// this is similar to a process_slots() call
|
|
34
21
|
epoch: computeCheckpointEpochAtStateSlot(anchorState.slot),
|
package/src/util/execution.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
BeaconStateBellatrix,
|
|
19
19
|
BeaconStateCapella,
|
|
20
20
|
BeaconStateExecutions,
|
|
21
|
+
BeaconStateGloas,
|
|
21
22
|
CachedBeaconStateAllForks,
|
|
22
23
|
CachedBeaconStateExecutions,
|
|
23
24
|
} from "../types.js";
|
|
@@ -46,7 +47,11 @@ export function isExecutionEnabled(state: BeaconStateExecutions, block: BeaconBl
|
|
|
46
47
|
* Merge is complete when the state includes execution layer data:
|
|
47
48
|
* state.latestExecutionPayloadHeader NOT EMPTY or state is post-capella
|
|
48
49
|
*/
|
|
49
|
-
export function isMergeTransitionComplete(state: BeaconStateExecutions): boolean {
|
|
50
|
+
export function isMergeTransitionComplete(state: BeaconStateExecutions | BeaconStateGloas): boolean {
|
|
51
|
+
if (isGloasStateType(state)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
if (isCapellaStateType(state)) {
|
|
51
56
|
// All networks have completed the merge transition before capella
|
|
52
57
|
return true;
|
|
@@ -71,6 +76,11 @@ export function isCapellaStateType(state: BeaconStateAllForks): state is BeaconS
|
|
|
71
76
|
);
|
|
72
77
|
}
|
|
73
78
|
|
|
79
|
+
/** Type guard for gloas.BeaconState */
|
|
80
|
+
export function isGloasStateType(state: BeaconStateAllForks): state is BeaconStateGloas {
|
|
81
|
+
return (state as BeaconStateGloas).latestBlockHash !== undefined;
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
/** Type guard for bellatrix.CachedBeaconState */
|
|
75
85
|
export function isExecutionCachedStateType(state: CachedBeaconStateAllForks): state is CachedBeaconStateExecutions {
|
|
76
86
|
return (state as CachedBeaconStateExecutions).latestExecutionPayloadHeader !== undefined;
|
package/src/util/gloas.ts
CHANGED
|
@@ -6,15 +6,20 @@ import {
|
|
|
6
6
|
EFFECTIVE_BALANCE_INCREMENT,
|
|
7
7
|
FAR_FUTURE_EPOCH,
|
|
8
8
|
MIN_DEPOSIT_AMOUNT,
|
|
9
|
+
MIN_SEED_LOOKAHEAD,
|
|
10
|
+
PTC_SIZE,
|
|
9
11
|
SLOTS_PER_EPOCH,
|
|
10
12
|
} from "@lodestar/params";
|
|
11
13
|
import {BuilderIndex, Epoch, ValidatorIndex, gloas} from "@lodestar/types";
|
|
12
14
|
import {AttestationData} from "@lodestar/types/phase0";
|
|
13
15
|
import {byteArrayEquals} from "@lodestar/utils";
|
|
14
|
-
import {CachedBeaconStateGloas} from "../types.js";
|
|
16
|
+
import {CachedBeaconStateFulu, CachedBeaconStateGloas} from "../types.js";
|
|
15
17
|
import {getBlockRootAtSlot} from "./blockRoot.js";
|
|
16
18
|
import {computeEpochAtSlot} from "./epoch.js";
|
|
19
|
+
import {computeEpochShuffling} from "./epochShuffling.js";
|
|
17
20
|
import {RootCache} from "./rootCache.js";
|
|
21
|
+
import {computePayloadTimelinessCommitteesForEpoch} from "./seed.js";
|
|
22
|
+
import {getActiveValidatorIndices} from "./validator.js";
|
|
18
23
|
|
|
19
24
|
export function isBuilderWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean {
|
|
20
25
|
return withdrawalCredentials[0] === BUILDER_WITHDRAWAL_PREFIX;
|
|
@@ -167,6 +172,44 @@ export function isAttestationSameSlotRootCache(rootCache: RootCache, data: Attes
|
|
|
167
172
|
return isMatchingBlockRoot && isCurrentBlockRoot;
|
|
168
173
|
}
|
|
169
174
|
|
|
170
|
-
export function
|
|
171
|
-
|
|
175
|
+
export function initializePtcWindow(state: CachedBeaconStateFulu): Uint32Array[] {
|
|
176
|
+
const ptcWindow: Uint32Array[] = Array.from({length: SLOTS_PER_EPOCH}, () => new Uint32Array(PTC_SIZE));
|
|
177
|
+
const currentEpoch = state.epochCtx.epoch;
|
|
178
|
+
|
|
179
|
+
for (let epochOffset = 0; epochOffset <= MIN_SEED_LOOKAHEAD; epochOffset++) {
|
|
180
|
+
const epoch = currentEpoch + epochOffset;
|
|
181
|
+
const shuffling =
|
|
182
|
+
state.epochCtx.getShufflingAtEpochOrNull(epoch) ??
|
|
183
|
+
computeEpochShuffling(state, getActiveValidatorIndices(state, epoch), epoch);
|
|
184
|
+
|
|
185
|
+
ptcWindow.push(
|
|
186
|
+
...computePayloadTimelinessCommitteesForEpoch(
|
|
187
|
+
state,
|
|
188
|
+
epoch,
|
|
189
|
+
shuffling.committees,
|
|
190
|
+
state.epochCtx.effectiveBalanceIncrements
|
|
191
|
+
)
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return ptcWindow;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function getPtcWindowEpochCacheData(state: CachedBeaconStateGloas): {
|
|
199
|
+
previousPayloadTimelinessCommittees: Uint32Array[];
|
|
200
|
+
payloadTimelinessCommittees: Uint32Array[];
|
|
201
|
+
nextPayloadTimelinessCommittees: Uint32Array[];
|
|
202
|
+
} {
|
|
203
|
+
const toUint32Arrays = (views: ReturnType<typeof state.ptcWindow.getReadonlyByRange>) =>
|
|
204
|
+
views.map((v) => Uint32Array.from(v.getAll()));
|
|
205
|
+
|
|
206
|
+
const previousPtcWindow = state.ptcWindow.getReadonlyByRange(0, SLOTS_PER_EPOCH);
|
|
207
|
+
const currentPtcWindow = state.ptcWindow.getReadonlyByRange(SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
|
|
208
|
+
const nextPtcWindow = state.ptcWindow.getReadonlyByRange(2 * SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
previousPayloadTimelinessCommittees: toUint32Arrays(previousPtcWindow),
|
|
212
|
+
payloadTimelinessCommittees: toUint32Arrays(currentPtcWindow),
|
|
213
|
+
nextPayloadTimelinessCommittees: toUint32Arrays(nextPtcWindow),
|
|
214
|
+
};
|
|
172
215
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { gloas } from "@lodestar/types";
|
|
2
|
-
import { CachedBeaconStateGloas } from "../types.js";
|
|
3
|
-
export type ProcessExecutionPayloadEnvelopeOpts = {
|
|
4
|
-
verifySignature?: boolean;
|
|
5
|
-
verifyStateRoot?: boolean;
|
|
6
|
-
dontTransferCache?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function processExecutionPayloadEnvelope(state: CachedBeaconStateGloas, signedEnvelope: gloas.SignedExecutionPayloadEnvelope, opts?: ProcessExecutionPayloadEnvelopeOpts): CachedBeaconStateGloas;
|
|
9
|
-
//# sourceMappingURL=processExecutionPayloadEnvelope.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processExecutionPayloadEnvelope.d.ts","sourceRoot":"","sources":["../../src/block/processExecutionPayloadEnvelope.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAM,MAAM,iBAAiB,CAAC;AAI3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,aAAa,CAAC;AAOnD,MAAM,MAAM,mCAAmC,GAAG;IAChD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAKF,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,sBAAsB,EAC7B,cAAc,EAAE,KAAK,CAAC,8BAA8B,EACpD,IAAI,CAAC,EAAE,mCAAmC,GACzC,sBAAsB,CAqDxB"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT } from "@lodestar/params";
|
|
2
|
-
import { ssz } from "@lodestar/types";
|
|
3
|
-
import { byteArrayEquals, toHex, toRootHex } from "@lodestar/utils";
|
|
4
|
-
import { getExecutionPayloadEnvelopeSignatureSet } from "../signatureSets/executionPayloadEnvelope.js";
|
|
5
|
-
import { BeaconStateView } from "../stateView/beaconStateView.js";
|
|
6
|
-
import { computeTimeAtSlot } from "../util/index.js";
|
|
7
|
-
import { verifySignatureSet } from "../util/signatureSets.js";
|
|
8
|
-
import { processConsolidationRequest } from "./processConsolidationRequest.js";
|
|
9
|
-
import { processDepositRequest } from "./processDepositRequest.js";
|
|
10
|
-
import { processWithdrawalRequest } from "./processWithdrawalRequest.js";
|
|
11
|
-
// Unlike other block processing functions which mutate state in-place, this function
|
|
12
|
-
// clones the state and returns the post-state, similar to stateTransition().
|
|
13
|
-
// This function does not call execution engine to verify payload. Need to call it from other place.
|
|
14
|
-
export function processExecutionPayloadEnvelope(state, signedEnvelope, opts) {
|
|
15
|
-
const { verifySignature = true, verifyStateRoot = true } = opts ?? {};
|
|
16
|
-
const envelope = signedEnvelope.message;
|
|
17
|
-
const payload = envelope.payload;
|
|
18
|
-
const fork = state.config.getForkSeq(envelope.slot);
|
|
19
|
-
if (verifySignature && !verifyExecutionPayloadEnvelopeSignature(state, signedEnvelope)) {
|
|
20
|
-
throw Error(`Execution payload envelope has invalid signature builderIndex=${envelope.builderIndex}`);
|
|
21
|
-
}
|
|
22
|
-
// .clone() before mutating state, similar to stateTransition()
|
|
23
|
-
const postState = state.clone(opts?.dontTransferCache);
|
|
24
|
-
validateExecutionPayloadEnvelope(postState, envelope);
|
|
25
|
-
const requests = envelope.executionRequests;
|
|
26
|
-
for (const deposit of requests.deposits) {
|
|
27
|
-
processDepositRequest(fork, postState, deposit);
|
|
28
|
-
}
|
|
29
|
-
for (const withdrawal of requests.withdrawals) {
|
|
30
|
-
processWithdrawalRequest(fork, postState, withdrawal);
|
|
31
|
-
}
|
|
32
|
-
for (const consolidation of requests.consolidations) {
|
|
33
|
-
processConsolidationRequest(postState, consolidation);
|
|
34
|
-
}
|
|
35
|
-
// Queue the builder payment
|
|
36
|
-
const paymentIndex = SLOTS_PER_EPOCH + (postState.slot % SLOTS_PER_EPOCH);
|
|
37
|
-
const payment = postState.builderPendingPayments.get(paymentIndex).clone();
|
|
38
|
-
const amount = payment.withdrawal.amount;
|
|
39
|
-
if (amount > 0) {
|
|
40
|
-
postState.builderPendingWithdrawals.push(payment.withdrawal);
|
|
41
|
-
}
|
|
42
|
-
postState.builderPendingPayments.set(paymentIndex, ssz.gloas.BuilderPendingPayment.defaultViewDU());
|
|
43
|
-
// Cache the execution payload hash
|
|
44
|
-
postState.executionPayloadAvailability.set(postState.slot % SLOTS_PER_HISTORICAL_ROOT, true);
|
|
45
|
-
postState.latestBlockHash = payload.blockHash;
|
|
46
|
-
postState.commit();
|
|
47
|
-
if (verifyStateRoot && !byteArrayEquals(envelope.stateRoot, postState.hashTreeRoot())) {
|
|
48
|
-
throw new Error(`Envelope's state root does not match state envelope=${toRootHex(envelope.stateRoot)} state=${toRootHex(postState.hashTreeRoot())}`);
|
|
49
|
-
}
|
|
50
|
-
return postState;
|
|
51
|
-
}
|
|
52
|
-
function validateExecutionPayloadEnvelope(state, envelope) {
|
|
53
|
-
const payload = envelope.payload;
|
|
54
|
-
// Cache latest block header state root
|
|
55
|
-
if (byteArrayEquals(state.latestBlockHeader.stateRoot, ssz.Root.defaultValue())) {
|
|
56
|
-
const previousStateRoot = state.hashTreeRoot();
|
|
57
|
-
state.latestBlockHeader.stateRoot = previousStateRoot;
|
|
58
|
-
}
|
|
59
|
-
// Verify consistency with the beacon block
|
|
60
|
-
if (!byteArrayEquals(envelope.beaconBlockRoot, state.latestBlockHeader.hashTreeRoot())) {
|
|
61
|
-
throw new Error(`Envelope's block is not the latest block header envelope=${toRootHex(envelope.beaconBlockRoot)} latestBlockHeader=${toRootHex(state.latestBlockHeader.hashTreeRoot())}`);
|
|
62
|
-
}
|
|
63
|
-
if (envelope.slot !== state.slot) {
|
|
64
|
-
throw new Error(`Slot mismatch between envelope and state envelope=${envelope.slot} state=${state.slot}`);
|
|
65
|
-
}
|
|
66
|
-
// Verify consistency with the committed bid
|
|
67
|
-
const committedBid = state.latestExecutionPayloadBid;
|
|
68
|
-
if (envelope.builderIndex !== committedBid.builderIndex) {
|
|
69
|
-
throw new Error(`Builder index mismatch between envelope and committed bid envelope=${envelope.builderIndex} committedBid=${committedBid.builderIndex}`);
|
|
70
|
-
}
|
|
71
|
-
if (!byteArrayEquals(committedBid.prevRandao, payload.prevRandao)) {
|
|
72
|
-
throw new Error(`Prev randao mismatch between committed bid and payload committedBid=${toHex(committedBid.prevRandao)} payload=${toHex(payload.prevRandao)}`);
|
|
73
|
-
}
|
|
74
|
-
// Verify consistency with expected withdrawals
|
|
75
|
-
const payloadWithdrawalsRoot = ssz.capella.Withdrawals.hashTreeRoot(payload.withdrawals);
|
|
76
|
-
const expectedWithdrawalsRoot = state.payloadExpectedWithdrawals.hashTreeRoot();
|
|
77
|
-
if (!byteArrayEquals(payloadWithdrawalsRoot, expectedWithdrawalsRoot)) {
|
|
78
|
-
throw new Error(`Withdrawals mismatch between payload and expected withdrawals payload=${toRootHex(payloadWithdrawalsRoot)} expected=${toRootHex(expectedWithdrawalsRoot)}`);
|
|
79
|
-
}
|
|
80
|
-
// Verify the gas_limit
|
|
81
|
-
if (Number(committedBid.gasLimit) !== payload.gasLimit) {
|
|
82
|
-
throw new Error(`Gas limit mismatch between envelope's payload and committed bid envelope=${payload.gasLimit} committedBid=${Number(committedBid.gasLimit)}`);
|
|
83
|
-
}
|
|
84
|
-
// Verify the block hash
|
|
85
|
-
if (!byteArrayEquals(committedBid.blockHash, payload.blockHash)) {
|
|
86
|
-
throw new Error(`Block hash mismatch between envelope's payload and committed bid envelope=${toRootHex(payload.blockHash)} committedBid=${toRootHex(committedBid.blockHash)}`);
|
|
87
|
-
}
|
|
88
|
-
// Verify consistency of the parent hash with respect to the previous execution payload
|
|
89
|
-
if (!byteArrayEquals(payload.parentHash, state.latestBlockHash)) {
|
|
90
|
-
throw new Error(`Parent hash mismatch between envelope's payload and state envelope=${toRootHex(payload.parentHash)} state=${toRootHex(state.latestBlockHash)}`);
|
|
91
|
-
}
|
|
92
|
-
// Verify timestamp
|
|
93
|
-
if (payload.timestamp !== computeTimeAtSlot(state.config, state.slot, state.genesisTime)) {
|
|
94
|
-
throw new Error(`Timestamp mismatch between envelope's payload and state envelope=${payload.timestamp} state=${computeTimeAtSlot(state.config, state.slot, state.genesisTime)}`);
|
|
95
|
-
}
|
|
96
|
-
// Skipped: Verify the execution payload is valid
|
|
97
|
-
}
|
|
98
|
-
function verifyExecutionPayloadEnvelopeSignature(state, signedEnvelope) {
|
|
99
|
-
const signatureSet = getExecutionPayloadEnvelopeSignatureSet(state.config, state.epochCtx.pubkeyCache, new BeaconStateView(state), signedEnvelope, state.latestBlockHeader.proposerIndex);
|
|
100
|
-
return verifySignatureSet(signatureSet);
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=processExecutionPayloadEnvelope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processExecutionPayloadEnvelope.js","sourceRoot":"","sources":["../../src/block/processExecutionPayloadEnvelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,yBAAyB,EAAC,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAQ,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,eAAe,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAC,uCAAuC,EAAC,MAAM,8CAA8C,CAAC;AACrG,OAAO,EAAC,eAAe,EAA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