@lodestar/state-transition 1.43.0-dev.9fa9f08ef6 → 1.43.0-dev.a140dd987e
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/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 +12 -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/signatureSets/executionPayloadEnvelope.js +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.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.js +1 -1
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +7 -3
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +20 -13
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +11 -3
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.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/gloas.d.ts +7 -1
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +27 -1
- package/lib/util/gloas.js.map +1 -1
- package/package.json +8 -8
- package/src/block/index.ts +12 -4
- 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/signatureSets/executionPayloadEnvelope.ts +1 -1
- package/src/slot/upgradeStateToGloas.ts +5 -1
- package/src/stateTransition.ts +1 -1
- package/src/stateView/beaconStateView.ts +24 -20
- package/src/stateView/interface.ts +13 -6
- package/src/util/computeAnchorCheckpoint.ts +6 -19
- package/src/util/gloas.ts +49 -1
- package/lib/block/processExecutionPayloadEnvelope.d.ts +0 -9
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +0 -1
- package/lib/block/processExecutionPayloadEnvelope.js +0 -106
- package/lib/block/processExecutionPayloadEnvelope.js.map +0 -1
- package/src/block/processExecutionPayloadEnvelope.ts +0 -175
|
@@ -3,7 +3,6 @@ import { BitArray, ByteViews } from "@chainsafe/ssz";
|
|
|
3
3
|
import { ForkName, ForkPostAltair, ForkPostBellatrix, ForkPostCapella, ForkPostDeneb, ForkPostElectra, ForkPostFulu, ForkPostGloas } from "@lodestar/params";
|
|
4
4
|
import { BeaconBlock, BeaconState, BlindedBeaconBlock, BuilderIndex, Bytes32, Epoch, ExecutionPayloadBid, ExecutionPayloadHeader, Root, RootHex, SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, ValidatorIndex, altair, capella, electra, fulu, gloas, phase0, rewards } from "@lodestar/types";
|
|
5
5
|
import { Checkpoint, Fork } from "@lodestar/types/phase0";
|
|
6
|
-
import { ProcessExecutionPayloadEnvelopeOpts } from "../block/processExecutionPayloadEnvelope.js";
|
|
7
6
|
import { VoluntaryExitValidity } from "../block/processVoluntaryExit.js";
|
|
8
7
|
import { EffectiveBalanceIncrements } from "../cache/effectiveBalanceIncrements.js";
|
|
9
8
|
import { EpochTransitionCacheOpts } from "../cache/epochTransitionCache.js";
|
|
@@ -73,7 +72,11 @@ export interface IBeaconStateView {
|
|
|
73
72
|
clonedCountWithTransferCache: number;
|
|
74
73
|
createdWithTransferCache: boolean;
|
|
75
74
|
isStateValidatorsNodesPopulated(): boolean;
|
|
76
|
-
|
|
75
|
+
/** Set `preloadValidatorsAndBalances` only when the whole state will be consumed
|
|
76
|
+
* immediately (e.g. CP reload before block replay). */
|
|
77
|
+
loadOtherState(stateBytes: Uint8Array, seedValidatorsBytes?: Uint8Array, opts?: {
|
|
78
|
+
preloadValidatorsAndBalances?: boolean;
|
|
79
|
+
}): IBeaconStateView;
|
|
77
80
|
toValue(): BeaconState;
|
|
78
81
|
serialize(): Uint8Array;
|
|
79
82
|
serializedSize(): number;
|
|
@@ -164,7 +167,12 @@ export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
|
|
|
164
167
|
getBuilder(index: BuilderIndex): gloas.Builder;
|
|
165
168
|
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
|
|
166
169
|
getIndexInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number;
|
|
167
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Compute expected withdrawals as if the parent was FULL.
|
|
172
|
+
* Clones the state, applies parent payload effects, then computes withdrawals.
|
|
173
|
+
* Used by prepare_execution_payload when building on FULL parent.
|
|
174
|
+
*/
|
|
175
|
+
getExpectedWithdrawalsForFullParent(executionRequests: electra.ExecutionRequests): capella.Withdrawal[];
|
|
168
176
|
}
|
|
169
177
|
/**
|
|
170
178
|
* Type constraint for the concrete BeaconStateView class.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/stateView/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EAQd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,KAAK,EACL,mBAAmB,EACnB,sBAAsB,EACtB,IAAI,EACJ,OAAO,EACP,iBAAiB,EACjB,wBAAwB,EACxB,IAAI,EACJ,cAAc,EACd,MAAM,EACN,OAAO,EACP,OAAO,EACP,IAAI,EACJ,KAAK,EACL,MAAM,EACN,OAAO,EACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/stateView/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EAQd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,WAAW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K,EAAE,gBAAgB,GAAG,KAAK,IAAI,qBAAqB,CAExF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,uBAAuB,CAE5F;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,oBAAoB,CAEtF;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,qBAAqB,CAExF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/stateView/interface.ts"],"names":[],"mappings":"AAEA,OAAO,EASL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/stateView/interface.ts"],"names":[],"mappings":"AAEA,OAAO,EASL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAmQ1B,MAAM,UAAU,iBAAiB,CAAC,KAAuB,EAAmC;IAC1F,OAAO,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAA,CACzC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAuB,EAAsC;IAChG,OAAO,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAA,CAC5C;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAuB,EAAoC;IAC5F,OAAO,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAA,CAC1C;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAuB,EAAkC;IACxF,OAAO,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAA,CACxC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAuB,EAAoC;IAC5F,OAAO,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAA,CAC1C;AAED,MAAM,UAAU,eAAe,CAAC,KAAuB,EAAiC;IACtF,OAAO,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAA,CACvC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAuB,EAAkC;IACxF,OAAO,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAAA,CACxC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChainForkConfig } from "@lodestar/config";
|
|
2
2
|
import { phase0 } from "@lodestar/types";
|
|
3
3
|
import { BeaconStateAllForks } from "../types.js";
|
|
4
|
-
export declare function computeAnchorCheckpoint(
|
|
4
|
+
export declare function computeAnchorCheckpoint(_config: ChainForkConfig, anchorState: BeaconStateAllForks): {
|
|
5
5
|
checkpoint: phase0.Checkpoint;
|
|
6
6
|
blockHeader: phase0.BeaconBlockHeader;
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeAnchorCheckpoint.d.ts","sourceRoot":"","sources":["../../src/util/computeAnchorCheckpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,MAAM,EAAM,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"computeAnchorCheckpoint.d.ts","sourceRoot":"","sources":["../../src/util/computeAnchorCheckpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAC,MAAM,EAAM,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAC;AAGhD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,mBAAmB,GAC/B;IAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC,iBAAiB,CAAA;CAAC,CAexE"}
|
|
@@ -1,27 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZERO_HASH } from "@lodestar/params";
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
|
-
import { blockToHeader } from "./blockRoot.js";
|
|
4
3
|
import { computeCheckpointEpochAtStateSlot } from "./epoch.js";
|
|
5
|
-
export function computeAnchorCheckpoint(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (anchorState.latestBlockHeader.slot === GENESIS_SLOT) {
|
|
10
|
-
const block = blockTypes.BeaconBlock.defaultValue();
|
|
11
|
-
block.stateRoot = anchorState.hashTreeRoot();
|
|
12
|
-
blockHeader = blockToHeader(config, block);
|
|
13
|
-
root = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
blockHeader = ssz.phase0.BeaconBlockHeader.clone(anchorState.latestBlockHeader);
|
|
17
|
-
if (ssz.Root.equals(blockHeader.stateRoot, ZERO_HASH)) {
|
|
18
|
-
blockHeader.stateRoot = anchorState.hashTreeRoot();
|
|
19
|
-
}
|
|
20
|
-
root = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader);
|
|
4
|
+
export function computeAnchorCheckpoint(_config, anchorState) {
|
|
5
|
+
const blockHeader = ssz.phase0.BeaconBlockHeader.clone(anchorState.latestBlockHeader);
|
|
6
|
+
if (ssz.Root.equals(blockHeader.stateRoot, ZERO_HASH)) {
|
|
7
|
+
blockHeader.stateRoot = anchorState.hashTreeRoot();
|
|
21
8
|
}
|
|
22
9
|
return {
|
|
23
10
|
checkpoint: {
|
|
24
|
-
root,
|
|
11
|
+
root: ssz.phase0.BeaconBlockHeader.hashTreeRoot(blockHeader),
|
|
25
12
|
// the checkpoint epoch = computeEpochAtSlot(anchorState.slot) + 1 if slot is not at epoch boundary
|
|
26
13
|
// this is similar to a process_slots() call
|
|
27
14
|
epoch: computeCheckpointEpochAtStateSlot(anchorState.slot),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeAnchorCheckpoint.js","sourceRoot":"","sources":["../../src/util/computeAnchorCheckpoint.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"computeAnchorCheckpoint.js","sourceRoot":"","sources":["../../src/util/computeAnchorCheckpoint.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAS,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,iCAAiC,EAAC,MAAM,YAAY,CAAC;AAE7D,MAAM,UAAU,uBAAuB,CACrC,OAAwB,EACxB,WAAgC,EACwC;IACxE,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IACtF,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC;QACtD,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC;IACrD,CAAC;IAED,OAAO;QACL,UAAU,EAAE;YACV,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,YAAY,CAAC,WAAW,CAAC;YAC5D,mGAAmG;YACnG,4CAA4C;YAC5C,KAAK,EAAE,iCAAiC,CAAC,WAAW,CAAC,IAAI,CAAC;SAC3D;QACD,WAAW;KACZ,CAAC;AAAA,CACH"}
|
package/lib/util/gloas.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuilderIndex, Epoch, ValidatorIndex, gloas } from "@lodestar/types";
|
|
2
2
|
import { AttestationData } from "@lodestar/types/phase0";
|
|
3
|
-
import { CachedBeaconStateGloas } from "../types.js";
|
|
3
|
+
import { CachedBeaconStateFulu, CachedBeaconStateGloas } from "../types.js";
|
|
4
4
|
import { RootCache } from "./rootCache.js";
|
|
5
5
|
export declare function isBuilderWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean;
|
|
6
6
|
export declare function getBuilderPaymentQuorumThreshold(state: CachedBeaconStateGloas): number;
|
|
@@ -49,4 +49,10 @@ export declare function findBuilderIndexByPubkey(state: CachedBeaconStateGloas,
|
|
|
49
49
|
export declare function isAttestationSameSlot(state: CachedBeaconStateGloas, data: AttestationData): boolean;
|
|
50
50
|
export declare function isAttestationSameSlotRootCache(rootCache: RootCache, data: AttestationData): boolean;
|
|
51
51
|
export declare function isParentBlockFull(state: CachedBeaconStateGloas): boolean;
|
|
52
|
+
export declare function initializePtcWindow(state: CachedBeaconStateFulu): Uint32Array[];
|
|
53
|
+
export declare function getPtcWindowEpochCacheData(state: CachedBeaconStateGloas): {
|
|
54
|
+
previousPayloadTimelinessCommittees: Uint32Array[];
|
|
55
|
+
payloadTimelinessCommittees: Uint32Array[];
|
|
56
|
+
nextPayloadTimelinessCommittees: Uint32Array[];
|
|
57
|
+
};
|
|
52
58
|
//# sourceMappingURL=gloas.d.ts.map
|
package/lib/util/gloas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gloas.d.ts","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gloas.d.ts","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAC,eAAe,EAAC,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAC,qBAAqB,EAAE,sBAAsB,EAAC,MAAM,aAAa,CAAC;AAI1E,OAAO,EAAC,SAAS,EAAC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CAAC,KAAK,EAAE,qBAAqB,GAAG,WAAW,EAAE,CAqB/E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,sBAAsB,GAAG;IACzE,mCAAmC,EAAE,WAAW,EAAE,CAAC;IACnD,2BAA2B,EAAE,WAAW,EAAE,CAAC;IAC3C,+BAA+B,EAAE,WAAW,EAAE,CAAC;CAChD,CAaA"}
|
package/lib/util/gloas.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { BUILDER_INDEX_FLAG, BUILDER_PAYMENT_THRESHOLD_DENOMINATOR, BUILDER_PAYMENT_THRESHOLD_NUMERATOR, BUILDER_WITHDRAWAL_PREFIX, EFFECTIVE_BALANCE_INCREMENT, FAR_FUTURE_EPOCH, MIN_DEPOSIT_AMOUNT, SLOTS_PER_EPOCH, } from "@lodestar/params";
|
|
1
|
+
import { BUILDER_INDEX_FLAG, BUILDER_PAYMENT_THRESHOLD_DENOMINATOR, BUILDER_PAYMENT_THRESHOLD_NUMERATOR, BUILDER_WITHDRAWAL_PREFIX, EFFECTIVE_BALANCE_INCREMENT, FAR_FUTURE_EPOCH, MIN_DEPOSIT_AMOUNT, MIN_SEED_LOOKAHEAD, PTC_SIZE, SLOTS_PER_EPOCH, } from "@lodestar/params";
|
|
2
2
|
import { byteArrayEquals } from "@lodestar/utils";
|
|
3
3
|
import { getBlockRootAtSlot } from "./blockRoot.js";
|
|
4
4
|
import { computeEpochAtSlot } from "./epoch.js";
|
|
5
|
+
import { computeEpochShuffling } from "./epochShuffling.js";
|
|
6
|
+
import { computePayloadTimelinessCommitteesForEpoch } from "./seed.js";
|
|
7
|
+
import { getActiveValidatorIndices } from "./validator.js";
|
|
5
8
|
export function isBuilderWithdrawalCredential(withdrawalCredentials) {
|
|
6
9
|
return withdrawalCredentials[0] === BUILDER_WITHDRAWAL_PREFIX;
|
|
7
10
|
}
|
|
@@ -122,7 +125,30 @@ export function isAttestationSameSlotRootCache(rootCache, data) {
|
|
|
122
125
|
const isCurrentBlockRoot = !byteArrayEquals(data.beaconBlockRoot, rootCache.getBlockRootAtSlot(data.slot - 1));
|
|
123
126
|
return isMatchingBlockRoot && isCurrentBlockRoot;
|
|
124
127
|
}
|
|
128
|
+
// TODO GLOAS: This function no longer exists in v1.7.0-alpha.5 specs. Remove it when appropriate to do so
|
|
125
129
|
export function isParentBlockFull(state) {
|
|
126
130
|
return byteArrayEquals(state.latestExecutionPayloadBid.blockHash, state.latestBlockHash);
|
|
127
131
|
}
|
|
132
|
+
export function initializePtcWindow(state) {
|
|
133
|
+
const ptcWindow = Array.from({ length: SLOTS_PER_EPOCH }, () => new Uint32Array(PTC_SIZE));
|
|
134
|
+
const currentEpoch = state.epochCtx.epoch;
|
|
135
|
+
for (let epochOffset = 0; epochOffset <= MIN_SEED_LOOKAHEAD; epochOffset++) {
|
|
136
|
+
const epoch = currentEpoch + epochOffset;
|
|
137
|
+
const shuffling = state.epochCtx.getShufflingAtEpochOrNull(epoch) ??
|
|
138
|
+
computeEpochShuffling(state, getActiveValidatorIndices(state, epoch), epoch);
|
|
139
|
+
ptcWindow.push(...computePayloadTimelinessCommitteesForEpoch(state, epoch, shuffling.committees, state.epochCtx.effectiveBalanceIncrements));
|
|
140
|
+
}
|
|
141
|
+
return ptcWindow;
|
|
142
|
+
}
|
|
143
|
+
export function getPtcWindowEpochCacheData(state) {
|
|
144
|
+
const toUint32Arrays = (views) => views.map((v) => Uint32Array.from(v.getAll()));
|
|
145
|
+
const previousPtcWindow = state.ptcWindow.getReadonlyByRange(0, SLOTS_PER_EPOCH);
|
|
146
|
+
const currentPtcWindow = state.ptcWindow.getReadonlyByRange(SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
|
|
147
|
+
const nextPtcWindow = state.ptcWindow.getReadonlyByRange(2 * SLOTS_PER_EPOCH, SLOTS_PER_EPOCH);
|
|
148
|
+
return {
|
|
149
|
+
previousPayloadTimelinessCommittees: toUint32Arrays(previousPtcWindow),
|
|
150
|
+
payloadTimelinessCommittees: toUint32Arrays(currentPtcWindow),
|
|
151
|
+
nextPayloadTimelinessCommittees: toUint32Arrays(nextPtcWindow),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
128
154
|
//# sourceMappingURL=gloas.js.map
|
package/lib/util/gloas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gloas.js","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,qCAAqC,EACrC,mCAAmC,EACnC,yBAAyB,EACzB,2BAA2B,EAC3B,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"gloas.js","sourceRoot":"","sources":["../../src/util/gloas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,qCAAqC,EACrC,mCAAmC,EACnC,yBAAyB,EACzB,2BAA2B,EAC3B,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAC,0CAA0C,EAAC,MAAM,WAAW,CAAC;AACrE,OAAO,EAAC,yBAAyB,EAAC,MAAM,gBAAgB,CAAC;AAEzD,MAAM,UAAU,6BAA6B,CAAC,qBAAiC,EAAW;IACxF,OAAO,qBAAqB,CAAC,CAAC,CAAC,K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K,EACL,KAAK,EACL,SAAS,CAAC,UAAU,EACpB,KAAK,CAAC,QAAQ,CAAC,0BAA0B,CAC1C,CACF,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AAAA,CAClB;AAED,MAAM,UAAU,0BAA0B,CAAC,KAA6B,EAItE;IACA,MAAM,cAAc,GAAG,CAAC,KAA4D,EAAE,EAAE,CACtF,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEjD,MAAM,iBAAiB,GAAG,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;IACjF,MAAM,gBAAgB,GAAG,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;IAC9F,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,GAAG,eAAe,EAAE,eAAe,CAAC,CAAC;IAE/F,OAAO;QACL,mCAAmC,EAAE,cAAc,CAAC,iBAAiB,CAAC;QACtE,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAAC;QAC7D,+BAA+B,EAAE,cAAc,CAAC,aAAa,CAAC;KAC/D,CAAC;AAAA,CACH"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.43.0-dev.
|
|
14
|
+
"version": "1.43.0-dev.a140dd987e",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
"@chainsafe/persistent-merkle-tree": "^1.2.1",
|
|
66
66
|
"@chainsafe/persistent-ts": "^1.0.0",
|
|
67
67
|
"@chainsafe/pubkey-index-map": "^3.0.0",
|
|
68
|
-
"@chainsafe/ssz": "^1.
|
|
68
|
+
"@chainsafe/ssz": "^1.4.0",
|
|
69
69
|
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
70
|
-
"@lodestar/config": "^1.43.0-dev.
|
|
71
|
-
"@lodestar/params": "^1.43.0-dev.
|
|
72
|
-
"@lodestar/types": "^1.43.0-dev.
|
|
73
|
-
"@lodestar/utils": "^1.43.0-dev.
|
|
70
|
+
"@lodestar/config": "^1.43.0-dev.a140dd987e",
|
|
71
|
+
"@lodestar/params": "^1.43.0-dev.a140dd987e",
|
|
72
|
+
"@lodestar/types": "^1.43.0-dev.a140dd987e",
|
|
73
|
+
"@lodestar/utils": "^1.43.0-dev.a140dd987e",
|
|
74
74
|
"@vekexasia/bigint-buffer2": "^1.1.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@lodestar/api": "^1.43.0-dev.
|
|
77
|
+
"@lodestar/api": "^1.43.0-dev.a140dd987e"
|
|
78
78
|
},
|
|
79
79
|
"keywords": [
|
|
80
80
|
"ethereum",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"beacon",
|
|
83
83
|
"blockchain"
|
|
84
84
|
],
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "5fb8f2dfb9c75239672ca0cf02585a66d316c256"
|
|
86
86
|
}
|
package/src/block/index.ts
CHANGED
|
@@ -14,8 +14,8 @@ import {processBlockHeader} from "./processBlockHeader.js";
|
|
|
14
14
|
import {processEth1Data} from "./processEth1Data.js";
|
|
15
15
|
import {processExecutionPayload} from "./processExecutionPayload.js";
|
|
16
16
|
import {processExecutionPayloadBid} from "./processExecutionPayloadBid.js";
|
|
17
|
-
import {processExecutionPayloadEnvelope} from "./processExecutionPayloadEnvelope.js";
|
|
18
17
|
import {processOperations} from "./processOperations.js";
|
|
18
|
+
import {processParentExecutionPayload} from "./processParentExecutionPayload.js";
|
|
19
19
|
import {processPayloadAttestation} from "./processPayloadAttestation.js";
|
|
20
20
|
import {processRandao} from "./processRandao.js";
|
|
21
21
|
import {processSyncAggregate} from "./processSyncCommittee.js";
|
|
@@ -32,7 +32,7 @@ export {
|
|
|
32
32
|
processWithdrawals,
|
|
33
33
|
processExecutionPayloadBid,
|
|
34
34
|
processPayloadAttestation,
|
|
35
|
-
|
|
35
|
+
processParentExecutionPayload,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export * from "./externalData.js";
|
|
@@ -51,10 +51,16 @@ export function processBlock(
|
|
|
51
51
|
): void {
|
|
52
52
|
const {verifySignatures = true} = opts ?? {};
|
|
53
53
|
|
|
54
|
+
// Apply the parent's deferred payload effects before everything else. Must run before
|
|
55
|
+
// processBlockHeader and processExecutionPayloadBid so subsequent steps see the updated state.
|
|
56
|
+
if (fork >= ForkSeq.gloas) {
|
|
57
|
+
processParentExecutionPayload(state as CachedBeaconStateGloas, block as BeaconBlock<ForkPostGloas>);
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
processBlockHeader(state, block);
|
|
55
61
|
|
|
56
62
|
if (fork >= ForkSeq.gloas) {
|
|
57
|
-
//
|
|
63
|
+
// Parent payload's execution requests were already applied by processParentExecutionPayload above
|
|
58
64
|
processWithdrawals(fork, state as CachedBeaconStateGloas);
|
|
59
65
|
} else if (fork >= ForkSeq.capella) {
|
|
60
66
|
const fullOrBlindedPayload = getFullOrBlindedPayload(block);
|
|
@@ -67,7 +73,9 @@ export function processBlock(
|
|
|
67
73
|
|
|
68
74
|
// The call to the process_execution_payload must happen before the call to the process_randao as the former depends
|
|
69
75
|
// on the randao_mix computed with the reveal of the previous block.
|
|
70
|
-
//
|
|
76
|
+
// Post-gloas: process_execution_payload is not part of block processing. The parent's payload
|
|
77
|
+
// effects are applied earlier via processParentExecutionPayload, and each execution payload is
|
|
78
|
+
// verified out-of-band via verifyExecutionPayloadEnvelope when it arrives.
|
|
71
79
|
if (
|
|
72
80
|
fork < ForkSeq.gloas &&
|
|
73
81
|
fork >= ForkSeq.bellatrix &&
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {ForkPostGloas, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
|
|
2
|
+
import {BeaconBlock, electra, ssz} from "@lodestar/types";
|
|
3
|
+
import {byteArrayEquals, toRootHex} from "@lodestar/utils";
|
|
4
|
+
import {CachedBeaconStateGloas} from "../types.js";
|
|
5
|
+
import {computeEpochAtSlot} from "../util/epoch.js";
|
|
6
|
+
import {processConsolidationRequest} from "./processConsolidationRequest.js";
|
|
7
|
+
import {getPendingValidatorPubkeys, processDepositRequest} from "./processDepositRequest.js";
|
|
8
|
+
import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Process parent execution payload effects as the first step of processBlock.
|
|
12
|
+
*
|
|
13
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.5/specs/gloas/beacon-chain.md#new-process_parent_execution_payload
|
|
14
|
+
*/
|
|
15
|
+
export function processParentExecutionPayload(state: CachedBeaconStateGloas, block: BeaconBlock<ForkPostGloas>): void {
|
|
16
|
+
const bid = block.body.signedExecutionPayloadBid.message;
|
|
17
|
+
const parentBid = state.latestExecutionPayloadBid;
|
|
18
|
+
const requests = block.body.parentExecutionRequests;
|
|
19
|
+
|
|
20
|
+
const isParentBlockFull = byteArrayEquals(bid.parentBlockHash, parentBid.blockHash);
|
|
21
|
+
if (!isParentBlockFull) {
|
|
22
|
+
// Parent was EMPTY -- no execution requests expected
|
|
23
|
+
assertEmptyExecutionRequests(requests);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Parent was FULL -- verify the bid commitment and apply the payload
|
|
28
|
+
const requestsRoot = ssz.electra.ExecutionRequests.hashTreeRoot(requests);
|
|
29
|
+
if (!byteArrayEquals(requestsRoot, parentBid.executionRequestsRoot)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Parent execution requests root mismatch actual=${toRootHex(requestsRoot)} expected=${toRootHex(parentBid.executionRequestsRoot)}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
applyParentExecutionPayload(state, requests);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Process the parent's execution requests, queue the builder payment, update payload availability,
|
|
40
|
+
* and update the latest block hash.
|
|
41
|
+
*
|
|
42
|
+
* Called from processParentExecutionPayload during block processing, and from the validator during
|
|
43
|
+
* block production before computing withdrawals.
|
|
44
|
+
*
|
|
45
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.5/specs/gloas/beacon-chain.md#new-apply_parent_execution_payload
|
|
46
|
+
*/
|
|
47
|
+
export function applyParentExecutionPayload(state: CachedBeaconStateGloas, requests: electra.ExecutionRequests): void {
|
|
48
|
+
const fork = state.config.getForkSeq(state.slot);
|
|
49
|
+
const parentBid = state.latestExecutionPayloadBid;
|
|
50
|
+
const parentSlot = parentBid.slot;
|
|
51
|
+
const parentEpoch = computeEpochAtSlot(parentSlot);
|
|
52
|
+
const currentEpoch = computeEpochAtSlot(state.slot);
|
|
53
|
+
|
|
54
|
+
// Process execution requests from parent's payload. The execution
|
|
55
|
+
// requests are processed at state.slot (child's slot), not the parent's slot.
|
|
56
|
+
if (requests.deposits.length > 0) {
|
|
57
|
+
const pendingValidatorPubkeys = getPendingValidatorPubkeys(state.config, state);
|
|
58
|
+
for (const deposit of requests.deposits) {
|
|
59
|
+
processDepositRequest(fork, state, deposit, pendingValidatorPubkeys);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const withdrawal of requests.withdrawals) {
|
|
64
|
+
processWithdrawalRequest(fork, state, withdrawal);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const consolidation of requests.consolidations) {
|
|
68
|
+
processConsolidationRequest(state, consolidation);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Settle the builder payment
|
|
72
|
+
if (parentEpoch === currentEpoch) {
|
|
73
|
+
settleBuilderPayment(state, SLOTS_PER_EPOCH + (parentSlot % SLOTS_PER_EPOCH));
|
|
74
|
+
} else if (parentEpoch === currentEpoch - 1) {
|
|
75
|
+
settleBuilderPayment(state, parentSlot % SLOTS_PER_EPOCH);
|
|
76
|
+
} else if (parentBid.value > 0) {
|
|
77
|
+
// Parent is older than the previous epoch, its payment entry has been evicted from
|
|
78
|
+
// builder_pending_payments. Append the withdrawal directly.
|
|
79
|
+
state.builderPendingWithdrawals.push(
|
|
80
|
+
ssz.gloas.BuilderPendingWithdrawal.toViewDU({
|
|
81
|
+
feeRecipient: parentBid.feeRecipient,
|
|
82
|
+
amount: parentBid.value,
|
|
83
|
+
builderIndex: parentBid.builderIndex,
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Update parent payload availability and latest block hash
|
|
89
|
+
state.executionPayloadAvailability.set(parentSlot % SLOTS_PER_HISTORICAL_ROOT, true);
|
|
90
|
+
state.latestBlockHash = parentBid.blockHash;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Settle a builder payment at the given index: move its withdrawal (if any) to the
|
|
95
|
+
* pending withdrawals list and clear the payment slot.
|
|
96
|
+
*
|
|
97
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.5/specs/gloas/beacon-chain.md#new-settle_builder_payment
|
|
98
|
+
*/
|
|
99
|
+
function settleBuilderPayment(state: CachedBeaconStateGloas, paymentIndex: number): void {
|
|
100
|
+
if (paymentIndex >= state.builderPendingPayments.length) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`Invalid builder payment index paymentIndex=${paymentIndex} limit=${state.builderPendingPayments.length}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const payment = state.builderPendingPayments.get(paymentIndex).clone();
|
|
106
|
+
if (payment.withdrawal.amount > 0) {
|
|
107
|
+
state.builderPendingWithdrawals.push(payment.withdrawal);
|
|
108
|
+
}
|
|
109
|
+
state.builderPendingPayments.set(paymentIndex, ssz.gloas.BuilderPendingPayment.defaultViewDU());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function assertEmptyExecutionRequests(requests: electra.ExecutionRequests): void {
|
|
113
|
+
if (requests.deposits.length !== 0 || requests.withdrawals.length !== 0 || requests.consolidations.length !== 0) {
|
|
114
|
+
throw new Error("Parent execution requests must be empty when parent block is EMPTY");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "@lodestar/params";
|
|
11
11
|
import {BuilderIndex, ValidatorIndex, capella, ssz} from "@lodestar/types";
|
|
12
12
|
import {byteArrayEquals, toRootHex} from "@lodestar/utils";
|
|
13
|
+
import {ZERO_HASH} from "../constants/index.js";
|
|
13
14
|
import {CachedBeaconStateCapella, CachedBeaconStateElectra, CachedBeaconStateGloas} from "../types.js";
|
|
14
15
|
import {
|
|
15
16
|
convertBuilderIndexToValidatorIndex,
|
|
@@ -31,9 +32,14 @@ export function processWithdrawals(
|
|
|
31
32
|
state: CachedBeaconStateCapella | CachedBeaconStateElectra | CachedBeaconStateGloas,
|
|
32
33
|
payload?: capella.FullOrBlindedExecutionPayload
|
|
33
34
|
): void {
|
|
34
|
-
// Return early if the parent block is empty
|
|
35
|
-
if (fork >= ForkSeq.gloas
|
|
36
|
-
|
|
35
|
+
// Return early if this is genesis block or the parent block is empty
|
|
36
|
+
if (fork >= ForkSeq.gloas) {
|
|
37
|
+
const stateGloas = state as CachedBeaconStateGloas;
|
|
38
|
+
const isGenesisBlock = byteArrayEquals(stateGloas.latestBlockHash, ZERO_HASH);
|
|
39
|
+
const isParentBlockEmpty = !isParentBlockFull(stateGloas);
|
|
40
|
+
if (isGenesisBlock || isParentBlockEmpty) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
// processedBuilderWithdrawalsCount is withdrawals coming from builder payment since gloas (EIP-7732)
|
|
@@ -48,7 +54,9 @@ export function processWithdrawals(
|
|
|
48
54
|
} = getExpectedWithdrawals(fork, state);
|
|
49
55
|
const numWithdrawals = expectedWithdrawals.length;
|
|
50
56
|
|
|
51
|
-
//
|
|
57
|
+
// Pre-gloas verifies the payload's withdrawals against expectedWithdrawals here.
|
|
58
|
+
// Post-gloas, the payload arrives later as an envelope and that consistency check
|
|
59
|
+
// happens in verifyExecutionPayloadEnvelope against state.payloadExpectedWithdrawals.
|
|
52
60
|
if (fork < ForkSeq.gloas) {
|
|
53
61
|
if (payload === undefined) {
|
|
54
62
|
throw Error("payload is required for pre-gloas processWithdrawals");
|
package/src/cache/epochCache.ts
CHANGED
|
@@ -32,10 +32,10 @@ import {
|
|
|
32
32
|
calculateShufflingDecisionRoot,
|
|
33
33
|
computeEpochShuffling,
|
|
34
34
|
} from "../util/epochShuffling.js";
|
|
35
|
+
import {getPtcWindowEpochCacheData} from "../util/gloas.js";
|
|
35
36
|
import {
|
|
36
37
|
computeActivationExitEpoch,
|
|
37
38
|
computeEpochAtSlot,
|
|
38
|
-
computePayloadTimelinessCommitteesForEpoch,
|
|
39
39
|
computeProposers,
|
|
40
40
|
computeSyncPeriodAtEpoch,
|
|
41
41
|
getActivationChurnLimit,
|
|
@@ -56,7 +56,7 @@ import {sumTargetUnslashedBalanceIncrements} from "../util/targetUnslashedBalanc
|
|
|
56
56
|
import {EffectiveBalanceIncrements, getEffectiveBalanceIncrementsWithLen} from "./effectiveBalanceIncrements.js";
|
|
57
57
|
import {EpochTransitionCache} from "./epochTransitionCache.js";
|
|
58
58
|
import {PubkeyCache, createPubkeyCache, syncPubkeys} from "./pubkeyCache.js";
|
|
59
|
-
import {CachedBeaconStateAllForks, CachedBeaconStateFulu} from "./stateCache.js";
|
|
59
|
+
import {CachedBeaconStateAllForks, CachedBeaconStateFulu, CachedBeaconStateGloas} from "./stateCache.js";
|
|
60
60
|
import {
|
|
61
61
|
SyncCommitteeCache,
|
|
62
62
|
SyncCommitteeCacheEmpty,
|
|
@@ -226,11 +226,12 @@ export class EpochCache {
|
|
|
226
226
|
/** TODO: Indexed SyncCommitteeCache */
|
|
227
227
|
nextSyncCommitteeIndexed: SyncCommitteeCache;
|
|
228
228
|
|
|
229
|
-
// TODO GLOAS: See if we need to cache PTC for next epoch
|
|
230
229
|
// PTC for previous epoch, required for slot N block validating slot N-1 attestations
|
|
231
230
|
previousPayloadTimelinessCommittees: Uint32Array[];
|
|
232
231
|
// PTC for current epoch, computed eagerly at epoch transition
|
|
233
232
|
payloadTimelinessCommittees: Uint32Array[];
|
|
233
|
+
// PTC for next epoch, precomputed from the ptc window for future duty serving
|
|
234
|
+
nextPayloadTimelinessCommittees: Uint32Array[];
|
|
234
235
|
|
|
235
236
|
// TODO: Helper stats
|
|
236
237
|
syncPeriod: SyncPeriod;
|
|
@@ -270,6 +271,7 @@ export class EpochCache {
|
|
|
270
271
|
nextSyncCommitteeIndexed: SyncCommitteeCache;
|
|
271
272
|
previousPayloadTimelinessCommittees: Uint32Array[];
|
|
272
273
|
payloadTimelinessCommittees: Uint32Array[];
|
|
274
|
+
nextPayloadTimelinessCommittees: Uint32Array[];
|
|
273
275
|
epoch: Epoch;
|
|
274
276
|
syncPeriod: SyncPeriod;
|
|
275
277
|
}) {
|
|
@@ -301,6 +303,7 @@ export class EpochCache {
|
|
|
301
303
|
this.nextSyncCommitteeIndexed = data.nextSyncCommitteeIndexed;
|
|
302
304
|
this.previousPayloadTimelinessCommittees = data.previousPayloadTimelinessCommittees;
|
|
303
305
|
this.payloadTimelinessCommittees = data.payloadTimelinessCommittees;
|
|
306
|
+
this.nextPayloadTimelinessCommittees = data.nextPayloadTimelinessCommittees;
|
|
304
307
|
this.epoch = data.epoch;
|
|
305
308
|
this.syncPeriod = data.syncPeriod;
|
|
306
309
|
}
|
|
@@ -451,25 +454,13 @@ export class EpochCache {
|
|
|
451
454
|
nextSyncCommitteeIndexed = new SyncCommitteeCacheEmpty();
|
|
452
455
|
}
|
|
453
456
|
|
|
454
|
-
//
|
|
457
|
+
// Copy previous/current epoch PTC slices from state.ptcWindow once, then serve hot-path lookups from epochCtx.
|
|
455
458
|
let previousPayloadTimelinessCommittees: Uint32Array[] = [];
|
|
456
459
|
let payloadTimelinessCommittees: Uint32Array[] = [];
|
|
460
|
+
let nextPayloadTimelinessCommittees: Uint32Array[] = [];
|
|
457
461
|
if (currentEpoch >= config.GLOAS_FORK_EPOCH) {
|
|
458
|
-
payloadTimelinessCommittees =
|
|
459
|
-
state
|
|
460
|
-
currentEpoch,
|
|
461
|
-
currentShuffling.committees,
|
|
462
|
-
effectiveBalanceIncrements
|
|
463
|
-
);
|
|
464
|
-
|
|
465
|
-
if (!isGenesis && previousEpoch >= config.GLOAS_FORK_EPOCH) {
|
|
466
|
-
previousPayloadTimelinessCommittees = computePayloadTimelinessCommitteesForEpoch(
|
|
467
|
-
state,
|
|
468
|
-
previousEpoch,
|
|
469
|
-
previousShuffling.committees,
|
|
470
|
-
effectiveBalanceIncrements
|
|
471
|
-
);
|
|
472
|
-
}
|
|
462
|
+
({previousPayloadTimelinessCommittees, payloadTimelinessCommittees, nextPayloadTimelinessCommittees} =
|
|
463
|
+
getPtcWindowEpochCacheData(state as CachedBeaconStateGloas));
|
|
473
464
|
}
|
|
474
465
|
|
|
475
466
|
// Precompute churnLimit for efficient initiateValidatorExit() during block proposing MUST be recompute everytime the
|
|
@@ -546,6 +537,7 @@ export class EpochCache {
|
|
|
546
537
|
nextSyncCommitteeIndexed,
|
|
547
538
|
previousPayloadTimelinessCommittees,
|
|
548
539
|
payloadTimelinessCommittees,
|
|
540
|
+
nextPayloadTimelinessCommittees,
|
|
549
541
|
epoch: currentEpoch,
|
|
550
542
|
syncPeriod: computeSyncPeriodAtEpoch(currentEpoch),
|
|
551
543
|
});
|
|
@@ -592,6 +584,7 @@ export class EpochCache {
|
|
|
592
584
|
nextSyncCommitteeIndexed: this.nextSyncCommitteeIndexed,
|
|
593
585
|
previousPayloadTimelinessCommittees: this.previousPayloadTimelinessCommittees,
|
|
594
586
|
payloadTimelinessCommittees: this.payloadTimelinessCommittees,
|
|
587
|
+
nextPayloadTimelinessCommittees: this.nextPayloadTimelinessCommittees,
|
|
595
588
|
epoch: this.epoch,
|
|
596
589
|
syncPeriod: this.syncPeriod,
|
|
597
590
|
});
|
|
@@ -695,21 +688,26 @@ export class EpochCache {
|
|
|
695
688
|
/**
|
|
696
689
|
* At fork boundary, this runs post-fork logic and it happens after `upgradeState*` is called.
|
|
697
690
|
*/
|
|
698
|
-
finalProcessEpoch(state: CachedBeaconStateAllForks): void {
|
|
691
|
+
finalProcessEpoch(state: CachedBeaconStateAllForks, epochTransitionCache: EpochTransitionCache): void {
|
|
699
692
|
// this.epoch was updated at the end of afterProcessEpoch()
|
|
700
693
|
const upcomingEpoch = this.epoch;
|
|
701
694
|
const epochAfterUpcoming = upcomingEpoch + 1;
|
|
702
695
|
|
|
703
696
|
this.proposersPrevEpoch = this.proposers;
|
|
704
697
|
if (upcomingEpoch >= this.config.GLOAS_FORK_EPOCH) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
698
|
+
if (epochTransitionCache.nextEpochPayloadTimelinessCommittees) {
|
|
699
|
+
// shift arrays from transition cache
|
|
700
|
+
this.previousPayloadTimelinessCommittees = this.payloadTimelinessCommittees;
|
|
701
|
+
this.payloadTimelinessCommittees = this.nextPayloadTimelinessCommittees;
|
|
702
|
+
this.nextPayloadTimelinessCommittees = epochTransitionCache.nextEpochPayloadTimelinessCommittees;
|
|
703
|
+
} else {
|
|
704
|
+
// Fork boundary: processPtcWindow didn't run, read from freshly initialized state.ptcWindow
|
|
705
|
+
({
|
|
706
|
+
previousPayloadTimelinessCommittees: this.previousPayloadTimelinessCommittees,
|
|
707
|
+
payloadTimelinessCommittees: this.payloadTimelinessCommittees,
|
|
708
|
+
nextPayloadTimelinessCommittees: this.nextPayloadTimelinessCommittees,
|
|
709
|
+
} = getPtcWindowEpochCacheData(state as CachedBeaconStateGloas));
|
|
710
|
+
}
|
|
713
711
|
}
|
|
714
712
|
if (upcomingEpoch >= this.config.FULU_FORK_EPOCH) {
|
|
715
713
|
// Populate proposer cache with lookahead from state
|
|
@@ -1034,12 +1032,16 @@ export class EpochCache {
|
|
|
1034
1032
|
throw new Error("Payload Timeliness Committee is not available before gloas fork");
|
|
1035
1033
|
}
|
|
1036
1034
|
|
|
1035
|
+
if (epoch === this.epoch - 1) {
|
|
1036
|
+
return this.previousPayloadTimelinessCommittees[slot % SLOTS_PER_EPOCH];
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1037
1039
|
if (epoch === this.epoch) {
|
|
1038
1040
|
return this.payloadTimelinessCommittees[slot % SLOTS_PER_EPOCH];
|
|
1039
1041
|
}
|
|
1040
1042
|
|
|
1041
|
-
if (epoch === this.epoch
|
|
1042
|
-
return this.
|
|
1043
|
+
if (epoch === this.epoch + 1) {
|
|
1044
|
+
return this.nextPayloadTimelinessCommittees[slot % SLOTS_PER_EPOCH];
|
|
1043
1045
|
}
|
|
1044
1046
|
|
|
1045
1047
|
throw new Error(`Payload Timeliness Committee is not available for slot=${slot}`);
|