@lodestar/beacon-node 1.49.0-dev.fa4ae94ccc → 1.49.0-rc.0
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 +13 -4
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +5 -3
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/metrics.js +2 -1
- package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +11 -2
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +46 -28
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts +2 -2
- package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/pruneHistory.js +1 -0
- package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
- package/lib/chain/blocks/importExecutionPayload.js +13 -0
- package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
- package/lib/chain/chain.d.ts +10 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +85 -16
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/errors/envelopeReconstructionError.d.ts +23 -0
- package/lib/chain/errors/envelopeReconstructionError.d.ts.map +1 -0
- package/lib/chain/errors/envelopeReconstructionError.js +13 -0
- package/lib/chain/errors/envelopeReconstructionError.js.map +1 -0
- package/lib/chain/errors/index.d.ts +1 -0
- package/lib/chain/errors/index.d.ts.map +1 -1
- package/lib/chain/errors/index.js +1 -0
- package/lib/chain/errors/index.js.map +1 -1
- package/lib/chain/interface.d.ts +6 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/interface.js.map +1 -1
- package/lib/chain/options.d.ts +2 -0
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -0
- package/lib/chain/options.js.map +1 -1
- package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts +21 -9
- package/lib/db/repositories/executionPayloadEnvelopeArchive.d.ts.map +1 -1
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js +32 -12
- package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
- package/lib/db/repositories/index.d.ts +1 -1
- package/lib/db/repositories/index.d.ts.map +1 -1
- package/lib/db/repositories/index.js +1 -1
- package/lib/db/repositories/index.js.map +1 -1
- package/lib/execution/engine/disabled.d.ts +1 -0
- package/lib/execution/engine/disabled.d.ts.map +1 -1
- package/lib/execution/engine/disabled.js +3 -0
- package/lib/execution/engine/disabled.js.map +1 -1
- package/lib/execution/engine/http.d.ts +2 -1
- package/lib/execution/engine/http.d.ts.map +1 -1
- package/lib/execution/engine/http.js +7 -1
- package/lib/execution/engine/http.js.map +1 -1
- package/lib/execution/engine/interface.d.ts +3 -1
- package/lib/execution/engine/interface.d.ts.map +1 -1
- package/lib/execution/engine/mock.d.ts +1 -0
- package/lib/execution/engine/mock.d.ts.map +1 -1
- package/lib/execution/engine/mock.js +14 -2
- package/lib/execution/engine/mock.js.map +1 -1
- package/lib/execution/engine/types.d.ts +11 -0
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +10 -0
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/metrics/metrics/beacon.d.ts +9 -0
- package/lib/metrics/metrics/beacon.d.ts.map +1 -1
- package/lib/metrics/metrics/beacon.js +16 -0
- package/lib/metrics/metrics/beacon.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +12 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +30 -0
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/metrics/metrics.d.ts +3 -1
- package/lib/metrics/metrics.d.ts.map +1 -1
- package/lib/metrics/metrics.js +2 -2
- package/lib/metrics/metrics.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +47 -34
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +23 -4
- package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
- package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/index.js +20 -4
- package/lib/network/reqresp/handlers/index.js.map +1 -1
- package/lib/sync/types.d.ts +0 -2
- package/lib/sync/types.d.ts.map +1 -1
- package/lib/sync/types.js +0 -2
- package/lib/sync/types.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +41 -13
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/util/execution.d.ts +42 -0
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +123 -2
- package/lib/util/execution.js.map +1 -1
- package/lib/util/headerEnvelope.d.ts +17 -0
- package/lib/util/headerEnvelope.d.ts.map +1 -0
- package/lib/util/headerEnvelope.js +43 -0
- package/lib/util/headerEnvelope.js.map +1 -0
- package/package.json +16 -16
- package/src/api/impl/beacon/blocks/index.ts +16 -3
- package/src/chain/archiveStore/archiveStore.ts +6 -3
- package/src/chain/archiveStore/historicalState/metrics.ts +3 -2
- package/src/chain/archiveStore/utils/archiveBlocks.ts +54 -32
- package/src/chain/archiveStore/utils/pruneHistory.ts +4 -2
- package/src/chain/blocks/importExecutionPayload.ts +14 -0
- package/src/chain/chain.ts +96 -20
- package/src/chain/errors/envelopeReconstructionError.ts +22 -0
- package/src/chain/errors/index.ts +1 -0
- package/src/chain/interface.ts +6 -1
- package/src/chain/options.ts +3 -0
- package/src/db/buckets.ts +1 -1
- package/src/db/repositories/executionPayloadEnvelopeArchive.ts +43 -13
- package/src/db/repositories/index.ts +6 -1
- package/src/execution/engine/disabled.ts +4 -0
- package/src/execution/engine/http.ts +12 -0
- package/src/execution/engine/interface.ts +4 -1
- package/src/execution/engine/mock.ts +22 -2
- package/src/execution/engine/types.ts +25 -0
- package/src/metrics/metrics/beacon.ts +16 -0
- package/src/metrics/metrics/lodestar.ts +31 -0
- package/src/metrics/metrics.ts +7 -2
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +57 -39
- package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +27 -5
- package/src/network/reqresp/handlers/index.ts +49 -5
- package/src/sync/types.ts +0 -2
- package/src/sync/unknownBlock.ts +41 -13
- package/src/util/execution.ts +175 -2
- package/src/util/headerEnvelope.ts +76 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ssz } from "@lodestar/types";
|
|
2
|
+
import { toRootHex } from "@lodestar/utils";
|
|
3
|
+
import { EnvelopeReconstructionError, EnvelopeReconstructionErrorCode, } from "../chain/errors/envelopeReconstructionError.js";
|
|
4
|
+
const { transactions, withdrawals, blockAccessList } = ssz.gloas.ExecutionPayload.fields;
|
|
5
|
+
/** Replace the three body lists by their roots; hashes to the same root as the full envelope */
|
|
6
|
+
export function toHeaderEnvelope(envelope) {
|
|
7
|
+
const { payload, ...envelopeFields } = envelope;
|
|
8
|
+
const { transactions: txs, withdrawals: wds, blockAccessList: bal, ...scalars } = payload;
|
|
9
|
+
return {
|
|
10
|
+
...envelopeFields,
|
|
11
|
+
payloadHeader: {
|
|
12
|
+
...scalars,
|
|
13
|
+
transactionsRoot: transactions.hashTreeRoot(txs),
|
|
14
|
+
withdrawalsRoot: withdrawals.hashTreeRoot(wds),
|
|
15
|
+
blockAccessListRoot: blockAccessList.hashTreeRoot(bal),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function toSignedHeaderEnvelope(envelope) {
|
|
20
|
+
return { message: toHeaderEnvelope(envelope.message), signature: envelope.signature };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Rebuild the full signed envelope from header envelope + EL bodies, each body verified against its stored
|
|
24
|
+
* root. Throws {@link EnvelopeReconstructionError} BODY_ROOT_MISMATCH naming the first body that differs.
|
|
25
|
+
*/
|
|
26
|
+
export function signedHeaderEnvelopeToFull(headerEnvelope, bodies) {
|
|
27
|
+
const { payloadHeader, ...envelopeFields } = headerEnvelope.message;
|
|
28
|
+
const { transactionsRoot, withdrawalsRoot, blockAccessListRoot, ...scalars } = payloadHeader;
|
|
29
|
+
const slot = scalars.slotNumber;
|
|
30
|
+
assertBodyRoot("transactions", slot, transactionsRoot, transactions.hashTreeRoot(bodies.transactions));
|
|
31
|
+
assertBodyRoot("withdrawals", slot, withdrawalsRoot, withdrawals.hashTreeRoot(bodies.withdrawals));
|
|
32
|
+
assertBodyRoot("blockAccessList", slot, blockAccessListRoot, blockAccessList.hashTreeRoot(bodies.blockAccessList));
|
|
33
|
+
return {
|
|
34
|
+
message: { ...envelopeFields, payload: { ...scalars, ...bodies } },
|
|
35
|
+
signature: headerEnvelope.signature,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function assertBodyRoot(field, slot, stored, rebuilt) {
|
|
39
|
+
if (!ssz.Root.equals(stored, rebuilt)) {
|
|
40
|
+
throw new EnvelopeReconstructionError({ code: EnvelopeReconstructionErrorCode.BODY_ROOT_MISMATCH, slot, field }, `reconstructed ${field} root mismatch slot=${slot} stored=${toRootHex(stored)} rebuilt=${toRootHex(rebuilt)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=headerEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerEnvelope.js","sourceRoot":"","sources":["../../src/util/headerEnvelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAUpC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,gDAAgD,CAAC;AAWxD,MAAM,EAAC,YAAY,EAAE,WAAW,EAAE,eAAe,EAAC,GAAG,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC;AAEvF,gGAAgG;AAChG,MAAM,UAAU,gBAAgB,CAAC,QAAkC;IACjE,MAAM,EAAC,OAAO,EAAE,GAAG,cAAc,EAAC,GAAG,QAAQ,CAAC;IAC9C,MAAM,EAAC,YAAY,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,OAAO,EAAC,GAAG,OAAO,CAAC;IACxF,OAAO;QACL,GAAG,cAAc;QACjB,aAAa,EAAE;YACb,GAAG,OAAO;YACV,gBAAgB,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC;YAChD,eAAe,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC;YAC9C,mBAAmB,EAAE,eAAe,CAAC,YAAY,CAAC,GAAG,CAAC;SACvD;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAwC;IAC7E,OAAO,EAAC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAC,CAAC;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAoD,EACpD,MAA8B;IAE9B,MAAM,EAAC,aAAa,EAAE,GAAG,cAAc,EAAC,GAAG,cAAc,CAAC,OAAO,CAAC;IAClE,MAAM,EAAC,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG,OAAO,EAAC,GAAG,aAAa,CAAC;IAC3F,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC;IAEhC,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACvG,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IACnG,cAAc,CAAC,iBAAiB,EAAE,IAAI,EAAE,mBAAmB,EAAE,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;IAEnH,OAAO;QACL,OAAO,EAAE,EAAC,GAAG,cAAc,EAAE,OAAO,EAAE,EAAC,GAAG,OAAO,EAAE,GAAG,MAAM,EAAC,EAAC;QAC9D,SAAS,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAgC,EAAE,IAAY,EAAE,MAAkB,EAAE,OAAmB;IAC7G,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,2BAA2B,CACnC,EAAC,IAAI,EAAE,+BAA+B,CAAC,kBAAkB,EAAE,IAAI,EAAE,KAAK,EAAC,EACvE,iBAAiB,KAAK,uBAAuB,IAAI,WAAW,SAAS,CAAC,MAAM,CAAC,YAAY,SAAS,CAAC,OAAO,CAAC,EAAE,CAC9G,CAAC;IACJ,CAAC;AACH,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.49.0-
|
|
14
|
+
"version": "1.49.0-rc.0",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@fastify/swagger-ui": "^5.0.1",
|
|
119
119
|
"@libp2p/bootstrap": "^12.0.30",
|
|
120
120
|
"@libp2p/crypto": "^5.1.23",
|
|
121
|
-
"@libp2p/gossipsub": "^17.1.
|
|
121
|
+
"@libp2p/gossipsub": "^17.1.2",
|
|
122
122
|
"@libp2p/identify": "^4.1.13",
|
|
123
123
|
"@libp2p/interface": "^3.3.0",
|
|
124
124
|
"@libp2p/mdns": "^12.0.30",
|
|
@@ -127,17 +127,17 @@
|
|
|
127
127
|
"@libp2p/prometheus-metrics": "^5.0.28",
|
|
128
128
|
"@libp2p/tcp": "^11.0.27",
|
|
129
129
|
"@libp2p/utils": "^7.4.0",
|
|
130
|
-
"@lodestar/api": "^1.49.0-
|
|
131
|
-
"@lodestar/config": "^1.49.0-
|
|
132
|
-
"@lodestar/db": "^1.49.0-
|
|
133
|
-
"@lodestar/fork-choice": "^1.49.0-
|
|
134
|
-
"@lodestar/logger": "^1.49.0-
|
|
135
|
-
"@lodestar/params": "^1.49.0-
|
|
136
|
-
"@lodestar/reqresp": "^1.49.0-
|
|
137
|
-
"@lodestar/state-transition": "^1.49.0-
|
|
138
|
-
"@lodestar/types": "^1.49.0-
|
|
139
|
-
"@lodestar/utils": "^1.49.0-
|
|
140
|
-
"@lodestar/validator": "^1.49.0-
|
|
130
|
+
"@lodestar/api": "^1.49.0-rc.0",
|
|
131
|
+
"@lodestar/config": "^1.49.0-rc.0",
|
|
132
|
+
"@lodestar/db": "^1.49.0-rc.0",
|
|
133
|
+
"@lodestar/fork-choice": "^1.49.0-rc.0",
|
|
134
|
+
"@lodestar/logger": "^1.49.0-rc.0",
|
|
135
|
+
"@lodestar/params": "^1.49.0-rc.0",
|
|
136
|
+
"@lodestar/reqresp": "^1.49.0-rc.0",
|
|
137
|
+
"@lodestar/state-transition": "^1.49.0-rc.0",
|
|
138
|
+
"@lodestar/types": "^1.49.0-rc.0",
|
|
139
|
+
"@lodestar/utils": "^1.49.0-rc.0",
|
|
140
|
+
"@lodestar/validator": "^1.49.0-rc.0",
|
|
141
141
|
"@multiformats/multiaddr": "^13.0.1",
|
|
142
142
|
"datastore-core": "^12.0.1",
|
|
143
143
|
"datastore-level": "^13.0.1",
|
|
@@ -156,10 +156,10 @@
|
|
|
156
156
|
"xxhash-wasm": "1.0.2"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
160
159
|
"@libp2p/interface-internal": "^3.1.12",
|
|
161
160
|
"@libp2p/logger": "^6.2.13",
|
|
162
|
-
"@lodestar/spec-test-util": "^1.49.0-
|
|
161
|
+
"@lodestar/spec-test-util": "^1.49.0-rc.0",
|
|
162
|
+
"@lodestar/test-utils": "^1.49.0-rc.0",
|
|
163
163
|
"@types/js-yaml": "^4.0.5",
|
|
164
164
|
"@types/qs": "^6.9.7",
|
|
165
165
|
"@types/tmp": "^0.2.3",
|
|
@@ -174,5 +174,5 @@
|
|
|
174
174
|
"beacon",
|
|
175
175
|
"blockchain"
|
|
176
176
|
],
|
|
177
|
-
"gitHead": "
|
|
177
|
+
"gitHead": "72d434162a8e245786d7ff64b86289a29e2a4769"
|
|
178
178
|
}
|
|
@@ -47,6 +47,8 @@ import {
|
|
|
47
47
|
BlockError,
|
|
48
48
|
BlockErrorCode,
|
|
49
49
|
BlockGossipError,
|
|
50
|
+
EnvelopeReconstructionError,
|
|
51
|
+
EnvelopeReconstructionErrorCode,
|
|
50
52
|
ExecutionPayloadEnvelopeError,
|
|
51
53
|
ExecutionPayloadEnvelopeErrorCode,
|
|
52
54
|
} from "../../../../chain/errors/index.js";
|
|
@@ -1109,9 +1111,20 @@ export function getBeaconBlockApi({
|
|
|
1109
1111
|
const blockRoot = config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block.message);
|
|
1110
1112
|
const blockRootHex = toRootHex(blockRoot);
|
|
1111
1113
|
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1114
|
+
let data: Uint8Array | gloas.SignedExecutionPayloadEnvelope | null;
|
|
1115
|
+
try {
|
|
1116
|
+
data = context?.returnBytes
|
|
1117
|
+
? await chain.getSerializedExecutionPayloadEnvelope(slot, blockRootHex)
|
|
1118
|
+
: await chain.getExecutionPayloadEnvelope(slot, blockRootHex);
|
|
1119
|
+
} catch (e) {
|
|
1120
|
+
if (e instanceof EnvelopeReconstructionError) {
|
|
1121
|
+
throw new ApiError(
|
|
1122
|
+
e.type.code === EnvelopeReconstructionErrorCode.ENGINE_UNAVAILABLE ? 503 : 500,
|
|
1123
|
+
`Failed to reconstruct execution payload envelope: ${e.message}`
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
throw e;
|
|
1127
|
+
}
|
|
1115
1128
|
|
|
1116
1129
|
if (!data) {
|
|
1117
1130
|
throw new ApiError(404, `Execution payload envelope not found for slot=${slot}, blockRoot=${blockRootHex}`);
|
|
@@ -103,7 +103,7 @@ export class ArchiveStore {
|
|
|
103
103
|
if (this.opts.pruneHistory) {
|
|
104
104
|
// prune ALL stale data before starting
|
|
105
105
|
this.logger.info("Pruning historical data");
|
|
106
|
-
await callFnWhenAwait(
|
|
106
|
+
const blockCutoffSlot = await callFnWhenAwait(
|
|
107
107
|
pruneHistory(
|
|
108
108
|
this.chain.config,
|
|
109
109
|
this.db,
|
|
@@ -116,6 +116,7 @@ export class ArchiveStore {
|
|
|
116
116
|
30_000,
|
|
117
117
|
this.signal
|
|
118
118
|
);
|
|
119
|
+
this.chain.earliestAvailableSlot = Math.max(this.chain.earliestAvailableSlot, blockCutoffSlot);
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
if (this.opts.serveHistoricalState) {
|
|
@@ -228,13 +229,14 @@ export class ArchiveStore {
|
|
|
228
229
|
isNodeSynced,
|
|
229
230
|
this.archiveDataEpochs,
|
|
230
231
|
this.chain.opts.persistOrphanedBlocks,
|
|
231
|
-
this.chain.opts.persistOrphanedBlocksDir
|
|
232
|
+
this.chain.opts.persistOrphanedBlocksDir,
|
|
233
|
+
this.chain.opts.dedupePayloads
|
|
232
234
|
);
|
|
233
235
|
timer?.({source: ArchiveStoreTask.ArchiveBlocks});
|
|
234
236
|
|
|
235
237
|
if (this.opts.pruneHistory) {
|
|
236
238
|
timer = this.metrics?.processFinalizedCheckpoint.durationByTask.startTimer();
|
|
237
|
-
await pruneHistory(
|
|
239
|
+
const blockCutoffSlot = await pruneHistory(
|
|
238
240
|
this.chain.config,
|
|
239
241
|
this.db,
|
|
240
242
|
this.logger,
|
|
@@ -242,6 +244,7 @@ export class ArchiveStore {
|
|
|
242
244
|
finalizedEpoch,
|
|
243
245
|
this.chain.clock.currentEpoch
|
|
244
246
|
);
|
|
247
|
+
this.chain.earliestAvailableSlot = Math.max(this.chain.earliestAvailableSlot, blockCutoffSlot);
|
|
245
248
|
timer?.({source: ArchiveStoreTask.PruneHistory});
|
|
246
249
|
}
|
|
247
250
|
|
|
@@ -156,9 +156,10 @@ export function createHistoricalStateTransitionMetrics(
|
|
|
156
156
|
name: "lodestar_historical_state_stfn_attestations_per_block_total",
|
|
157
157
|
help: "Count of attestations per block",
|
|
158
158
|
}),
|
|
159
|
-
progressiveBalancesMismatches: metricsRegister.counter({
|
|
159
|
+
progressiveBalancesMismatches: metricsRegister.counter<{target: "current" | "previous"}>({
|
|
160
160
|
name: "lodestar_historical_state_stfn_progressive_balances_mismatches_total",
|
|
161
|
-
help: "Total count of progressive balance cache mismatches",
|
|
161
|
+
help: "Total count of progressive balance cache mismatches by target balance",
|
|
162
|
+
labelNames: ["target"],
|
|
162
163
|
}),
|
|
163
164
|
proposerRewards: metricsRegister.gauge<{type: ProposerRewardType}>({
|
|
164
165
|
name: "lodestar_historical_state_stfn_proposer_rewards_total",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {KeyValue} from "@lodestar/db";
|
|
4
|
-
import {CheckpointWithHex, IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
4
|
+
import {CheckpointWithHex, ExecutionStatus, IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
|
|
5
5
|
import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
6
6
|
import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
7
7
|
import {Epoch, Slot} from "@lodestar/types";
|
|
8
8
|
import {Logger, fromAsync, fromHex, prettyPrintIndices, toRootHex} from "@lodestar/utils";
|
|
9
9
|
import {IBeaconDb} from "../../../db/index.js";
|
|
10
|
-
import {BlockArchiveBatchPutBinaryItem} from "../../../db/repositories/index.js";
|
|
10
|
+
import {BlockArchiveBatchPutBinaryItem, encodeArchivedHeaderEnvelope} from "../../../db/repositories/index.js";
|
|
11
11
|
import {Metrics} from "../../../metrics/metrics.js";
|
|
12
12
|
import {ensureDir, writeIfNotExist} from "../../../util/file.js";
|
|
13
|
+
import {toSignedHeaderEnvelope} from "../../../util/headerEnvelope.js";
|
|
13
14
|
import {BlockRootHex} from "../../../util/sszBytes.js";
|
|
14
15
|
import {LightClientServer} from "../../lightClient/index.js";
|
|
15
16
|
|
|
@@ -69,7 +70,8 @@ export async function archiveBlocks(
|
|
|
69
70
|
isNodeSynced: boolean,
|
|
70
71
|
archiveDataEpochs?: number,
|
|
71
72
|
persistOrphanedBlocks?: boolean,
|
|
72
|
-
persistOrphanedBlocksDir?: string
|
|
73
|
+
persistOrphanedBlocksDir?: string,
|
|
74
|
+
dedupePayloads = true
|
|
73
75
|
): Promise<void> {
|
|
74
76
|
// Use fork choice to determine the blocks to archive and delete.
|
|
75
77
|
// `ancestors` is the canonical walk back from the finalized root, including the previous finalized
|
|
@@ -156,7 +158,8 @@ export async function archiveBlocks(
|
|
|
156
158
|
config,
|
|
157
159
|
db,
|
|
158
160
|
logger,
|
|
159
|
-
finalizedCanonicalBlocks
|
|
161
|
+
finalizedCanonicalBlocks,
|
|
162
|
+
dedupePayloads
|
|
160
163
|
);
|
|
161
164
|
logger.verbose("Migrated executionPayloadEnvelopes from hot DB to cold DB", {
|
|
162
165
|
...logCtx,
|
|
@@ -475,49 +478,68 @@ async function migrateDataColumnSidecarsFromHotToColdDb(
|
|
|
475
478
|
/**
|
|
476
479
|
* Post-gloas given a finalized checkpoint at a block root, payload of that block root
|
|
477
480
|
* is not considered finalized, hence they are archived in the next run.
|
|
481
|
+
*
|
|
482
|
+
* With `dedupePayloads` (default), execution-valid envelopes are archived as header envelopes. Envelopes of
|
|
483
|
+
* still-optimistic blocks are archived in full, since the EL may not serve their bodies, and are not
|
|
484
|
+
* converted later. Archive put + hot delete are one atomic db batch.
|
|
478
485
|
*/
|
|
479
|
-
async function migrateExecutionPayloadEnvelopesFromHotToColdDb(
|
|
486
|
+
export async function migrateExecutionPayloadEnvelopesFromHotToColdDb(
|
|
480
487
|
config: ChainForkConfig,
|
|
481
488
|
db: IBeaconDb,
|
|
482
489
|
logger: Logger,
|
|
483
|
-
canonicalBlocks: ProtoBlock[]
|
|
490
|
+
canonicalBlocks: ProtoBlock[],
|
|
491
|
+
dedupePayloads: boolean
|
|
484
492
|
): Promise<Slot[]> {
|
|
485
493
|
const payloadBlocks = canonicalBlocks.filter(
|
|
486
|
-
(block) => config.getForkSeq(block.slot)
|
|
494
|
+
(block) => config.getForkSeq(block.slot) >= ForkSeq.gloas && block.payloadStatus === PayloadStatus.FULL
|
|
487
495
|
);
|
|
488
496
|
if (payloadBlocks.length === 0) return [];
|
|
489
|
-
const blocks = payloadBlocks.map((block) => ({slot: block.slot, root: fromHex(block.blockRoot)}));
|
|
490
497
|
|
|
491
|
-
const
|
|
492
|
-
const migratedRoots: Uint8Array[] = [];
|
|
498
|
+
const migratedSlots: Slot[] = [];
|
|
493
499
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
)
|
|
500
|
+
// Process in chunks to bound memory: after a long non-finality period the ancestor walk can span
|
|
501
|
+
// thousands of blocks, and each full envelope is a few hundred KB when deserialized.
|
|
502
|
+
for (let i = 0; i < payloadBlocks.length; i += BLOCK_BATCH_SIZE) {
|
|
503
|
+
const batch = payloadBlocks.slice(i, i + BLOCK_BATCH_SIZE);
|
|
504
|
+
// Only header envelopes need deserializing; full ones are copied as bytes
|
|
505
|
+
const archivedBytesArray = await Promise.all(
|
|
506
|
+
batch.map(async (block) => {
|
|
507
|
+
const root = fromHex(block.blockRoot);
|
|
508
|
+
if (dedupePayloads && block.executionStatus === ExecutionStatus.Valid) {
|
|
509
|
+
const envelope = await db.executionPayloadEnvelope.get(root);
|
|
510
|
+
return envelope === null ? null : encodeArchivedHeaderEnvelope(toSignedHeaderEnvelope(envelope));
|
|
511
|
+
}
|
|
512
|
+
return db.executionPayloadEnvelope.getBinary(root);
|
|
513
|
+
})
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
const entries: {slot: Slot; archivedBytes: Uint8Array; hotKey: Uint8Array}[] = [];
|
|
517
|
+
for (let j = 0; j < batch.length; j++) {
|
|
518
|
+
const block = batch[j];
|
|
519
|
+
const archivedBytes = archivedBytesArray[j];
|
|
520
|
+
if (archivedBytes === null) {
|
|
521
|
+
logger.debug("ExecutionPayloadEnvelope in forkchoice but missing in hot db, could be already archived", {
|
|
522
|
+
slot: block.slot,
|
|
523
|
+
root: block.blockRoot,
|
|
524
|
+
});
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
497
527
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
migratedRoots.push(blocks[i].root);
|
|
503
|
-
} else {
|
|
504
|
-
logger.debug("ExecutionPayloadEnvelope in forkchoice but missing in hot db, could be already archived", {
|
|
505
|
-
slot: blocks[i].slot,
|
|
506
|
-
root: toRootHex(blocks[i].root),
|
|
528
|
+
entries.push({
|
|
529
|
+
slot: block.slot,
|
|
530
|
+
archivedBytes,
|
|
531
|
+
hotKey: db.executionPayloadEnvelope.encodeKey(fromHex(block.blockRoot)),
|
|
507
532
|
});
|
|
533
|
+
migratedSlots.push(block.slot);
|
|
508
534
|
}
|
|
509
|
-
}
|
|
510
535
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
db.executionPayloadEnvelope.batchDelete(migratedRoots),
|
|
516
|
-
]);
|
|
536
|
+
if (entries.length > 0) {
|
|
537
|
+
await db.executionPayloadEnvelopeArchive.batchArchiveAndDeleteHot(entries);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
517
540
|
|
|
518
|
-
//
|
|
519
|
-
|
|
520
|
-
return envelopeEntries.map((entry) => entry.key).sort((a, b) => a - b);
|
|
541
|
+
// Ancestor walk is newest to oldest; sort ascending so `prettyPrintIndices` renders cleanly.
|
|
542
|
+
return migratedSlots.sort((a, b) => a - b);
|
|
521
543
|
}
|
|
522
544
|
|
|
523
545
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ChainConfig} from "@lodestar/config";
|
|
2
2
|
import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
|
|
3
|
-
import {Epoch} from "@lodestar/types";
|
|
3
|
+
import {Epoch, Slot} from "@lodestar/types";
|
|
4
4
|
import {Logger, prettyPrintIndices} from "@lodestar/utils";
|
|
5
5
|
import {IBeaconDb} from "../../../db/interface.js";
|
|
6
6
|
import {Metrics} from "../../../metrics/index.js";
|
|
@@ -12,7 +12,7 @@ export async function pruneHistory(
|
|
|
12
12
|
metrics: Metrics | null | undefined,
|
|
13
13
|
finalizedEpoch: Epoch,
|
|
14
14
|
currentEpoch: Epoch
|
|
15
|
-
): Promise<
|
|
15
|
+
): Promise<Slot> {
|
|
16
16
|
const blockCutoffEpoch = Math.min(
|
|
17
17
|
// set by config, with underflow protection
|
|
18
18
|
Math.max(currentEpoch - config.MIN_EPOCHS_FOR_BLOCK_REQUESTS, 0),
|
|
@@ -63,4 +63,6 @@ export async function pruneHistory(
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
metrics?.pruneHistory.pruneCount.inc();
|
|
66
|
+
|
|
67
|
+
return blockCutoffSlot;
|
|
66
68
|
}
|
|
@@ -12,6 +12,7 @@ import {isQueueErrorAborted} from "../../util/queue/index.js";
|
|
|
12
12
|
import {BeaconChain} from "../chain.js";
|
|
13
13
|
import {RegenCaller} from "../regen/interface.js";
|
|
14
14
|
import {PayloadEnvelopeInput} from "../seenCache/seenPayloadEnvelopeInput.js";
|
|
15
|
+
import {PayloadEnvelopeInputSource} from "./payloadEnvelopeInput/index.js";
|
|
15
16
|
import {ImportPayloadOpts} from "./types.js";
|
|
16
17
|
import {
|
|
17
18
|
verifyExecutionPayloadEnvelope,
|
|
@@ -172,6 +173,9 @@ export async function importExecutionPayload(
|
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
// 4a. Run EL and signature verification in parallel
|
|
176
|
+
const logCtx = {slot, root: blockRootHex, executionBlock: envelope.payload.blockNumber};
|
|
177
|
+
this.logger.debug("Call engine api newPayload", logCtx);
|
|
178
|
+
const verifyStartSec = Date.now() / 1000;
|
|
175
179
|
const [execResult, signatureValid] = await Promise.all([
|
|
176
180
|
this.executionEngine.notifyNewPayload(
|
|
177
181
|
fork,
|
|
@@ -191,6 +195,8 @@ export async function importExecutionPayload(
|
|
|
191
195
|
this.bls
|
|
192
196
|
),
|
|
193
197
|
]);
|
|
198
|
+
this.logger.debug("Receive engine api newPayload result", {...logCtx, status: execResult.status});
|
|
199
|
+
this.metrics?.engineNotifyNewPayloadResult.inc({result: execResult.status});
|
|
194
200
|
|
|
195
201
|
// 4b. Check signature verification result
|
|
196
202
|
if (!signatureValid) {
|
|
@@ -223,6 +229,14 @@ export async function importExecutionPayload(
|
|
|
223
229
|
});
|
|
224
230
|
}
|
|
225
231
|
|
|
232
|
+
const {source, seenTimestampSec} = payloadInput.getPayloadEnvelopeSource();
|
|
233
|
+
if (execResult.status === ExecutionPayloadStatus.VALID && source === PayloadEnvelopeInputSource.gossip) {
|
|
234
|
+
const nowSec = Date.now() / 1000;
|
|
235
|
+
this.metrics?.gossipExecutionPayloadEnvelope.executionPayload.recvToValidation.observe(nowSec - seenTimestampSec);
|
|
236
|
+
// same metric as pre-gloas, it tracks EL verification time regardless of fork
|
|
237
|
+
this.metrics?.gossipBlock.executionPayload.validationTime.observe(nowSec - verifyStartSec);
|
|
238
|
+
}
|
|
239
|
+
|
|
226
240
|
// 5. Persist payload envelope to hot DB. Wait for write-queue space here to apply backpressure
|
|
227
241
|
// on the import pipeline during sync, then perform the write asynchronously to avoid blocking.
|
|
228
242
|
await this.unfinalizedPayloadEnvelopeWrites.waitForSpace();
|
package/src/chain/chain.ts
CHANGED
|
@@ -61,6 +61,7 @@ import {ProcessShutdownCallback} from "@lodestar/validator";
|
|
|
61
61
|
import {GENESIS_EPOCH, ZERO_HASH} from "../constants/index.js";
|
|
62
62
|
import {IBeaconDb} from "../db/index.js";
|
|
63
63
|
import {BLOB_SIDECARS_IN_WRAPPER_INDEX} from "../db/repositories/blobSidecars.js";
|
|
64
|
+
import {decodeArchivedEnvelope} from "../db/repositories/index.js";
|
|
64
65
|
import {BuilderApiClient, BuilderApiClientOpts} from "../execution/builder/apiClient.js";
|
|
65
66
|
import {BuilderStatus} from "../execution/builder/http.js";
|
|
66
67
|
import {IExecutionBuilder, IExecutionEngine} from "../execution/index.js";
|
|
@@ -70,6 +71,7 @@ import {BufferPool} from "../util/bufferPool.js";
|
|
|
70
71
|
import {Clock, ClockEvent, IClock} from "../util/clock.js";
|
|
71
72
|
import {CustodyConfig, getValidatorsCustodyRequirement} from "../util/dataColumns.js";
|
|
72
73
|
import {callInNextEventLoop} from "../util/eventLoop.js";
|
|
74
|
+
import {ReconstructMismatchPolicy, isRebuildMiss, reconstructExecutionPayloadEnvelopes} from "../util/execution.js";
|
|
73
75
|
import {ensureDir, writeIfNotExist} from "../util/file.js";
|
|
74
76
|
import {isOptimisticBlock} from "../util/forkChoice.js";
|
|
75
77
|
import {JobItemQueue} from "../util/queue/itemQueue.js";
|
|
@@ -926,21 +928,71 @@ export class BeaconChain implements IBeaconChain {
|
|
|
926
928
|
}
|
|
927
929
|
|
|
928
930
|
async getSerializedExecutionPayloadEnvelope(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null> {
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
931
|
+
const [bytes] = await this.getSerializedExecutionPayloadEnvelopes([{blockSlot, blockRootHex}]);
|
|
932
|
+
return bytes;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Batch variant: archived header envelopes are rebuilt 32 per EL round-trip. Aligned with `requests`.
|
|
937
|
+
* A body root mismatch is a local inconsistency: `"throw"` surfaces it, `"omit"` logs it and
|
|
938
|
+
* returns null for that entry, for peer-facing paths where the spec allows omission.
|
|
939
|
+
*/
|
|
940
|
+
async getSerializedExecutionPayloadEnvelopes(
|
|
941
|
+
requests: {blockSlot: Slot; blockRootHex: RootHex}[],
|
|
942
|
+
onMismatch: ReconstructMismatchPolicy = "throw"
|
|
943
|
+
): Promise<(Uint8Array | null)[]> {
|
|
944
|
+
const out: (Uint8Array | null)[] = new Array(requests.length).fill(null);
|
|
945
|
+
const headerEnvelopes: gloas.SignedExecutionPayloadHeaderEnvelope[] = [];
|
|
946
|
+
const headerEnvelopeIdxs: number[] = [];
|
|
947
|
+
|
|
948
|
+
for (let i = 0; i < requests.length; i++) {
|
|
949
|
+
const {blockSlot, blockRootHex} = requests[i];
|
|
950
|
+
|
|
951
|
+
const payloadInput = this.seenPayloadEnvelopeInputCache.get(blockRootHex);
|
|
952
|
+
if (payloadInput?.hasPayloadEnvelope()) {
|
|
953
|
+
const envelope = payloadInput.getPayloadEnvelope();
|
|
954
|
+
out[i] = this.serializedCache.get(envelope) ?? ssz.gloas.SignedExecutionPayloadEnvelope.serialize(envelope);
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
const hot = await this.db.executionPayloadEnvelope.getBinary(fromHex(blockRootHex));
|
|
959
|
+
if (hot !== null) {
|
|
960
|
+
out[i] = hot;
|
|
961
|
+
continue;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
const archivedBytes = await this.db.executionPayloadEnvelopeArchive.getBinary(blockSlot);
|
|
965
|
+
if (archivedBytes === null) continue;
|
|
966
|
+
|
|
967
|
+
const archived = decodeArchivedEnvelope(archivedBytes);
|
|
968
|
+
if (archived.envelopeBytes !== undefined) {
|
|
969
|
+
out[i] = archived.envelopeBytes;
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
headerEnvelopes.push(archived.headerEnvelope);
|
|
973
|
+
headerEnvelopeIdxs.push(i);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
if (headerEnvelopes.length > 0) {
|
|
977
|
+
const rebuilt = await reconstructExecutionPayloadEnvelopes(this.executionEngine, this.metrics, headerEnvelopes);
|
|
978
|
+
for (let j = 0; j < rebuilt.length; j++) {
|
|
979
|
+
const result = rebuilt[j];
|
|
980
|
+
if (isRebuildMiss(result)) {
|
|
981
|
+
if (result.reason === "mismatch") {
|
|
982
|
+
if (onMismatch === "throw") throw result.error;
|
|
983
|
+
this.logger.debug(
|
|
984
|
+
"Archived envelope failed body root check against EL bodies",
|
|
985
|
+
{slot: result.slot},
|
|
986
|
+
result.error
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
out[headerEnvelopeIdxs[j]] = ssz.gloas.SignedExecutionPayloadEnvelope.serialize(result);
|
|
935
992
|
}
|
|
936
|
-
return ssz.gloas.SignedExecutionPayloadEnvelope.serialize(envelope);
|
|
937
993
|
}
|
|
938
994
|
|
|
939
|
-
return
|
|
940
|
-
(await this.db.executionPayloadEnvelope.getBinary(fromHex(blockRootHex))) ??
|
|
941
|
-
(await this.db.executionPayloadEnvelopeArchive.getBinary(blockSlot)) ??
|
|
942
|
-
null
|
|
943
|
-
);
|
|
995
|
+
return out;
|
|
944
996
|
}
|
|
945
997
|
|
|
946
998
|
async getExecutionPayloadEnvelope(
|
|
@@ -952,11 +1004,23 @@ export class BeaconChain implements IBeaconChain {
|
|
|
952
1004
|
return payloadInput.getPayloadEnvelope();
|
|
953
1005
|
}
|
|
954
1006
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
);
|
|
1007
|
+
const hot = await this.db.executionPayloadEnvelope.get(fromHex(blockRootHex));
|
|
1008
|
+
if (hot !== null) return hot;
|
|
1009
|
+
|
|
1010
|
+
const archivedBytes = await this.db.executionPayloadEnvelopeArchive.getBinary(blockSlot);
|
|
1011
|
+
if (archivedBytes === null) return null;
|
|
1012
|
+
const archived = decodeArchivedEnvelope(archivedBytes);
|
|
1013
|
+
if (archived.envelopeBytes !== undefined) {
|
|
1014
|
+
return ssz.gloas.SignedExecutionPayloadEnvelope.deserialize(archived.envelopeBytes);
|
|
1015
|
+
}
|
|
1016
|
+
const [result] = await reconstructExecutionPayloadEnvelopes(this.executionEngine, this.metrics, [
|
|
1017
|
+
archived.headerEnvelope,
|
|
1018
|
+
]);
|
|
1019
|
+
if (isRebuildMiss(result)) {
|
|
1020
|
+
if (result.reason === "mismatch") throw result.error;
|
|
1021
|
+
return null;
|
|
1022
|
+
}
|
|
1023
|
+
return result;
|
|
960
1024
|
}
|
|
961
1025
|
|
|
962
1026
|
async getParentExecutionRequests(
|
|
@@ -967,11 +1031,23 @@ export class BeaconChain implements IBeaconChain {
|
|
|
967
1031
|
if (!isForkPostGloas(this.config.getForkName(parentBlockSlot))) {
|
|
968
1032
|
return ssz.gloas.ExecutionRequests.defaultValue();
|
|
969
1033
|
}
|
|
970
|
-
|
|
971
|
-
|
|
1034
|
+
// executionRequests is kept in the header envelope, so read it without reconstructing
|
|
1035
|
+
const payloadInput = this.seenPayloadEnvelopeInputCache.get(parentBlockRootHex);
|
|
1036
|
+
if (payloadInput?.hasPayloadEnvelope()) {
|
|
1037
|
+
return payloadInput.getPayloadEnvelope().message.executionRequests;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
const hot = await this.db.executionPayloadEnvelope.get(fromHex(parentBlockRootHex));
|
|
1041
|
+
if (hot !== null) return hot.message.executionRequests;
|
|
1042
|
+
|
|
1043
|
+
const archivedBytes = await this.db.executionPayloadEnvelopeArchive.getBinary(parentBlockSlot);
|
|
1044
|
+
if (archivedBytes === null) {
|
|
972
1045
|
throw Error(`Parent execution payload envelope not found slot=${parentBlockSlot}, root=${parentBlockRootHex}`);
|
|
973
1046
|
}
|
|
974
|
-
|
|
1047
|
+
const archived = decodeArchivedEnvelope(archivedBytes);
|
|
1048
|
+
return archived.envelopeBytes !== undefined
|
|
1049
|
+
? ssz.gloas.SignedExecutionPayloadEnvelope.deserialize(archived.envelopeBytes).message.executionRequests
|
|
1050
|
+
: archived.headerEnvelope.message.executionRequests;
|
|
975
1051
|
}
|
|
976
1052
|
|
|
977
1053
|
async getDataColumnSidecars(blockSlot: Slot, blockRootHex: string): Promise<DataColumnSidecar[]> {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Slot} from "@lodestar/types";
|
|
2
|
+
import {LodestarError} from "@lodestar/utils";
|
|
3
|
+
|
|
4
|
+
export enum EnvelopeReconstructionErrorCode {
|
|
5
|
+
/** The EL failed to answer engine_getPayloadBodiesByHashV2 (transport / EL down). Transient. */
|
|
6
|
+
ENGINE_UNAVAILABLE = "ENVELOPE_RECONSTRUCTION_ERROR_ENGINE_UNAVAILABLE",
|
|
7
|
+
/** A body returned by the EL does not hash to the root stored in the header envelope. Local DB/EL inconsistency. */
|
|
8
|
+
BODY_ROOT_MISMATCH = "ENVELOPE_RECONSTRUCTION_ERROR_BODY_ROOT_MISMATCH",
|
|
9
|
+
/** A by-range stream stopped short at a slot that cannot be served; the response so far is still valid */
|
|
10
|
+
RANGE_UNSERVABLE = "ENVELOPE_RECONSTRUCTION_ERROR_RANGE_UNSERVABLE",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type EnvelopeReconstructionErrorType =
|
|
14
|
+
| {code: EnvelopeReconstructionErrorCode.ENGINE_UNAVAILABLE}
|
|
15
|
+
| {
|
|
16
|
+
code: EnvelopeReconstructionErrorCode.BODY_ROOT_MISMATCH;
|
|
17
|
+
slot: Slot;
|
|
18
|
+
field: "transactions" | "withdrawals" | "blockAccessList";
|
|
19
|
+
}
|
|
20
|
+
| {code: EnvelopeReconstructionErrorCode.RANGE_UNSERVABLE; slot: Slot};
|
|
21
|
+
|
|
22
|
+
export class EnvelopeReconstructionError extends LodestarError<EnvelopeReconstructionErrorType> {}
|
|
@@ -4,6 +4,7 @@ export * from "./blobSidecarError.js";
|
|
|
4
4
|
export * from "./blockError.js";
|
|
5
5
|
export * from "./blsToExecutionChangeError.js";
|
|
6
6
|
export * from "./dataColumnSidecarError.js";
|
|
7
|
+
export * from "./envelopeReconstructionError.js";
|
|
7
8
|
export * from "./executionPayloadBid.js";
|
|
8
9
|
export * from "./executionPayloadEnvelope.js";
|
|
9
10
|
export * from "./gossipValidation.js";
|
package/src/chain/interface.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {Metrics} from "../metrics/metrics.js";
|
|
|
30
30
|
import {BufferPool} from "../util/bufferPool.js";
|
|
31
31
|
import {IClock} from "../util/clock.js";
|
|
32
32
|
import {CustodyConfig} from "../util/dataColumns.js";
|
|
33
|
+
import {ReconstructMismatchPolicy} from "../util/execution.js";
|
|
33
34
|
import {SerializedCache} from "../util/serializedCache.js";
|
|
34
35
|
import {IArchiveStore} from "./archiveStore/interface.js";
|
|
35
36
|
import {CheckpointBalancesCache} from "./balancesCache.js";
|
|
@@ -96,7 +97,7 @@ export enum FindHeadFnName {
|
|
|
96
97
|
export interface IBeaconChain {
|
|
97
98
|
readonly genesisTime: UintNum64;
|
|
98
99
|
readonly genesisValidatorsRoot: Root;
|
|
99
|
-
|
|
100
|
+
earliestAvailableSlot: Slot;
|
|
100
101
|
readonly executionEngine: IExecutionEngine;
|
|
101
102
|
readonly executionBuilder?: IExecutionBuilder;
|
|
102
103
|
readonly builderCircuitBreaker: BuilderCircuitBreaker;
|
|
@@ -236,6 +237,10 @@ export interface IBeaconChain {
|
|
|
236
237
|
indices: number[]
|
|
237
238
|
): Promise<(Uint8Array | undefined)[]>;
|
|
238
239
|
getSerializedExecutionPayloadEnvelope(blockSlot: Slot, blockRootHex: string): Promise<Uint8Array | null>;
|
|
240
|
+
getSerializedExecutionPayloadEnvelopes(
|
|
241
|
+
requests: {blockSlot: Slot; blockRootHex: RootHex}[],
|
|
242
|
+
onMismatch?: ReconstructMismatchPolicy
|
|
243
|
+
): Promise<(Uint8Array | null)[]>;
|
|
239
244
|
getExecutionPayloadEnvelope(
|
|
240
245
|
blockSlot: Slot,
|
|
241
246
|
blockRootHex: string
|
package/src/chain/options.ts
CHANGED
|
@@ -29,6 +29,8 @@ export type IChainOptions = BlockProcessOpts &
|
|
|
29
29
|
blacklistedBlocks?: string[];
|
|
30
30
|
// TODO GLOAS: add similar option for execution payload envelopes?
|
|
31
31
|
persistProducedBlocks?: boolean;
|
|
32
|
+
/** Archive finalized Gloas payload envelopes as headers (bodies reconstructed from the EL on read) */
|
|
33
|
+
dedupePayloads?: boolean;
|
|
32
34
|
persistInvalidSszObjects?: boolean;
|
|
33
35
|
persistInvalidSszObjectsDir?: string;
|
|
34
36
|
persistOrphanedBlocks?: boolean;
|
|
@@ -105,6 +107,7 @@ export const defaultChainOptions: IChainOptions = {
|
|
|
105
107
|
disableBlsBatchVerify: false,
|
|
106
108
|
proposerBoost: true,
|
|
107
109
|
proposerBoostReorg: true,
|
|
110
|
+
dedupePayloads: true,
|
|
108
111
|
computeUnrealized: true,
|
|
109
112
|
fastConfirmation: false,
|
|
110
113
|
suggestedFeeRecipient: defaultValidatorOptions.suggestedFeeRecipient,
|
package/src/db/buckets.ts
CHANGED
|
@@ -71,7 +71,7 @@ export enum Bucket {
|
|
|
71
71
|
allForks_dataColumnSidecarsArchive = 58, // BeaconBlockSlot -> DataColumnSidecars
|
|
72
72
|
|
|
73
73
|
gloas_executionPayloadEnvelope = 59, // GLOAS BeaconBlockRoot -> SignedExecutionPayloadEnvelope
|
|
74
|
-
gloas_executionPayloadEnvelopeArchive = 60, // GLOAS Slot -> SignedExecutionPayloadEnvelope
|
|
74
|
+
gloas_executionPayloadEnvelopeArchive = 60, // GLOAS Slot -> SignedExecutionPayloadEnvelope, or 0x00 + SignedExecutionPayloadHeaderEnvelope
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export function getBucketNameByValue<T extends Bucket>(enumValue: T): keyof typeof Bucket {
|