@lodestar/state-transition 1.50.0-dev.c24762bc60 → 1.50.0-dev.c785f2463a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/block/index.d.ts.map +1 -1
- package/lib/block/index.js +1 -1
- package/lib/block/index.js.map +1 -1
- package/lib/block/processDeposit.d.ts +2 -2
- package/lib/block/processDeposit.d.ts.map +1 -1
- package/lib/block/processDeposit.js.map +1 -1
- package/lib/block/processEth1Data.d.ts +3 -3
- package/lib/block/processEth1Data.d.ts.map +1 -1
- package/lib/block/processEth1Data.js.map +1 -1
- package/lib/block/processOperations.d.ts.map +1 -1
- package/lib/block/processOperations.js +8 -6
- package/lib/block/processOperations.js.map +1 -1
- package/lib/cache/stateCache.d.ts +2 -1
- package/lib/cache/stateCache.d.ts.map +1 -1
- package/lib/cache/stateCache.js.map +1 -1
- package/lib/cache/types.d.ts +2 -1
- package/lib/cache/types.d.ts.map +1 -1
- package/lib/epoch/index.d.ts.map +1 -1
- package/lib/epoch/index.js +3 -1
- package/lib/epoch/index.js.map +1 -1
- package/lib/epoch/processEth1DataReset.d.ts +2 -2
- package/lib/epoch/processEth1DataReset.d.ts.map +1 -1
- package/lib/epoch/processEth1DataReset.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/slot/upgradeStateToHeze.d.ts.map +1 -1
- package/lib/slot/upgradeStateToHeze.js +4 -4
- package/lib/slot/upgradeStateToHeze.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +3 -0
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +4 -0
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/types.d.ts +2 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/util/blindedBlock.d.ts +1 -1
- package/lib/util/blindedBlock.d.ts.map +1 -1
- package/lib/util/blindedBlock.js +5 -2
- package/lib/util/blindedBlock.js.map +1 -1
- package/lib/util/clock.d.ts +5 -0
- package/lib/util/clock.d.ts.map +1 -1
- package/lib/util/clock.js +19 -16
- package/lib/util/clock.js.map +1 -1
- package/lib/util/deposit.d.ts +2 -2
- package/lib/util/deposit.d.ts.map +1 -1
- package/lib/util/deposit.js.map +1 -1
- package/lib/util/genesis.d.ts.map +1 -1
- package/lib/util/genesis.js +40 -22
- package/lib/util/genesis.js.map +1 -1
- package/lib/util/slot.d.ts +3 -1
- package/lib/util/slot.d.ts.map +1 -1
- package/lib/util/slot.js +4 -0
- package/lib/util/slot.js.map +1 -1
- package/package.json +7 -7
- package/src/block/index.ts +4 -3
- package/src/block/processDeposit.ts +7 -2
- package/src/block/processEth1Data.ts +3 -3
- package/src/block/processOperations.ts +14 -11
- package/src/cache/stateCache.ts +2 -0
- package/src/cache/types.ts +2 -1
- package/src/epoch/index.ts +4 -1
- package/src/epoch/processEth1DataReset.ts +2 -2
- package/src/index.ts +2 -0
- package/src/slot/upgradeStateToHeze.ts +6 -4
- package/src/stateView/beaconStateView.ts +5 -1
- package/src/stateView/nativeBeaconStateView.ts +3 -0
- package/src/types.ts +2 -0
- package/src/util/blindedBlock.ts +8 -3
- package/src/util/clock.ts +25 -16
- package/src/util/deposit.ts +2 -2
- package/src/util/genesis.ts +45 -28
- package/src/util/slot.ts +6 -1
package/lib/util/genesis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EFFECTIVE_BALANCE_INCREMENT, EPOCHS_PER_HISTORICAL_VECTOR, ForkSeq, GENESIS_EPOCH, GENESIS_SLOT, MAX_EFFECTIVE_BALANCE, UNSET_DEPOSIT_REQUESTS_START_INDEX, } from "@lodestar/params";
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
|
-
import { processDeposit } from "../block/processDeposit.js";
|
|
3
|
+
import { applyDeposit, processDeposit } from "../block/processDeposit.js";
|
|
4
4
|
import { createCachedBeaconState } from "../cache/stateCache.js";
|
|
5
5
|
import { increaseBalance } from "../index.js";
|
|
6
6
|
import { newFilledArray } from "./array.js";
|
|
@@ -55,7 +55,9 @@ export function getGenesisBeaconState(config, genesisEth1Data, latestBlockHeader
|
|
|
55
55
|
// Randomness and committees
|
|
56
56
|
state.latestBlockHeader = ssz.phase0.BeaconBlockHeader.toViewDU(latestBlockHeader);
|
|
57
57
|
// Ethereum 1.0 chain data
|
|
58
|
-
|
|
58
|
+
if (config.getForkSeq(GENESIS_SLOT) < ForkSeq.heze) {
|
|
59
|
+
state.eth1Data = ssz.phase0.Eth1Data.toViewDU(genesisEth1Data);
|
|
60
|
+
}
|
|
59
61
|
state.randaoMixes = ssz.phase0.RandaoMixes.toViewDU(randaoMixes);
|
|
60
62
|
return state;
|
|
61
63
|
}
|
|
@@ -66,7 +68,9 @@ export function getGenesisBeaconState(config, genesisEth1Data, latestBlockHeader
|
|
|
66
68
|
* @param eth1BlockHash eth1 block hash
|
|
67
69
|
*/
|
|
68
70
|
export function applyEth1BlockHash(state, eth1BlockHash) {
|
|
69
|
-
state.
|
|
71
|
+
if (state.config.getForkSeq(state.slot) < ForkSeq.heze) {
|
|
72
|
+
state.eth1Data.blockHash = eth1BlockHash;
|
|
73
|
+
}
|
|
70
74
|
state.randaoMixes = ssz.phase0.RandaoMixes.toViewDU(newFilledArray(EPOCHS_PER_HISTORICAL_VECTOR, eth1BlockHash));
|
|
71
75
|
}
|
|
72
76
|
/**
|
|
@@ -93,29 +97,37 @@ export function applyTimestamp(config, state, eth1Timestamp) {
|
|
|
93
97
|
*/
|
|
94
98
|
export function applyDeposits(config, state, newDeposits, fullDepositDataRootList) {
|
|
95
99
|
const fork = config.getForkSeq(state.slot);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for (let index = 0; index < depositCount; index++) {
|
|
101
|
-
depositDataRootList.push(fullDepositDataRootArr[index]);
|
|
100
|
+
if (fork >= ForkSeq.heze) {
|
|
101
|
+
// Genesis deposits do not use the removed legacy deposit tree.
|
|
102
|
+
for (const deposit of newDeposits) {
|
|
103
|
+
applyDeposit(fork, state, deposit.data);
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
else {
|
|
107
|
+
const statePreHeze = state;
|
|
108
|
+
const depositDataRootList = [];
|
|
109
|
+
const fullDepositDataRootArr = fullDepositDataRootList ? fullDepositDataRootList.getAllReadonlyValues() : null;
|
|
108
110
|
if (fullDepositDataRootArr) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
const depositCount = Number(statePreHeze.eth1Data.depositCount);
|
|
112
|
+
for (let index = 0; index < depositCount; index++) {
|
|
113
|
+
depositDataRootList.push(fullDepositDataRootArr[index]);
|
|
114
|
+
}
|
|
111
115
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
const initDepositCount = depositDataRootList.length;
|
|
117
|
+
const depositDatas = fullDepositDataRootList ? null : newDeposits.map((deposit) => deposit.data);
|
|
118
|
+
const { DepositData, DepositDataRootList } = ssz.phase0;
|
|
119
|
+
for (const [index, deposit] of newDeposits.entries()) {
|
|
120
|
+
if (fullDepositDataRootArr) {
|
|
121
|
+
depositDataRootList.push(fullDepositDataRootArr[index + initDepositCount]);
|
|
122
|
+
statePreHeze.eth1Data.depositRoot = DepositDataRootList.hashTreeRoot(depositDataRootList);
|
|
123
|
+
}
|
|
124
|
+
else if (depositDatas) {
|
|
125
|
+
const depositDataList = depositDatas.slice(0, index + 1);
|
|
126
|
+
statePreHeze.eth1Data.depositRoot = DepositDataRootList.hashTreeRoot(depositDataList.map((d) => DepositData.hashTreeRoot(d)));
|
|
127
|
+
}
|
|
128
|
+
statePreHeze.eth1Data.depositCount += 1n;
|
|
129
|
+
processDeposit(fork, statePreHeze, deposit);
|
|
115
130
|
}
|
|
116
|
-
state.eth1Data.depositCount += 1n;
|
|
117
|
-
const fork = config.getForkSeq(GENESIS_SLOT);
|
|
118
|
-
processDeposit(fork, state, deposit);
|
|
119
131
|
}
|
|
120
132
|
// Process deposit balance updates
|
|
121
133
|
if (fork >= ForkSeq.electra) {
|
|
@@ -229,7 +241,9 @@ export function initializeBeaconStateFromEth1(config, immutableData, eth1BlockHa
|
|
|
229
241
|
stateElectra.latestExecutionPayloadHeader =
|
|
230
242
|
executionPayloadHeader ??
|
|
231
243
|
ssz.electra.ExecutionPayloadHeader.defaultViewDU();
|
|
232
|
-
|
|
244
|
+
if (fork < ForkSeq.heze) {
|
|
245
|
+
stateElectra.depositRequestsStartIndex = UNSET_DEPOSIT_REQUESTS_START_INDEX;
|
|
246
|
+
}
|
|
233
247
|
}
|
|
234
248
|
if (fork >= ForkSeq.fulu) {
|
|
235
249
|
const stateFulu = state;
|
|
@@ -238,6 +252,10 @@ export function initializeBeaconStateFromEth1(config, immutableData, eth1BlockHa
|
|
|
238
252
|
stateFulu.latestExecutionPayloadHeader =
|
|
239
253
|
executionPayloadHeader ??
|
|
240
254
|
ssz.fulu.ExecutionPayloadHeader.defaultViewDU();
|
|
255
|
+
if (fork < ForkSeq.heze) {
|
|
256
|
+
// Fulu retires the legacy bridge after the genesis deposits.
|
|
257
|
+
stateFulu.depositRequestsStartIndex = BigInt(stateFulu.eth1DepositIndex);
|
|
258
|
+
}
|
|
241
259
|
}
|
|
242
260
|
if (fork >= ForkSeq.gloas) {
|
|
243
261
|
const stateGloas = state;
|
package/lib/util/genesis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genesis.js","sourceRoot":"","sources":["../../src/util/genesis.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAE5B,OAAO,EACP,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,kCAAkC,GACnC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAqC,GAAG,EAAC,MAA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I,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,KAAqD,CAAC;QACxE,SAAS,CAAC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAC1D,SAAS,CAAC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,MAAM,EAAE,CAAC;IAEf,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/lib/util/slot.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { ChainConfig } from "@lodestar/config";
|
|
1
|
+
import { ChainConfig, ChainForkConfig } from "@lodestar/config";
|
|
2
2
|
import { Epoch, Slot, TimeSeconds } from "@lodestar/types";
|
|
3
|
+
/** Slot duration in ms for a given slot */
|
|
4
|
+
export declare function getSlotDurationMs(config: ChainForkConfig, slot: Slot): number;
|
|
3
5
|
export declare function getSlotsSinceGenesis(config: ChainConfig, genesisTime: TimeSeconds): Slot;
|
|
4
6
|
export declare function getCurrentSlot(config: ChainConfig, genesisTime: TimeSeconds): Slot;
|
|
5
7
|
export declare function computeSlotsSinceEpochStart(slot: Slot, epoch?: Epoch): Slot;
|
package/lib/util/slot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAGzD,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7E;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAGxF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAElF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAG3E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,WAAW,CAExG"}
|
package/lib/util/slot.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { GENESIS_SLOT } from "@lodestar/params";
|
|
2
2
|
import { computeEpochAtSlot, computeStartSlotAtEpoch } from "./epoch.js";
|
|
3
|
+
/** Slot duration in ms for a given slot */
|
|
4
|
+
export function getSlotDurationMs(config, slot) {
|
|
5
|
+
return config.getSlotDurationMs(config.getForkName(slot));
|
|
6
|
+
}
|
|
3
7
|
export function getSlotsSinceGenesis(config, genesisTime) {
|
|
4
8
|
const diffInSeconds = Date.now() / 1000 - genesisTime;
|
|
5
9
|
return Math.floor(diffInSeconds / (config.SLOT_DURATION_MS / 1000));
|
package/lib/util/slot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAEvE,MAAM,UAAU,oBAAoB,CAAC,MAAmB,EAAE,WAAwB;IAChF,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,WAAW,CAAC;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa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,GAAG,oBAAoB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,IAAU,EAAE,KAAa;IACnE,MAAM,YAAY,GAAG,KAAK,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,IAAI,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAmB,EAAE,IAAU,EAAE,WAAwB;IACzF,OAAO,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;AAC/D,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.c785f2463a",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
"@chainsafe/lodestar-z": "catalog:",
|
|
70
70
|
"@chainsafe/persistent-merkle-tree": "^1.3.1",
|
|
71
71
|
"@chainsafe/ssz": "^1.8.1",
|
|
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.
|
|
72
|
+
"@lodestar/config": "^1.50.0-dev.c785f2463a",
|
|
73
|
+
"@lodestar/params": "^1.50.0-dev.c785f2463a",
|
|
74
|
+
"@lodestar/types": "^1.50.0-dev.c785f2463a",
|
|
75
|
+
"@lodestar/utils": "^1.50.0-dev.c785f2463a",
|
|
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.c785f2463a"
|
|
80
80
|
},
|
|
81
81
|
"keywords": [
|
|
82
82
|
"ethereum",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"beacon",
|
|
85
85
|
"blockchain"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "478b2a501b90e13d159ae83ed71ee20400b805be"
|
|
88
88
|
}
|
package/src/block/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ForkPostGloas, ForkSeq} from "@lodestar/params";
|
|
1
|
+
import {ForkPostGloas, ForkPreHeze, ForkSeq} from "@lodestar/params";
|
|
2
2
|
import {BeaconBlock, BlindedBeaconBlock, Slot, altair, capella} from "@lodestar/types";
|
|
3
3
|
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
4
4
|
import {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CachedBeaconStateBellatrix,
|
|
7
7
|
CachedBeaconStateCapella,
|
|
8
8
|
CachedBeaconStateGloas,
|
|
9
|
+
CachedBeaconStatePreHeze,
|
|
9
10
|
} from "../types.js";
|
|
10
11
|
import {getFullOrBlindedPayload, isExecutionEnabled} from "../util/execution.js";
|
|
11
12
|
import {BlockExternalData, DataAvailabilityStatus} from "./externalData.js";
|
|
@@ -117,9 +118,9 @@ export function processBlock(
|
|
|
117
118
|
timer?.();
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
{
|
|
121
|
+
if (fork < ForkSeq.heze) {
|
|
121
122
|
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processEth1Data});
|
|
122
|
-
processEth1Data(state, block.body.eth1Data);
|
|
123
|
+
processEth1Data(state as CachedBeaconStatePreHeze, (block as BeaconBlock<ForkPreHeze>).body.eth1Data);
|
|
123
124
|
timer?.();
|
|
124
125
|
}
|
|
125
126
|
|
|
@@ -17,7 +17,12 @@ import {
|
|
|
17
17
|
import {BLSPubkey, Bytes32, UintNum64, electra, phase0, ssz} from "@lodestar/types";
|
|
18
18
|
import {verifyMerkleBranch} from "@lodestar/utils";
|
|
19
19
|
import {ZERO_HASH} from "../constants/index.js";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
CachedBeaconStateAllForks,
|
|
22
|
+
CachedBeaconStateAltair,
|
|
23
|
+
CachedBeaconStateElectra,
|
|
24
|
+
CachedBeaconStatePreHeze,
|
|
25
|
+
} from "../types.js";
|
|
21
26
|
import {
|
|
22
27
|
computeDomain,
|
|
23
28
|
computeSigningRoot,
|
|
@@ -33,7 +38,7 @@ import {
|
|
|
33
38
|
*
|
|
34
39
|
* PERF: Work depends on number of Deposit per block. On regular networks the average is 0 / block.
|
|
35
40
|
*/
|
|
36
|
-
export function processDeposit(fork: ForkSeq, state:
|
|
41
|
+
export function processDeposit(fork: ForkSeq, state: CachedBeaconStatePreHeze, deposit: phase0.Deposit): void {
|
|
37
42
|
// verify the merkle branch
|
|
38
43
|
if (
|
|
39
44
|
!verifyMerkleBranch(
|
|
@@ -2,7 +2,7 @@ import {Node} from "@chainsafe/persistent-merkle-tree";
|
|
|
2
2
|
import {CompositeViewDU} from "@chainsafe/ssz";
|
|
3
3
|
import {EPOCHS_PER_ETH1_VOTING_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
4
4
|
import {phase0, ssz} from "@lodestar/types";
|
|
5
|
-
import {
|
|
5
|
+
import {BeaconStatePreHeze, CachedBeaconStatePreHeze} from "../types.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Store vote counts for every eth-execution block that has votes; if any eth-execution block wins majority support within a 1024-slot
|
|
@@ -12,7 +12,7 @@ import {BeaconStateAllForks, CachedBeaconStateAllForks} from "../types.js";
|
|
|
12
12
|
* - Best case: Vote is already decided, zero work. See becomesNewEth1Data conditions
|
|
13
13
|
* - Worst case: 1023 votes and no majority vote yet.
|
|
14
14
|
*/
|
|
15
|
-
export function processEth1Data(state:
|
|
15
|
+
export function processEth1Data(state: CachedBeaconStatePreHeze, eth1Data: phase0.Eth1Data): void {
|
|
16
16
|
// Convert to view first to hash once and compare hashes
|
|
17
17
|
const eth1DataView = ssz.phase0.Eth1Data.toViewDU(eth1Data);
|
|
18
18
|
|
|
@@ -28,7 +28,7 @@ export function processEth1Data(state: CachedBeaconStateAllForks, eth1Data: phas
|
|
|
28
28
|
* result in a change to `state.eth1Data`.
|
|
29
29
|
*/
|
|
30
30
|
export function becomesNewEth1Data(
|
|
31
|
-
state:
|
|
31
|
+
state: BeaconStatePreHeze,
|
|
32
32
|
newEth1Data: CompositeViewDU<typeof ssz.phase0.Eth1Data>
|
|
33
33
|
): boolean {
|
|
34
34
|
const SLOTS_PER_ETH1_VOTING_PERIOD = EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ForkSeq} from "@lodestar/params";
|
|
1
|
+
import {ForkPreHeze, ForkSeq} from "@lodestar/params";
|
|
2
2
|
import {BeaconBlockBody, Slot, capella, electra, gloas} from "@lodestar/types";
|
|
3
3
|
import {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
4
4
|
import {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CachedBeaconStateCapella,
|
|
7
7
|
CachedBeaconStateElectra,
|
|
8
8
|
CachedBeaconStateGloas,
|
|
9
|
+
CachedBeaconStatePreHeze,
|
|
9
10
|
} from "../types.js";
|
|
10
11
|
import {getEth1DepositCount} from "../util/deposit.js";
|
|
11
12
|
import {processAttestations} from "./processAttestations.js";
|
|
@@ -40,13 +41,15 @@ export function processOperations(
|
|
|
40
41
|
opts: ProcessBlockOpts = {verifySignatures: true},
|
|
41
42
|
metrics?: BeaconStateTransitionMetrics | null
|
|
42
43
|
): void {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
if (fork < ForkSeq.heze) {
|
|
45
|
+
// From Fulu the eth1 bridge deposit mechanism was removed, so blocks must not contain any deposits.
|
|
46
|
+
const deposits = (body as BeaconBlockBody<ForkPreHeze>).deposits;
|
|
47
|
+
const maxDeposits = fork >= ForkSeq.fulu ? 0 : getEth1DepositCount(state as CachedBeaconStatePreHeze);
|
|
48
|
+
if (deposits.length !== maxDeposits) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Block contains incorrect number of deposits: depositCount=${deposits.length} expected=${maxDeposits}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
{
|
|
@@ -71,10 +74,10 @@ export function processOperations(
|
|
|
71
74
|
timer?.();
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
{
|
|
77
|
+
if (fork < ForkSeq.heze) {
|
|
75
78
|
const timer = metrics?.processOperationsStepTime.startTimer({step: ProcessOperationsStep.processDeposit});
|
|
76
|
-
for (const deposit of body.deposits) {
|
|
77
|
-
processDeposit(fork, state, deposit);
|
|
79
|
+
for (const deposit of (body as BeaconBlockBody<ForkPreHeze>).deposits) {
|
|
80
|
+
processDeposit(fork, state as CachedBeaconStatePreHeze, deposit);
|
|
78
81
|
}
|
|
79
82
|
timer?.();
|
|
80
83
|
}
|
package/src/cache/stateCache.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
BeaconStateGloas,
|
|
16
16
|
BeaconStateHeze,
|
|
17
17
|
BeaconStatePhase0,
|
|
18
|
+
BeaconStatePreHeze,
|
|
18
19
|
} from "./types.js";
|
|
19
20
|
|
|
20
21
|
export type BeaconStateCache = {
|
|
@@ -142,6 +143,7 @@ export type CachedBeaconStateHeze = CachedBeaconState<BeaconStateHeze>;
|
|
|
142
143
|
|
|
143
144
|
export type CachedBeaconStateAllForks = CachedBeaconState<BeaconStateAllForks>;
|
|
144
145
|
export type CachedBeaconStateExecutions = CachedBeaconState<BeaconStateExecutions>;
|
|
146
|
+
export type CachedBeaconStatePreHeze = CachedBeaconState<BeaconStatePreHeze>;
|
|
145
147
|
/**
|
|
146
148
|
* Create CachedBeaconState computing a new EpochCache instance
|
|
147
149
|
* TODO ELECTRA: rename this to createFinalizedCachedBeaconState() as it's intended for finalized state only
|
package/src/cache/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {CompositeViewDU} from "@chainsafe/ssz";
|
|
2
|
-
import {ForkAll, ForkName, ForkPostBellatrix, ForkPreGloas} from "@lodestar/params";
|
|
2
|
+
import {ForkAll, ForkName, ForkPostBellatrix, ForkPreGloas, ForkPreHeze} from "@lodestar/params";
|
|
3
3
|
import {Epoch, RootHex, SSZTypesFor} from "@lodestar/types";
|
|
4
4
|
import {EpochShuffling} from "../util/epochShuffling.js";
|
|
5
5
|
|
|
@@ -15,5 +15,6 @@ export type BeaconStateHeze = CompositeViewDU<SSZTypesFor<ForkName.heze, "Beacon
|
|
|
15
15
|
|
|
16
16
|
export type BeaconStateAllForks = CompositeViewDU<SSZTypesFor<ForkAll, "BeaconState">>;
|
|
17
17
|
export type BeaconStateExecutions = CompositeViewDU<SSZTypesFor<ForkPostBellatrix & ForkPreGloas, "BeaconState">>;
|
|
18
|
+
export type BeaconStatePreHeze = CompositeViewDU<SSZTypesFor<ForkPreHeze, "BeaconState">>;
|
|
18
19
|
|
|
19
20
|
export type ShufflingGetter = (shufflingEpoch: Epoch, dependentRoot: RootHex) => EpochShuffling | null;
|
package/src/epoch/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
CachedBeaconStateFulu,
|
|
15
15
|
CachedBeaconStateGloas,
|
|
16
16
|
CachedBeaconStatePhase0,
|
|
17
|
+
CachedBeaconStatePreHeze,
|
|
17
18
|
EpochTransitionCache,
|
|
18
19
|
} from "../types.js";
|
|
19
20
|
import {processBuilderPendingPayments} from "./processBuilderPendingPayments.js";
|
|
@@ -140,7 +141,9 @@ export function processEpoch(
|
|
|
140
141
|
timer?.();
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
if (fork < ForkSeq.heze) {
|
|
145
|
+
processEth1DataReset(state as CachedBeaconStatePreHeze, cache);
|
|
146
|
+
}
|
|
144
147
|
|
|
145
148
|
if (fork >= ForkSeq.electra) {
|
|
146
149
|
const stateElectra = state as CachedBeaconStateElectra;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {EPOCHS_PER_ETH1_VOTING_PERIOD} from "@lodestar/params";
|
|
2
2
|
import {ssz} from "@lodestar/types";
|
|
3
|
-
import {
|
|
3
|
+
import {CachedBeaconStatePreHeze, EpochTransitionCache} from "../types.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Reset eth1DataVotes tree every `EPOCHS_PER_ETH1_VOTING_PERIOD`.
|
|
7
7
|
*
|
|
8
8
|
* PERF: Almost no (constant) cost
|
|
9
9
|
*/
|
|
10
|
-
export function processEth1DataReset(state:
|
|
10
|
+
export function processEth1DataReset(state: CachedBeaconStatePreHeze, cache: EpochTransitionCache): void {
|
|
11
11
|
const nextEpoch = cache.currentEpoch + 1;
|
|
12
12
|
|
|
13
13
|
// reset eth1 data votes
|
package/src/index.ts
CHANGED
|
@@ -80,6 +80,7 @@ export type {
|
|
|
80
80
|
BeaconStateHeze,
|
|
81
81
|
// Non-cached states
|
|
82
82
|
BeaconStatePhase0,
|
|
83
|
+
BeaconStatePreHeze,
|
|
83
84
|
CachedBeaconStateAllForks,
|
|
84
85
|
CachedBeaconStateAltair,
|
|
85
86
|
CachedBeaconStateBellatrix,
|
|
@@ -91,5 +92,6 @@ export type {
|
|
|
91
92
|
CachedBeaconStateGloas,
|
|
92
93
|
CachedBeaconStateHeze,
|
|
93
94
|
CachedBeaconStatePhase0,
|
|
95
|
+
CachedBeaconStatePreHeze,
|
|
94
96
|
} from "./types.js";
|
|
95
97
|
export * from "./util/index.js";
|
|
@@ -7,6 +7,12 @@ import {CachedBeaconStateGloas, CachedBeaconStateHeze} from "../types.js";
|
|
|
7
7
|
* Spec: heze/fork.md `upgrade_to_heze`.
|
|
8
8
|
*/
|
|
9
9
|
export function upgradeStateToHeze(stateGloas: CachedBeaconStateGloas): CachedBeaconStateHeze {
|
|
10
|
+
// In Heze, the old deposit mechanism must be fully drained before the fork
|
|
11
|
+
if (BigInt(stateGloas.eth1DepositIndex) !== stateGloas.depositRequestsStartIndex) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Cannot upgrade to Heze: legacy deposit mechanism still active eth1DepositIndex=${stateGloas.eth1DepositIndex} depositRequestsStartIndex=${stateGloas.depositRequestsStartIndex}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
10
16
|
const {config} = stateGloas;
|
|
11
17
|
|
|
12
18
|
ssz.gloas.BeaconState.commitViewDU(stateGloas);
|
|
@@ -26,9 +32,6 @@ export function upgradeStateToHeze(stateGloas: CachedBeaconStateGloas): CachedBe
|
|
|
26
32
|
stateHezeView.blockRoots = stateHezeCloned.blockRoots;
|
|
27
33
|
stateHezeView.stateRoots = stateHezeCloned.stateRoots;
|
|
28
34
|
stateHezeView.historicalRoots = stateHezeCloned.historicalRoots;
|
|
29
|
-
stateHezeView.eth1Data = stateHezeCloned.eth1Data;
|
|
30
|
-
stateHezeView.eth1DataVotes = stateHezeCloned.eth1DataVotes;
|
|
31
|
-
stateHezeView.eth1DepositIndex = stateHezeCloned.eth1DepositIndex;
|
|
32
35
|
stateHezeView.validators = stateHezeCloned.validators;
|
|
33
36
|
stateHezeView.balances = stateHezeCloned.balances;
|
|
34
37
|
stateHezeView.randaoMixes = stateHezeCloned.randaoMixes;
|
|
@@ -46,7 +49,6 @@ export function upgradeStateToHeze(stateGloas: CachedBeaconStateGloas): CachedBe
|
|
|
46
49
|
stateHezeView.nextWithdrawalIndex = stateHezeCloned.nextWithdrawalIndex;
|
|
47
50
|
stateHezeView.nextWithdrawalValidatorIndex = stateHezeCloned.nextWithdrawalValidatorIndex;
|
|
48
51
|
stateHezeView.historicalSummaries = stateHezeCloned.historicalSummaries;
|
|
49
|
-
stateHezeView.depositRequestsStartIndex = stateHezeCloned.depositRequestsStartIndex;
|
|
50
52
|
stateHezeView.depositBalanceToConsume = stateHezeCloned.depositBalanceToConsume;
|
|
51
53
|
stateHezeView.exitBalanceToConsume = stateHezeCloned.exitBalanceToConsume;
|
|
52
54
|
stateHezeView.earliestExitEpoch = stateHezeCloned.earliestExitEpoch;
|
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
CachedBeaconStateExecutions,
|
|
41
41
|
CachedBeaconStateFulu,
|
|
42
42
|
CachedBeaconStateGloas,
|
|
43
|
+
CachedBeaconStatePreHeze,
|
|
43
44
|
createCachedBeaconState,
|
|
44
45
|
isStateValidatorsNodesPopulated,
|
|
45
46
|
} from "../cache/stateCache.js";
|
|
@@ -145,7 +146,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
get eth1Data(): phase0.Eth1Data {
|
|
148
|
-
|
|
149
|
+
if (this.forkSeq >= ForkSeq.heze) {
|
|
150
|
+
throw new Error("eth1Data was removed from the beacon state in Heze");
|
|
151
|
+
}
|
|
152
|
+
return (this.cachedState as CachedBeaconStatePreHeze).eth1Data;
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
get latestBlockHeader(): phase0.BeaconBlockHeader {
|
|
@@ -228,6 +228,9 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
get eth1Data(): phase0.Eth1Data {
|
|
231
|
+
if (this.forkSeq >= ForkSeq.heze) {
|
|
232
|
+
throw new Error("eth1Data was removed from the beacon state in Heze");
|
|
233
|
+
}
|
|
231
234
|
if (this.cachedEth1Data === null) {
|
|
232
235
|
this.cachedEth1Data = this.binding.eth1Data;
|
|
233
236
|
}
|
package/src/types.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type {
|
|
|
12
12
|
CachedBeaconStateGloas,
|
|
13
13
|
CachedBeaconStateHeze,
|
|
14
14
|
CachedBeaconStatePhase0,
|
|
15
|
+
CachedBeaconStatePreHeze,
|
|
15
16
|
} from "./cache/stateCache.js";
|
|
16
17
|
export type {
|
|
17
18
|
BeaconStateAllForks,
|
|
@@ -25,5 +26,6 @@ export type {
|
|
|
25
26
|
BeaconStateGloas,
|
|
26
27
|
BeaconStateHeze,
|
|
27
28
|
BeaconStatePhase0,
|
|
29
|
+
BeaconStatePreHeze,
|
|
28
30
|
ShufflingGetter,
|
|
29
31
|
} from "./cache/types.js";
|
package/src/util/blindedBlock.ts
CHANGED
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
ForkName,
|
|
4
4
|
ForkPostBellatrix,
|
|
5
5
|
ForkPostDeneb,
|
|
6
|
+
ForkPreDeneb,
|
|
6
7
|
ForkPreGloas,
|
|
7
8
|
ForkSeq,
|
|
8
9
|
isForkPostBellatrix,
|
|
9
10
|
isForkPostDeneb,
|
|
11
|
+
isForkPostGloas,
|
|
10
12
|
} from "@lodestar/params";
|
|
11
13
|
import {
|
|
12
14
|
BeaconBlock,
|
|
@@ -128,7 +130,10 @@ export function reconstructSignedBlockContents(
|
|
|
128
130
|
signedBlindedBlock: SignedBlindedBeaconBlock,
|
|
129
131
|
executionPayload: ExecutionPayload | null,
|
|
130
132
|
blobsBundle: BlobsBundle | null
|
|
131
|
-
): SignedBlockContents {
|
|
133
|
+
): SignedBlockContents<ForkPreGloas> {
|
|
134
|
+
if (isForkPostGloas(fork)) {
|
|
135
|
+
throw Error("Blinded block reconstruction is not supported after Gloas");
|
|
136
|
+
}
|
|
132
137
|
const signedBlock = signedBlindedBlockToFull(fork, signedBlindedBlock, executionPayload);
|
|
133
138
|
|
|
134
139
|
if (isForkPostDeneb(fork)) {
|
|
@@ -136,10 +141,10 @@ export function reconstructSignedBlockContents(
|
|
|
136
141
|
throw Error("Missing blobs bundle to reconstruct post-deneb block contents");
|
|
137
142
|
}
|
|
138
143
|
return {
|
|
139
|
-
signedBlock: signedBlock as SignedBeaconBlock<ForkPostDeneb>,
|
|
144
|
+
signedBlock: signedBlock as SignedBeaconBlock<ForkPostDeneb & ForkPreGloas>,
|
|
140
145
|
kzgProofs: blobsBundle.proofs,
|
|
141
146
|
blobs: blobsBundle.blobs,
|
|
142
147
|
};
|
|
143
148
|
}
|
|
144
|
-
return {signedBlock};
|
|
149
|
+
return {signedBlock: signedBlock as SignedBeaconBlock<ForkPreDeneb>};
|
|
145
150
|
}
|
package/src/util/clock.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
-
import {
|
|
2
|
+
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
3
3
|
import {Epoch, Slot, TimeSeconds} from "@lodestar/types";
|
|
4
4
|
import {ErrorAborted, Logger, isErrorAborted, sleep} from "@lodestar/utils";
|
|
5
5
|
import {computeEpochAtSlot} from "./epoch.js";
|
|
6
|
-
import {computeTimeAtSlot, getCurrentSlot} from "./slot.js";
|
|
6
|
+
import {computeTimeAtSlot, getCurrentSlot, getSlotDurationMs} from "./slot.js";
|
|
7
7
|
|
|
8
8
|
type RunEveryFn = (slot: Slot, signal: AbortSignal) => Promise<void>;
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ export type ClockOptions = {
|
|
|
13
13
|
|
|
14
14
|
export interface IClock {
|
|
15
15
|
readonly genesisTime: number;
|
|
16
|
+
/** @deprecated Use getSlotDurationMs(slot) instead */
|
|
16
17
|
readonly secondsPerSlot: number;
|
|
17
18
|
|
|
18
19
|
readonly currentEpoch: number;
|
|
@@ -25,6 +26,8 @@ export interface IClock {
|
|
|
25
26
|
secFromSlot(slot: Slot): number;
|
|
26
27
|
getCurrentSlot(): Slot;
|
|
27
28
|
getCurrentEpoch(): Epoch;
|
|
29
|
+
/** Slot duration in ms for a given slot */
|
|
30
|
+
getSlotDurationMs(slot: Slot): number;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
export enum TimeItem {
|
|
@@ -95,6 +98,11 @@ export class Clock implements IClock {
|
|
|
95
98
|
return Date.now() / 1000 - computeTimeAtSlot(this.config, slot, this.genesisTime);
|
|
96
99
|
}
|
|
97
100
|
|
|
101
|
+
/** Slot duration in ms for a given slot */
|
|
102
|
+
getSlotDurationMs(slot: Slot): number {
|
|
103
|
+
return getSlotDurationMs(this.config, slot);
|
|
104
|
+
}
|
|
105
|
+
|
|
98
106
|
/**
|
|
99
107
|
* If a task happens to take more than one slot to run, we might skip a slot. This is unfortunate,
|
|
100
108
|
* however the alternative is to *always* process every slot, which has the chance of creating a
|
|
@@ -145,20 +153,17 @@ export class Clock implements IClock {
|
|
|
145
153
|
}
|
|
146
154
|
|
|
147
155
|
private timeUntilNext(timeItem: TimeItem): number {
|
|
148
|
-
const
|
|
149
|
-
const msFromGenesis = Date.now() - this.genesisTime * 1000;
|
|
156
|
+
const currentSlot = getCurrentSlot(this.config, this.genesisTime);
|
|
150
157
|
|
|
151
158
|
if (timeItem === TimeItem.Slot) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
return Math.abs(msFromGenesis) % milliSecondsPerSlot;
|
|
159
|
+
const nextSlotTimeSec = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime);
|
|
160
|
+
return Math.max(0, nextSlotTimeSec * 1000 - Date.now());
|
|
156
161
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return Math.
|
|
162
|
+
|
|
163
|
+
const currentEpoch = computeEpochAtSlot(currentSlot);
|
|
164
|
+
const nextEpochSlot = (currentEpoch + 1) * SLOTS_PER_EPOCH;
|
|
165
|
+
const nextEpochTimeSec = computeTimeAtSlot(this.config, nextEpochSlot, this.genesisTime);
|
|
166
|
+
return Math.max(0, nextEpochTimeSec * 1000 - Date.now());
|
|
162
167
|
}
|
|
163
168
|
}
|
|
164
169
|
|
|
@@ -166,9 +171,13 @@ export class Clock implements IClock {
|
|
|
166
171
|
* Same to the spec but we use Math.round instead of Math.floor.
|
|
167
172
|
*/
|
|
168
173
|
export function getCurrentSlotAround(config: ChainForkConfig, genesisTime: TimeSeconds): Slot {
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
174
|
+
const floorSlot = getCurrentSlot(config, genesisTime);
|
|
175
|
+
const slotStartSec = computeTimeAtSlot(config, floorSlot, genesisTime);
|
|
176
|
+
const slotDurationMs = getSlotDurationMs(config, floorSlot);
|
|
177
|
+
const slotDurationSec = slotDurationMs / 1000;
|
|
178
|
+
const elapsed = Date.now() / 1000 - slotStartSec;
|
|
179
|
+
|
|
180
|
+
return elapsed >= slotDurationSec / 2 ? floorSlot + 1 : floorSlot;
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
// function useEventStream() {
|