@lodestar/state-transition 1.43.0-dev.e5b13221e5 → 1.43.0-dev.ff409c46ce
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/processConsolidationRequest.d.ts.map +1 -1
- package/lib/block/processConsolidationRequest.js +2 -1
- package/lib/block/processConsolidationRequest.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts +20 -0
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -0
- package/lib/block/processParentExecutionPayload.js +100 -0
- package/lib/block/processParentExecutionPayload.js.map +1 -0
- package/lib/block/processWithdrawals.d.ts.map +1 -1
- package/lib/block/processWithdrawals.js +10 -4
- package/lib/block/processWithdrawals.js.map +1 -1
- package/lib/cache/epochCache.js +3 -3
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/epoch/processPendingDeposits.d.ts.map +1 -1
- package/lib/epoch/processPendingDeposits.js +4 -2
- package/lib/epoch/processPendingDeposits.js.map +1 -1
- package/lib/signatureSets/index.d.ts +1 -0
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +1 -0
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/proposerPreferences.d.ts +4 -0
- package/lib/signatureSets/proposerPreferences.d.ts.map +1 -0
- package/lib/signatureSets/proposerPreferences.js +8 -0
- package/lib/signatureSets/proposerPreferences.js.map +1 -0
- package/lib/slot/upgradeStateToElectra.d.ts.map +1 -1
- package/lib/slot/upgradeStateToElectra.js +2 -2
- package/lib/slot/upgradeStateToElectra.js.map +1 -1
- package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
- package/lib/slot/upgradeStateToGloas.js +1 -0
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +9 -3
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +32 -8
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +8 -2
- 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/epoch.d.ts.map +1 -1
- package/lib/util/epoch.js +6 -4
- package/lib/util/epoch.js.map +1 -1
- package/lib/util/gloas.d.ts +0 -1
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +0 -4
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/loadState/loadState.js +4 -4
- package/lib/util/loadState/loadState.js.map +1 -1
- package/lib/util/validator.d.ts +14 -2
- package/lib/util/validator.d.ts.map +1 -1
- package/lib/util/validator.js +24 -2
- package/lib/util/validator.js.map +1 -1
- package/package.json +7 -7
- package/src/block/index.ts +12 -4
- package/src/block/processConsolidationRequest.ts +2 -1
- package/src/block/processParentExecutionPayload.ts +116 -0
- package/src/block/processWithdrawals.ts +12 -4
- package/src/cache/epochCache.ts +3 -3
- package/src/epoch/processPendingDeposits.ts +5 -2
- package/src/signatureSets/index.ts +1 -0
- package/src/signatureSets/proposerPreferences.ts +12 -0
- package/src/slot/upgradeStateToElectra.ts +4 -2
- package/src/slot/upgradeStateToGloas.ts +3 -0
- package/src/stateView/beaconStateView.ts +36 -17
- package/src/stateView/interface.ts +8 -5
- package/src/util/computeAnchorCheckpoint.ts +6 -19
- package/src/util/epoch.ts +13 -4
- package/src/util/gloas.ts +0 -5
- package/src/util/loadState/loadState.ts +4 -4
- package/src/util/validator.ts +42 -2
- package/lib/block/processExecutionPayloadEnvelope.d.ts +0 -9
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +0 -1
- package/lib/block/processExecutionPayloadEnvelope.js +0 -103
- package/lib/block/processExecutionPayloadEnvelope.js.map +0 -1
- package/src/block/processExecutionPayloadEnvelope.ts +0 -169
|
@@ -73,8 +73,8 @@ export function loadStateAndValidators(chainForkConfig, stateBytes) {
|
|
|
73
73
|
* Sco0 Sco1 Sco2 Sco3a
|
|
74
74
|
*/
|
|
75
75
|
function loadInactivityScores(migratedState, seedState, inactivityScoresBytes) {
|
|
76
|
-
//
|
|
77
|
-
migratedState.inactivityScores = seedState.inactivityScores.clone();
|
|
76
|
+
// true = do not transfer cache
|
|
77
|
+
migratedState.inactivityScores = seedState.inactivityScores.clone(true);
|
|
78
78
|
const oldValidator = migratedState.inactivityScores.length;
|
|
79
79
|
// UintNum64 = 8 bytes
|
|
80
80
|
const newValidator = inactivityScoresBytes.length / 8;
|
|
@@ -135,8 +135,8 @@ function loadValidators(migratedState, seedState, newValidatorsBytes, seedStateV
|
|
|
135
135
|
const newValidatorCount = Math.floor(newValidatorsBytes.length / VALIDATOR_BYTES_SIZE);
|
|
136
136
|
const isMoreValidator = newValidatorCount >= seedValidatorCount;
|
|
137
137
|
const minValidatorCount = Math.min(seedValidatorCount, newValidatorCount);
|
|
138
|
-
//
|
|
139
|
-
migratedState.validators = seedState.validators.clone();
|
|
138
|
+
// true = do not transfer cache
|
|
139
|
+
migratedState.validators = seedState.validators.clone(true);
|
|
140
140
|
// 80% of validators serialization time comes from memory allocation
|
|
141
141
|
// seedStateValidatorsBytes is an optimization at beacon-node side to avoid memory allocation here
|
|
142
142
|
const seedValidatorsBytes = seedStateValidatorsBytes ?? seedState.validators.serialize();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadState.js","sourceRoot":"","sources":["../../../src/util/loadState/loadState.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAC,gCAAgC,EAAE,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAC,oBAAoB,E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,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC;QAChH,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,IAAI,iBAAiB,IAAI,kBAAkB,EAAE,CAAC;QAC5C,qBAAqB;QACrB,KAAK,IAAI,cAAc,GAAG,kBAAkB,EAAE,cAAc,GAAG,iBAAiB,EAAE,cAAc,EAAE,EAAE,CAAC;YACnG,aAAa,CAAC,UAAU,CAAC,IAAI,CAC3B,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CACtC,kBAAkB,CAAC,QAAQ,CACzB,cAAc,GAAG,oBAAoB,EACrC,CAAC,cAAc,GAAG,CAAC,CAAC,GAAG,oBAAoB,CAC5C,CACF,CACF,CAAC;YACF,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,aAAa,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,GAAG,CAAC,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,kBAAkB,CAAC;AAAA,CAC3B"}
|
package/lib/util/validator.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare function isSlashableValidator(validator: phase0.Validator, epoch:
|
|
|
16
16
|
* NAIVE - SLOW CODE 🐢
|
|
17
17
|
*/
|
|
18
18
|
export declare function getActiveValidatorIndices(state: BeaconStateAllForks, epoch: Epoch): Uint32Array;
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function getValidatorActivationChurnLimit(config: ChainForkConfig, fork: ForkSeq, activeValidatorCount: number): number;
|
|
20
20
|
export declare function getChurnLimit(config: ChainForkConfig, activeValidatorCount: number): number;
|
|
21
21
|
/**
|
|
22
22
|
* Get combined churn limit of activation-exit and consolidation
|
|
@@ -24,7 +24,19 @@ export declare function getChurnLimit(config: ChainForkConfig, activeValidatorCo
|
|
|
24
24
|
export declare function getBalanceChurnLimit(totalActiveBalanceIncrements: number, churnLimitQuotient: number, minPerEpochChurnLimit: number): number;
|
|
25
25
|
export declare function getBalanceChurnLimitFromCache(epochCtx: EpochCache): number;
|
|
26
26
|
export declare function getActivationExitChurnLimit(epochCtx: EpochCache): number;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.6/specs/gloas/beacon-chain.md#new-get_activation_churn_limit
|
|
29
|
+
*/
|
|
30
|
+
export declare function getActivationChurnLimit(epochCtx: EpochCache): number;
|
|
31
|
+
/**
|
|
32
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.6/specs/gloas/beacon-chain.md#new-get_exit_churn_limit
|
|
33
|
+
*/
|
|
34
|
+
export declare function getExitChurnLimit(epochCtx: EpochCache): number;
|
|
35
|
+
/**
|
|
36
|
+
* Spec (electra): get_consolidation_churn_limit (uses combined balance churn minus activation+exit churn)
|
|
37
|
+
* Spec (gloas): get_consolidation_churn_limit (independent quotient, no MIN floor)
|
|
38
|
+
*/
|
|
39
|
+
export declare function getConsolidationChurnLimit(fork: ForkSeq, epochCtx: EpochCache): number;
|
|
28
40
|
export declare function getMaxEffectiveBalance(withdrawalCredentials: Uint8Array): number;
|
|
29
41
|
/**
|
|
30
42
|
* Check if validator is partially withdrawable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/util/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAEL,OAAO,EAIR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAC,mBAAmB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAI9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ACH,wBAAgB,oBAAoB,CAClC,4BAA4B,EAAE,MAAM,EACpC,kBAAkB,EAAE,MAAM,EAC1B,qBAAqB,EAAE,MAAM,GAC5B,MAAM,CAQR;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAM1E;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAExE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAOpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,CAM9D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,CAUtF;AAED,wBAAgB,sBAAsB,CAAC,qBAAqB,EAAE,UAAU,GAAG,MAAM,CAMhF;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAsBrH;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,wBAAwB,GAAG,sBAAsB,EACxD,cAAc,EAAE,cAAc,GAC7B,MAAM,CASR"}
|
package/lib/util/validator.js
CHANGED
|
@@ -29,7 +29,8 @@ export function getActiveValidatorIndices(state, epoch) {
|
|
|
29
29
|
}
|
|
30
30
|
return new Uint32Array(indices);
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
// Deneb fork upgrade only
|
|
33
|
+
export function getValidatorActivationChurnLimit(config, fork, activeValidatorCount) {
|
|
33
34
|
if (fork >= ForkSeq.deneb) {
|
|
34
35
|
return Math.min(config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT, getChurnLimit(config, activeValidatorCount));
|
|
35
36
|
}
|
|
@@ -52,7 +53,28 @@ export function getBalanceChurnLimitFromCache(epochCtx) {
|
|
|
52
53
|
export function getActivationExitChurnLimit(epochCtx) {
|
|
53
54
|
return Math.min(epochCtx.config.MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT, getBalanceChurnLimitFromCache(epochCtx));
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
/**
|
|
57
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.6/specs/gloas/beacon-chain.md#new-get_activation_churn_limit
|
|
58
|
+
*/
|
|
59
|
+
export function getActivationChurnLimit(epochCtx) {
|
|
60
|
+
const churn = getBalanceChurnLimit(epochCtx.totalActiveBalanceIncrements, epochCtx.config.CHURN_LIMIT_QUOTIENT_GLOAS, epochCtx.config.MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA);
|
|
61
|
+
return Math.min(epochCtx.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT_GLOAS, churn);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.6/specs/gloas/beacon-chain.md#new-get_exit_churn_limit
|
|
65
|
+
*/
|
|
66
|
+
export function getExitChurnLimit(epochCtx) {
|
|
67
|
+
return getBalanceChurnLimit(epochCtx.totalActiveBalanceIncrements, epochCtx.config.CHURN_LIMIT_QUOTIENT_GLOAS, epochCtx.config.MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Spec (electra): get_consolidation_churn_limit (uses combined balance churn minus activation+exit churn)
|
|
71
|
+
* Spec (gloas): get_consolidation_churn_limit (independent quotient, no MIN floor)
|
|
72
|
+
*/
|
|
73
|
+
export function getConsolidationChurnLimit(fork, epochCtx) {
|
|
74
|
+
if (fork >= ForkSeq.gloas) {
|
|
75
|
+
// No MIN floor — pass 0 so getBalanceChurnLimit's max(churn, min) is a no-op.
|
|
76
|
+
return getBalanceChurnLimit(epochCtx.totalActiveBalanceIncrements, epochCtx.config.CONSOLIDATION_CHURN_LIMIT_QUOTIENT, 0);
|
|
77
|
+
}
|
|
56
78
|
return getBalanceChurnLimitFromCache(epochCtx) - getActivationExitChurnLimit(epochCtx);
|
|
57
79
|
}
|
|
58
80
|
export function getMaxEffectiveBalance(withdrawalCredentials) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/util/validator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,OAAO,EACP,qBAAqB,EACrB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAC,2BAA2B,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,kCAAkC,EAAE,gCAAgC,EAAC,MAAM,cAAc,CAAC;AAElG;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAA2B,EAAE,KAAY,EAAW;IACpF,OAAO,SAAS,CAAC,eAAe,IAAI,KAAK,IAAI,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC;AAAA,CAC1E;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA2B,EAAE,KAAY,EAAW;IACvF,OAAO,CAAC,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,eAAe,IAAI,KAAK,IAAI,KAAK,GAAG,SAAS,CAAC,iBAAiB,CAAC;AAAA,CACxG;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAA0B,EAAE,KAAY,EAAe;IAC/F,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC;IAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,iBAAiB,CAAC,aAAa,CAAC,CA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": "1.43.0-dev.
|
|
14
|
+
"version": "1.43.0-dev.ff409c46ce",
|
|
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.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.ff409c46ce",
|
|
71
|
+
"@lodestar/params": "^1.43.0-dev.ff409c46ce",
|
|
72
|
+
"@lodestar/types": "^1.43.0-dev.ff409c46ce",
|
|
73
|
+
"@lodestar/utils": "^1.43.0-dev.ff409c46ce",
|
|
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.ff409c46ce"
|
|
78
78
|
},
|
|
79
79
|
"keywords": [
|
|
80
80
|
"ethereum",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"beacon",
|
|
83
83
|
"blockchain"
|
|
84
84
|
],
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "17bea196ab9143547831e03cf33a52e5d0b98ff2"
|
|
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 &&
|
|
@@ -46,7 +46,8 @@ export function processConsolidationRequest(
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// If there is too little available consolidation churn limit, consolidation requests are ignored
|
|
49
|
-
|
|
49
|
+
const fork = state.config.getForkSeq(state.slot);
|
|
50
|
+
if (getConsolidationChurnLimit(fork, state.epochCtx) <= MIN_ACTIVATION_BALANCE) {
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -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.6/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.6/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.6/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
|
+
}
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
convertBuilderIndexToValidatorIndex,
|
|
16
16
|
convertValidatorIndexToBuilderIndex,
|
|
17
17
|
isBuilderIndex,
|
|
18
|
-
isParentBlockFull,
|
|
19
18
|
} from "../util/gloas.js";
|
|
20
19
|
import {
|
|
21
20
|
decreaseBalance,
|
|
@@ -32,8 +31,15 @@ export function processWithdrawals(
|
|
|
32
31
|
payload?: capella.FullOrBlindedExecutionPayload
|
|
33
32
|
): void {
|
|
34
33
|
// Return early if the parent block is empty
|
|
35
|
-
if (fork >= ForkSeq.gloas
|
|
36
|
-
|
|
34
|
+
if (fork >= ForkSeq.gloas) {
|
|
35
|
+
const stateGloas = state as CachedBeaconStateGloas;
|
|
36
|
+
const isParentBlockEmpty = !byteArrayEquals(
|
|
37
|
+
stateGloas.latestBlockHash,
|
|
38
|
+
stateGloas.latestExecutionPayloadBid.blockHash
|
|
39
|
+
);
|
|
40
|
+
if (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
|
@@ -38,9 +38,9 @@ import {
|
|
|
38
38
|
computeEpochAtSlot,
|
|
39
39
|
computeProposers,
|
|
40
40
|
computeSyncPeriodAtEpoch,
|
|
41
|
-
getActivationChurnLimit,
|
|
42
41
|
getChurnLimit,
|
|
43
42
|
getSeed,
|
|
43
|
+
getValidatorActivationChurnLimit,
|
|
44
44
|
isActiveValidator,
|
|
45
45
|
isAggregatorFromCommitteeLength,
|
|
46
46
|
} from "../util/index.js";
|
|
@@ -478,7 +478,7 @@ export class EpochCache {
|
|
|
478
478
|
// the first block of the epoch process_block() call. So churnLimit must be computed at the end of the before epoch
|
|
479
479
|
// transition and the result is valid until the end of the next epoch transition
|
|
480
480
|
const churnLimit = getChurnLimit(config, currentShuffling.activeIndices.length);
|
|
481
|
-
const activationChurnLimit =
|
|
481
|
+
const activationChurnLimit = getValidatorActivationChurnLimit(
|
|
482
482
|
config,
|
|
483
483
|
config.getForkSeq(state.slot),
|
|
484
484
|
currentShuffling.activeIndices.length
|
|
@@ -652,7 +652,7 @@ export class EpochCache {
|
|
|
652
652
|
// the first block of the epoch process_block() call. So churnLimit must be computed at the end of the before epoch
|
|
653
653
|
// transition and the result is valid until the end of the next epoch transition
|
|
654
654
|
this.churnLimit = getChurnLimit(this.config, this.currentShuffling.activeIndices.length);
|
|
655
|
-
this.activationChurnLimit =
|
|
655
|
+
this.activationChurnLimit = getValidatorActivationChurnLimit(
|
|
656
656
|
this.config,
|
|
657
657
|
this.config.getForkSeq(state.slot),
|
|
658
658
|
this.currentShuffling.activeIndices.length
|
|
@@ -5,7 +5,7 @@ import {CachedBeaconStateElectra, EpochTransitionCache} from "../types.js";
|
|
|
5
5
|
import {increaseBalance} from "../util/balance.js";
|
|
6
6
|
import {hasCompoundingWithdrawalCredential, isValidatorKnown} from "../util/electra.js";
|
|
7
7
|
import {computeStartSlotAtEpoch} from "../util/epoch.js";
|
|
8
|
-
import {getActivationExitChurnLimit} from "../util/validator.js";
|
|
8
|
+
import {getActivationChurnLimit, getActivationExitChurnLimit} from "../util/validator.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Starting from Electra:
|
|
@@ -17,8 +17,11 @@ import {getActivationExitChurnLimit} from "../util/validator.js";
|
|
|
17
17
|
* TODO Electra: Update ssz library to support batch push to `pendingDeposits`
|
|
18
18
|
*/
|
|
19
19
|
export function processPendingDeposits(state: CachedBeaconStateElectra, cache: EpochTransitionCache): void {
|
|
20
|
+
const fork = state.config.getForkSeq(state.slot);
|
|
20
21
|
const nextEpoch = state.epochCtx.epoch + 1;
|
|
21
|
-
const
|
|
22
|
+
const churnLimit =
|
|
23
|
+
fork >= ForkSeq.gloas ? getActivationChurnLimit(state.epochCtx) : getActivationExitChurnLimit(state.epochCtx);
|
|
24
|
+
const availableForProcessing = state.depositBalanceToConsume + BigInt(churnLimit);
|
|
22
25
|
let processedAmount = 0;
|
|
23
26
|
let nextDepositIndex = 0;
|
|
24
27
|
const depositsToPostpone = [];
|
|
@@ -20,6 +20,7 @@ export * from "./executionPayloadEnvelope.js";
|
|
|
20
20
|
export * from "./indexedAttestation.js";
|
|
21
21
|
export * from "./indexedPayloadAttestation.js";
|
|
22
22
|
export * from "./proposer.js";
|
|
23
|
+
export * from "./proposerPreferences.js";
|
|
23
24
|
export * from "./proposerSlashings.js";
|
|
24
25
|
export * from "./randao.js";
|
|
25
26
|
export * from "./voluntaryExits.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
+
import {DOMAIN_PROPOSER_PREFERENCES} from "@lodestar/params";
|
|
3
|
+
import {gloas, ssz} from "@lodestar/types";
|
|
4
|
+
import {computeSigningRoot} from "../util/index.js";
|
|
5
|
+
|
|
6
|
+
export function getProposerPreferencesSigningRoot(
|
|
7
|
+
config: BeaconConfig,
|
|
8
|
+
preferences: gloas.ProposerPreferences
|
|
9
|
+
): Uint8Array {
|
|
10
|
+
const domain = config.getDomain(preferences.proposalSlot, DOMAIN_PROPOSER_PREFERENCES);
|
|
11
|
+
return computeSigningRoot(ssz.gloas.ProposerPreferences, preferences, domain);
|
|
12
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {FAR_FUTURE_EPOCH, GENESIS_SLOT, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params";
|
|
1
|
+
import {FAR_FUTURE_EPOCH, ForkSeq, GENESIS_SLOT, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params";
|
|
2
2
|
import {ValidatorIndex, ssz} from "@lodestar/types";
|
|
3
3
|
import {CachedBeaconStateElectra, getCachedBeaconState} from "../cache/stateCache.js";
|
|
4
4
|
import {G2_POINT_AT_INFINITY} from "../constants/constants.js";
|
|
@@ -78,7 +78,9 @@ export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): Cache
|
|
|
78
78
|
stateElectraView.commit();
|
|
79
79
|
const tmpElectraState = getCachedBeaconState(stateElectraView, stateDeneb);
|
|
80
80
|
stateElectraView.exitBalanceToConsume = BigInt(getActivationExitChurnLimit(tmpElectraState.epochCtx));
|
|
81
|
-
stateElectraView.consolidationBalanceToConsume = BigInt(
|
|
81
|
+
stateElectraView.consolidationBalanceToConsume = BigInt(
|
|
82
|
+
getConsolidationChurnLimit(ForkSeq.electra, tmpElectraState.epochCtx)
|
|
83
|
+
);
|
|
82
84
|
|
|
83
85
|
preActivation.sort((i0, i1) => {
|
|
84
86
|
const res = validatorsArr[i0].activationEligibilityEpoch - validatorsArr[i1].activationEligibilityEpoch;
|
|
@@ -48,6 +48,9 @@ export function upgradeStateToGloas(stateFulu: CachedBeaconStateFulu): CachedBea
|
|
|
48
48
|
stateGloasView.currentSyncCommittee = stateGloasCloned.currentSyncCommittee;
|
|
49
49
|
stateGloasView.nextSyncCommittee = stateGloasCloned.nextSyncCommittee;
|
|
50
50
|
stateGloasView.latestExecutionPayloadBid.blockHash = stateFulu.latestExecutionPayloadHeader.blockHash;
|
|
51
|
+
stateGloasView.latestExecutionPayloadBid.executionRequestsRoot = ssz.electra.ExecutionRequests.hashTreeRoot(
|
|
52
|
+
ssz.electra.ExecutionRequests.defaultValue()
|
|
53
|
+
);
|
|
51
54
|
stateGloasView.nextWithdrawalIndex = stateGloasCloned.nextWithdrawalIndex;
|
|
52
55
|
stateGloasView.nextWithdrawalValidatorIndex = stateGloasCloned.nextWithdrawalValidatorIndex;
|
|
53
56
|
stateGloasView.historicalSummaries = stateGloasCloned.historicalSummaries;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {CompactMultiProof, ProofType, Tree, createProof} from "@chainsafe/persistent-merkle-tree";
|
|
2
2
|
import {BitArray, ByteViews} from "@chainsafe/ssz";
|
|
3
3
|
import {BeaconConfig} from "@lodestar/config";
|
|
4
|
-
import {ForkName, ForkSeq, SLOTS_PER_HISTORICAL_ROOT
|
|
4
|
+
import {ForkName, ForkSeq, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
|
|
5
5
|
import {
|
|
6
6
|
BeaconBlock,
|
|
7
7
|
BeaconState,
|
|
@@ -28,8 +28,7 @@ import {
|
|
|
28
28
|
rewards,
|
|
29
29
|
} from "@lodestar/types";
|
|
30
30
|
import {Checkpoint, Fork} from "@lodestar/types/phase0";
|
|
31
|
-
import {
|
|
32
|
-
import {ProcessExecutionPayloadEnvelopeOpts} from "../block/processExecutionPayloadEnvelope.js";
|
|
31
|
+
import {applyParentExecutionPayload} from "../block/processParentExecutionPayload.js";
|
|
33
32
|
import {VoluntaryExitValidity, getVoluntaryExitValidity} from "../block/processVoluntaryExit.js";
|
|
34
33
|
import {getExpectedWithdrawals} from "../block/processWithdrawals.js";
|
|
35
34
|
import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js";
|
|
@@ -69,7 +68,7 @@ import {canBuilderCoverBid} from "../util/gloas.js";
|
|
|
69
68
|
import {loadState} from "../util/loadState/loadState.js";
|
|
70
69
|
import {getRandaoMix} from "../util/seed.js";
|
|
71
70
|
import {getLatestWeakSubjectivityCheckpointEpoch} from "../util/weakSubjectivity.js";
|
|
72
|
-
import {IBeaconStateView, IBeaconStateViewLatestFork} from "./interface.js";
|
|
71
|
+
import {IBeaconStateView, IBeaconStateViewGloas, IBeaconStateViewLatestFork, isStatePostGloas} from "./interface.js";
|
|
73
72
|
|
|
74
73
|
export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
75
74
|
private readonly config: BeaconConfig;
|
|
@@ -406,6 +405,23 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
406
405
|
return canBuilderCoverBid(this.cachedState as CachedBeaconStateGloas, builderIndex, bidAmount);
|
|
407
406
|
}
|
|
408
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Return the PTCs for an epoch
|
|
410
|
+
*/
|
|
411
|
+
getEpochPTCs(epoch: Epoch): Uint32Array[] {
|
|
412
|
+
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
413
|
+
throw new Error("PTC committees are not supported before Gloas");
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const epochCtx = (this.cachedState as CachedBeaconStateGloas).epochCtx;
|
|
417
|
+
if (epoch === epochCtx.epoch) {
|
|
418
|
+
return epochCtx.payloadTimelinessCommittees;
|
|
419
|
+
}
|
|
420
|
+
if (epoch === epochCtx.nextEpoch) {
|
|
421
|
+
return epochCtx.nextPayloadTimelinessCommittees;
|
|
422
|
+
}
|
|
423
|
+
throw new Error(`PTC committees are not available for epoch=${epoch}`);
|
|
424
|
+
}
|
|
409
425
|
/**
|
|
410
426
|
* Return the index of the validator in the PTC committee for the given slot.
|
|
411
427
|
* return -1 if validator is not in the PTC committee for the given slot.
|
|
@@ -784,19 +800,22 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
784
800
|
return new BeaconStateView(newState);
|
|
785
801
|
}
|
|
786
802
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
):
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
throw Error(`processExecutionPayloadEnvelope is only available for gloas+ forks, got fork=${fork}`);
|
|
803
|
+
/**
|
|
804
|
+
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.5/specs/gloas/validator.md#executionpayload
|
|
805
|
+
*/
|
|
806
|
+
withParentPayloadApplied(executionRequests: electra.ExecutionRequests): IBeaconStateViewGloas {
|
|
807
|
+
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
808
|
+
throw new Error("withParentPayloadApplied is not available before Gloas");
|
|
794
809
|
}
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
);
|
|
800
|
-
|
|
810
|
+
const stateCopy = this.cachedState.clone(true) as CachedBeaconStateGloas;
|
|
811
|
+
|
|
812
|
+
applyParentExecutionPayload(stateCopy, executionRequests);
|
|
813
|
+
|
|
814
|
+
const stateView = new BeaconStateView(stateCopy);
|
|
815
|
+
if (!isStatePostGloas(stateView)) {
|
|
816
|
+
throw new Error("Expected gloas state after clone");
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
return stateView;
|
|
801
820
|
}
|
|
802
821
|
}
|
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
rewards,
|
|
42
42
|
} from "@lodestar/types";
|
|
43
43
|
import {Checkpoint, Fork} from "@lodestar/types/phase0";
|
|
44
|
-
import {ProcessExecutionPayloadEnvelopeOpts} from "../block/processExecutionPayloadEnvelope.js";
|
|
45
44
|
import {VoluntaryExitValidity} from "../block/processVoluntaryExit.js";
|
|
46
45
|
import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js";
|
|
47
46
|
import {EpochTransitionCacheOpts} from "../cache/epochTransitionCache.js";
|
|
@@ -253,11 +252,15 @@ export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
|
|
|
253
252
|
payloadExpectedWithdrawals: capella.Withdrawal[];
|
|
254
253
|
getBuilder(index: BuilderIndex): gloas.Builder;
|
|
255
254
|
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
|
|
255
|
+
getEpochPTCs(epoch: Epoch): Uint32Array[];
|
|
256
256
|
getIndexInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Clone the state and apply parent execution payload effects.
|
|
259
|
+
* Used during block production and prepareNextSlot so that withdrawals and
|
|
260
|
+
* operation selection (e.g. voluntary exits) see the same post-apply state that the block
|
|
261
|
+
* processor will see at import.
|
|
262
|
+
*/
|
|
263
|
+
withParentPayloadApplied(executionRequests: electra.ExecutionRequests): IBeaconStateViewGloas;
|
|
261
264
|
}
|
|
262
265
|
|
|
263
266
|
/**
|