@lodestar/state-transition 1.50.0-dev.b4eaa62b30 → 1.50.0-dev.b726a05a4d
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/indexedBuilderState.d.ts +19 -0
- package/lib/block/indexedBuilderState.d.ts.map +1 -0
- package/lib/block/indexedBuilderState.js +60 -0
- package/lib/block/indexedBuilderState.js.map +1 -0
- package/lib/block/processBuilderDepositRequest.d.ts +2 -2
- package/lib/block/processBuilderDepositRequest.d.ts.map +1 -1
- package/lib/block/processBuilderDepositRequest.js +5 -4
- package/lib/block/processBuilderDepositRequest.js.map +1 -1
- package/lib/block/processBuilderExitRequest.d.ts +2 -2
- package/lib/block/processBuilderExitRequest.d.ts.map +1 -1
- package/lib/block/processBuilderExitRequest.js +4 -3
- package/lib/block/processBuilderExitRequest.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
- package/lib/block/processParentExecutionPayload.js +23 -18
- package/lib/block/processParentExecutionPayload.js.map +1 -1
- package/lib/block/processProposerSlashing.d.ts.map +1 -1
- package/lib/block/processProposerSlashing.js +0 -23
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/slashValidator.d.ts.map +1 -1
- package/lib/block/slashValidator.js +11 -0
- package/lib/block/slashValidator.js.map +1 -1
- package/lib/epoch/processPendingDeposits.d.ts.map +1 -1
- package/lib/epoch/processPendingDeposits.js +8 -4
- package/lib/epoch/processPendingDeposits.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/rewards/attestationsRewards.d.ts.map +1 -1
- package/lib/rewards/attestationsRewards.js +13 -3
- package/lib/rewards/attestationsRewards.js.map +1 -1
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +2 -2
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +2 -6
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +2 -32
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +22 -21
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +71 -71
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +34 -21
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +92 -100
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +339 -368
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts +10 -17
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +17 -13
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/lib/util/gloas.d.ts +11 -14
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +2 -42
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/sszBytes.d.ts +16 -17
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +93 -20
- package/lib/util/sszBytes.js.map +1 -1
- package/lib/util/weakSubjectivity.d.ts +11 -6
- package/lib/util/weakSubjectivity.d.ts.map +1 -1
- package/lib/util/weakSubjectivity.js +22 -28
- package/lib/util/weakSubjectivity.js.map +1 -1
- package/package.json +8 -8
- package/src/block/indexedBuilderState.ts +65 -0
- package/src/block/processBuilderDepositRequest.ts +6 -17
- package/src/block/processBuilderExitRequest.ts +5 -9
- package/src/block/processParentExecutionPayload.ts +27 -23
- package/src/block/processProposerSlashing.ts +2 -28
- package/src/block/slashValidator.ts +13 -2
- package/src/epoch/processPendingDeposits.ts +14 -3
- package/src/index.ts +4 -1
- package/src/rewards/attestationsRewards.ts +15 -2
- package/src/signatureSets/index.ts +4 -2
- package/src/signatureSets/voluntaryExits.ts +3 -55
- package/src/stateView/beaconStateView.ts +75 -76
- package/src/stateView/interface.ts +61 -21
- package/src/stateView/nativeBeaconStateView.ts +354 -375
- package/src/stateView/stateViewFactory.ts +29 -27
- package/src/util/gloas.ts +2 -53
- package/src/util/index.ts +6 -0
- package/src/util/sszBytes.ts +129 -22
- package/src/util/weakSubjectivity.ts +43 -40
package/lib/util/sszBytes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sszBytes.js","sourceRoot":"","sources":["../../src/util/sszBytes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sszBytes.js","sourceRoot":"","sources":["../../src/util/sszBytes.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,2BAA2B,EAAmB,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAA2B,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,kCAAkC,GAAG,WAAW,GAAG,SAAS,CAAC;AACnE,MAAM,iCAAiC,GAAG,kCAAkC,GAAG,WAAW,GAAG,CAAC,GAAG,WAAW,CAAC;AAC7G,MAAM,2BAA2B,GAAG,iCAAiC,GAAG,WAAW,CAAC;AACpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,GAAG,WAAW,GAAG,WAAW,CAAC;AAE5F;;;;;;;;GAQG;AACH,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,oCAAoC,GAAG,yBAAyB,GAAG,WAAW,CAAC;AACrF,MAA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AU,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;QAC/F,MAAM,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5E,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,oBAAoB,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Epoch, Root } from "@lodestar/types";
|
|
3
|
-
import { Checkpoint } from "@lodestar/types/phase0";
|
|
1
|
+
import { ChainForkConfig } from "@lodestar/config";
|
|
2
|
+
import { Epoch, Root, TimeSeconds } from "@lodestar/types";
|
|
4
3
|
import { BeaconStateAllForks, CachedBeaconStateAllForks } from "../types.js";
|
|
4
|
+
import { StateBytesMetadata } from "./sszBytes.js";
|
|
5
5
|
export declare const ETH_TO_GWEI: number;
|
|
6
6
|
/**
|
|
7
7
|
* Returns the epoch of the latest weak subjectivity checkpoint for the given
|
|
@@ -19,13 +19,18 @@ export declare function getLatestWeakSubjectivityCheckpointEpoch(config: ChainFo
|
|
|
19
19
|
export declare function computeWeakSubjectivityPeriodCachedState(config: ChainForkConfig, state: CachedBeaconStateAllForks): number;
|
|
20
20
|
/**
|
|
21
21
|
* Same to computeWeakSubjectivityPeriodCachedState but for normal state
|
|
22
|
-
* This is called only 1 time at app startup so it's ok to calculate totalActiveBalanceIncrements manually
|
|
23
22
|
*/
|
|
24
23
|
export declare function computeWeakSubjectivityPeriod(config: ChainForkConfig, state: BeaconStateAllForks): number;
|
|
25
24
|
export declare function computeWeakSubjectivityPeriodFromConstituentsPhase0(activeValidatorCount: number, totalBalanceByIncrement: number, churnLimit: number, minWithdrawabilityDelay: number): number;
|
|
26
25
|
export declare function computeWeakSubjectivityPeriodFromConstituentsElectra(totalBalanceByIncrement: number, balanceChurnLimit: number, minWithdrawabilityDelay: number): number;
|
|
27
26
|
export declare function computeWeakSubjectivityPeriodFromConstituentsGloas(totalBalanceByIncrement: number, exitChurnLimit: number, activationChurnLimit: number, consolidationChurnLimit: number, minWithdrawabilityDelay: number): number;
|
|
28
27
|
export declare function getLatestBlockRoot(state: BeaconStateAllForks): Root;
|
|
29
|
-
export
|
|
30
|
-
|
|
28
|
+
export type WeakSubjectivitySummary = {
|
|
29
|
+
checkpointEpoch: Epoch;
|
|
30
|
+
genesisTime: number;
|
|
31
|
+
period: number;
|
|
32
|
+
};
|
|
33
|
+
/** The metadata must describe the supplied state bytes. */
|
|
34
|
+
export declare function computeWeakSubjectivitySummaryFromStateBytes(config: ChainForkConfig, bytes: Uint8Array, metadata: StateBytesMetadata): WeakSubjectivitySummary | null;
|
|
35
|
+
export declare function isWithinWeakSubjectivityPeriodFromSummary(config: ChainForkConfig, summary: WeakSubjectivitySummary, now?: TimeSeconds): boolean;
|
|
31
36
|
//# sourceMappingURL=weakSubjectivity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weakSubjectivity.d.ts","sourceRoot":"","sources":["../../src/util/weakSubjectivity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3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eAAe,EAAE,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC;AAEpG,2DAA2D;AAC3D,wBAAgB,4CAA4C,CAC1D,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,kBAAkB,GAC3B,uBAAuB,GAAG,IAAI,CAOhC;AAED,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,uBAAuB,EAChC,GAAG,GAAE,WAA+B,GACnC,OAAO,CAGT"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { EFFECTIVE_BALANCE_INCREMENT, ForkSeq, MAX_DEPOSITS, MAX_EFFECTIVE_BALANCE, SLOTS_PER_EPOCH, isForkPostElectra, isForkPostGloas, } from "@lodestar/params";
|
|
1
|
+
import { EFFECTIVE_BALANCE_INCREMENT, ForkSeq, GENESIS_SLOT, MAX_DEPOSITS, MAX_EFFECTIVE_BALANCE, SLOTS_PER_EPOCH, isForkPostElectra, isForkPostGloas, } from "@lodestar/params";
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
|
-
import { toRootHex } from "@lodestar/utils";
|
|
4
3
|
import { ZERO_HASH } from "../constants/constants.js";
|
|
5
4
|
import { computeCheckpointEpochAtStateSlot, computeEpochAtSlot, getCurrentEpoch } from "./epoch.js";
|
|
6
|
-
import {
|
|
5
|
+
import { getStateTypeFromBytes, scanActiveValidatorsFromStateBytes } from "./sszBytes.js";
|
|
7
6
|
import { getActivationChurnLimit, getActiveValidatorIndices, getBalanceChurnLimit, getBalanceChurnLimitFromCache, getChurnLimit, getConsolidationChurnLimit, getExitChurnLimit, getGloasChurnLimits, } from "./validator.js";
|
|
8
7
|
export const ETH_TO_GWEI = 10 ** 9;
|
|
9
8
|
const SAFETY_DECAY = 10;
|
|
@@ -33,12 +32,10 @@ export function computeWeakSubjectivityPeriodCachedState(config, state) {
|
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
35
34
|
* Same to computeWeakSubjectivityPeriodCachedState but for normal state
|
|
36
|
-
* This is called only 1 time at app startup so it's ok to calculate totalActiveBalanceIncrements manually
|
|
37
35
|
*/
|
|
38
36
|
export function computeWeakSubjectivityPeriod(config, state) {
|
|
39
37
|
const activeIndices = getActiveValidatorIndices(state, getCurrentEpoch(state));
|
|
40
38
|
const validators = state.validators.getAllReadonlyValues();
|
|
41
|
-
const fork = config.getForkName(state.slot);
|
|
42
39
|
let totalActiveBalanceIncrements = 0;
|
|
43
40
|
for (const index of activeIndices) {
|
|
44
41
|
totalActiveBalanceIncrements += Math.floor(validators[index].effectiveBalance / EFFECTIVE_BALANCE_INCREMENT);
|
|
@@ -46,12 +43,19 @@ export function computeWeakSubjectivityPeriod(config, state) {
|
|
|
46
43
|
if (totalActiveBalanceIncrements <= 1) {
|
|
47
44
|
totalActiveBalanceIncrements = 1;
|
|
48
45
|
}
|
|
46
|
+
return computeWeakSubjectivityPeriodFromActiveValidators(config, state.slot, {
|
|
47
|
+
activeValidatorCount: activeIndices.length,
|
|
48
|
+
totalActiveBalanceIncrements,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function computeWeakSubjectivityPeriodFromActiveValidators(config, slot, { activeValidatorCount, totalActiveBalanceIncrements, }) {
|
|
52
|
+
const fork = config.getForkName(slot);
|
|
49
53
|
const churnLimitsGloas = getGloasChurnLimits(config, totalActiveBalanceIncrements);
|
|
50
54
|
return isForkPostGloas(fork)
|
|
51
55
|
? computeWeakSubjectivityPeriodFromConstituentsGloas(totalActiveBalanceIncrements, churnLimitsGloas.exit, churnLimitsGloas.activation, churnLimitsGloas.consolidation, config.MIN_VALIDATOR_WITHDRAWABILITY_DELAY)
|
|
52
56
|
: isForkPostElectra(fork)
|
|
53
57
|
? computeWeakSubjectivityPeriodFromConstituentsElectra(totalActiveBalanceIncrements, getBalanceChurnLimit(totalActiveBalanceIncrements, config.CHURN_LIMIT_QUOTIENT, config.MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA), config.MIN_VALIDATOR_WITHDRAWABILITY_DELAY)
|
|
54
|
-
: computeWeakSubjectivityPeriodFromConstituentsPhase0(
|
|
58
|
+
: computeWeakSubjectivityPeriodFromConstituentsPhase0(activeValidatorCount, totalActiveBalanceIncrements, getChurnLimit(config, activeValidatorCount), config.MIN_VALIDATOR_WITHDRAWABILITY_DELAY);
|
|
55
59
|
}
|
|
56
60
|
export function computeWeakSubjectivityPeriodFromConstituentsPhase0(activeValidatorCount, totalBalanceByIncrement, churnLimit, minWithdrawabilityDelay) {
|
|
57
61
|
const N = activeValidatorCount;
|
|
@@ -98,28 +102,18 @@ export function getLatestBlockRoot(state) {
|
|
|
98
102
|
}
|
|
99
103
|
return ssz.phase0.BeaconBlockHeader.hashTreeRoot(header);
|
|
100
104
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
|
|
105
|
+
/** The metadata must describe the supplied state bytes. */
|
|
106
|
+
export function computeWeakSubjectivitySummaryFromStateBytes(config, bytes, metadata) {
|
|
107
|
+
const { slot, genesisTime } = metadata;
|
|
108
|
+
const stateType = getStateTypeFromBytes(config, bytes);
|
|
109
|
+
const activeValidators = scanActiveValidatorsFromStateBytes(bytes, stateType, computeEpochAtSlot(slot));
|
|
110
|
+
if (activeValidators === null)
|
|
111
|
+
return null;
|
|
112
|
+
const period = computeWeakSubjectivityPeriodFromActiveValidators(config, slot, activeValidators);
|
|
113
|
+
return { checkpointEpoch: computeCheckpointEpochAtStateSlot(slot), genesisTime, period };
|
|
109
114
|
}
|
|
110
|
-
export function
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
if (!ssz.Root.equals(blockRoot, wsCheckpoint.root)) {
|
|
114
|
-
throw new Error(`Roots do not match. expected=${toRootHex(wsCheckpoint.root)}, actual=${toRootHex(blockRoot)}`);
|
|
115
|
-
}
|
|
116
|
-
if (!ssz.Epoch.equals(wsStateEpoch, wsCheckpoint.epoch)) {
|
|
117
|
-
throw new Error(`Epochs do not match. expected=${wsCheckpoint.epoch}, actual=${wsStateEpoch}`);
|
|
118
|
-
}
|
|
119
|
-
const wsPeriod = computeWeakSubjectivityPeriod(config, wsState);
|
|
120
|
-
const clockEpoch = computeEpochAtSlot(getCurrentSlot(config, wsState.genesisTime));
|
|
121
|
-
if (clockEpoch > wsStateEpoch + wsPeriod) {
|
|
122
|
-
throw new Error(`The downloaded state with epoch ${wsStateEpoch} is not within weak subjectivity period of ${wsPeriod} from the current epoch ${clockEpoch}. Please verify your checkpoint source`);
|
|
123
|
-
}
|
|
115
|
+
export function isWithinWeakSubjectivityPeriodFromSummary(config, summary, now = Date.now() / 1000) {
|
|
116
|
+
const clockSlot = GENESIS_SLOT + Math.floor((now - summary.genesisTime) / (config.SLOT_DURATION_MS / 1000));
|
|
117
|
+
return computeEpochAtSlot(clockSlot) <= summary.checkpointEpoch + summary.period;
|
|
124
118
|
}
|
|
125
119
|
//# sourceMappingURL=weakSubjectivity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weakSubjectivity.js","sourceRoot":"","sources":["../../src/util/weakSubjectivity.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,OAAO,EACP,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"weakSubjectivity.js","sourceRoot":"","sources":["../../src/util/weakSubjectivity.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAiC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAC,SAAS,EAAC,M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,gBAAgB,CAAC,CAAC;IACjG,OAAO,EAAC,eAAe,EAAE,iCAAiC,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,MAAM,EAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,yCAAyC,CACvD,MAAuB,EACvB,OAAgC,EAChC,GAAG,GAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI;IAEpC,MAAM,SAAS,GAAG,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5G,OAAO,kBAAkB,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;AACnF,CAAC"}
|
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.50.0-dev.
|
|
14
|
+
"version": "1.50.0-dev.b726a05a4d",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -68,15 +68,15 @@
|
|
|
68
68
|
"@chainsafe/as-sha256": "^1.2.5",
|
|
69
69
|
"@chainsafe/lodestar-z": "catalog:",
|
|
70
70
|
"@chainsafe/persistent-merkle-tree": "^1.3.1",
|
|
71
|
-
"@chainsafe/ssz": "^1.8.
|
|
72
|
-
"@lodestar/config": "^1.50.0-dev.
|
|
73
|
-
"@lodestar/params": "^1.50.0-dev.
|
|
74
|
-
"@lodestar/types": "^1.50.0-dev.
|
|
75
|
-
"@lodestar/utils": "^1.50.0-dev.
|
|
71
|
+
"@chainsafe/ssz": "^1.8.1",
|
|
72
|
+
"@lodestar/config": "^1.50.0-dev.b726a05a4d",
|
|
73
|
+
"@lodestar/params": "^1.50.0-dev.b726a05a4d",
|
|
74
|
+
"@lodestar/types": "^1.50.0-dev.b726a05a4d",
|
|
75
|
+
"@lodestar/utils": "^1.50.0-dev.b726a05a4d",
|
|
76
76
|
"@vekexasia/bigint-buffer2": "^1.1.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@lodestar/test-utils": "^1.50.0-dev.
|
|
79
|
+
"@lodestar/test-utils": "^1.50.0-dev.b726a05a4d"
|
|
80
80
|
},
|
|
81
81
|
"keywords": [
|
|
82
82
|
"ethereum",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"beacon",
|
|
85
85
|
"blockchain"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "56329aea78b93f7d5a9ad649e6052f718cd3190b"
|
|
88
88
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {BuilderIndex, Epoch, PubkeyHex} from "@lodestar/types";
|
|
2
|
+
import {Builder} from "@lodestar/types/gloas";
|
|
3
|
+
import {toPubkeyHex} from "@lodestar/utils";
|
|
4
|
+
import {CachedBeaconStateGloas} from "../types.js";
|
|
5
|
+
import {computeEpochAtSlot} from "../util/epoch.js";
|
|
6
|
+
import {createBuilderView} from "../util/gloas.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Block-scoped pubkey -> index map and ascending reuse candidates for `state.builders`, built in one pass.
|
|
10
|
+
* Only valid while builder pubkeys change exclusively via `addBuilderToRegistry()` and no builder becomes
|
|
11
|
+
* newly reusable (candidates are re-checked lazily, never added). Do not use across blocks/slots.
|
|
12
|
+
*/
|
|
13
|
+
export class IndexedBuilderState {
|
|
14
|
+
private readonly currentEpoch: Epoch;
|
|
15
|
+
private readonly indexByPubkey = new Map<PubkeyHex, BuilderIndex>();
|
|
16
|
+
private readonly reusableIndexCandidates: BuilderIndex[] = [];
|
|
17
|
+
private candidateCursor = 0;
|
|
18
|
+
|
|
19
|
+
constructor(readonly state: CachedBeaconStateGloas) {
|
|
20
|
+
state.builders.commit();
|
|
21
|
+
const builders = state.builders.getAllReadonlyValues();
|
|
22
|
+
this.currentEpoch = computeEpochAtSlot(state.slot);
|
|
23
|
+
for (const [index, builder] of builders.entries()) {
|
|
24
|
+
const pubkeyHex = toPubkeyHex(builder.pubkey);
|
|
25
|
+
this.indexByPubkey.set(pubkeyHex, index);
|
|
26
|
+
if (canReuseBuilder(builder, this.currentEpoch)) {
|
|
27
|
+
this.reusableIndexCandidates.push(index);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
findBuilderIndexByPubkey(pubkey: Uint8Array): BuilderIndex | null {
|
|
33
|
+
return this.indexByPubkey.get(toPubkeyHex(pubkey)) ?? null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
addBuilderToRegistry(pubkey: Uint8Array, version: number, executionAddress: Uint8Array, amount: number): void {
|
|
37
|
+
const builder = createBuilderView(pubkey, version, executionAddress, amount, this.currentEpoch);
|
|
38
|
+
const reusableIndex = this.findReusableBuilderIndex();
|
|
39
|
+
const index = reusableIndex ?? this.state.builders.length;
|
|
40
|
+
if (reusableIndex !== null) {
|
|
41
|
+
const oldBuilder = this.state.builders.getReadonly(index);
|
|
42
|
+
this.indexByPubkey.delete(toPubkeyHex(oldBuilder.pubkey));
|
|
43
|
+
this.state.builders.set(index, builder);
|
|
44
|
+
} else {
|
|
45
|
+
this.state.builders.push(builder);
|
|
46
|
+
}
|
|
47
|
+
this.indexByPubkey.set(toPubkeyHex(pubkey), index);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private findReusableBuilderIndex(): BuilderIndex | null {
|
|
51
|
+
while (this.candidateCursor < this.reusableIndexCandidates.length) {
|
|
52
|
+
const index = this.reusableIndexCandidates[this.candidateCursor++];
|
|
53
|
+
const builder = this.state.builders.getReadonly(index);
|
|
54
|
+
// Top-ups can invalidate initial candidates
|
|
55
|
+
if (canReuseBuilder(builder, this.currentEpoch)) {
|
|
56
|
+
return index;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function canReuseBuilder(builder: Builder, currentEpoch: Epoch): boolean {
|
|
64
|
+
return builder.withdrawableEpoch <= currentEpoch && builder.balance === 0;
|
|
65
|
+
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import {FAR_FUTURE_EPOCH, PAYLOAD_BUILDER_VERSION} from "@lodestar/params";
|
|
2
2
|
import {gloas} from "@lodestar/types";
|
|
3
|
-
import {CachedBeaconStateGloas} from "../types.js";
|
|
4
3
|
import {computeEpochAtSlot} from "../util/epoch.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
findBuilderIndexByPubkey,
|
|
8
|
-
isBuilderWithdrawalCredential,
|
|
9
|
-
isValidBuilderDepositSignature,
|
|
10
|
-
} from "../util/gloas.js";
|
|
4
|
+
import {isBuilderWithdrawalCredential, isValidBuilderDepositSignature} from "../util/gloas.js";
|
|
5
|
+
import {IndexedBuilderState} from "./indexedBuilderState.js";
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
8
|
* Process a builder deposit request from the execution layer: register a new builder
|
|
@@ -16,9 +11,10 @@ import {
|
|
|
16
11
|
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.11/specs/gloas/beacon-chain.md#new-process_builder_deposit_request
|
|
17
12
|
*/
|
|
18
13
|
export function processBuilderDepositRequest(
|
|
19
|
-
|
|
14
|
+
indexedState: IndexedBuilderState,
|
|
20
15
|
request: gloas.BuilderDepositRequest
|
|
21
16
|
): void {
|
|
17
|
+
const {state} = indexedState;
|
|
22
18
|
const {pubkey, withdrawalCredentials, amount, signature} = request;
|
|
23
19
|
|
|
24
20
|
// Ignore deposits with unexpected withdrawal credential prefixes.
|
|
@@ -26,18 +22,11 @@ export function processBuilderDepositRequest(
|
|
|
26
22
|
return;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
const builderIndex = findBuilderIndexByPubkey(
|
|
25
|
+
const builderIndex = indexedState.findBuilderIndexByPubkey(pubkey);
|
|
30
26
|
|
|
31
27
|
if (builderIndex === null) {
|
|
32
28
|
if (isValidBuilderDepositSignature(state.config, pubkey, withdrawalCredentials, amount, signature)) {
|
|
33
|
-
addBuilderToRegistry(
|
|
34
|
-
state,
|
|
35
|
-
pubkey,
|
|
36
|
-
PAYLOAD_BUILDER_VERSION,
|
|
37
|
-
withdrawalCredentials.subarray(12),
|
|
38
|
-
amount,
|
|
39
|
-
state.slot
|
|
40
|
-
);
|
|
29
|
+
indexedState.addBuilderToRegistry(pubkey, PAYLOAD_BUILDER_VERSION, withdrawalCredentials.subarray(12), amount);
|
|
41
30
|
}
|
|
42
31
|
return;
|
|
43
32
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import {gloas} from "@lodestar/types";
|
|
2
2
|
import {byteArrayEquals} from "@lodestar/utils";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
findBuilderIndexByPubkey,
|
|
6
|
-
getPendingBalanceToWithdrawForBuilder,
|
|
7
|
-
initiateBuilderExit,
|
|
8
|
-
isActiveBuilder,
|
|
9
|
-
} from "../util/gloas.js";
|
|
3
|
+
import {getPendingBalanceToWithdrawForBuilder, initiateBuilderExit, isActiveBuilder} from "../util/gloas.js";
|
|
4
|
+
import {IndexedBuilderState} from "./indexedBuilderState.js";
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* Apply a builder exit request. Authorizes the exit via `source_address` (the builder's
|
|
@@ -17,8 +12,9 @@ import {
|
|
|
17
12
|
*
|
|
18
13
|
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.11/specs/gloas/beacon-chain.md#new-process_builder_exit_request
|
|
19
14
|
*/
|
|
20
|
-
export function processBuilderExitRequest(
|
|
21
|
-
const
|
|
15
|
+
export function processBuilderExitRequest(indexedState: IndexedBuilderState, request: gloas.BuilderExitRequest): void {
|
|
16
|
+
const {state} = indexedState;
|
|
17
|
+
const builderIndex = indexedState.findBuilderIndexByPubkey(request.pubkey);
|
|
22
18
|
if (builderIndex === null) {
|
|
23
19
|
return;
|
|
24
20
|
}
|
|
@@ -3,6 +3,7 @@ import {BeaconBlock, gloas, ssz} from "@lodestar/types";
|
|
|
3
3
|
import {byteArrayEquals, toRootHex} from "@lodestar/utils";
|
|
4
4
|
import {CachedBeaconStateGloas} from "../types.js";
|
|
5
5
|
import {computeEpochAtSlot} from "../util/epoch.js";
|
|
6
|
+
import {IndexedBuilderState} from "./indexedBuilderState.js";
|
|
6
7
|
import {processBuilderDepositRequest} from "./processBuilderDepositRequest.js";
|
|
7
8
|
import {processBuilderExitRequest} from "./processBuilderExitRequest.js";
|
|
8
9
|
import {processConsolidationRequest} from "./processConsolidationRequest.js";
|
|
@@ -53,29 +54,8 @@ export function applyParentExecutionPayload(state: CachedBeaconStateGloas, reque
|
|
|
53
54
|
const parentEpoch = computeEpochAtSlot(parentSlot);
|
|
54
55
|
const currentEpoch = computeEpochAtSlot(state.slot);
|
|
55
56
|
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
for (const deposit of requests.deposits) {
|
|
59
|
-
processDepositRequest(fork, state, deposit);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
for (const withdrawal of requests.withdrawals) {
|
|
63
|
-
processWithdrawalRequest(fork, state, withdrawal);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
for (const consolidation of requests.consolidations) {
|
|
67
|
-
processConsolidationRequest(state, consolidation);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
for (const builderDeposit of requests.builderDeposits) {
|
|
71
|
-
processBuilderDepositRequest(state, builderDeposit);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
for (const builderExit of requests.builderExits) {
|
|
75
|
-
processBuilderExitRequest(state, builderExit);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Settle the builder payment
|
|
57
|
+
// Settle the builder payment before the requests so that a builder exit request
|
|
58
|
+
// is rejected while the payment is pending
|
|
79
59
|
if (parentEpoch === currentEpoch) {
|
|
80
60
|
settleBuilderPayment(state, SLOTS_PER_EPOCH + (parentSlot % SLOTS_PER_EPOCH));
|
|
81
61
|
} else if (parentEpoch === currentEpoch - 1) {
|
|
@@ -92,6 +72,30 @@ export function applyParentExecutionPayload(state: CachedBeaconStateGloas, reque
|
|
|
92
72
|
);
|
|
93
73
|
}
|
|
94
74
|
|
|
75
|
+
// Process execution requests from parent's payload. The execution
|
|
76
|
+
// requests are processed at state.slot (child's slot), not the parent's slot.
|
|
77
|
+
for (const deposit of requests.deposits) {
|
|
78
|
+
processDepositRequest(fork, state, deposit);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const withdrawal of requests.withdrawals) {
|
|
82
|
+
processWithdrawalRequest(fork, state, withdrawal);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for (const consolidation of requests.consolidations) {
|
|
86
|
+
processConsolidationRequest(state, consolidation);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (requests.builderDeposits.length > 0 || requests.builderExits.length > 0) {
|
|
90
|
+
const indexedState = new IndexedBuilderState(state);
|
|
91
|
+
for (const builderDeposit of requests.builderDeposits) {
|
|
92
|
+
processBuilderDepositRequest(indexedState, builderDeposit);
|
|
93
|
+
}
|
|
94
|
+
for (const builderExit of requests.builderExits) {
|
|
95
|
+
processBuilderExitRequest(indexedState, builderExit);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
95
99
|
// Update parent payload availability and latest block hash
|
|
96
100
|
state.executionPayloadAvailability.set(parentSlot % SLOTS_PER_HISTORICAL_ROOT, true);
|
|
97
101
|
state.latestBlockHash = parentBid.blockHash;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
-
import {ForkSeq
|
|
2
|
+
import {ForkSeq} from "@lodestar/params";
|
|
3
3
|
import {Slot, phase0, ssz} from "@lodestar/types";
|
|
4
4
|
import {Validator} from "@lodestar/types/phase0";
|
|
5
5
|
import {getProposerSlashingSignatureSets} from "../signatureSets/index.js";
|
|
6
|
-
import {CachedBeaconStateAllForks
|
|
6
|
+
import {CachedBeaconStateAllForks} from "../types.js";
|
|
7
7
|
import {computeEpochAtSlot, isSlashableValidator} from "../util/index.js";
|
|
8
8
|
import {verifySignatureSet} from "../util/signatureSets.js";
|
|
9
9
|
import {slashValidator} from "./slashValidator.js";
|
|
@@ -23,32 +23,6 @@ export function processProposerSlashing(
|
|
|
23
23
|
const proposer = state.validators.getReadonly(proposerSlashing.signedHeader1.message.proposerIndex);
|
|
24
24
|
assertValidProposerSlashing(state.config, state.slot, proposerSlashing, proposer, verifySignatures);
|
|
25
25
|
|
|
26
|
-
if (fork >= ForkSeq.gloas) {
|
|
27
|
-
// Remove the BuilderPendingPayment corresponding to this proposal if it is still in the
|
|
28
|
-
// 2-epoch window. Only clear it when the slashed validator is the proposer associated with
|
|
29
|
-
// the payment; otherwise an unrelated same-slot equivocation could grief an honest proposer's
|
|
30
|
-
// payment.
|
|
31
|
-
const slot = Number(proposerSlashing.signedHeader1.message.slot);
|
|
32
|
-
const proposalEpoch = computeEpochAtSlot(slot);
|
|
33
|
-
const currentEpoch = state.epochCtx.epoch;
|
|
34
|
-
const previousEpoch = currentEpoch - 1;
|
|
35
|
-
|
|
36
|
-
const paymentIndex =
|
|
37
|
-
proposalEpoch === currentEpoch
|
|
38
|
-
? SLOTS_PER_EPOCH + (slot % SLOTS_PER_EPOCH)
|
|
39
|
-
: proposalEpoch === previousEpoch
|
|
40
|
-
? slot % SLOTS_PER_EPOCH
|
|
41
|
-
: undefined;
|
|
42
|
-
|
|
43
|
-
if (paymentIndex !== undefined) {
|
|
44
|
-
const builderPendingPayments = (state as CachedBeaconStateGloas).builderPendingPayments;
|
|
45
|
-
const payment = builderPendingPayments.get(paymentIndex);
|
|
46
|
-
if (payment.proposerIndex === proposerSlashing.signedHeader1.message.proposerIndex) {
|
|
47
|
-
builderPendingPayments.set(paymentIndex, ssz.gloas.BuilderPendingPayment.defaultViewDU());
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
26
|
slashValidator(fork, state, proposerSlashing.signedHeader1.message.proposerIndex);
|
|
53
27
|
}
|
|
54
28
|
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
WHISTLEBLOWER_REWARD_QUOTIENT,
|
|
14
14
|
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA,
|
|
15
15
|
} from "@lodestar/params";
|
|
16
|
-
import {ValidatorIndex} from "@lodestar/types";
|
|
17
|
-
import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../types.js";
|
|
16
|
+
import {ValidatorIndex, ssz} from "@lodestar/types";
|
|
17
|
+
import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStateGloas} from "../types.js";
|
|
18
18
|
import {decreaseBalance, increaseBalance} from "../util/index.js";
|
|
19
19
|
import {initiateValidatorExit} from "./initiateValidatorExit.js";
|
|
20
20
|
|
|
@@ -95,4 +95,15 @@ export function slashValidator(
|
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
if (fork >= ForkSeq.gloas) {
|
|
100
|
+
// Cleared on every slashing, not only proposer slashings: a proposer slashed via an attester slashing
|
|
101
|
+
// first would otherwise keep the builder paying for a block it equivocated on
|
|
102
|
+
const {builderPendingPayments} = state as CachedBeaconStateGloas;
|
|
103
|
+
for (let i = 0; i < builderPendingPayments.length; i++) {
|
|
104
|
+
if (builderPendingPayments.getReadonly(i).proposerIndex === slashedIndex) {
|
|
105
|
+
builderPendingPayments.set(i, ssz.gloas.BuilderPendingPayment.defaultViewDU());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
98
109
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BLS_WITHDRAWAL_PREFIX,
|
|
3
|
+
FAR_FUTURE_EPOCH,
|
|
4
|
+
ForkSeq,
|
|
5
|
+
GENESIS_SLOT,
|
|
6
|
+
MAX_PENDING_DEPOSITS_PER_EPOCH,
|
|
7
|
+
} from "@lodestar/params";
|
|
2
8
|
import {electra} from "@lodestar/types";
|
|
3
9
|
import {addValidatorToRegistry, isValidDepositSignature} from "../block/processDeposit.js";
|
|
4
10
|
import {CachedBeaconStateElectra, EpochTransitionCache} from "../types.js";
|
|
@@ -71,7 +77,7 @@ export function processPendingDeposits(state: CachedBeaconStateElectra, cache: E
|
|
|
71
77
|
|
|
72
78
|
if (isValidatorWithdrawn) {
|
|
73
79
|
// Deposited balance will never become active. Increase balance but do not consume churn
|
|
74
|
-
applyPendingDeposit(state, deposit, cache);
|
|
80
|
+
applyPendingDeposit(fork, state, deposit, cache);
|
|
75
81
|
} else if (isValidatorExited) {
|
|
76
82
|
// Validator is exiting, postpone the deposit until after withdrawable epoch
|
|
77
83
|
depositsToPostpone.push(deposit);
|
|
@@ -83,7 +89,7 @@ export function processPendingDeposits(state: CachedBeaconStateElectra, cache: E
|
|
|
83
89
|
}
|
|
84
90
|
// Consume churn and apply deposit.
|
|
85
91
|
processedAmount += deposit.amount;
|
|
86
|
-
applyPendingDeposit(state, deposit, cache);
|
|
92
|
+
applyPendingDeposit(fork, state, deposit, cache);
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
// Regardless of how the deposit was handled, we move on in the queue.
|
|
@@ -110,6 +116,7 @@ export function processPendingDeposits(state: CachedBeaconStateElectra, cache: E
|
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
function applyPendingDeposit(
|
|
119
|
+
fork: ForkSeq,
|
|
113
120
|
state: CachedBeaconStateElectra,
|
|
114
121
|
deposit: electra.PendingDeposit,
|
|
115
122
|
cache: EpochTransitionCache
|
|
@@ -119,6 +126,10 @@ function applyPendingDeposit(
|
|
|
119
126
|
const cachedBalances = cache.balances;
|
|
120
127
|
|
|
121
128
|
if (!isValidatorKnown(state, validatorIndex)) {
|
|
129
|
+
// Do not create validators with BLS withdrawal credentials, the deposit is skipped without a refund
|
|
130
|
+
if (fork >= ForkSeq.heze && withdrawalCredentials[0] === BLS_WITHDRAWAL_PREFIX) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
122
133
|
// Verify the deposit signature (proof of possession) which is not checked by the deposit contract
|
|
123
134
|
if (isValidDepositSignature(state.config, pubkey, withdrawalCredentials, amount, signature)) {
|
|
124
135
|
addValidatorToRegistry(ForkSeq.electra, state, pubkey, withdrawalCredentials, amount);
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {type BlockExternalData, DataAvailabilityStatus, ExecutionPayloadStatus} from "./block/externalData.js";
|
|
2
|
+
export {IndexedBuilderState} from "./block/indexedBuilderState.js";
|
|
2
3
|
export {getAttestationParticipationStatus, processAttestationsAltair} from "./block/processAttestationsAltair.js";
|
|
3
4
|
export {assertValidAttesterSlashing} from "./block/processAttesterSlashing.js";
|
|
4
5
|
export {isValidBlsToExecutionChange} from "./block/processBlsToExecutionChange.js";
|
|
@@ -43,7 +44,7 @@ export * from "./signatureSets/index.js";
|
|
|
43
44
|
export * from "./stateTransition.js";
|
|
44
45
|
export {BeaconStateView} from "./stateView/beaconStateView.js";
|
|
45
46
|
export {
|
|
46
|
-
type
|
|
47
|
+
type BlockSTFInput,
|
|
47
48
|
type ComputeNewStateRootResult,
|
|
48
49
|
type IBeaconStateView,
|
|
49
50
|
type IBeaconStateViewAltair,
|
|
@@ -54,6 +55,7 @@ export {
|
|
|
54
55
|
type IBeaconStateViewFulu,
|
|
55
56
|
type IBeaconStateViewGloas,
|
|
56
57
|
type IBeaconStateViewHeze,
|
|
58
|
+
type IBeaconStateViewNative,
|
|
57
59
|
isStatePostAltair,
|
|
58
60
|
isStatePostBellatrix,
|
|
59
61
|
isStatePostCapella,
|
|
@@ -63,6 +65,7 @@ export {
|
|
|
63
65
|
isStatePostGloas,
|
|
64
66
|
isStatePostHeze,
|
|
65
67
|
} from "./stateView/interface.js";
|
|
68
|
+
export {NativeBeaconStateView} from "./stateView/nativeBeaconStateView.js";
|
|
66
69
|
export {createBeaconStateView, createBeaconStateViewForHistoricalRegen} from "./stateView/stateViewFactory.js";
|
|
67
70
|
export type {
|
|
68
71
|
BeaconStateAllForks,
|
|
@@ -3,7 +3,9 @@ import {BeaconConfig} from "@lodestar/config";
|
|
|
3
3
|
import {
|
|
4
4
|
EFFECTIVE_BALANCE_INCREMENT,
|
|
5
5
|
ForkName,
|
|
6
|
+
ForkSeq,
|
|
6
7
|
INACTIVITY_PENALTY_QUOTIENT_ALTAIR,
|
|
8
|
+
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX,
|
|
7
9
|
MAX_EFFECTIVE_BALANCE,
|
|
8
10
|
MAX_EFFECTIVE_BALANCE_ELECTRA,
|
|
9
11
|
PARTICIPATION_FLAG_WEIGHTS,
|
|
@@ -16,6 +18,8 @@ import {
|
|
|
16
18
|
import {ValidatorIndex, rewards} from "@lodestar/types";
|
|
17
19
|
import {fromHex} from "@lodestar/utils";
|
|
18
20
|
import {EpochTransitionCache, beforeProcessEpoch} from "../cache/epochTransitionCache.js";
|
|
21
|
+
import {processInactivityUpdates} from "../epoch/processInactivityUpdates.js";
|
|
22
|
+
import {processJustificationAndFinalization} from "../epoch/processJustificationAndFinalization.js";
|
|
19
23
|
import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../types.js";
|
|
20
24
|
import {
|
|
21
25
|
FLAG_ELIGIBLE_ATTESTER,
|
|
@@ -43,8 +47,13 @@ export async function computeAttestationsRewards(
|
|
|
43
47
|
throw Error("Unsupported fork. Attestations rewards calculation is not available in phase0");
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
// Rewards are computed after justification and inactivity updates in epoch processing, so apply both to a clone
|
|
51
|
+
// before reading finality and inactivity scores, see
|
|
52
|
+
// https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.2/specs/altair/beacon-chain.md#epoch-processing
|
|
53
|
+
const stateAltair = state.clone() as CachedBeaconStateAltair;
|
|
47
54
|
const transitionCache = beforeProcessEpoch(stateAltair);
|
|
55
|
+
processJustificationAndFinalization(stateAltair, transitionCache);
|
|
56
|
+
processInactivityUpdates(stateAltair, transitionCache);
|
|
48
57
|
|
|
49
58
|
const [idealRewards, penalties] = computeIdealAttestationsRewardsAndPenaltiesAltair(
|
|
50
59
|
config,
|
|
@@ -155,7 +164,11 @@ function computeTotalAttestationsRewardsAltair(
|
|
|
155
164
|
.map((id) => (typeof id === "number" ? id : pubkeyCache.getIndex(fromHex(id))))
|
|
156
165
|
.filter((index) => index !== undefined); // Validator indices to include in the result
|
|
157
166
|
|
|
158
|
-
const
|
|
167
|
+
const inactivityPenaltyQuotient =
|
|
168
|
+
config.getForkSeq(state.slot) === ForkSeq.altair
|
|
169
|
+
? INACTIVITY_PENALTY_QUOTIENT_ALTAIR
|
|
170
|
+
: INACTIVITY_PENALTY_QUOTIENT_BELLATRIX;
|
|
171
|
+
const inactivityPenaltyDenominator = config.INACTIVITY_SCORE_BIAS * inactivityPenaltyQuotient;
|
|
159
172
|
|
|
160
173
|
for (let i = 0; i < flags.length; i++) {
|
|
161
174
|
if (validatorIndices.length && !validatorIndices.includes(i)) {
|