@lodestar/state-transition 1.48.0-dev.0dbea0de1b → 1.48.0-dev.262a9c1d16
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.map +1 -1
- package/lib/block/index.js +3 -2
- package/lib/block/index.js.map +1 -1
- package/lib/block/processExecutionPayloadBid.d.ts +2 -2
- package/lib/block/processExecutionPayloadBid.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadBid.js +3 -2
- package/lib/block/processExecutionPayloadBid.js.map +1 -1
- package/lib/block/processOperations.d.ts.map +1 -1
- package/lib/block/processOperations.js +2 -18
- package/lib/block/processOperations.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
- package/lib/block/processParentExecutionPayload.js +2 -16
- package/lib/block/processParentExecutionPayload.js.map +1 -1
- package/lib/block/processPayloadAttestation.d.ts +1 -1
- package/lib/block/processPayloadAttestation.d.ts.map +1 -1
- package/lib/block/processPayloadAttestation.js +2 -2
- package/lib/block/processPayloadAttestation.js.map +1 -1
- package/lib/epoch/processInactivityUpdates.d.ts.map +1 -1
- package/lib/epoch/processInactivityUpdates.js +7 -1
- package/lib/epoch/processInactivityUpdates.js.map +1 -1
- package/lib/epoch/processPtcWindow.js +1 -1
- package/lib/epoch/processPtcWindow.js.map +1 -1
- package/lib/lightClient/spec/index.d.ts +1 -1
- package/lib/lightClient/spec/index.d.ts.map +1 -1
- package/lib/lightClient/spec/index.js +1 -1
- package/lib/lightClient/spec/index.js.map +1 -1
- package/lib/lightClient/spec/utils.d.ts +2 -2
- package/lib/lightClient/spec/utils.d.ts.map +1 -1
- package/lib/lightClient/spec/utils.js +2 -2
- package/lib/lightClient/spec/utils.js.map +1 -1
- package/lib/rewards/blockRewards.d.ts.map +1 -1
- package/lib/rewards/blockRewards.js +1 -3
- package/lib/rewards/blockRewards.js.map +1 -1
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +8 -0
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/slot/upgradeStateToGloas.js +1 -1
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +6 -1
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +12 -0
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +3 -1
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +4 -1
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +10 -0
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/package.json +8 -8
- package/src/block/index.ts +5 -2
- package/src/block/processExecutionPayloadBid.ts +6 -5
- package/src/block/processOperations.ts +2 -29
- package/src/block/processParentExecutionPayload.ts +2 -27
- package/src/block/processPayloadAttestation.ts +3 -2
- package/src/epoch/processInactivityUpdates.ts +8 -1
- package/src/epoch/processPtcWindow.ts +1 -1
- package/src/lightClient/spec/index.ts +1 -1
- package/src/lightClient/spec/utils.ts +2 -2
- package/src/rewards/blockRewards.ts +1 -3
- package/src/signatureSets/index.ts +17 -3
- package/src/slot/upgradeStateToGloas.ts +1 -1
- package/src/stateView/beaconStateView.ts +16 -0
- package/src/stateView/interface.ts +3 -0
- package/src/stateView/nativeBeaconStateView.ts +13 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
PAYLOAD_BUILDER_VERSION,
|
|
6
6
|
SLOTS_PER_EPOCH,
|
|
7
7
|
} from "@lodestar/params";
|
|
8
|
-
import {
|
|
8
|
+
import {gloas, heze, ssz} from "@lodestar/types";
|
|
9
9
|
import {byteArrayEquals, toHex, toRootHex} from "@lodestar/utils";
|
|
10
10
|
import {G2_POINT_AT_INFINITY} from "../constants/constants.js";
|
|
11
11
|
import {getExecutionPayloadBidSigningRoot} from "../signatureSets/executionPayloadBid.js";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
export function processExecutionPayloadBid(
|
|
23
23
|
state: CachedBeaconStateGloas | CachedBeaconStateHeze,
|
|
24
24
|
signedBid: gloas.SignedExecutionPayloadBid
|
|
25
|
-
):
|
|
25
|
+
): void {
|
|
26
26
|
const bid = signedBid.message;
|
|
27
27
|
const {builderIndex, value: amount} = bid;
|
|
28
28
|
|
|
@@ -76,6 +76,10 @@ export function processExecutionPayloadBid(
|
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
if (byteArrayEquals(bid.blockHash, bid.parentBlockHash)) {
|
|
80
|
+
throw Error(`Block hash ${toRootHex(bid.blockHash)} of bid must not equal its parent block hash`);
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
const parentBlockRoot = getBlockRootAtSlot(state, state.slot - 1);
|
|
80
84
|
if (!byteArrayEquals(bid.parentBlockRoot, parentBlockRoot)) {
|
|
81
85
|
throw Error(
|
|
@@ -110,14 +114,11 @@ export function processExecutionPayloadBid(
|
|
|
110
114
|
state.builderPendingPayments.set(SLOTS_PER_EPOCH + (bid.slot % SLOTS_PER_EPOCH), pendingPaymentView);
|
|
111
115
|
}
|
|
112
116
|
|
|
113
|
-
const parentSlot = state.latestExecutionPayloadBid.slot;
|
|
114
117
|
if (state.config.getForkSeq(state.slot) >= ForkSeq.heze) {
|
|
115
118
|
state.latestExecutionPayloadBid = ssz.heze.ExecutionPayloadBid.toViewDU(bid as heze.ExecutionPayloadBid);
|
|
116
119
|
} else {
|
|
117
120
|
state.latestExecutionPayloadBid = ssz.gloas.ExecutionPayloadBid.toViewDU(bid);
|
|
118
121
|
}
|
|
119
|
-
|
|
120
|
-
return parentSlot;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
function verifyExecutionPayloadBidSignature(
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ForkSeq,
|
|
3
|
-
MAX_ATTESTATIONS_ELECTRA,
|
|
4
|
-
MAX_ATTESTER_SLASHINGS_ELECTRA,
|
|
5
|
-
MAX_BLS_TO_EXECUTION_CHANGES,
|
|
6
|
-
MAX_PAYLOAD_ATTESTATIONS,
|
|
7
|
-
MAX_PROPOSER_SLASHINGS,
|
|
8
|
-
MAX_VOLUNTARY_EXITS,
|
|
9
|
-
} from "@lodestar/params";
|
|
1
|
+
import {ForkSeq} from "@lodestar/params";
|
|
10
2
|
import {BeaconBlockBody, Slot, capella, electra, gloas} from "@lodestar/types";
|
|
11
3
|
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
12
4
|
import {
|
|
@@ -48,10 +40,6 @@ export function processOperations(
|
|
|
48
40
|
opts: ProcessBlockOpts = {verifySignatures: true},
|
|
49
41
|
metrics?: BeaconStateTransitionMetrics | null
|
|
50
42
|
): void {
|
|
51
|
-
if (fork >= ForkSeq.gloas) {
|
|
52
|
-
assertGloasOperationLimits(body as gloas.BeaconBlockBody);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
43
|
// verify that outstanding deposits are processed up to the maximum number of deposits.
|
|
56
44
|
// From Fulu the eth1 bridge deposit mechanism was removed, so blocks must not contain any deposits.
|
|
57
45
|
const maxDeposits = fork >= ForkSeq.fulu ? 0 : getEth1DepositCount(state);
|
|
@@ -103,22 +91,7 @@ export function processOperations(
|
|
|
103
91
|
|
|
104
92
|
if (fork >= ForkSeq.gloas) {
|
|
105
93
|
for (const payloadAttestation of (body as gloas.BeaconBlockBody).payloadAttestations) {
|
|
106
|
-
processPayloadAttestation(state as CachedBeaconStateGloas, payloadAttestation);
|
|
94
|
+
processPayloadAttestation(state as CachedBeaconStateGloas, payloadAttestation, opts.verifySignatures);
|
|
107
95
|
}
|
|
108
96
|
}
|
|
109
97
|
}
|
|
110
|
-
|
|
111
|
-
function assertGloasOperationLimits(body: gloas.BeaconBlockBody): void {
|
|
112
|
-
assertMaxLength("proposerSlashings", body.proposerSlashings.length, MAX_PROPOSER_SLASHINGS);
|
|
113
|
-
assertMaxLength("attesterSlashings", body.attesterSlashings.length, MAX_ATTESTER_SLASHINGS_ELECTRA);
|
|
114
|
-
assertMaxLength("attestations", body.attestations.length, MAX_ATTESTATIONS_ELECTRA);
|
|
115
|
-
assertMaxLength("voluntaryExits", body.voluntaryExits.length, MAX_VOLUNTARY_EXITS);
|
|
116
|
-
assertMaxLength("blsToExecutionChanges", body.blsToExecutionChanges.length, MAX_BLS_TO_EXECUTION_CHANGES);
|
|
117
|
-
assertMaxLength("payloadAttestations", body.payloadAttestations.length, MAX_PAYLOAD_ATTESTATIONS);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function assertMaxLength(name: string, length: number, limit: number): void {
|
|
121
|
-
if (length > limit) {
|
|
122
|
-
throw new Error(`Block contains too many ${name}: count=${length} limit=${limit}`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ForkPostGloas,
|
|
3
|
-
MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD,
|
|
4
|
-
MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD,
|
|
5
|
-
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD,
|
|
6
|
-
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD,
|
|
7
|
-
SLOTS_PER_EPOCH,
|
|
8
|
-
SLOTS_PER_HISTORICAL_ROOT,
|
|
9
|
-
} from "@lodestar/params";
|
|
1
|
+
import {ForkPostGloas, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
|
|
10
2
|
import {BeaconBlock, gloas, ssz} from "@lodestar/types";
|
|
11
3
|
import {byteArrayEquals, toRootHex} from "@lodestar/utils";
|
|
12
4
|
import {CachedBeaconStateGloas} from "../types.js";
|
|
@@ -55,11 +47,9 @@ export function processParentExecutionPayload(state: CachedBeaconStateGloas, blo
|
|
|
55
47
|
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.6/specs/gloas/beacon-chain.md#new-apply_parent_execution_payload
|
|
56
48
|
*/
|
|
57
49
|
export function applyParentExecutionPayload(state: CachedBeaconStateGloas, requests: gloas.ExecutionRequests): void {
|
|
58
|
-
assertExecutionRequestsWithinLimits(requests);
|
|
59
|
-
|
|
60
50
|
const fork = state.config.getForkSeq(state.slot);
|
|
61
51
|
const parentBid = state.latestExecutionPayloadBid;
|
|
62
|
-
const parentSlot =
|
|
52
|
+
const parentSlot = state.latestBlockHeader.slot;
|
|
63
53
|
const parentEpoch = computeEpochAtSlot(parentSlot);
|
|
64
54
|
const currentEpoch = computeEpochAtSlot(state.slot);
|
|
65
55
|
|
|
@@ -126,21 +116,6 @@ function settleBuilderPayment(state: CachedBeaconStateGloas, paymentIndex: numbe
|
|
|
126
116
|
state.builderPendingPayments.set(paymentIndex, ssz.gloas.BuilderPendingPayment.defaultViewDU());
|
|
127
117
|
}
|
|
128
118
|
|
|
129
|
-
function assertExecutionRequestsWithinLimits(requests: gloas.ExecutionRequests): void {
|
|
130
|
-
assertMaxLength("withdrawals", requests.withdrawals.length, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD);
|
|
131
|
-
assertMaxLength("consolidations", requests.consolidations.length, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD);
|
|
132
|
-
// New in GLOAS:EIP8282
|
|
133
|
-
assertMaxLength("builderDeposits", requests.builderDeposits.length, MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD);
|
|
134
|
-
// New in GLOAS:EIP8282
|
|
135
|
-
assertMaxLength("builderExits", requests.builderExits.length, MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function assertMaxLength(name: string, length: number, limit: number): void {
|
|
139
|
-
if (length > limit) {
|
|
140
|
-
throw new Error(`Too many parent execution request ${name} count=${length} limit=${limit}`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
119
|
function assertEmptyExecutionRequests(requests: gloas.ExecutionRequests): void {
|
|
145
120
|
if (
|
|
146
121
|
requests.deposits.length !== 0 ||
|
|
@@ -5,7 +5,8 @@ import {isValidIndexedPayloadAttestation} from "./isValidIndexedPayloadAttestati
|
|
|
5
5
|
|
|
6
6
|
export function processPayloadAttestation(
|
|
7
7
|
state: CachedBeaconStateGloas,
|
|
8
|
-
payloadAttestation: gloas.PayloadAttestation
|
|
8
|
+
payloadAttestation: gloas.PayloadAttestation,
|
|
9
|
+
verifySignature = true
|
|
9
10
|
): void {
|
|
10
11
|
const data = payloadAttestation.data;
|
|
11
12
|
|
|
@@ -19,7 +20,7 @@ export function processPayloadAttestation(
|
|
|
19
20
|
|
|
20
21
|
const indexedPayloadAttestation = state.epochCtx.getIndexedPayloadAttestation(data.slot, payloadAttestation);
|
|
21
22
|
|
|
22
|
-
if (!isValidIndexedPayloadAttestation(state, indexedPayloadAttestation,
|
|
23
|
+
if (!isValidIndexedPayloadAttestation(state, indexedPayloadAttestation, verifySignature)) {
|
|
23
24
|
throw Error("Invalid payload attestation");
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -37,6 +37,7 @@ export function processInactivityUpdates(state: CachedBeaconStateAltair, cache:
|
|
|
37
37
|
|
|
38
38
|
inactivityScoresArr.length = state.validators.length;
|
|
39
39
|
inactivityScores.getAll(inactivityScoresArr);
|
|
40
|
+
let shouldSetInactivityScores = false;
|
|
40
41
|
|
|
41
42
|
for (let i = 0; i < flags.length; i++) {
|
|
42
43
|
const flag = flags[i];
|
|
@@ -53,8 +54,14 @@ export function processInactivityUpdates(state: CachedBeaconStateAltair, cache:
|
|
|
53
54
|
inactivityScore -= Math.min(INACTIVITY_SCORE_RECOVERY_RATE, inactivityScore);
|
|
54
55
|
}
|
|
55
56
|
if (inactivityScore !== prevInactivityScore) {
|
|
56
|
-
|
|
57
|
+
inactivityScoresArr[i] = inactivityScore;
|
|
58
|
+
shouldSetInactivityScores = true;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
}
|
|
62
|
+
|
|
63
|
+
if (shouldSetInactivityScores) {
|
|
64
|
+
// Rebuilding the full view is slightly slower than individual sets only when very few scores change.
|
|
65
|
+
state.inactivityScores = state.type.fields.inactivityScores.toViewDU(inactivityScoresArr);
|
|
66
|
+
}
|
|
60
67
|
}
|
|
@@ -30,7 +30,7 @@ export function processPtcWindow(state: CachedBeaconStateGloas, cache: EpochTran
|
|
|
30
30
|
|
|
31
31
|
// Write shifted window to state: current(N) + next(N+1) + newlyComputed(N+2)
|
|
32
32
|
// From the perspective of upcoming epoch N+1, this is previous + current + next
|
|
33
|
-
state.ptcWindow = ssz.gloas.
|
|
33
|
+
state.ptcWindow = ssz.gloas.PayloadTimelinessCommitteeWindow.toViewDU([
|
|
34
34
|
...state.epochCtx.payloadTimelinessCommittees,
|
|
35
35
|
...state.epochCtx.nextPayloadTimelinessCommittees,
|
|
36
36
|
...newNextPayloadTimelinessCommittees,
|
|
@@ -207,9 +207,9 @@ function getGindexIndex(gindex: number): number {
|
|
|
207
207
|
* Gloas headers removed `execution` so Pre-Gloas headers upgraded to the Gloas format
|
|
208
208
|
* require reconstruction of the original execution payload header root.
|
|
209
209
|
*
|
|
210
|
-
* Spec: https://github.com/ethereum/consensus-specs/blob/
|
|
210
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/gloas/light-client/sync-protocol.md#modified-get_lc_execution_root
|
|
211
211
|
*/
|
|
212
|
-
export function
|
|
212
|
+
export function getLightClientExecutionRoot(config: ChainForkConfig, header: LightClientHeader): Uint8Array {
|
|
213
213
|
const epoch = computeEpochAtSlot(header.beacon.slot);
|
|
214
214
|
|
|
215
215
|
if (!isGloasLightClientHeader(header)) {
|
|
@@ -42,9 +42,7 @@ export async function computeBlockRewards(
|
|
|
42
42
|
let syncAggregateReward = cachedSyncAggregateReward;
|
|
43
43
|
|
|
44
44
|
if (blockAttestationReward === 0) {
|
|
45
|
-
const parentSlot = isForkPostGloas(fork)
|
|
46
|
-
? (preState as CachedBeaconStateGloas).latestExecutionPayloadBid.slot
|
|
47
|
-
: null;
|
|
45
|
+
const parentSlot = isForkPostGloas(fork) ? (preState as CachedBeaconStateGloas).latestBlockHeader.slot : null;
|
|
48
46
|
blockAttestationReward =
|
|
49
47
|
fork === ForkName.phase0
|
|
50
48
|
? computeBlockAttestationRewardPhase0(block as phase0.BeaconBlock, preState as CachedBeaconStatePhase0)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {ForkSeq} from "@lodestar/params";
|
|
3
|
-
import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
|
|
3
|
+
import {IndexedAttestation, SignedBeaconBlock, altair, capella, gloas} from "@lodestar/types";
|
|
4
4
|
import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
|
|
5
5
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
6
|
-
import {IBeaconStateView} from "../stateView/interface.js";
|
|
7
|
-
import {ISignatureSet} from "../util/index.js";
|
|
6
|
+
import {IBeaconStateView, IBeaconStateViewGloas} from "../stateView/interface.js";
|
|
7
|
+
import {ISignatureSet, createAggregateSignatureSetFromComponents} from "../util/index.js";
|
|
8
8
|
import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
|
|
9
9
|
import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js";
|
|
10
10
|
import {getAttestationsSignatureSets} from "./indexedAttestation.js";
|
|
11
|
+
import {getPayloadAttestationDataSigningRoot} from "./indexedPayloadAttestation.js";
|
|
11
12
|
import {getBlockProposerSignatureSet} from "./proposer.js";
|
|
12
13
|
import {getProposerSlashingsSignatureSets} from "./proposerSlashings.js";
|
|
13
14
|
import {getRandaoRevealSignatureSet} from "./randao.js";
|
|
@@ -79,5 +80,18 @@ export function getBlockSignatureSets(
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
if (fork >= ForkSeq.gloas) {
|
|
84
|
+
for (const payloadAttestation of (signedBlock as gloas.SignedBeaconBlock).message.body.payloadAttestations) {
|
|
85
|
+
const ptc = (state as IBeaconStateViewGloas).getPayloadTimelinessCommittee(payloadAttestation.data.slot);
|
|
86
|
+
signatureSets.push(
|
|
87
|
+
createAggregateSignatureSetFromComponents(
|
|
88
|
+
payloadAttestation.aggregationBits.intersectValues(ptc),
|
|
89
|
+
getPayloadAttestationDataSigningRoot(config, payloadAttestation.data),
|
|
90
|
+
payloadAttestation.signature
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
82
96
|
return signatureSets;
|
|
83
97
|
}
|
|
@@ -110,7 +110,7 @@ export function upgradeStateToGloas(
|
|
|
110
110
|
ssz.gloas.PendingConsolidations
|
|
111
111
|
);
|
|
112
112
|
stateGloasView.proposerLookahead = stateGloasCloned.proposerLookahead;
|
|
113
|
-
stateGloasView.ptcWindow = ssz.gloas.
|
|
113
|
+
stateGloasView.ptcWindow = ssz.gloas.PayloadTimelinessCommitteeWindow.toViewDU(initializePtcWindow(stateFulu));
|
|
114
114
|
|
|
115
115
|
for (let i = 0; i < SLOTS_PER_HISTORICAL_ROOT; i++) {
|
|
116
116
|
stateGloasView.executionPayloadAvailability.set(i, true);
|
|
@@ -116,6 +116,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
116
116
|
return this.config.getForkName(this.cachedState.slot);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
get forkSeq(): ForkSeq {
|
|
120
|
+
return this.config.getForkSeq(this.cachedState.slot);
|
|
121
|
+
}
|
|
122
|
+
|
|
119
123
|
get slot(): number {
|
|
120
124
|
return this.cachedState.slot;
|
|
121
125
|
}
|
|
@@ -452,6 +456,18 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
452
456
|
}
|
|
453
457
|
throw new Error(`PTC committees are not available for epoch=${epoch}`);
|
|
454
458
|
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Return the PTC for a slot in the previous, current or next epoch
|
|
462
|
+
*/
|
|
463
|
+
getPayloadTimelinessCommittee(slot: Slot): Uint32Array {
|
|
464
|
+
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
465
|
+
throw new Error("PTC committees are not supported before Gloas");
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return (this.cachedState as CachedBeaconStateGloas).epochCtx.getPayloadTimelinessCommittee(slot);
|
|
469
|
+
}
|
|
470
|
+
|
|
455
471
|
/**
|
|
456
472
|
* Return all positions of the validator in the PTC committee for the given slot.
|
|
457
473
|
*
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ForkPostFulu,
|
|
11
11
|
ForkPostGloas,
|
|
12
12
|
ForkPostHeze,
|
|
13
|
+
ForkSeq,
|
|
13
14
|
isForkPostAltair,
|
|
14
15
|
isForkPostBellatrix,
|
|
15
16
|
isForkPostCapella,
|
|
@@ -77,6 +78,7 @@ export interface IBeaconStateView {
|
|
|
77
78
|
|
|
78
79
|
// phase0
|
|
79
80
|
forkName: ForkName;
|
|
81
|
+
forkSeq: ForkSeq;
|
|
80
82
|
slot: Slot;
|
|
81
83
|
fork: Fork;
|
|
82
84
|
epoch: Epoch;
|
|
@@ -283,6 +285,7 @@ export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
|
|
|
283
285
|
getBuildersLength(): number;
|
|
284
286
|
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
|
|
285
287
|
getEpochPTCs(epoch: Epoch): Uint32Array[];
|
|
288
|
+
getPayloadTimelinessCommittee(slot: Slot): Uint32Array;
|
|
286
289
|
getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[];
|
|
287
290
|
/**
|
|
288
291
|
* Clone the state and apply parent execution payload effects.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {CompactMultiProof} from "@chainsafe/persistent-merkle-tree";
|
|
2
2
|
import {BitArray, ByteViews} from "@chainsafe/ssz";
|
|
3
|
-
import {ForkName} from "@lodestar/params";
|
|
3
|
+
import {ForkName, ForkSeq} from "@lodestar/params";
|
|
4
4
|
import {
|
|
5
5
|
BeaconBlock,
|
|
6
6
|
BeaconState,
|
|
@@ -66,6 +66,7 @@ import {
|
|
|
66
66
|
export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
67
67
|
// phase0
|
|
68
68
|
private _forkName: ForkName | null = null;
|
|
69
|
+
private _forkSeq: ForkSeq | null = null;
|
|
69
70
|
private _slot: Slot | null = null;
|
|
70
71
|
private _fork: Fork | null = null;
|
|
71
72
|
private _epoch: Epoch | null = null;
|
|
@@ -194,6 +195,13 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
194
195
|
return this._forkName;
|
|
195
196
|
}
|
|
196
197
|
|
|
198
|
+
get forkSeq(): ForkSeq {
|
|
199
|
+
if (this._forkSeq === null) {
|
|
200
|
+
this._forkSeq = this.binding.forkSeq;
|
|
201
|
+
}
|
|
202
|
+
return this._forkSeq;
|
|
203
|
+
}
|
|
204
|
+
|
|
197
205
|
get slot(): Slot {
|
|
198
206
|
if (this._slot === null) {
|
|
199
207
|
this._slot = this.binding.slot;
|
|
@@ -918,6 +926,10 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
918
926
|
return cached;
|
|
919
927
|
}
|
|
920
928
|
|
|
929
|
+
getPayloadTimelinessCommittee(slot: Slot): Uint32Array {
|
|
930
|
+
return this.binding.getPayloadTimelinessCommittee(slot);
|
|
931
|
+
}
|
|
932
|
+
|
|
921
933
|
getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[] {
|
|
922
934
|
return this.binding.getIndicesInPayloadTimelinessCommittee(validatorIndex, slot);
|
|
923
935
|
}
|