@lodestar/beacon-node 1.52.0-dev.f3cc451977 → 2.0.0-rc.1
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/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +63 -39
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/pool/index.js +3 -1
- package/lib/api/impl/beacon/pool/index.js.map +1 -1
- package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
- package/lib/api/impl/beacon/state/utils.js +2 -1
- package/lib/api/impl/beacon/state/utils.js.map +1 -1
- package/lib/api/impl/debug/index.d.ts.map +1 -1
- package/lib/api/impl/debug/index.js +6 -2
- package/lib/api/impl/debug/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +17 -7
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +4 -0
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +25 -5
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/blocks/index.d.ts.map +1 -1
- package/lib/chain/blocks/index.js +3 -17
- package/lib/chain/blocks/index.js.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +12 -11
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -5
- package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
- package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
- package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
- package/lib/chain/bls/utils.js +1 -1
- package/lib/chain/bls/utils.js.map +1 -1
- package/lib/chain/chain.d.ts +6 -5
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +74 -26
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/attestationError.d.ts +15 -1
- package/lib/chain/errors/attestationError.d.ts.map +1 -1
- package/lib/chain/errors/attestationError.js +8 -0
- package/lib/chain/errors/attestationError.js.map +1 -1
- package/lib/chain/errors/executionPayloadBid.d.ts +3 -2
- package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadBid.js +1 -1
- package/lib/chain/errors/executionPayloadBid.js.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
- package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/errors/executionPayloadEnvelope.js +7 -0
- package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts +1 -4
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +1 -4
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/forkChoiceExecutionEngine.d.ts +5 -3
- package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
- package/lib/chain/forkChoiceExecutionEngine.js +34 -11
- package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
- package/lib/chain/interface.d.ts +1 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/lightClient/index.d.ts +13 -6
- package/lib/chain/lightClient/index.d.ts.map +1 -1
- package/lib/chain/lightClient/index.js +95 -115
- package/lib/chain/lightClient/index.js.map +1 -1
- package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
- package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
- package/lib/chain/opPools/inclusionListStore.js +5 -2
- package/lib/chain/opPools/inclusionListStore.js.map +1 -1
- package/lib/chain/opPools/opPool.js +6 -6
- package/lib/chain/opPools/opPool.js.map +1 -1
- package/lib/chain/options.js +1 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
- package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenAttesters.js +1 -1
- package/lib/chain/seenCache/seenAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
- package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
- package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
- package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
- package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
- package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
- package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
- package/lib/chain/shufflingCache.d.ts +5 -0
- package/lib/chain/shufflingCache.d.ts.map +1 -1
- package/lib/chain/shufflingCache.js +39 -1
- package/lib/chain/shufflingCache.js.map +1 -1
- package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
- package/lib/chain/validation/aggregateAndProof.js +37 -9
- package/lib/chain/validation/aggregateAndProof.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +32 -16
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +9 -1
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadBid.js +30 -40
- package/lib/chain/validation/executionPayloadBid.js.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/chain/validation/executionPayloadEnvelope.js +79 -4
- package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
- package/lib/chain/validation/payloadAttestationMessage.js +9 -0
- package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
- package/lib/chain/validatorMonitor.js +43 -43
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +2 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +9 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/gossipsub.js +2 -2
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +1 -7
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/gossip/topic.js +0 -13
- package/lib/network/gossip/topic.js.map +1 -1
- package/lib/network/network.d.ts +1 -0
- package/lib/network/network.d.ts.map +1 -1
- package/lib/network/network.js +20 -11
- package/lib/network/network.js.map +1 -1
- package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
- package/lib/network/processor/gossipHandlers.js +19 -6
- package/lib/network/processor/gossipHandlers.js.map +1 -1
- package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
- package/lib/network/processor/gossipValidatorFn.js +4 -1
- package/lib/network/processor/gossipValidatorFn.js.map +1 -1
- package/lib/network/processor/index.d.ts.map +1 -1
- package/lib/network/processor/index.js +4 -2
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/utils/collect.d.ts +4 -4
- package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collect.js +9 -8
- package/lib/network/reqresp/utils/collect.js.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
- package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
- package/lib/sync/range/batch.d.ts +6 -0
- package/lib/sync/range/batch.d.ts.map +1 -1
- package/lib/sync/range/batch.js +17 -0
- package/lib/sync/range/batch.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +8 -1
- package/lib/sync/range/chain.js.map +1 -1
- package/lib/sync/range/range.d.ts.map +1 -1
- package/lib/sync/range/range.js +43 -3
- package/lib/sync/range/range.js.map +1 -1
- package/lib/sync/types.d.ts +12 -1
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +2 -0
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts +28 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +256 -24
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/sync/utils/downloadByRange.d.ts +14 -1
- package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRange.js +12 -2
- package/lib/sync/utils/downloadByRange.js.map +1 -1
- package/lib/sync/utils/downloadByRoot.d.ts +24 -2
- package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
- package/lib/sync/utils/downloadByRoot.js +43 -1
- package/lib/sync/utils/downloadByRoot.js.map +1 -1
- package/lib/util/eventLoop.d.ts +3 -3
- package/lib/util/eventLoop.d.ts.map +1 -1
- package/lib/util/eventLoop.js +3 -3
- package/lib/util/eventLoop.js.map +1 -1
- package/package.json +18 -18
- package/src/api/impl/beacon/blocks/index.ts +74 -47
- package/src/api/impl/beacon/pool/index.ts +9 -7
- package/src/api/impl/beacon/state/utils.ts +2 -1
- package/src/api/impl/debug/index.ts +6 -2
- package/src/api/impl/validator/index.ts +19 -7
- package/src/chain/ColumnReconstructionTracker.ts +5 -0
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
- package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
- package/src/chain/blocks/importExecutionPayload.ts +30 -4
- package/src/chain/blocks/index.ts +3 -31
- package/src/chain/blocks/verifyBlock.ts +14 -10
- package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +7 -4
- package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
- package/src/chain/bls/utils.ts +1 -1
- package/src/chain/chain.ts +107 -43
- package/src/chain/errors/attestationError.ts +11 -1
- package/src/chain/errors/executionPayloadBid.ts +3 -2
- package/src/chain/errors/executionPayloadEnvelope.ts +50 -0
- package/src/chain/forkChoice/index.ts +1 -4
- package/src/chain/forkChoiceExecutionEngine.ts +48 -15
- package/src/chain/interface.ts +1 -1
- package/src/chain/lightClient/index.ts +108 -142
- package/src/chain/opPools/inclusionListStore.ts +5 -2
- package/src/chain/opPools/opPool.ts +6 -6
- package/src/chain/options.ts +1 -1
- package/src/chain/seenCache/seenAttesters.ts +1 -1
- package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
- package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
- package/src/chain/shufflingCache.ts +40 -1
- package/src/chain/validation/aggregateAndProof.ts +43 -14
- package/src/chain/validation/attestation.ts +31 -20
- package/src/chain/validation/block.ts +9 -1
- package/src/chain/validation/executionPayloadBid.ts +40 -42
- package/src/chain/validation/executionPayloadEnvelope.ts +87 -3
- package/src/chain/validation/payloadAttestationMessage.ts +10 -0
- package/src/chain/validatorMonitor.ts +43 -43
- package/src/metrics/metrics/lodestar.ts +9 -0
- package/src/network/gossip/gossipsub.ts +2 -2
- package/src/network/gossip/topic.ts +1 -14
- package/src/network/network.ts +33 -11
- package/src/network/processor/gossipHandlers.ts +25 -13
- package/src/network/processor/gossipValidatorFn.ts +4 -0
- package/src/network/processor/index.ts +7 -2
- package/src/network/reqresp/utils/collect.ts +16 -8
- package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
- package/src/sync/range/batch.ts +20 -0
- package/src/sync/range/chain.ts +8 -0
- package/src/sync/range/range.ts +56 -3
- package/src/sync/types.ts +11 -0
- package/src/sync/unknownBlock.ts +295 -24
- package/src/sync/utils/downloadByRange.ts +29 -3
- package/src/sync/utils/downloadByRoot.ts +68 -2
- package/src/util/eventLoop.ts +3 -3
|
@@ -151,6 +151,14 @@ export enum AttestationErrorCode {
|
|
|
151
151
|
* Gloas: index-1 attestation but the execution payload has not been seen yet
|
|
152
152
|
*/
|
|
153
153
|
EXECUTION_PAYLOAD_NOT_SEEN = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_NOT_SEEN",
|
|
154
|
+
/**
|
|
155
|
+
* Gloas: index-1 attestation to a block whose execution payload is not yet validated by the execution engine
|
|
156
|
+
*/
|
|
157
|
+
EXECUTION_PAYLOAD_OPTIMISTIC = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_OPTIMISTIC",
|
|
158
|
+
/**
|
|
159
|
+
* Gloas: index-1 attestation to a block whose execution payload was invalidated
|
|
160
|
+
*/
|
|
161
|
+
EXECUTION_PAYLOAD_INVALID = "ATTESTATION_ERROR_EXECUTION_PAYLOAD_INVALID",
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
export type AttestationErrorType =
|
|
@@ -190,7 +198,9 @@ export type AttestationErrorType =
|
|
|
190
198
|
| {code: AttestationErrorCode.ATTESTER_NOT_IN_COMMITTEE}
|
|
191
199
|
| {code: AttestationErrorCode.INVALID_PAYLOAD_STATUS_VALUE; attDataIndex: number}
|
|
192
200
|
| {code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT}
|
|
193
|
-
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN; beaconBlockRoot: RootHex}
|
|
201
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN; beaconBlockRoot: RootHex}
|
|
202
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_OPTIMISTIC; beaconBlockRoot: RootHex}
|
|
203
|
+
| {code: AttestationErrorCode.EXECUTION_PAYLOAD_INVALID; beaconBlockRoot: RootHex};
|
|
194
204
|
|
|
195
205
|
export class AttestationError extends GossipActionError<AttestationErrorType> {
|
|
196
206
|
getMetadata(): Record<string, string | number | null> {
|
|
@@ -7,7 +7,7 @@ export enum ExecutionPayloadBidErrorCode {
|
|
|
7
7
|
NON_ZERO_EXECUTION_PAYMENT = "EXECUTION_PAYLOAD_BID_ERROR_NON_ZERO_EXECUTION_PAYMENT",
|
|
8
8
|
BLOCK_HASH_EQUALS_PARENT_BLOCK_HASH = "EXECUTION_PAYLOAD_BID_ERROR_BLOCK_HASH_EQUALS_PARENT_BLOCK_HASH",
|
|
9
9
|
INCOMPATIBLE_WITH_HEAD = "EXECUTION_PAYLOAD_BID_ERROR_INCOMPATIBLE_WITH_HEAD",
|
|
10
|
-
|
|
10
|
+
BID_LIMIT_REACHED = "EXECUTION_PAYLOAD_BID_ERROR_BID_LIMIT_REACHED",
|
|
11
11
|
BID_TOO_LOW = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_LOW",
|
|
12
12
|
BID_TOO_HIGH = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_HIGH",
|
|
13
13
|
BUILDER_MAY_EXIT = "EXECUTION_PAYLOAD_BID_ERROR_BUILDER_MAY_EXIT",
|
|
@@ -46,11 +46,12 @@ export type ExecutionPayloadBidErrorType =
|
|
|
46
46
|
headBlockRoot: RootHex;
|
|
47
47
|
}
|
|
48
48
|
| {
|
|
49
|
-
code: ExecutionPayloadBidErrorCode.
|
|
49
|
+
code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED;
|
|
50
50
|
builderIndex: BuilderIndex;
|
|
51
51
|
slot: Slot;
|
|
52
52
|
parentBlockRoot: RootHex;
|
|
53
53
|
parentBlockHash: RootHex;
|
|
54
|
+
bidLimit: number;
|
|
54
55
|
}
|
|
55
56
|
| {code: ExecutionPayloadBidErrorCode.BID_TOO_LOW; bidValue: number; currentHighestBid: number}
|
|
56
57
|
| {code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH; bidValue: number; builderBalance: number}
|
|
@@ -9,10 +9,17 @@ export enum ExecutionPayloadEnvelopeErrorCode {
|
|
|
9
9
|
ENVELOPE_ALREADY_KNOWN = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_ALREADY_KNOWN",
|
|
10
10
|
INVALID_BLOCK = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_BLOCK",
|
|
11
11
|
SLOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_SLOT_MISMATCH",
|
|
12
|
+
PARENT_BEACON_BLOCK_ROOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PARENT_BEACON_BLOCK_ROOT_MISMATCH",
|
|
12
13
|
BUILDER_INDEX_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BUILDER_INDEX_MISMATCH",
|
|
14
|
+
PREV_RANDAO_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PREV_RANDAO_MISMATCH",
|
|
15
|
+
GAS_LIMIT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_GAS_LIMIT_MISMATCH",
|
|
13
16
|
BLOCK_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_HASH_MISMATCH",
|
|
14
17
|
EXECUTION_REQUESTS_ROOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_EXECUTION_REQUESTS_ROOT_MISMATCH",
|
|
15
18
|
TOO_MANY_TRANSACTIONS = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_TOO_MANY_TRANSACTIONS",
|
|
19
|
+
PARENT_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PARENT_HASH_MISMATCH",
|
|
20
|
+
INCORRECT_TIMESTAMP = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INCORRECT_TIMESTAMP",
|
|
21
|
+
EMPTY_TRANSACTION = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_EMPTY_TRANSACTION",
|
|
22
|
+
WITHDRAWALS_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_WITHDRAWALS_MISMATCH",
|
|
16
23
|
INVALID_SIGNATURE = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_SIGNATURE",
|
|
17
24
|
PAYLOAD_ENVELOPE_INPUT_MISSING = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PAYLOAD_ENVELOPE_INPUT_MISSING",
|
|
18
25
|
}
|
|
@@ -34,6 +41,13 @@ export type ExecutionPayloadEnvelopeErrorType =
|
|
|
34
41
|
envelopeSlot: Slot;
|
|
35
42
|
blockSlot: Slot;
|
|
36
43
|
}
|
|
44
|
+
| {
|
|
45
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_BEACON_BLOCK_ROOT_MISMATCH;
|
|
46
|
+
slot: Slot;
|
|
47
|
+
root: RootHex;
|
|
48
|
+
envelopeParentBeaconBlockRoot: RootHex;
|
|
49
|
+
blockParentRoot: RootHex;
|
|
50
|
+
}
|
|
37
51
|
| {
|
|
38
52
|
code: ExecutionPayloadEnvelopeErrorCode.BUILDER_INDEX_MISMATCH;
|
|
39
53
|
slot: Slot;
|
|
@@ -41,6 +55,20 @@ export type ExecutionPayloadEnvelopeErrorType =
|
|
|
41
55
|
envelopeBuilderIndex: BuilderIndex;
|
|
42
56
|
bidBuilderIndex: BuilderIndex | null;
|
|
43
57
|
}
|
|
58
|
+
| {
|
|
59
|
+
code: ExecutionPayloadEnvelopeErrorCode.PREV_RANDAO_MISMATCH;
|
|
60
|
+
slot: Slot;
|
|
61
|
+
root: RootHex;
|
|
62
|
+
envelopePrevRandao: RootHex;
|
|
63
|
+
bidPrevRandao: RootHex;
|
|
64
|
+
}
|
|
65
|
+
| {
|
|
66
|
+
code: ExecutionPayloadEnvelopeErrorCode.GAS_LIMIT_MISMATCH;
|
|
67
|
+
slot: Slot;
|
|
68
|
+
root: RootHex;
|
|
69
|
+
envelopeGasLimit: number;
|
|
70
|
+
bidGasLimit: bigint;
|
|
71
|
+
}
|
|
44
72
|
| {
|
|
45
73
|
code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH;
|
|
46
74
|
slot: Slot;
|
|
@@ -62,6 +90,28 @@ export type ExecutionPayloadEnvelopeErrorType =
|
|
|
62
90
|
transactionCount: number;
|
|
63
91
|
maxTransactionCount: number;
|
|
64
92
|
}
|
|
93
|
+
| {
|
|
94
|
+
code: ExecutionPayloadEnvelopeErrorCode.PARENT_HASH_MISMATCH;
|
|
95
|
+
slot: Slot;
|
|
96
|
+
root: RootHex;
|
|
97
|
+
envelopeParentHash: RootHex;
|
|
98
|
+
latestBlockHash: RootHex;
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
code: ExecutionPayloadEnvelopeErrorCode.INCORRECT_TIMESTAMP;
|
|
102
|
+
slot: Slot;
|
|
103
|
+
root: RootHex;
|
|
104
|
+
envelopeTimestamp: number;
|
|
105
|
+
expectedTimestamp: number;
|
|
106
|
+
}
|
|
107
|
+
| {code: ExecutionPayloadEnvelopeErrorCode.EMPTY_TRANSACTION; slot: Slot; root: RootHex; transactionIndex: number}
|
|
108
|
+
| {
|
|
109
|
+
code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_MISMATCH;
|
|
110
|
+
slot: Slot;
|
|
111
|
+
root: RootHex;
|
|
112
|
+
envelopeWithdrawalsRoot: RootHex;
|
|
113
|
+
expectedWithdrawalsRoot: RootHex;
|
|
114
|
+
}
|
|
65
115
|
| {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE; slot: Slot; root: RootHex}
|
|
66
116
|
| {code: ExecutionPayloadEnvelopeErrorCode.PAYLOAD_ENVELOPE_INPUT_MISSING; blockRoot: RootHex};
|
|
67
117
|
|
|
@@ -37,10 +37,7 @@ export enum ForkchoiceCaller {
|
|
|
37
37
|
executionInvalid = "execution_invalid",
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* Where an execution engine INVALID verdict comes from. Only `blockSegment` verdicts are about the payload the engine
|
|
42
|
-
* just processed and keep the consensus failure semantics in fork choice, the others are applied leniently.
|
|
43
|
-
*/
|
|
40
|
+
/** Where an execution engine INVALID verdict comes from, a label for logs and metrics */
|
|
44
41
|
export enum ExecutionInvalidSource {
|
|
45
42
|
forkchoiceUpdated = "forkchoice_updated",
|
|
46
43
|
newPayload = "new_payload",
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ExecutionStatus,
|
|
3
|
+
IForkChoice,
|
|
4
|
+
LVHInvalidJudged,
|
|
5
|
+
LVHInvalidResponse,
|
|
6
|
+
LVHNotAppliedReason,
|
|
7
|
+
LVHVerdictResult,
|
|
8
|
+
} from "@lodestar/fork-choice";
|
|
2
9
|
import {ForkName, ForkPostFulu} from "@lodestar/params";
|
|
3
10
|
import {RootHex, bellatrix} from "@lodestar/types";
|
|
4
11
|
import {BlobAndProofV2} from "@lodestar/types/fulu";
|
|
5
|
-
import {Logger} from "@lodestar/utils";
|
|
12
|
+
import {LogDataBasic, Logger} from "@lodestar/utils";
|
|
6
13
|
import {ExecutionPayloadBodyV2} from "../execution/engine/types.js";
|
|
7
14
|
import {DATA} from "../execution/engine/utils.js";
|
|
8
15
|
import {
|
|
@@ -119,18 +126,25 @@ export class ForkChoiceExecutionEngine {
|
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
/**
|
|
122
|
-
* Apply an execution engine INVALID verdict to fork choice and move the chain head off the invalid chain
|
|
129
|
+
* Apply an execution engine INVALID verdict to fork choice and move the chain head off the invalid chain.
|
|
130
|
+
* `judgedLogCtx` identifies the judged payload in logs when it is not the from node.
|
|
123
131
|
*/
|
|
124
|
-
invalidateExecutionPayloads(
|
|
132
|
+
invalidateExecutionPayloads(
|
|
133
|
+
lvh: LVHInvalidResponse,
|
|
134
|
+
source: ExecutionInvalidSource,
|
|
135
|
+
judgedLogCtx?: Record<string, LogDataBasic>
|
|
136
|
+
): void {
|
|
125
137
|
const logCtx = {
|
|
138
|
+
...judgedLogCtx,
|
|
126
139
|
source,
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
judged: lvh.judged,
|
|
141
|
+
fromBlockRoot: lvh.invalidateFromBlockRoot,
|
|
142
|
+
fromBlockHash: lvh.invalidateFromBlockHash,
|
|
129
143
|
latestValidHash: lvh.latestValidExecHash ?? "null",
|
|
130
144
|
};
|
|
131
|
-
const
|
|
132
|
-
if (!applied) {
|
|
133
|
-
this.
|
|
145
|
+
const result = this.forkChoice.validateLatestHash(lvh);
|
|
146
|
+
if (!result.applied) {
|
|
147
|
+
this.logNotApplied(result, logCtx);
|
|
134
148
|
return;
|
|
135
149
|
}
|
|
136
150
|
this.metrics?.forkChoice.executionInvalidations.inc({source});
|
|
@@ -143,6 +157,20 @@ export class ForkChoiceExecutionEngine {
|
|
|
143
157
|
}
|
|
144
158
|
}
|
|
145
159
|
|
|
160
|
+
private logNotApplied(
|
|
161
|
+
result: Exclude<LVHVerdictResult, {applied: true}>,
|
|
162
|
+
logCtx: Record<string, LogDataBasic>
|
|
163
|
+
): void {
|
|
164
|
+
const message = "Execution engine verdict not applied to fork choice";
|
|
165
|
+
if (result.reason === LVHNotAppliedReason.Error) {
|
|
166
|
+
this.logger.error(message, {...logCtx, reason: result.reason}, result.error);
|
|
167
|
+
} else if (result.reason === LVHNotAppliedReason.AlreadyApplied) {
|
|
168
|
+
this.logger.debug(message, {...logCtx, reason: result.reason});
|
|
169
|
+
} else {
|
|
170
|
+
this.logger.warn(message, {...logCtx, reason: result.reason});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
146
174
|
private applyForkchoiceUpdatedResult(
|
|
147
175
|
headBlockRoot: RootHex,
|
|
148
176
|
headBlockHash: RootHex,
|
|
@@ -165,16 +193,21 @@ export class ForkChoiceExecutionEngine {
|
|
|
165
193
|
{
|
|
166
194
|
executionStatus: ExecutionStatus.Invalid,
|
|
167
195
|
latestValidExecHash: latestValidHash,
|
|
168
|
-
|
|
169
|
-
|
|
196
|
+
invalidateFromBlockRoot: headBlockRoot,
|
|
197
|
+
invalidateFromBlockHash: headBlockHash,
|
|
198
|
+
judged: LVHInvalidJudged.FromBlock,
|
|
170
199
|
},
|
|
171
200
|
ExecutionInvalidSource.forkchoiceUpdated
|
|
172
201
|
);
|
|
173
202
|
} else if (status === ExecutionPayloadStatus.VALID && executionStatus === ExecutionStatus.Syncing) {
|
|
174
|
-
this.forkChoice.validateLatestHash(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
203
|
+
const result = this.forkChoice.validateLatestHash({
|
|
204
|
+
executionStatus: ExecutionStatus.Valid,
|
|
205
|
+
latestValidExecHash: headBlockHash,
|
|
206
|
+
blockRoot: headBlockRoot,
|
|
207
|
+
});
|
|
208
|
+
if (!result.applied) {
|
|
209
|
+
this.logNotApplied(result, {source: ExecutionInvalidSource.forkchoiceUpdated, headBlockRoot, headBlockHash});
|
|
210
|
+
}
|
|
178
211
|
}
|
|
179
212
|
} catch (e) {
|
|
180
213
|
this.logger.error("Error applying forkchoice update result", {headBlockRoot, headBlockHash, status}, e as Error);
|
package/src/chain/interface.ts
CHANGED
|
@@ -303,8 +303,8 @@ export interface IBeaconChain {
|
|
|
303
303
|
postState: IBeaconStateView,
|
|
304
304
|
block: SignedBeaconBlock
|
|
305
305
|
): Promise<void>;
|
|
306
|
+
persistInvalidSignature(state: IBeaconStateView, block: SignedBeaconBlock): Promise<void>;
|
|
306
307
|
persistInvalidSszValue<T>(type: Type<T>, sszObject: T, suffix?: string, rootHex?: RootHex): void;
|
|
307
|
-
persistInvalidSszBytes(type: string, sszBytes: Uint8Array, rootHex: RootHex, suffix?: string): void;
|
|
308
308
|
regenStateForAttestationVerification(
|
|
309
309
|
attEpoch: Epoch,
|
|
310
310
|
shufflingDependentRoot: RootHex,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ForkPostGloas,
|
|
9
9
|
ForkPreGloas,
|
|
10
10
|
ForkSeq,
|
|
11
|
+
GENESIS_EPOCH,
|
|
11
12
|
MIN_SYNC_COMMITTEE_PARTICIPANTS,
|
|
12
13
|
SLOTS_PER_EPOCH,
|
|
13
14
|
SYNC_COMMITTEE_SIZE,
|
|
@@ -16,8 +17,6 @@ import {
|
|
|
16
17
|
} from "@lodestar/params";
|
|
17
18
|
import {
|
|
18
19
|
type IBeaconStateViewAltair,
|
|
19
|
-
computeStartSlotAtEpoch,
|
|
20
|
-
computeSyncPeriodAtEpoch,
|
|
21
20
|
computeSyncPeriodAtSlot,
|
|
22
21
|
executionPayloadToPayloadHeader,
|
|
23
22
|
} from "@lodestar/state-transition";
|
|
@@ -44,8 +43,7 @@ import {
|
|
|
44
43
|
phase0,
|
|
45
44
|
ssz,
|
|
46
45
|
} from "@lodestar/types";
|
|
47
|
-
import {Logger, MapDef,
|
|
48
|
-
import {ZERO_HASH} from "../../constants/index.js";
|
|
46
|
+
import {Logger, MapDef, pruneSetToMax, toRootHex} from "@lodestar/utils";
|
|
49
47
|
import {IBeaconDb} from "../../db/index.js";
|
|
50
48
|
import {NUM_WITNESS, NUM_WITNESS_ELECTRA} from "../../db/repositories/lightclientSyncCommitteeWitness.js";
|
|
51
49
|
import {Metrics} from "../../metrics/index.js";
|
|
@@ -72,16 +70,9 @@ export type SyncAttestedData = {
|
|
|
72
70
|
attestedHeader: LightClientHeader;
|
|
73
71
|
/** Precomputed root to prevent re-hashing */
|
|
74
72
|
blockRoot: Uint8Array;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
finalityBranch: Uint8Array[];
|
|
79
|
-
finalizedCheckpoint: phase0.Checkpoint;
|
|
80
|
-
}
|
|
81
|
-
| {
|
|
82
|
-
isFinalized: false;
|
|
83
|
-
}
|
|
84
|
-
);
|
|
73
|
+
finalizedCheckpoint: phase0.Checkpoint;
|
|
74
|
+
finalityBranch: Uint8Array[];
|
|
75
|
+
};
|
|
85
76
|
|
|
86
77
|
type LightClientServerModules = {
|
|
87
78
|
config: ChainForkConfig;
|
|
@@ -435,33 +426,14 @@ export class LightClientServer {
|
|
|
435
426
|
// Store header in case it is referenced latter by a future finalized checkpoint
|
|
436
427
|
await this.db.checkpointHeader.put(blockRoot, header);
|
|
437
428
|
|
|
438
|
-
// Store finalized checkpoint data
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
finalizedCheckpoint.epoch !== 0 &&
|
|
447
|
-
!byteArrayEquals(finalizedCheckpoint.root, ZERO_HASH);
|
|
448
|
-
|
|
449
|
-
this.prevHeadData.set(
|
|
450
|
-
blockRootHex,
|
|
451
|
-
isFinalized
|
|
452
|
-
? {
|
|
453
|
-
isFinalized: true,
|
|
454
|
-
attestedHeader: header,
|
|
455
|
-
blockRoot,
|
|
456
|
-
finalityBranch: postState.getFinalizedRootProof(),
|
|
457
|
-
finalizedCheckpoint,
|
|
458
|
-
}
|
|
459
|
-
: {
|
|
460
|
-
isFinalized: false,
|
|
461
|
-
attestedHeader: header,
|
|
462
|
-
blockRoot,
|
|
463
|
-
}
|
|
464
|
-
);
|
|
429
|
+
// Store finalized checkpoint data. The finality branch only depends on the post state, so it is
|
|
430
|
+
// collected for every block; see `buildUpdate` for the cases in which it is served.
|
|
431
|
+
this.prevHeadData.set(blockRootHex, {
|
|
432
|
+
attestedHeader: header,
|
|
433
|
+
blockRoot,
|
|
434
|
+
finalizedCheckpoint: postState.finalizedCheckpoint,
|
|
435
|
+
finalityBranch: postState.getFinalizedRootProof(),
|
|
436
|
+
});
|
|
465
437
|
|
|
466
438
|
pruneSetToMax(this.prevHeadData, MAX_PREV_HEAD_DATA);
|
|
467
439
|
}
|
|
@@ -505,7 +477,7 @@ export class LightClientServer {
|
|
|
505
477
|
return;
|
|
506
478
|
}
|
|
507
479
|
|
|
508
|
-
const {attestedHeader
|
|
480
|
+
const {attestedHeader} = attestedData;
|
|
509
481
|
const attestedPeriod = computeSyncPeriodAtSlot(attestedHeader.beacon.slot);
|
|
510
482
|
if (syncPeriod !== attestedPeriod) {
|
|
511
483
|
this.logger.debug("attested data period different than signature period", {syncPeriod, attestedPeriod});
|
|
@@ -555,41 +527,36 @@ export class LightClientServer {
|
|
|
555
527
|
this.metrics?.lightclientServer.onSyncAggregate.inc({event: "update_latest_head_update"});
|
|
556
528
|
}
|
|
557
529
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
if (!isStaleLightClientUpdate) {
|
|
581
|
-
// Note: Ignores gossip rule to always emit finality_update with higher finalized_header.slot, for simplicity
|
|
582
|
-
this.emitter.emit(routes.events.EventType.lightClientFinalityUpdate, {
|
|
583
|
-
version: attestedFork,
|
|
584
|
-
data: this.finalized,
|
|
585
|
-
});
|
|
586
|
-
}
|
|
530
|
+
const builtUpdate = await this.buildUpdate(attestedData, syncAggregate, signatureSlot);
|
|
531
|
+
if (
|
|
532
|
+
builtUpdate?.hasFinality &&
|
|
533
|
+
(!this.finalized ||
|
|
534
|
+
builtUpdate.update.finalizedHeader.beacon.slot > this.finalized.finalizedHeader.beacon.slot ||
|
|
535
|
+
syncAggregateParticipation > sumBits(this.finalized.syncAggregate.syncCommitteeBits))
|
|
536
|
+
) {
|
|
537
|
+
this.finalized = {
|
|
538
|
+
attestedHeader,
|
|
539
|
+
finalizedHeader: builtUpdate.update.finalizedHeader,
|
|
540
|
+
syncAggregate,
|
|
541
|
+
finalityBranch: builtUpdate.update.finalityBranch,
|
|
542
|
+
signatureSlot,
|
|
543
|
+
};
|
|
544
|
+
this.metrics?.lightclientServer.onSyncAggregate.inc({event: "update_latest_finalized_update"});
|
|
545
|
+
|
|
546
|
+
if (!isStaleLightClientUpdate) {
|
|
547
|
+
// Note: Ignores gossip rule to always emit finality_update with higher finalized_header.slot, for simplicity
|
|
548
|
+
this.emitter.emit(routes.events.EventType.lightClientFinalityUpdate, {
|
|
549
|
+
version: attestedFork,
|
|
550
|
+
data: this.finalized,
|
|
551
|
+
});
|
|
587
552
|
}
|
|
588
553
|
}
|
|
589
554
|
|
|
590
555
|
// Check if this update is better, otherwise ignore
|
|
591
556
|
try {
|
|
592
|
-
|
|
557
|
+
if (builtUpdate) {
|
|
558
|
+
await this.maybeStoreNewBestUpdate(syncPeriod, builtUpdate);
|
|
559
|
+
}
|
|
593
560
|
} catch (e) {
|
|
594
561
|
this.logger.error(
|
|
595
562
|
"Error updating best LightClientUpdate",
|
|
@@ -605,36 +572,50 @@ export class LightClientServer {
|
|
|
605
572
|
*/
|
|
606
573
|
private async maybeStoreNewBestUpdate(
|
|
607
574
|
syncPeriod: SyncPeriod,
|
|
608
|
-
|
|
609
|
-
signatureSlot: Slot,
|
|
610
|
-
attestedData: SyncAttestedData
|
|
575
|
+
built: {update: LightClientUpdate; summary: LightClientUpdateSummary}
|
|
611
576
|
): Promise<void> {
|
|
612
577
|
const prevBestUpdate = await this.db.bestLightClientUpdate.get(syncPeriod);
|
|
613
|
-
|
|
578
|
+
if (prevBestUpdate && !isBetterUpdate(built.summary, toLightClientUpdateSummary(prevBestUpdate))) {
|
|
579
|
+
this.metrics?.lightclientServer.updateNotBetter.inc();
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
614
582
|
|
|
615
|
-
|
|
616
|
-
|
|
583
|
+
// attestedData and the block of syncAggregate may not be in same sync period
|
|
584
|
+
// should not use attested data slot as sync period
|
|
585
|
+
// see https://github.com/ChainSafe/lodestar/issues/3933
|
|
586
|
+
await this.db.bestLightClientUpdate.put(syncPeriod, built.update);
|
|
587
|
+
this.logger.debug("Stored new PartialLightClientUpdate", {
|
|
588
|
+
syncPeriod,
|
|
589
|
+
isFinalized: built.summary.isFinalityUpdate,
|
|
590
|
+
participation: sumBits(built.update.syncAggregate.syncCommitteeBits) / SYNC_COMMITTEE_SIZE,
|
|
591
|
+
});
|
|
617
592
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
// All updates include a valid `nextSyncCommitteeBranch`, see below code
|
|
629
|
-
isSyncCommitteeUpdate: true,
|
|
630
|
-
isFinalityUpdate: attestedData.isFinalized,
|
|
631
|
-
};
|
|
593
|
+
// Count total persisted updates per type. DB metrics don't diff between each type.
|
|
594
|
+
// The frequency of finalized vs non-finalized is critical to debug if finalizedHeader is not available
|
|
595
|
+
this.metrics?.lightclientServer.onSyncAggregate.inc({
|
|
596
|
+
event: built.summary.isFinalityUpdate ? "store_finalized_update" : "store_nonfinalized_update",
|
|
597
|
+
});
|
|
598
|
+
this.metrics?.lightclientServer.highestSlot.set(
|
|
599
|
+
{item: built.summary.isFinalityUpdate ? "best_finalized_update" : "best_nonfinalized_update"},
|
|
600
|
+
built.update.attestedHeader.beacon.slot
|
|
601
|
+
);
|
|
602
|
+
}
|
|
632
603
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
604
|
+
/**
|
|
605
|
+
* Build the update for `syncAggregate` attesting to `attestedData`.
|
|
606
|
+
*
|
|
607
|
+
* Finality is indicated whenever it can be proven, in one of three ways:
|
|
608
|
+
* - the finalized checkpoint is genesis: the branch is served, the header stays empty, since
|
|
609
|
+
* genesis cannot be proven by a header and the branch alone proves that `finalized_root` is zero
|
|
610
|
+
* - the finalized header is available locally: both the header and the branch are served
|
|
611
|
+
* - the finalized header is not available: neither is served, and `hasFinality` is false
|
|
612
|
+
*/
|
|
613
|
+
private async buildUpdate(
|
|
614
|
+
attestedData: SyncAttestedData,
|
|
615
|
+
syncAggregate: altair.SyncAggregate,
|
|
616
|
+
signatureSlot: Slot
|
|
617
|
+
): Promise<{update: LightClientUpdate; summary: LightClientUpdateSummary; hasFinality: boolean} | null> {
|
|
618
|
+
const {attestedHeader} = attestedData;
|
|
638
619
|
|
|
639
620
|
const syncCommitteeWitness = await this.db.syncCommitteeWitness.get(attestedData.blockRoot);
|
|
640
621
|
if (!syncCommitteeWitness) {
|
|
@@ -662,41 +643,34 @@ export class LightClientServer {
|
|
|
662
643
|
throw Error("nextSyncCommittee not available");
|
|
663
644
|
}
|
|
664
645
|
const nextSyncCommitteeBranch = getNextSyncCommitteeBranch(syncCommitteeWitness);
|
|
665
|
-
const finalizedHeaderAttested = attestedData.isFinalized
|
|
666
|
-
? await this.getFinalizedHeader(attestedData.finalizedCheckpoint.root)
|
|
667
|
-
: null;
|
|
668
646
|
|
|
669
|
-
|
|
647
|
+
const zeroFinality = this.getZeroFinality(attestedFork, attestedHeader.beacon.slot);
|
|
648
|
+
const {finalizedCheckpoint} = attestedData;
|
|
649
|
+
let finalityBranch = zeroFinality.finalityBranch;
|
|
650
|
+
let finalizedHeader = zeroFinality.finalizedHeader;
|
|
651
|
+
let hasFinality = false;
|
|
670
652
|
|
|
671
|
-
if (
|
|
672
|
-
|
|
673
|
-
finalizedHeaderAttested &&
|
|
674
|
-
computeSyncPeriodAtSlot(finalizedHeaderAttested.beacon.slot) === syncPeriod
|
|
675
|
-
) {
|
|
676
|
-
isFinalized = true;
|
|
653
|
+
if (finalizedCheckpoint.epoch === GENESIS_EPOCH) {
|
|
654
|
+
// Genesis cannot be proven by a header, the branch alone proves that finalized_root is zero
|
|
677
655
|
finalityBranch = attestedData.finalityBranch;
|
|
678
|
-
|
|
679
|
-
// Fork of LightClientUpdate is based off on attested header's fork
|
|
680
|
-
if (this.config.getForkName(finalizedHeader.beacon.slot) !== attestedFork) {
|
|
681
|
-
finalizedHeader = upgradeLightClientHeader(this.config, attestedFork, finalizedHeader);
|
|
682
|
-
}
|
|
656
|
+
hasFinality = true;
|
|
683
657
|
} else {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
if (
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
this.
|
|
658
|
+
const finalizedHeaderAttested = await this.getFinalizedHeader(finalizedCheckpoint.root);
|
|
659
|
+
// If the finalized block is not available locally, both stay empty
|
|
660
|
+
if (finalizedHeaderAttested) {
|
|
661
|
+
finalityBranch = attestedData.finalityBranch;
|
|
662
|
+
finalizedHeader = finalizedHeaderAttested;
|
|
663
|
+
hasFinality = true;
|
|
664
|
+
// Fork of LightClientUpdate is based off on attested header's fork
|
|
665
|
+
if (this.config.getForkName(finalizedHeader.beacon.slot) !== attestedFork) {
|
|
666
|
+
finalizedHeader = upgradeLightClientHeader(this.config, attestedFork, finalizedHeader);
|
|
667
|
+
}
|
|
692
668
|
}
|
|
693
|
-
finalityBranch = zeroFinality.finalityBranch;
|
|
694
|
-
finalizedHeader = zeroFinality.finalizedHeader;
|
|
695
669
|
}
|
|
696
670
|
|
|
697
|
-
const
|
|
671
|
+
const update = {
|
|
698
672
|
attestedHeader,
|
|
699
|
-
nextSyncCommittee
|
|
673
|
+
nextSyncCommittee,
|
|
700
674
|
nextSyncCommitteeBranch,
|
|
701
675
|
finalizedHeader,
|
|
702
676
|
finalityBranch,
|
|
@@ -704,25 +678,17 @@ export class LightClientServer {
|
|
|
704
678
|
signatureSlot,
|
|
705
679
|
} as LightClientUpdate;
|
|
706
680
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
// see https://github.com/ChainSafe/lodestar/issues/3933
|
|
710
|
-
await this.db.bestLightClientUpdate.put(syncPeriod, newUpdate);
|
|
711
|
-
this.logger.debug("Stored new PartialLightClientUpdate", {
|
|
712
|
-
syncPeriod,
|
|
713
|
-
isFinalized,
|
|
714
|
-
participation: sumBits(syncAggregate.syncCommitteeBits) / SYNC_COMMITTEE_SIZE,
|
|
715
|
-
});
|
|
681
|
+
return {update, summary: toLightClientUpdateSummary(update), hasFinality};
|
|
682
|
+
}
|
|
716
683
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
);
|
|
684
|
+
private getZeroFinality(attestedFork: ForkName, attestedSlot: Slot): LightClientZeroFinality {
|
|
685
|
+
let zeroFinality = this.zeroFinalityByFork.get(attestedFork);
|
|
686
|
+
if (!zeroFinality) {
|
|
687
|
+
const zero = this.config.getPostAltairForkTypes(attestedSlot).LightClientUpdate.defaultValue();
|
|
688
|
+
zeroFinality = {finalityBranch: zero.finalityBranch, finalizedHeader: zero.finalizedHeader};
|
|
689
|
+
this.zeroFinalityByFork.set(attestedFork, zeroFinality);
|
|
690
|
+
}
|
|
691
|
+
return zeroFinality;
|
|
726
692
|
}
|
|
727
693
|
|
|
728
694
|
private async storeSyncCommittee(syncCommittee: altair.SyncCommittee, syncCommitteeRoot: Uint8Array): Promise<void> {
|
|
@@ -164,9 +164,12 @@ export class InclusionListStore {
|
|
|
164
164
|
return out;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Lists are kept one slot past the MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS serving window, the lists of slot N are
|
|
169
|
+
* read when the payload of slot N + 1 is processed, which may happen during slot N + 2
|
|
170
|
+
*/
|
|
168
171
|
prune(clockSlot: Slot): void {
|
|
169
|
-
const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS;
|
|
172
|
+
const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS - 1;
|
|
170
173
|
|
|
171
174
|
for (const slot of this.inclusionLists.keys()) {
|
|
172
175
|
if (slot < horizon) {
|
|
@@ -290,7 +290,7 @@ export class OpPool {
|
|
|
290
290
|
const endAttesterSlashings = stepsMetrics?.startTimer();
|
|
291
291
|
const attesterSlashings: AttesterSlashing[] = [];
|
|
292
292
|
const maxAttesterSlashings = stateFork >= ForkSeq.electra ? MAX_ATTESTER_SLASHINGS_ELECTRA : MAX_ATTESTER_SLASHINGS;
|
|
293
|
-
|
|
293
|
+
for (const [key, attesterSlashing] of this.attesterSlashings) {
|
|
294
294
|
const domains = getAttesterSlashingSignatureDomains(this.config, state.slot, attesterSlashing.attesterSlashing);
|
|
295
295
|
if (!attesterSlashing.verifiedDomains.every((domain, i) => byteArrayEquals(domain, domains[i]))) {
|
|
296
296
|
this.attesterSlashings.delete(key);
|
|
@@ -300,18 +300,15 @@ export class OpPool {
|
|
|
300
300
|
const slashableIndices = new Set<ValidatorIndex>();
|
|
301
301
|
for (let i = 0; i < attesterSlashing.intersectingIndices.length; i++) {
|
|
302
302
|
const index = attesterSlashing.intersectingIndices[i];
|
|
303
|
-
//
|
|
303
|
+
// Covered by an earlier slashing in this block, the remaining indices may still be slashable
|
|
304
304
|
if (toBeSlashedIndices.has(index)) {
|
|
305
|
-
continue
|
|
305
|
+
continue;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
const validator = state.getValidator(index);
|
|
309
309
|
if (isSlashableAtEpoch(validator, stateEpoch)) {
|
|
310
310
|
slashableIndices.add(index);
|
|
311
311
|
}
|
|
312
|
-
if (attesterSlashings.length >= maxAttesterSlashings) {
|
|
313
|
-
break attesterSlashing;
|
|
314
|
-
}
|
|
315
312
|
}
|
|
316
313
|
|
|
317
314
|
// If there were slashable indices in this slashing
|
|
@@ -321,6 +318,9 @@ export class OpPool {
|
|
|
321
318
|
for (const index of slashableIndices) {
|
|
322
319
|
toBeSlashedIndices.add(index);
|
|
323
320
|
}
|
|
321
|
+
if (attesterSlashings.length >= maxAttesterSlashings) {
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
endAttesterSlashings?.({
|
package/src/chain/options.ts
CHANGED
|
@@ -132,7 +132,7 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
132
132
|
// - users can prune the persisted checkpoint state files manually to save disc space
|
|
133
133
|
// - it helps debug easier when network is unfinalized
|
|
134
134
|
nHistoricalStatesFileDataStore: true,
|
|
135
|
-
nativeStateTransition:
|
|
135
|
+
nativeStateTransition: true,
|
|
136
136
|
maxBlockStates: DEFAULT_MAX_BLOCK_STATES,
|
|
137
137
|
maxCPStateEpochsInMemory: DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY,
|
|
138
138
|
maxCPStateEpochsOnDisk: DEFAULT_MAX_CP_STATE_ON_DISK,
|