@lodestar/state-transition 1.48.0-dev.e9c9b8835d → 1.48.0-dev.fd70e5fc15
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 +11 -41
- package/lib/block/index.js.map +1 -1
- package/lib/block/processOperations.d.ts.map +1 -1
- package/lib/block/processOperations.js +16 -61
- package/lib/block/processOperations.js.map +1 -1
- package/lib/block/processPayloadAttestation.d.ts +1 -1
- package/lib/block/processPayloadAttestation.d.ts.map +1 -1
- package/lib/block/processPayloadAttestation.js +2 -2
- package/lib/block/processPayloadAttestation.js.map +1 -1
- package/lib/block/types.d.ts +0 -30
- package/lib/block/types.d.ts.map +1 -1
- package/lib/block/types.js +0 -32
- package/lib/block/types.js.map +1 -1
- package/lib/epoch/processPtcWindow.d.ts.map +1 -1
- package/lib/epoch/processPtcWindow.js +9 -12
- package/lib/epoch/processPtcWindow.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/metrics.d.ts +1 -7
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +1 -12
- package/lib/metrics.js.map +1 -1
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +0 -8
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +0 -4
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +0 -9
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +0 -1
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +0 -1
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +0 -3
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +1 -1
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/seed.d.ts +1 -1
- package/lib/util/seed.d.ts.map +1 -1
- package/lib/util/seed.js +11 -14
- package/lib/util/seed.js.map +1 -1
- package/package.json +7 -7
- package/src/block/index.ts +15 -48
- package/src/block/processOperations.ts +17 -62
- package/src/block/processPayloadAttestation.ts +2 -3
- package/src/block/types.ts +0 -32
- package/src/epoch/processPtcWindow.ts +8 -15
- package/src/index.ts +1 -1
- package/src/metrics.ts +2 -13
- package/src/signatureSets/index.ts +3 -17
- package/src/stateView/beaconStateView.ts +0 -12
- package/src/stateView/interface.ts +0 -1
- package/src/stateView/nativeBeaconStateView.ts +0 -4
- package/src/util/gloas.ts +0 -1
- package/src/util/seed.ts +13 -25
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.48.0-dev.
|
|
14
|
+
"version": "1.48.0-dev.fd70e5fc15",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -70,14 +70,14 @@
|
|
|
70
70
|
"@chainsafe/persistent-merkle-tree": "^1.3.1",
|
|
71
71
|
"@chainsafe/ssz": "^1.7.0",
|
|
72
72
|
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
73
|
-
"@lodestar/config": "^1.48.0-dev.
|
|
74
|
-
"@lodestar/params": "^1.48.0-dev.
|
|
75
|
-
"@lodestar/types": "^1.48.0-dev.
|
|
76
|
-
"@lodestar/utils": "^1.48.0-dev.
|
|
73
|
+
"@lodestar/config": "^1.48.0-dev.fd70e5fc15",
|
|
74
|
+
"@lodestar/params": "^1.48.0-dev.fd70e5fc15",
|
|
75
|
+
"@lodestar/types": "^1.48.0-dev.fd70e5fc15",
|
|
76
|
+
"@lodestar/utils": "^1.48.0-dev.fd70e5fc15",
|
|
77
77
|
"@vekexasia/bigint-buffer2": "^1.1.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@lodestar/api": "^1.48.0-dev.
|
|
80
|
+
"@lodestar/api": "^1.48.0-dev.fd70e5fc15"
|
|
81
81
|
},
|
|
82
82
|
"keywords": [
|
|
83
83
|
"ethereum",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"beacon",
|
|
86
86
|
"blockchain"
|
|
87
87
|
],
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "dbc49c8fa4a2870bc2b4b102fe61a4d2909621fa"
|
|
89
89
|
}
|
package/src/block/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {processPayloadAttestation} from "./processPayloadAttestation.js";
|
|
|
20
20
|
import {processRandao} from "./processRandao.js";
|
|
21
21
|
import {processSyncAggregate} from "./processSyncCommittee.js";
|
|
22
22
|
import {processWithdrawals} from "./processWithdrawals.js";
|
|
23
|
-
import {
|
|
23
|
+
import {ProcessBlockOpts, ProposerRewardType} from "./types.js";
|
|
24
24
|
|
|
25
25
|
// Spec tests
|
|
26
26
|
export {
|
|
@@ -60,31 +60,21 @@ export function processBlock(
|
|
|
60
60
|
// Apply the parent's deferred payload effects before everything else. Must run before
|
|
61
61
|
// processBlockHeader and processExecutionPayloadBid so subsequent steps see the updated state.
|
|
62
62
|
if (fork >= ForkSeq.gloas) {
|
|
63
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processParentExecutionPayload});
|
|
64
63
|
processParentExecutionPayload(state as CachedBeaconStateGloas, block as BeaconBlock<ForkPostGloas>);
|
|
65
|
-
timer?.();
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processBlockHeader});
|
|
70
|
-
processBlockHeader(state, block);
|
|
71
|
-
timer?.();
|
|
72
|
-
}
|
|
66
|
+
processBlockHeader(state, block);
|
|
73
67
|
|
|
74
|
-
if (fork >= ForkSeq.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
fullOrBlindedPayload as capella.FullOrBlindedExecutionPayload
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
timer?.();
|
|
68
|
+
if (fork >= ForkSeq.gloas) {
|
|
69
|
+
// Parent payload's execution requests were already applied by processParentExecutionPayload above
|
|
70
|
+
processWithdrawals(fork, state as CachedBeaconStateGloas);
|
|
71
|
+
} else if (fork >= ForkSeq.capella) {
|
|
72
|
+
const fullOrBlindedPayload = getFullOrBlindedPayload(block);
|
|
73
|
+
processWithdrawals(
|
|
74
|
+
fork,
|
|
75
|
+
state as CachedBeaconStateCapella,
|
|
76
|
+
fullOrBlindedPayload as capella.FullOrBlindedExecutionPayload
|
|
77
|
+
);
|
|
88
78
|
}
|
|
89
79
|
|
|
90
80
|
// The call to the process_execution_payload must happen before the call to the process_randao as the former depends
|
|
@@ -97,48 +87,25 @@ export function processBlock(
|
|
|
97
87
|
fork >= ForkSeq.bellatrix &&
|
|
98
88
|
isExecutionEnabled(state as CachedBeaconStateBellatrix, block)
|
|
99
89
|
) {
|
|
100
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processExecutionPayload});
|
|
101
90
|
processExecutionPayload(fork, state as CachedBeaconStateBellatrix, block.body, externalData);
|
|
102
|
-
timer?.();
|
|
103
91
|
}
|
|
104
92
|
|
|
105
93
|
if (fork >= ForkSeq.gloas) {
|
|
106
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processExecutionPayloadBid});
|
|
107
94
|
processExecutionPayloadBid(
|
|
108
95
|
state as CachedBeaconStateGloas,
|
|
109
96
|
(block as BeaconBlock<ForkPostGloas>).body.signedExecutionPayloadBid
|
|
110
97
|
);
|
|
111
|
-
timer?.();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processRandao});
|
|
116
|
-
processRandao(state, block, verifySignatures);
|
|
117
|
-
timer?.();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processEth1Data});
|
|
122
|
-
processEth1Data(state, block.body.eth1Data);
|
|
123
|
-
timer?.();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
{
|
|
127
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processOperations});
|
|
128
|
-
processOperations(fork, state, block.body, parentSlot, opts, metrics);
|
|
129
|
-
timer?.();
|
|
130
98
|
}
|
|
131
99
|
|
|
100
|
+
processRandao(state, block, verifySignatures);
|
|
101
|
+
processEth1Data(state, block.body.eth1Data);
|
|
102
|
+
processOperations(fork, state, block.body, parentSlot, opts, metrics);
|
|
132
103
|
if (fork >= ForkSeq.altair) {
|
|
133
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processSyncAggregate});
|
|
134
104
|
processSyncAggregate(state, block as altair.BeaconBlock, verifySignatures);
|
|
135
|
-
timer?.();
|
|
136
105
|
}
|
|
137
106
|
|
|
138
107
|
if (fork >= ForkSeq.deneb) {
|
|
139
|
-
const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processBlobKzgCommitments});
|
|
140
108
|
processBlobKzgCommitments(externalData);
|
|
141
|
-
timer?.();
|
|
142
109
|
// Only throw PreData so beacon can also sync/process blocks optimistically
|
|
143
110
|
// and let forkChoice handle it
|
|
144
111
|
if (externalData.dataAvailabilityStatus === DataAvailabilityStatus.PreData) {
|
|
@@ -18,7 +18,7 @@ import {processPayloadAttestation} from "./processPayloadAttestation.js";
|
|
|
18
18
|
import {processProposerSlashing} from "./processProposerSlashing.js";
|
|
19
19
|
import {processVoluntaryExit} from "./processVoluntaryExit.js";
|
|
20
20
|
import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
|
|
21
|
-
import {ProcessBlockOpts
|
|
21
|
+
import {ProcessBlockOpts} from "./types.js";
|
|
22
22
|
|
|
23
23
|
export {
|
|
24
24
|
processProposerSlashing,
|
|
@@ -49,94 +49,49 @@ export function processOperations(
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
for (const proposerSlashing of body.proposerSlashings) {
|
|
55
|
-
processProposerSlashing(fork, state, proposerSlashing, opts.verifySignatures);
|
|
56
|
-
}
|
|
57
|
-
timer?.();
|
|
52
|
+
for (const proposerSlashing of body.proposerSlashings) {
|
|
53
|
+
processProposerSlashing(fork, state, proposerSlashing, opts.verifySignatures);
|
|
58
54
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const timer = metrics?.processOperationsStepTime.startTimer({step: ProcessOperationsStep.processAttesterSlashing});
|
|
62
|
-
for (const attesterSlashing of body.attesterSlashings) {
|
|
63
|
-
processAttesterSlashing(fork, state, attesterSlashing, opts.verifySignatures);
|
|
64
|
-
}
|
|
65
|
-
timer?.();
|
|
55
|
+
for (const attesterSlashing of body.attesterSlashings) {
|
|
56
|
+
processAttesterSlashing(fork, state, attesterSlashing, opts.verifySignatures);
|
|
66
57
|
}
|
|
67
58
|
|
|
68
|
-
|
|
69
|
-
const timer = metrics?.processOperationsStepTime.startTimer({step: ProcessOperationsStep.processAttestations});
|
|
70
|
-
processAttestations(fork, state, body.attestations, parentSlot, opts.verifySignatures, metrics);
|
|
71
|
-
timer?.();
|
|
72
|
-
}
|
|
59
|
+
processAttestations(fork, state, body.attestations, parentSlot, opts.verifySignatures, metrics);
|
|
73
60
|
|
|
74
|
-
{
|
|
75
|
-
|
|
76
|
-
for (const deposit of body.deposits) {
|
|
77
|
-
processDeposit(fork, state, deposit);
|
|
78
|
-
}
|
|
79
|
-
timer?.();
|
|
61
|
+
for (const deposit of body.deposits) {
|
|
62
|
+
processDeposit(fork, state, deposit);
|
|
80
63
|
}
|
|
81
64
|
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
for (const voluntaryExit of body.voluntaryExits) {
|
|
85
|
-
processVoluntaryExit(fork, state, voluntaryExit, opts.verifySignatures);
|
|
86
|
-
}
|
|
87
|
-
timer?.();
|
|
65
|
+
for (const voluntaryExit of body.voluntaryExits) {
|
|
66
|
+
processVoluntaryExit(fork, state, voluntaryExit, opts.verifySignatures);
|
|
88
67
|
}
|
|
89
68
|
|
|
90
69
|
if (fork >= ForkSeq.capella) {
|
|
91
|
-
const timer = metrics?.processOperationsStepTime.startTimer({
|
|
92
|
-
step: ProcessOperationsStep.processBlsToExecutionChange,
|
|
93
|
-
});
|
|
94
70
|
for (const blsToExecutionChange of (body as capella.BeaconBlockBody).blsToExecutionChanges) {
|
|
95
71
|
processBlsToExecutionChange(state as CachedBeaconStateCapella, blsToExecutionChange);
|
|
96
72
|
}
|
|
97
|
-
timer?.();
|
|
98
73
|
}
|
|
99
74
|
|
|
100
75
|
if (fork >= ForkSeq.electra && fork < ForkSeq.gloas) {
|
|
101
76
|
const stateElectra = state as CachedBeaconStateElectra;
|
|
102
77
|
const bodyElectra = body as electra.BeaconBlockBody;
|
|
103
78
|
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
for (const depositRequest of bodyElectra.executionRequests.deposits) {
|
|
107
|
-
processDepositRequest(fork, stateElectra, depositRequest);
|
|
108
|
-
}
|
|
109
|
-
timer?.();
|
|
79
|
+
for (const depositRequest of bodyElectra.executionRequests.deposits) {
|
|
80
|
+
processDepositRequest(fork, stateElectra, depositRequest);
|
|
110
81
|
}
|
|
111
82
|
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
step: ProcessOperationsStep.processWithdrawalRequest,
|
|
115
|
-
});
|
|
116
|
-
for (const elWithdrawalRequest of bodyElectra.executionRequests.withdrawals) {
|
|
117
|
-
processWithdrawalRequest(fork, stateElectra, elWithdrawalRequest);
|
|
118
|
-
}
|
|
119
|
-
timer?.();
|
|
83
|
+
for (const elWithdrawalRequest of bodyElectra.executionRequests.withdrawals) {
|
|
84
|
+
processWithdrawalRequest(fork, stateElectra, elWithdrawalRequest);
|
|
120
85
|
}
|
|
121
86
|
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
step: ProcessOperationsStep.processConsolidationRequest,
|
|
125
|
-
});
|
|
126
|
-
for (const elConsolidationRequest of bodyElectra.executionRequests.consolidations) {
|
|
127
|
-
processConsolidationRequest(stateElectra, elConsolidationRequest);
|
|
128
|
-
}
|
|
129
|
-
timer?.();
|
|
87
|
+
for (const elConsolidationRequest of bodyElectra.executionRequests.consolidations) {
|
|
88
|
+
processConsolidationRequest(stateElectra, elConsolidationRequest);
|
|
130
89
|
}
|
|
131
90
|
}
|
|
132
91
|
|
|
133
92
|
if (fork >= ForkSeq.gloas) {
|
|
134
|
-
const timer = metrics?.processOperationsStepTime.startTimer({
|
|
135
|
-
step: ProcessOperationsStep.processPayloadAttestation,
|
|
136
|
-
});
|
|
137
93
|
for (const payloadAttestation of (body as gloas.BeaconBlockBody).payloadAttestations) {
|
|
138
|
-
processPayloadAttestation(state as CachedBeaconStateGloas, payloadAttestation
|
|
94
|
+
processPayloadAttestation(state as CachedBeaconStateGloas, payloadAttestation);
|
|
139
95
|
}
|
|
140
|
-
timer?.();
|
|
141
96
|
}
|
|
142
97
|
}
|
|
@@ -5,8 +5,7 @@ import {isValidIndexedPayloadAttestation} from "./isValidIndexedPayloadAttestati
|
|
|
5
5
|
|
|
6
6
|
export function processPayloadAttestation(
|
|
7
7
|
state: CachedBeaconStateGloas,
|
|
8
|
-
payloadAttestation: gloas.PayloadAttestation
|
|
9
|
-
verifySignature = true
|
|
8
|
+
payloadAttestation: gloas.PayloadAttestation
|
|
10
9
|
): void {
|
|
11
10
|
const data = payloadAttestation.data;
|
|
12
11
|
|
|
@@ -20,7 +19,7 @@ export function processPayloadAttestation(
|
|
|
20
19
|
|
|
21
20
|
const indexedPayloadAttestation = state.epochCtx.getIndexedPayloadAttestation(data.slot, payloadAttestation);
|
|
22
21
|
|
|
23
|
-
if (!isValidIndexedPayloadAttestation(state, indexedPayloadAttestation,
|
|
22
|
+
if (!isValidIndexedPayloadAttestation(state, indexedPayloadAttestation, true)) {
|
|
24
23
|
throw Error("Invalid payload attestation");
|
|
25
24
|
}
|
|
26
25
|
}
|
package/src/block/types.ts
CHANGED
|
@@ -7,35 +7,3 @@ export enum ProposerRewardType {
|
|
|
7
7
|
syncAggregate = "sync_aggregate",
|
|
8
8
|
slashing = "slashing",
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Steps of `processBlock()` tracked in metrics
|
|
13
|
-
*/
|
|
14
|
-
export enum BlockProcessStep {
|
|
15
|
-
processParentExecutionPayload = "processParentExecutionPayload",
|
|
16
|
-
processBlockHeader = "processBlockHeader",
|
|
17
|
-
processWithdrawals = "processWithdrawals",
|
|
18
|
-
processExecutionPayload = "processExecutionPayload",
|
|
19
|
-
processExecutionPayloadBid = "processExecutionPayloadBid",
|
|
20
|
-
processRandao = "processRandao",
|
|
21
|
-
processEth1Data = "processEth1Data",
|
|
22
|
-
processOperations = "processOperations",
|
|
23
|
-
processSyncAggregate = "processSyncAggregate",
|
|
24
|
-
processBlobKzgCommitments = "processBlobKzgCommitments",
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Steps of `processOperations()` tracked in metrics
|
|
29
|
-
*/
|
|
30
|
-
export enum ProcessOperationsStep {
|
|
31
|
-
processProposerSlashing = "processProposerSlashing",
|
|
32
|
-
processAttesterSlashing = "processAttesterSlashing",
|
|
33
|
-
processAttestations = "processAttestations",
|
|
34
|
-
processDeposit = "processDeposit",
|
|
35
|
-
processVoluntaryExit = "processVoluntaryExit",
|
|
36
|
-
processBlsToExecutionChange = "processBlsToExecutionChange",
|
|
37
|
-
processDepositRequest = "processDepositRequest",
|
|
38
|
-
processWithdrawalRequest = "processWithdrawalRequest",
|
|
39
|
-
processConsolidationRequest = "processConsolidationRequest",
|
|
40
|
-
processPayloadAttestation = "processPayloadAttestation",
|
|
41
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {MIN_SEED_LOOKAHEAD
|
|
1
|
+
import {MIN_SEED_LOOKAHEAD} from "@lodestar/params";
|
|
2
2
|
import {ssz} from "@lodestar/types";
|
|
3
3
|
import {CachedBeaconStateGloas, EpochTransitionCache} from "../types.js";
|
|
4
4
|
import {computeEpochShuffling} from "../util/epochShuffling.js";
|
|
@@ -22,24 +22,17 @@ export function processPtcWindow(state: CachedBeaconStateGloas, cache: EpochTran
|
|
|
22
22
|
state,
|
|
23
23
|
nextEpoch,
|
|
24
24
|
nextEpochShuffling.committees,
|
|
25
|
-
nextEpochShuffling.shuffling,
|
|
26
25
|
state.epochCtx.effectiveBalanceIncrements
|
|
27
26
|
);
|
|
28
27
|
|
|
29
28
|
// Stash for finalProcessEpoch to shift into epoch cache
|
|
30
29
|
cache.nextEpochPayloadTimelinessCommittees = newNextPayloadTimelinessCommittees;
|
|
31
30
|
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (let i = 0; i < SLOTS_PER_EPOCH; i++) {
|
|
40
|
-
ptcWindow.set(
|
|
41
|
-
retainedLength + i,
|
|
42
|
-
ssz.gloas.PayloadTimelinessCommittee.toViewDU(newNextPayloadTimelinessCommittees[i])
|
|
43
|
-
);
|
|
44
|
-
}
|
|
31
|
+
// Write shifted window to state: current(N) + next(N+1) + newlyComputed(N+2)
|
|
32
|
+
// From the perspective of upcoming epoch N+1, this is previous + current + next
|
|
33
|
+
state.ptcWindow = ssz.gloas.PayloadTimelinessCommitteeWindow.toViewDU([
|
|
34
|
+
...state.epochCtx.payloadTimelinessCommittees,
|
|
35
|
+
...state.epochCtx.nextPayloadTimelinessCommittees,
|
|
36
|
+
...newNextPayloadTimelinessCommittees,
|
|
37
|
+
]);
|
|
45
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ export {
|
|
|
13
13
|
} from "./block/processVoluntaryExit.js";
|
|
14
14
|
// Withdrawals for new blocks
|
|
15
15
|
export {getExpectedWithdrawals} from "./block/processWithdrawals.js";
|
|
16
|
-
export {
|
|
16
|
+
export {ProposerRewardType} from "./block/types.js";
|
|
17
17
|
export {
|
|
18
18
|
type EffectiveBalanceIncrements,
|
|
19
19
|
getEffectiveBalanceIncrementsWithLen,
|
package/src/metrics.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ForkName} from "@lodestar/params";
|
|
2
2
|
import {MetricsRegister} from "@lodestar/utils";
|
|
3
|
-
import {
|
|
3
|
+
import {ProposerRewardType} from "./block/types.js";
|
|
4
4
|
import {EpochTransitionStep} from "./epoch/index.js";
|
|
5
5
|
import {StateCloneSource, StateHashTreeRootSource} from "./stateTransition.js";
|
|
6
6
|
import {CachedBeaconStateAllForks} from "./types.js";
|
|
@@ -57,21 +57,10 @@ export function getMetrics(register: MetricsRegister) {
|
|
|
57
57
|
processBlockTime: register.histogram({
|
|
58
58
|
name: "lodestar_stfn_process_block_seconds",
|
|
59
59
|
help: "Time to process a single block in seconds",
|
|
60
|
+
// TODO: Add metrics for each step
|
|
60
61
|
// Block processing can take 5-40ms, 100ms max
|
|
61
62
|
buckets: [0.005, 0.01, 0.02, 0.05, 0.1, 1],
|
|
62
63
|
}),
|
|
63
|
-
processBlockStepTime: register.histogram<{step: BlockProcessStep}>({
|
|
64
|
-
name: "lodestar_stfn_process_block_step_seconds",
|
|
65
|
-
help: "Time to call each step of process block in seconds",
|
|
66
|
-
labelNames: ["step"],
|
|
67
|
-
buckets: [0.001, 0.005, 0.01, 0.025, 0.05, 0.1],
|
|
68
|
-
}),
|
|
69
|
-
processOperationsStepTime: register.histogram<{step: ProcessOperationsStep}>({
|
|
70
|
-
name: "lodestar_stfn_process_operations_step_seconds",
|
|
71
|
-
help: "Time to call each step of process operations in seconds",
|
|
72
|
-
labelNames: ["step"],
|
|
73
|
-
buckets: [0.001, 0.005, 0.01, 0.025, 0.05, 0.1],
|
|
74
|
-
}),
|
|
75
64
|
processBlockCommitTime: register.histogram({
|
|
76
65
|
name: "lodestar_stfn_process_block_commit_seconds",
|
|
77
66
|
help: "Time to call commit after process a single block in seconds",
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {ForkSeq} from "@lodestar/params";
|
|
3
|
-
import {IndexedAttestation, SignedBeaconBlock, altair, capella
|
|
3
|
+
import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
|
|
4
4
|
import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
|
|
5
5
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
6
|
-
import {IBeaconStateView
|
|
7
|
-
import {ISignatureSet
|
|
6
|
+
import {IBeaconStateView} from "../stateView/interface.js";
|
|
7
|
+
import {ISignatureSet} from "../util/index.js";
|
|
8
8
|
import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
|
|
9
9
|
import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js";
|
|
10
10
|
import {getAttestationsSignatureSets} from "./indexedAttestation.js";
|
|
11
|
-
import {getPayloadAttestationDataSigningRoot} from "./indexedPayloadAttestation.js";
|
|
12
11
|
import {getBlockProposerSignatureSet} from "./proposer.js";
|
|
13
12
|
import {getProposerSlashingsSignatureSets} from "./proposerSlashings.js";
|
|
14
13
|
import {getRandaoRevealSignatureSet} from "./randao.js";
|
|
@@ -80,18 +79,5 @@ export function getBlockSignatureSets(
|
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
if (fork >= ForkSeq.gloas) {
|
|
84
|
-
for (const payloadAttestation of (signedBlock as gloas.SignedBeaconBlock).message.body.payloadAttestations) {
|
|
85
|
-
const ptc = (state as IBeaconStateViewGloas).getPayloadTimelinessCommittee(payloadAttestation.data.slot);
|
|
86
|
-
signatureSets.push(
|
|
87
|
-
createAggregateSignatureSetFromComponents(
|
|
88
|
-
payloadAttestation.aggregationBits.intersectValues(ptc),
|
|
89
|
-
getPayloadAttestationDataSigningRoot(config, payloadAttestation.data),
|
|
90
|
-
payloadAttestation.signature
|
|
91
|
-
)
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
82
|
return signatureSets;
|
|
97
83
|
}
|
|
@@ -456,18 +456,6 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
456
456
|
}
|
|
457
457
|
throw new Error(`PTC committees are not available for epoch=${epoch}`);
|
|
458
458
|
}
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Return the PTC for a slot in the previous, current or next epoch
|
|
462
|
-
*/
|
|
463
|
-
getPayloadTimelinessCommittee(slot: Slot): Uint32Array {
|
|
464
|
-
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
|
|
465
|
-
throw new Error("PTC committees are not supported before Gloas");
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
return (this.cachedState as CachedBeaconStateGloas).epochCtx.getPayloadTimelinessCommittee(slot);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
459
|
/**
|
|
472
460
|
* Return all positions of the validator in the PTC committee for the given slot.
|
|
473
461
|
*
|
|
@@ -285,7 +285,6 @@ export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
|
|
|
285
285
|
getBuildersLength(): number;
|
|
286
286
|
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
|
|
287
287
|
getEpochPTCs(epoch: Epoch): Uint32Array[];
|
|
288
|
-
getPayloadTimelinessCommittee(slot: Slot): Uint32Array;
|
|
289
288
|
getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[];
|
|
290
289
|
/**
|
|
291
290
|
* Clone the state and apply parent execution payload effects.
|
|
@@ -926,10 +926,6 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
926
926
|
return cached;
|
|
927
927
|
}
|
|
928
928
|
|
|
929
|
-
getPayloadTimelinessCommittee(slot: Slot): Uint32Array {
|
|
930
|
-
return this.binding.getPayloadTimelinessCommittee(slot);
|
|
931
|
-
}
|
|
932
|
-
|
|
933
929
|
getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[] {
|
|
934
930
|
return this.binding.getIndicesInPayloadTimelinessCommittee(validatorIndex, slot);
|
|
935
931
|
}
|
package/src/util/gloas.ts
CHANGED
package/src/util/seed.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {digest} from "@chainsafe/as-sha256";
|
|
2
|
-
import {computePtcIndicesForEpoch} from "@chainsafe/lodestar-z/shuffle";
|
|
3
2
|
import {
|
|
4
3
|
computeProposerIndex as nativeComputeProposerIndex,
|
|
5
4
|
computeSyncCommitteeIndices as nativeComputeSyncCommitteeIndices,
|
|
@@ -276,36 +275,25 @@ export function computePayloadTimelinessCommitteesForEpoch(
|
|
|
276
275
|
state: BeaconStateAllForks,
|
|
277
276
|
epoch: number,
|
|
278
277
|
committees: Uint32Array[][],
|
|
279
|
-
shuffling: Uint32Array,
|
|
280
278
|
effectiveBalanceIncrements: EffectiveBalanceIncrements
|
|
281
279
|
): Uint32Array[] {
|
|
282
280
|
const epochSeed = getSeed(state, epoch, DOMAIN_PTC_ATTESTER);
|
|
283
281
|
const startSlot = epoch * SLOTS_PER_EPOCH;
|
|
284
|
-
const slotOffsets = new Uint32Array(SLOTS_PER_EPOCH + 1);
|
|
285
|
-
let shufflingLength = 0;
|
|
286
|
-
for (let i = 0; i < SLOTS_PER_EPOCH; i++) {
|
|
287
|
-
slotOffsets[i] = shufflingLength;
|
|
288
|
-
for (const committee of committees[i]) {
|
|
289
|
-
shufflingLength += committee.length;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
slotOffsets[SLOTS_PER_EPOCH] = shufflingLength;
|
|
293
|
-
|
|
294
|
-
// Native sampling returns all committees concatenated in slot order, with PTC_SIZE indices per slot.
|
|
295
|
-
const flatPtcIndices = computePtcIndicesForEpoch(
|
|
296
|
-
epochSeed,
|
|
297
|
-
startSlot,
|
|
298
|
-
SLOTS_PER_EPOCH,
|
|
299
|
-
shuffling,
|
|
300
|
-
slotOffsets,
|
|
301
|
-
effectiveBalanceIncrements,
|
|
302
|
-
PTC_SIZE,
|
|
303
|
-
MAX_EFFECTIVE_BALANCE_ELECTRA,
|
|
304
|
-
EFFECTIVE_BALANCE_INCREMENT
|
|
305
|
-
);
|
|
306
282
|
const result: Uint32Array[] = new Array(SLOTS_PER_EPOCH);
|
|
283
|
+
|
|
284
|
+
// Pre-allocate slot seed buffer once, reuse across all slots
|
|
285
|
+
const slotSeedInput = new Uint8Array(epochSeed.length + 8);
|
|
286
|
+
slotSeedInput.set(epochSeed, 0);
|
|
287
|
+
const slotSeedView = new DataView(slotSeedInput.buffer, slotSeedInput.byteOffset, slotSeedInput.byteLength);
|
|
288
|
+
|
|
307
289
|
for (let i = 0; i < SLOTS_PER_EPOCH; i++) {
|
|
308
|
-
|
|
290
|
+
const slot = startSlot + i;
|
|
291
|
+
// Write slot as little-endian uint64 (fits in uint32 range)
|
|
292
|
+
slotSeedView.setUint32(epochSeed.length, slot, true);
|
|
293
|
+
slotSeedView.setUint32(epochSeed.length + 4, 0, true);
|
|
294
|
+
const slotSeed = digest(slotSeedInput);
|
|
295
|
+
|
|
296
|
+
result[i] = computePayloadTimelinessCommitteeForSlot(slotSeed, committees[i], effectiveBalanceIncrements);
|
|
309
297
|
}
|
|
310
298
|
return result;
|
|
311
299
|
}
|