@lodestar/state-transition 1.42.0-dev.1d50253953 → 1.42.0-dev.2219bb0cb8
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/isValidIndexedAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +2 -3
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/processAttestationsAltair.d.ts +2 -1
- package/lib/block/processAttestationsAltair.d.ts.map +1 -1
- package/lib/block/processAttestationsAltair.js +5 -3
- package/lib/block/processAttestationsAltair.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/processExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.js +7 -3
- package/lib/block/processExecutionPayloadEnvelope.js.map +1 -1
- 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 +4 -0
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
- package/lib/signatureSets/index.d.ts +2 -2
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +1 -2
- package/lib/signatureSets/index.js.map +1 -1
- 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/upgradeStateToAltair.d.ts.map +1 -1
- package/lib/slot/upgradeStateToAltair.js +2 -1
- package/lib/slot/upgradeStateToAltair.js.map +1 -1
- package/lib/stateTransition.d.ts +1 -1
- package/lib/stateTransition.d.ts.map +1 -1
- package/lib/stateTransition.js +1 -1
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +12 -11
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +26 -37
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/index.d.ts +1 -0
- package/lib/stateView/index.d.ts.map +1 -1
- package/lib/stateView/index.js +1 -0
- package/lib/stateView/index.js.map +1 -1
- package/lib/stateView/interface.d.ts +105 -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/stateView/stateViewFactory.d.ts +40 -0
- package/lib/stateView/stateViewFactory.d.ts.map +1 -0
- package/lib/stateView/stateViewFactory.js +46 -0
- package/lib/stateView/stateViewFactory.js.map +1 -0
- package/lib/testUtils/cache.d.ts.map +1 -1
- package/lib/testUtils/cache.js +1 -1
- package/lib/testUtils/cache.js.map +1 -1
- package/lib/testUtils/util.d.ts +13 -1
- package/lib/testUtils/util.d.ts.map +1 -1
- package/lib/testUtils/util.js +119 -19
- package/lib/testUtils/util.js.map +1 -1
- package/lib/util/gloas.d.ts +2 -1
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/rootCache.d.ts +2 -2
- package/lib/util/rootCache.d.ts.map +1 -1
- package/lib/util/rootCache.js +2 -3
- package/lib/util/rootCache.js.map +1 -1
- package/lib/util/shuffling.d.ts +2 -1
- package/lib/util/shuffling.d.ts.map +1 -1
- package/lib/util/shuffling.js +2 -2
- package/lib/util/shuffling.js.map +1 -1
- package/package.json +7 -7
- package/src/block/isValidIndexedAttestation.ts +2 -3
- package/src/block/processAttestationsAltair.ts +7 -4
- package/src/block/processDepositRequest.ts +50 -5
- package/src/block/processExecutionPayloadEnvelope.ts +8 -3
- package/src/index.ts +20 -2
- package/src/signatureSets/executionPayloadEnvelope.ts +5 -1
- package/src/signatureSets/index.ts +3 -4
- package/src/signatureSets/voluntaryExits.ts +5 -2
- package/src/slot/upgradeStateToAltair.ts +2 -1
- package/src/stateTransition.ts +1 -1
- package/src/stateView/beaconStateView.ts +42 -56
- package/src/stateView/index.ts +1 -0
- package/src/stateView/interface.ts +148 -73
- package/src/stateView/stateViewFactory.ts +78 -0
- package/src/testUtils/cache.ts +1 -1
- package/src/testUtils/util.ts +136 -22
- package/src/util/gloas.ts +2 -1
- package/src/util/rootCache.ts +4 -5
- package/src/util/shuffling.ts +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffling.d.ts","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAkC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,EACL,kBAAkB,EAClB,IAAI,EACJ,IAAI,EACJ,cAAc,EAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"shuffling.d.ts","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAkC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EACX,cAAc,EACd,KAAK,EACL,kBAAkB,EAClB,IAAI,EACJ,IAAI,EACJ,cAAc,EAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,yBAAyB,EAAC,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CA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ACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,cAAe,SAAQ,aAAa,CAAC,kBAAkB,CAAC;CAAG"}
|
package/lib/util/shuffling.js
CHANGED
|
@@ -14,7 +14,7 @@ export function proposerShufflingDecisionRoot(fork, state) {
|
|
|
14
14
|
if (state.slot === decisionSlot) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
return getBlockRootAtSlot(
|
|
17
|
+
return state.getBlockRootAtSlot(decisionSlot);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Returns the slot at which the proposer shuffling was decided. The block root at this slot
|
|
@@ -22,7 +22,7 @@ export function proposerShufflingDecisionRoot(fork, state) {
|
|
|
22
22
|
*/
|
|
23
23
|
function proposerShufflingDecisionSlot(fork, state) {
|
|
24
24
|
// After fulu, the decision slot is in previous epoch due to deterministic proposer lookahead
|
|
25
|
-
const epoch = isForkPostFulu(fork) ? state.
|
|
25
|
+
const epoch = isForkPostFulu(fork) ? state.epoch - 1 : state.epoch;
|
|
26
26
|
const startSlot = computeStartSlotAtEpoch(epoch);
|
|
27
27
|
return Math.max(startSlot - 1, 0);
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffling.js","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAWpF,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"shuffling.js","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAWpF,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OA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AC9B,IAAU,EACV,OAAyB,EACV;IACf,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,IAAI,GAAG,eAAe,CAAC,CAAC;IACzE,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,IAAI,cAAc,CAAC;gBACvB,IAAI,EAAE,kBAAkB,CAAC,4BAA4B;gBACrD,KAAK;gBACL,QAAQ,EAAE,cAAc,CAAC,MAAM;aAChC,CAAC,CAAC;QACL,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,UAAU,CAAC;AAAA,CACnB;SAEW,kBAAkB;AAA9B,IAAY,kBAEX;AAFD,WAAY,kBAAkB;IAC5B,mGAA6E,CAAA;AAAC,CAChF,EAFY,kBAAkB,KAAlB,kBAAkB,QAE7B;AAQD,MAAM,OAAO,cAAe,SAAQ,aAAiC;CAAG"}
|
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.42.0-dev.
|
|
14
|
+
"version": "1.42.0-dev.2219bb0cb8",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"@chainsafe/pubkey-index-map": "^3.0.0",
|
|
68
68
|
"@chainsafe/ssz": "^1.2.2",
|
|
69
69
|
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
70
|
-
"@lodestar/config": "^1.42.0-dev.
|
|
71
|
-
"@lodestar/params": "^1.42.0-dev.
|
|
72
|
-
"@lodestar/types": "^1.42.0-dev.
|
|
73
|
-
"@lodestar/utils": "^1.42.0-dev.
|
|
70
|
+
"@lodestar/config": "^1.42.0-dev.2219bb0cb8",
|
|
71
|
+
"@lodestar/params": "^1.42.0-dev.2219bb0cb8",
|
|
72
|
+
"@lodestar/types": "^1.42.0-dev.2219bb0cb8",
|
|
73
|
+
"@lodestar/utils": "^1.42.0-dev.2219bb0cb8",
|
|
74
74
|
"@vekexasia/bigint-buffer2": "^1.1.1"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@lodestar/api": "^1.42.0-dev.
|
|
77
|
+
"@lodestar/api": "^1.42.0-dev.2219bb0cb8"
|
|
78
78
|
},
|
|
79
79
|
"keywords": [
|
|
80
80
|
"ethereum",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"beacon",
|
|
83
83
|
"blockchain"
|
|
84
84
|
],
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "3761783c9d8c8c6122f34db2f2de8f3aea2582ad"
|
|
86
86
|
}
|
|
@@ -74,9 +74,8 @@ export function isValidIndexedAttestationIndices(
|
|
|
74
74
|
prev = index;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
// check if indices are out of bounds,
|
|
78
|
-
|
|
79
|
-
if (lastIndex && lastIndex >= validatorsLen) {
|
|
77
|
+
// check if indices are out of bounds, `prev` is the highest index since indices are sorted
|
|
78
|
+
if (prev >= validatorsLen) {
|
|
80
79
|
return false;
|
|
81
80
|
}
|
|
82
81
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BitArray} from "@chainsafe/ssz";
|
|
1
2
|
import {
|
|
2
3
|
EFFECTIVE_BALANCE_INCREMENT,
|
|
3
4
|
ForkSeq,
|
|
@@ -17,6 +18,7 @@ import {Attestation, Epoch, phase0} from "@lodestar/types";
|
|
|
17
18
|
import {byteArrayEquals, intSqrt} from "@lodestar/utils";
|
|
18
19
|
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
19
20
|
import {getAttestationWithIndicesSignatureSet} from "../signatureSets/indexedAttestation.js";
|
|
21
|
+
import {BeaconStateView} from "../stateView/beaconStateView.js";
|
|
20
22
|
import {CachedBeaconStateAltair, CachedBeaconStateGloas} from "../types.js";
|
|
21
23
|
import {isAttestationSameSlot, isAttestationSameSlotRootCache} from "../util/gloas.js";
|
|
22
24
|
import {increaseBalance, verifySignatureSet} from "../util/index.js";
|
|
@@ -41,7 +43,7 @@ export function processAttestationsAltair(
|
|
|
41
43
|
const {epochCtx} = state;
|
|
42
44
|
const {effectiveBalanceIncrements} = epochCtx;
|
|
43
45
|
const stateSlot = state.slot;
|
|
44
|
-
const rootCache = new RootCache(state);
|
|
46
|
+
const rootCache = new RootCache(new BeaconStateView(state));
|
|
45
47
|
const currentEpoch = epochCtx.epoch;
|
|
46
48
|
|
|
47
49
|
// Process all attestations first and then increase the balance of the proposer once
|
|
@@ -80,7 +82,7 @@ export function processAttestationsAltair(
|
|
|
80
82
|
stateSlot - data.slot,
|
|
81
83
|
epochCtx.epoch,
|
|
82
84
|
rootCache,
|
|
83
|
-
fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability
|
|
85
|
+
fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability : null
|
|
84
86
|
);
|
|
85
87
|
|
|
86
88
|
// For each participant, update their participation
|
|
@@ -177,7 +179,7 @@ export function getAttestationParticipationStatus(
|
|
|
177
179
|
inclusionDelay: number,
|
|
178
180
|
currentEpoch: Epoch,
|
|
179
181
|
rootCache: RootCache,
|
|
180
|
-
executionPayloadAvailability:
|
|
182
|
+
executionPayloadAvailability: BitArray | null
|
|
181
183
|
): number {
|
|
182
184
|
const justifiedCheckpoint =
|
|
183
185
|
data.target.epoch === currentEpoch ? rootCache.currentJustifiedCheckpoint : rootCache.previousJustifiedCheckpoint;
|
|
@@ -221,7 +223,8 @@ export function getAttestationParticipationStatus(
|
|
|
221
223
|
throw new Error(`data index must be 0 or 1 index=${data.index}`);
|
|
222
224
|
}
|
|
223
225
|
|
|
224
|
-
isMatchingPayload =
|
|
226
|
+
isMatchingPayload =
|
|
227
|
+
Boolean(data.index) === executionPayloadAvailability.get(data.slot % SLOTS_PER_HISTORICAL_ROOT);
|
|
225
228
|
}
|
|
226
229
|
|
|
227
230
|
isMatchingHead = isMatchingHead && isMatchingPayload;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {FAR_FUTURE_EPOCH, ForkSeq, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params";
|
|
2
|
-
import {BLSPubkey, Bytes32, UintNum64, electra, ssz} from "@lodestar/types";
|
|
3
|
+
import {BLSPubkey, Bytes32, PubkeyHex, UintNum64, electra, ssz} from "@lodestar/types";
|
|
4
|
+
import {toPubkeyHex} from "@lodestar/utils";
|
|
3
5
|
import {CachedBeaconStateElectra, CachedBeaconStateGloas} from "../types.js";
|
|
4
6
|
import {findBuilderIndexByPubkey, isBuilderWithdrawalCredential} from "../util/gloas.js";
|
|
5
7
|
import {computeEpochAtSlot, isValidatorKnown} from "../util/index.js";
|
|
@@ -74,16 +76,24 @@ function addBuilderToRegistry(
|
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
79
|
+
// TODO GLOAS: pendingValidatorPubkeys cache is currently naive and has room for improvement.
|
|
80
|
+
// Currently the cache lives in process_block, but we should put it in epochCache or elsewhere that has longer
|
|
81
|
+
// lifetime to avoid duplicated deposit signature computation
|
|
82
|
+
// See https://github.com/ChainSafe/lodestar/issues/9181
|
|
77
83
|
export function processDepositRequest(
|
|
78
84
|
fork: ForkSeq,
|
|
79
85
|
state: CachedBeaconStateElectra | CachedBeaconStateGloas,
|
|
80
|
-
depositRequest: electra.DepositRequest
|
|
86
|
+
depositRequest: electra.DepositRequest,
|
|
87
|
+
pendingValidatorPubkeysCache?: Set<PubkeyHex>
|
|
81
88
|
): void {
|
|
82
89
|
const {pubkey, withdrawalCredentials, amount, signature} = depositRequest;
|
|
83
90
|
|
|
84
91
|
// Check if this is a builder or validator deposit
|
|
85
92
|
if (fork >= ForkSeq.gloas) {
|
|
86
93
|
const stateGloas = state as CachedBeaconStateGloas;
|
|
94
|
+
const pendingValidatorPubkeys =
|
|
95
|
+
pendingValidatorPubkeysCache ?? getPendingValidatorPubkeys(state.config, stateGloas);
|
|
96
|
+
const pubkeyHex = toPubkeyHex(pubkey);
|
|
87
97
|
const builderIndex = findBuilderIndexByPubkey(stateGloas, pubkey);
|
|
88
98
|
const validatorIndex = state.epochCtx.getValidatorIndex(pubkey);
|
|
89
99
|
|
|
@@ -91,14 +101,24 @@ export function processDepositRequest(
|
|
|
91
101
|
// already exists with this pubkey, apply the deposit to their balance
|
|
92
102
|
const isBuilder = builderIndex !== null;
|
|
93
103
|
const isValidator = isValidatorKnown(state, validatorIndex);
|
|
94
|
-
const
|
|
104
|
+
const isPendingValidator = pendingValidatorPubkeys.has(pubkeyHex);
|
|
95
105
|
|
|
96
|
-
|
|
97
|
-
if (isBuilder || (isBuilderPrefix && !isValidator)) {
|
|
106
|
+
if (isBuilder || (isBuilderWithdrawalCredential(withdrawalCredentials) && !isValidator && !isPendingValidator)) {
|
|
98
107
|
// Apply builder deposits immediately
|
|
99
108
|
applyDepositForBuilder(stateGloas, pubkey, withdrawalCredentials, amount, signature, state.slot);
|
|
100
109
|
return;
|
|
101
110
|
}
|
|
111
|
+
|
|
112
|
+
// Keep the shared cache in sync: if this deposit has a valid signature, subsequent
|
|
113
|
+
// deposit requests for the same pubkey in this envelope must see it as a pending validator
|
|
114
|
+
if (
|
|
115
|
+
pendingValidatorPubkeysCache &&
|
|
116
|
+
!isValidator &&
|
|
117
|
+
!isPendingValidator &&
|
|
118
|
+
isValidDepositSignature(state.config, pubkey, withdrawalCredentials, amount, signature)
|
|
119
|
+
) {
|
|
120
|
+
pendingValidatorPubkeys.add(pubkeyHex);
|
|
121
|
+
}
|
|
102
122
|
}
|
|
103
123
|
|
|
104
124
|
// Only set deposit_requests_start_index in Electra fork, not Gloas
|
|
@@ -116,3 +136,28 @@ export function processDepositRequest(
|
|
|
116
136
|
});
|
|
117
137
|
state.pendingDeposits.push(pendingDeposit);
|
|
118
138
|
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Build a set of pubkeys (hex-encoded) from pending deposits that have valid signatures.
|
|
142
|
+
* This is computed once and passed to each processDepositRequest call to avoid
|
|
143
|
+
* repeatedly iterating state.pendingDeposits.
|
|
144
|
+
*
|
|
145
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.3/specs/gloas/beacon-chain.md#new-is_pending_validator
|
|
146
|
+
*/
|
|
147
|
+
export function getPendingValidatorPubkeys(config: BeaconConfig, state: CachedBeaconStateGloas): Set<PubkeyHex> {
|
|
148
|
+
const result = new Set<PubkeyHex>();
|
|
149
|
+
for (const pendingDeposit of state.pendingDeposits.getAllReadonly()) {
|
|
150
|
+
if (
|
|
151
|
+
isValidDepositSignature(
|
|
152
|
+
config,
|
|
153
|
+
pendingDeposit.pubkey,
|
|
154
|
+
pendingDeposit.withdrawalCredentials,
|
|
155
|
+
pendingDeposit.amount,
|
|
156
|
+
pendingDeposit.signature
|
|
157
|
+
)
|
|
158
|
+
) {
|
|
159
|
+
result.add(toPubkeyHex(pendingDeposit.pubkey));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
@@ -7,7 +7,7 @@ import {CachedBeaconStateGloas} from "../types.js";
|
|
|
7
7
|
import {computeTimeAtSlot} from "../util/index.js";
|
|
8
8
|
import {verifySignatureSet} from "../util/signatureSets.js";
|
|
9
9
|
import {processConsolidationRequest} from "./processConsolidationRequest.js";
|
|
10
|
-
import {processDepositRequest} from "./processDepositRequest.js";
|
|
10
|
+
import {getPendingValidatorPubkeys, processDepositRequest} from "./processDepositRequest.js";
|
|
11
11
|
import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
|
|
12
12
|
|
|
13
13
|
export type ProcessExecutionPayloadEnvelopeOpts = {
|
|
@@ -40,8 +40,13 @@ export function processExecutionPayloadEnvelope(
|
|
|
40
40
|
|
|
41
41
|
const requests = envelope.executionRequests;
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (requests.deposits.length > 0) {
|
|
44
|
+
// Build cache of pending validator pubkeys once, shared across all deposit requests
|
|
45
|
+
const pendingValidatorPubkeys = getPendingValidatorPubkeys(postState.config, postState);
|
|
46
|
+
|
|
47
|
+
for (const deposit of requests.deposits) {
|
|
48
|
+
processDepositRequest(fork, postState, deposit, pendingValidatorPubkeys);
|
|
49
|
+
}
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
for (const withdrawal of requests.withdrawals) {
|
package/src/index.ts
CHANGED
|
@@ -35,14 +35,32 @@ export {
|
|
|
35
35
|
isStateValidatorsNodesPopulated,
|
|
36
36
|
loadCachedBeaconState,
|
|
37
37
|
} from "./cache/stateCache.js";
|
|
38
|
-
export {type SyncCommitteeCache} from "./cache/syncCommitteeCache.js";
|
|
38
|
+
export {type SyncCommitteeCache, SyncCommitteeCacheEmpty} from "./cache/syncCommitteeCache.js";
|
|
39
39
|
export * from "./constants/index.js";
|
|
40
40
|
export type {EpochTransitionStep} from "./epoch/index.js";
|
|
41
41
|
export {type BeaconStateTransitionMetrics, getMetrics} from "./metrics.js";
|
|
42
42
|
export * from "./rewards/index.js";
|
|
43
43
|
export * from "./signatureSets/index.js";
|
|
44
44
|
export * from "./stateTransition.js";
|
|
45
|
-
export
|
|
45
|
+
export {BeaconStateView} from "./stateView/beaconStateView.js";
|
|
46
|
+
export {
|
|
47
|
+
type IBeaconStateView,
|
|
48
|
+
type IBeaconStateViewAltair,
|
|
49
|
+
type IBeaconStateViewBellatrix,
|
|
50
|
+
type IBeaconStateViewCapella,
|
|
51
|
+
type IBeaconStateViewDeneb,
|
|
52
|
+
type IBeaconStateViewElectra,
|
|
53
|
+
type IBeaconStateViewFulu,
|
|
54
|
+
type IBeaconStateViewGloas,
|
|
55
|
+
isStatePostAltair,
|
|
56
|
+
isStatePostBellatrix,
|
|
57
|
+
isStatePostCapella,
|
|
58
|
+
isStatePostDeneb,
|
|
59
|
+
isStatePostElectra,
|
|
60
|
+
isStatePostFulu,
|
|
61
|
+
isStatePostGloas,
|
|
62
|
+
} from "./stateView/interface.js";
|
|
63
|
+
export {createBeaconStateView, createBeaconStateViewForHistoricalRegen} from "./stateView/stateViewFactory.js";
|
|
46
64
|
export type {
|
|
47
65
|
BeaconStateAllForks,
|
|
48
66
|
BeaconStateAltair,
|
|
@@ -3,7 +3,7 @@ import {BeaconConfig} from "@lodestar/config";
|
|
|
3
3
|
import {BUILDER_INDEX_SELF_BUILD, DOMAIN_BEACON_BUILDER} from "@lodestar/params";
|
|
4
4
|
import {ValidatorIndex, gloas, ssz} from "@lodestar/types";
|
|
5
5
|
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
|
-
import {IBeaconStateView} from "../stateView/interface.js";
|
|
6
|
+
import {IBeaconStateView, isStatePostGloas} from "../stateView/interface.js";
|
|
7
7
|
import {computeSigningRoot} from "../util/index.js";
|
|
8
8
|
import {type SingleSignatureSet, createSingleSignatureSetFromComponents} from "../util/signatureSets.js";
|
|
9
9
|
|
|
@@ -23,6 +23,10 @@ export function getExecutionPayloadEnvelopeSignatureSet(
|
|
|
23
23
|
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
|
|
24
24
|
proposerIndex: ValidatorIndex
|
|
25
25
|
): SingleSignatureSet {
|
|
26
|
+
if (!isStatePostGloas(state)) {
|
|
27
|
+
throw new Error(`Expected gloas+ state for execution payload envelope signature, got fork=${state.forkName}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
const envelope = signedEnvelope.message;
|
|
27
31
|
const pubkey =
|
|
28
32
|
envelope.builderIndex === BUILDER_INDEX_SELF_BUILD
|
|
@@ -3,8 +3,7 @@ import {ForkSeq} from "@lodestar/params";
|
|
|
3
3
|
import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
|
|
4
4
|
import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
|
|
5
5
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
6
|
-
import {
|
|
7
|
-
import {CachedBeaconStateAllForks} from "../types.js";
|
|
6
|
+
import {IBeaconStateView} from "../stateView/interface.js";
|
|
8
7
|
import {ISignatureSet} from "../util/index.js";
|
|
9
8
|
import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
|
|
10
9
|
import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js";
|
|
@@ -32,7 +31,7 @@ export * from "./voluntaryExits.js";
|
|
|
32
31
|
export function getBlockSignatureSets(
|
|
33
32
|
config: BeaconConfig,
|
|
34
33
|
currentSyncCommitteeIndexed: SyncCommitteeCache,
|
|
35
|
-
state:
|
|
34
|
+
state: IBeaconStateView,
|
|
36
35
|
signedBlock: SignedBeaconBlock,
|
|
37
36
|
indexedAttestations: IndexedAttestation[],
|
|
38
37
|
opts?: {
|
|
@@ -48,7 +47,7 @@ export function getBlockSignatureSets(
|
|
|
48
47
|
...getProposerSlashingsSignatureSets(config, signedBlock),
|
|
49
48
|
...getAttesterSlashingsSignatureSets(config, signedBlock),
|
|
50
49
|
...getAttestationsSignatureSets(config, signedBlock, indexedAttestations),
|
|
51
|
-
...getVoluntaryExitsSignatureSets(config,
|
|
50
|
+
...getVoluntaryExitsSignatureSets(config, state, signedBlock),
|
|
52
51
|
];
|
|
53
52
|
|
|
54
53
|
if (!opts?.skipProposerSignature) {
|
|
@@ -3,7 +3,7 @@ import {BeaconConfig} from "@lodestar/config";
|
|
|
3
3
|
import {ForkSeq} from "@lodestar/params";
|
|
4
4
|
import {SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
|
|
5
5
|
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
|
-
import {IBeaconStateView} from "../stateView/interface.js";
|
|
6
|
+
import {IBeaconStateView, IBeaconStateViewGloas, isStatePostGloas} from "../stateView/interface.js";
|
|
7
7
|
import {
|
|
8
8
|
ISignatureSet,
|
|
9
9
|
SignatureSetType,
|
|
@@ -34,6 +34,9 @@ export function getVoluntaryExitSignatureSet(
|
|
|
34
34
|
const fork = config.getForkSeq(state.slot);
|
|
35
35
|
|
|
36
36
|
if (fork >= ForkSeq.gloas && isBuilderVoluntaryExit(signedVoluntaryExit)) {
|
|
37
|
+
if (!isStatePostGloas(state)) {
|
|
38
|
+
throw new Error(`Expected gloas+ state for builder voluntary exit signature, got fork=${state.forkName}`);
|
|
39
|
+
}
|
|
37
40
|
return getBuilderVoluntaryExitSignatureSet(config, state, signedVoluntaryExit);
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -68,7 +71,7 @@ export function getValidatorVoluntaryExitSignatureSet(
|
|
|
68
71
|
|
|
69
72
|
export function getBuilderVoluntaryExitSignatureSet(
|
|
70
73
|
config: BeaconConfig,
|
|
71
|
-
state:
|
|
74
|
+
state: IBeaconStateViewGloas,
|
|
72
75
|
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
73
76
|
): ISignatureSet {
|
|
74
77
|
const messageSlot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
|
|
@@ -3,6 +3,7 @@ import {ForkSeq} from "@lodestar/params";
|
|
|
3
3
|
import {ssz} from "@lodestar/types";
|
|
4
4
|
import {getAttestationParticipationStatus} from "../block/processAttestationsAltair.js";
|
|
5
5
|
import {getCachedBeaconState} from "../cache/stateCache.js";
|
|
6
|
+
import {BeaconStateView} from "../stateView/beaconStateView.js";
|
|
6
7
|
import {CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../types.js";
|
|
7
8
|
import {RootCache, newZeroedArray} from "../util/index.js";
|
|
8
9
|
import {getNextSyncCommittee} from "../util/syncCommittee.js";
|
|
@@ -125,7 +126,7 @@ function translateParticipation(
|
|
|
125
126
|
pendingAttesations: CompositeViewDU<typeof ssz.phase0.EpochAttestations>
|
|
126
127
|
): void {
|
|
127
128
|
const {epochCtx} = state;
|
|
128
|
-
const rootCache = new RootCache(state);
|
|
129
|
+
const rootCache = new RootCache(new BeaconStateView(state));
|
|
129
130
|
const epochParticipation = state.previousEpochParticipation;
|
|
130
131
|
|
|
131
132
|
for (const attestation of pendingAttesations.getAllReadonly()) {
|
package/src/stateTransition.ts
CHANGED
|
@@ -76,7 +76,7 @@ export enum StateHashTreeRootSource {
|
|
|
76
76
|
prepareNextEpoch = "prepare_next_epoch",
|
|
77
77
|
regenState = "regen_state",
|
|
78
78
|
computeNewStateRoot = "compute_new_state_root",
|
|
79
|
-
|
|
79
|
+
computePayloadEnvelopeStateRoot = "compute_payload_envelope_state_root",
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {CompactMultiProof, ProofType, Tree, createProof} from "@chainsafe/persistent-merkle-tree";
|
|
2
|
-
import {ByteViews} from "@chainsafe/ssz";
|
|
2
|
+
import {BitArray, ByteViews} from "@chainsafe/ssz";
|
|
3
3
|
import {BeaconConfig} from "@lodestar/config";
|
|
4
|
-
import {ForkSeq, SLOTS_PER_HISTORICAL_ROOT, isForkPostGloas} from "@lodestar/params";
|
|
4
|
+
import {ForkName, ForkSeq, SLOTS_PER_HISTORICAL_ROOT, isForkPostGloas} from "@lodestar/params";
|
|
5
5
|
import {
|
|
6
6
|
BeaconBlock,
|
|
7
|
+
BeaconState,
|
|
7
8
|
BlindedBeaconBlock,
|
|
8
9
|
BuilderIndex,
|
|
9
10
|
Bytes32,
|
|
@@ -33,7 +34,6 @@ import {VoluntaryExitValidity, getVoluntaryExitValidity} from "../block/processV
|
|
|
33
34
|
import {getExpectedWithdrawals} from "../block/processWithdrawals.js";
|
|
34
35
|
import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js";
|
|
35
36
|
import {EpochTransitionCacheOpts} from "../cache/epochTransitionCache.js";
|
|
36
|
-
import {PubkeyCache, createPubkeyCache} from "../cache/pubkeyCache.js";
|
|
37
37
|
import {RewardCache} from "../cache/rewardCache.js";
|
|
38
38
|
import {
|
|
39
39
|
CachedBeaconStateAllForks,
|
|
@@ -47,7 +47,6 @@ import {
|
|
|
47
47
|
isStateValidatorsNodesPopulated,
|
|
48
48
|
} from "../cache/stateCache.js";
|
|
49
49
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
50
|
-
import {BeaconStateAllForks} from "../cache/types.js";
|
|
51
50
|
import {computeUnrealizedCheckpoints} from "../epoch/computeUnrealizedCheckpoints.js";
|
|
52
51
|
import {getFinalizedRootProof, getSyncCommitteesWitness} from "../lightClient/proofs.js";
|
|
53
52
|
import {SyncCommitteeWitness} from "../lightClient/types.js";
|
|
@@ -64,11 +63,10 @@ import {isExecutionEnabled, isExecutionStateType, isMergeTransitionComplete} fro
|
|
|
64
63
|
import {canBuilderCoverBid} from "../util/gloas.js";
|
|
65
64
|
import {loadState} from "../util/loadState/loadState.js";
|
|
66
65
|
import {getRandaoMix} from "../util/seed.js";
|
|
67
|
-
import {getStateTypeFromBytes} from "../util/sszBytes.js";
|
|
68
66
|
import {getLatestWeakSubjectivityCheckpointEpoch} from "../util/weakSubjectivity.js";
|
|
69
|
-
import {IBeaconStateView} from "./interface.js";
|
|
67
|
+
import {IBeaconStateView, IBeaconStateViewLatestFork} from "./interface.js";
|
|
70
68
|
|
|
71
|
-
export class BeaconStateView implements
|
|
69
|
+
export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
72
70
|
private readonly config: BeaconConfig;
|
|
73
71
|
// Cached values extracted from the tree
|
|
74
72
|
// phase0
|
|
@@ -92,8 +90,9 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
92
90
|
// fulu
|
|
93
91
|
private _proposerLookahead: fulu.ProposerLookahead | null = null;
|
|
94
92
|
// gloas
|
|
95
|
-
private _executionPayloadAvailability:
|
|
93
|
+
private _executionPayloadAvailability: BitArray | null = null;
|
|
96
94
|
private _latestExecutionPayloadBid: ExecutionPayloadBid | null = null;
|
|
95
|
+
private _payloadExpectedWithdrawals: capella.Withdrawal[] | null = null;
|
|
97
96
|
|
|
98
97
|
constructor(readonly cachedState: CachedBeaconStateAllForks) {
|
|
99
98
|
this.config = cachedState.config;
|
|
@@ -101,6 +100,10 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
101
100
|
|
|
102
101
|
// phase0
|
|
103
102
|
|
|
103
|
+
get forkName(): ForkName {
|
|
104
|
+
return this.config.getForkName(this.cachedState.slot);
|
|
105
|
+
}
|
|
106
|
+
|
|
104
107
|
get slot(): number {
|
|
105
108
|
return this.cachedState.slot;
|
|
106
109
|
}
|
|
@@ -357,15 +360,15 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
357
360
|
|
|
358
361
|
// gloas
|
|
359
362
|
|
|
360
|
-
get executionPayloadAvailability():
|
|
363
|
+
get executionPayloadAvailability(): BitArray {
|
|
361
364
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
362
|
-
throw new Error("executionPayloadAvailability is not available before
|
|
365
|
+
throw new Error("executionPayloadAvailability is not available before Gloas");
|
|
363
366
|
}
|
|
364
367
|
|
|
365
368
|
if (this._executionPayloadAvailability === null) {
|
|
366
|
-
this._executionPayloadAvailability = (
|
|
367
|
-
.
|
|
368
|
-
|
|
369
|
+
this._executionPayloadAvailability = (
|
|
370
|
+
this.cachedState as CachedBeaconStateGloas
|
|
371
|
+
).executionPayloadAvailability.toValue();
|
|
369
372
|
}
|
|
370
373
|
|
|
371
374
|
return this._executionPayloadAvailability;
|
|
@@ -373,7 +376,7 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
373
376
|
|
|
374
377
|
get latestExecutionPayloadBid(): ExecutionPayloadBid {
|
|
375
378
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
376
|
-
throw new Error("latestExecutionPayloadBid is not available before
|
|
379
|
+
throw new Error("latestExecutionPayloadBid is not available before Gloas");
|
|
377
380
|
}
|
|
378
381
|
|
|
379
382
|
if (this._latestExecutionPayloadBid === null) {
|
|
@@ -384,9 +387,22 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
384
387
|
return this._latestExecutionPayloadBid;
|
|
385
388
|
}
|
|
386
389
|
|
|
390
|
+
get payloadExpectedWithdrawals(): capella.Withdrawal[] {
|
|
391
|
+
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
392
|
+
throw new Error("payloadExpectedWithdrawals is not available before Gloas");
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (this._payloadExpectedWithdrawals === null) {
|
|
396
|
+
this._payloadExpectedWithdrawals = (
|
|
397
|
+
this.cachedState as CachedBeaconStateGloas
|
|
398
|
+
).payloadExpectedWithdrawals.toValue();
|
|
399
|
+
}
|
|
400
|
+
return this._payloadExpectedWithdrawals;
|
|
401
|
+
}
|
|
402
|
+
|
|
387
403
|
getBuilder(index: BuilderIndex): gloas.Builder {
|
|
388
404
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
389
|
-
throw new Error("Builders are not supported before
|
|
405
|
+
throw new Error("Builders are not supported before Gloas");
|
|
390
406
|
}
|
|
391
407
|
|
|
392
408
|
return (this.cachedState as CachedBeaconStateGloas).builders.getReadonly(index);
|
|
@@ -394,7 +410,7 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
394
410
|
|
|
395
411
|
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean {
|
|
396
412
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
397
|
-
throw new Error("Builders are not supported before
|
|
413
|
+
throw new Error("Builders are not supported before Gloas");
|
|
398
414
|
}
|
|
399
415
|
|
|
400
416
|
return canBuilderCoverBid(this.cachedState as CachedBeaconStateGloas, builderIndex, bidAmount);
|
|
@@ -404,9 +420,9 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
404
420
|
* Return the index of the validator in the PTC committee for the given slot.
|
|
405
421
|
* return -1 if validator is not in the PTC committee for the given slot.
|
|
406
422
|
*/
|
|
407
|
-
|
|
423
|
+
getIndexInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number {
|
|
408
424
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
409
|
-
throw new Error("PTC committees are not supported before
|
|
425
|
+
throw new Error("PTC committees are not supported before Gloas");
|
|
410
426
|
}
|
|
411
427
|
|
|
412
428
|
const ptcCommittee = (this.cachedState as CachedBeaconStateGloas).epochCtx.getPayloadTimelinessCommittee(slot);
|
|
@@ -503,6 +519,10 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
503
519
|
return this.cachedState.epochCtx.syncProposerReward;
|
|
504
520
|
}
|
|
505
521
|
|
|
522
|
+
getIndexedSyncCommittee(slot: Slot): SyncCommitteeCache {
|
|
523
|
+
return this.cachedState.epochCtx.getIndexedSyncCommittee(slot);
|
|
524
|
+
}
|
|
525
|
+
|
|
506
526
|
getIndexedSyncCommitteeAtEpoch(epoch: Epoch): SyncCommitteeCache {
|
|
507
527
|
return this.cachedState.epochCtx.getIndexedSyncCommitteeAtEpoch(epoch);
|
|
508
528
|
}
|
|
@@ -713,6 +733,10 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
713
733
|
return new BeaconStateView(cachedState);
|
|
714
734
|
}
|
|
715
735
|
|
|
736
|
+
toValue(): BeaconState {
|
|
737
|
+
return this.cachedState.toValue();
|
|
738
|
+
}
|
|
739
|
+
|
|
716
740
|
serialize(): Uint8Array {
|
|
717
741
|
return this.cachedState.serialize();
|
|
718
742
|
}
|
|
@@ -778,41 +802,3 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
778
802
|
return new BeaconStateView(postPayloadState);
|
|
779
803
|
}
|
|
780
804
|
}
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Create BeaconStateView for historical state regen, no need to sync pubkey cache there.
|
|
784
|
-
*/
|
|
785
|
-
export function createBeaconStateViewForHistoricalRegen(
|
|
786
|
-
config: BeaconConfig,
|
|
787
|
-
stateBytes: Uint8Array
|
|
788
|
-
): IBeaconStateView {
|
|
789
|
-
const state = getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes);
|
|
790
|
-
|
|
791
|
-
const pubkeyCache = createPubkeyCache();
|
|
792
|
-
syncPubkeyCache(state, pubkeyCache);
|
|
793
|
-
const cachedState = createCachedBeaconState(
|
|
794
|
-
state,
|
|
795
|
-
{
|
|
796
|
-
config,
|
|
797
|
-
pubkeyCache,
|
|
798
|
-
},
|
|
799
|
-
{
|
|
800
|
-
skipSyncPubkeys: true,
|
|
801
|
-
}
|
|
802
|
-
);
|
|
803
|
-
|
|
804
|
-
return new BeaconStateView(cachedState);
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* Populate a PubkeyIndexMap with any new entries based on a BeaconState
|
|
809
|
-
*/
|
|
810
|
-
function syncPubkeyCache(state: BeaconStateAllForks, pubkeyCache: PubkeyCache): void {
|
|
811
|
-
// Get the validators sub tree once for all the loop
|
|
812
|
-
|
|
813
|
-
const newCount = state.validators.length;
|
|
814
|
-
for (let i = pubkeyCache.size; i < newCount; i++) {
|
|
815
|
-
const pubkey = state.validators.getReadonly(i).pubkey;
|
|
816
|
-
pubkeyCache.set(i, pubkey);
|
|
817
|
-
}
|
|
818
|
-
}
|
package/src/stateView/index.ts
CHANGED