@lodestar/beacon-node 1.52.0-dev.6ab73fec0a → 1.52.0-dev.6f38e91359

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.
Files changed (314) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +63 -39
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +3 -1
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +2 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +19 -11
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
  17. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  18. package/lib/chain/ColumnReconstructionTracker.js +4 -0
  19. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  23. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  24. package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
  25. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  26. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  27. package/lib/chain/blocks/blockInput/blockInput.js +3 -1
  28. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.js +25 -5
  32. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  33. package/lib/chain/blocks/index.d.ts.map +1 -1
  34. package/lib/chain/blocks/index.js +3 -17
  35. package/lib/chain/blocks/index.js.map +1 -1
  36. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  37. package/lib/chain/blocks/verifyBlock.js +21 -17
  38. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  39. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +2 -2
  40. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  41. package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -3
  42. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  44. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -5
  45. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  47. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  48. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
  49. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  50. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +2 -2
  51. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  52. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +3 -3
  53. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  54. package/lib/chain/bls/utils.js +1 -1
  55. package/lib/chain/bls/utils.js.map +1 -1
  56. package/lib/chain/chain.d.ts +6 -5
  57. package/lib/chain/chain.d.ts.map +1 -1
  58. package/lib/chain/chain.js +74 -26
  59. package/lib/chain/chain.js.map +1 -1
  60. package/lib/chain/errors/attestationError.d.ts +15 -1
  61. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  62. package/lib/chain/errors/attestationError.js +8 -0
  63. package/lib/chain/errors/attestationError.js.map +1 -1
  64. package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
  65. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  66. package/lib/chain/errors/executionPayloadBid.js +2 -1
  67. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  68. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  69. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  70. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  71. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  72. package/lib/chain/forkChoice/index.d.ts +1 -4
  73. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  74. package/lib/chain/forkChoice/index.js +1 -4
  75. package/lib/chain/forkChoice/index.js.map +1 -1
  76. package/lib/chain/forkChoiceExecutionEngine.d.ts +5 -3
  77. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
  78. package/lib/chain/forkChoiceExecutionEngine.js +34 -11
  79. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
  80. package/lib/chain/interface.d.ts +1 -1
  81. package/lib/chain/interface.d.ts.map +1 -1
  82. package/lib/chain/lightClient/index.d.ts +13 -6
  83. package/lib/chain/lightClient/index.d.ts.map +1 -1
  84. package/lib/chain/lightClient/index.js +95 -115
  85. package/lib/chain/lightClient/index.js.map +1 -1
  86. package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
  87. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
  88. package/lib/chain/opPools/inclusionListStore.js +5 -2
  89. package/lib/chain/opPools/inclusionListStore.js.map +1 -1
  90. package/lib/chain/opPools/opPool.js +6 -6
  91. package/lib/chain/opPools/opPool.js.map +1 -1
  92. package/lib/chain/options.js +1 -1
  93. package/lib/chain/options.js.map +1 -1
  94. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  95. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  96. package/lib/chain/seenCache/seenAttesters.js +1 -1
  97. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  98. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  99. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  100. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  101. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  102. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  103. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  104. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  105. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  106. package/lib/chain/shufflingCache.d.ts +5 -0
  107. package/lib/chain/shufflingCache.d.ts.map +1 -1
  108. package/lib/chain/shufflingCache.js +39 -1
  109. package/lib/chain/shufflingCache.js.map +1 -1
  110. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  111. package/lib/chain/validation/aggregateAndProof.js +37 -9
  112. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  113. package/lib/chain/validation/attestation.d.ts.map +1 -1
  114. package/lib/chain/validation/attestation.js +32 -16
  115. package/lib/chain/validation/attestation.js.map +1 -1
  116. package/lib/chain/validation/block.d.ts.map +1 -1
  117. package/lib/chain/validation/block.js +9 -1
  118. package/lib/chain/validation/block.js.map +1 -1
  119. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  120. package/lib/chain/validation/dataColumnSidecar.js +8 -1
  121. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  122. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  123. package/lib/chain/validation/executionPayloadBid.js +47 -42
  124. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  125. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  126. package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
  127. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  128. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  129. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  130. package/lib/execution/engine/blockHash.d.ts +12 -0
  131. package/lib/execution/engine/blockHash.d.ts.map +1 -0
  132. package/lib/execution/engine/blockHash.js +17 -0
  133. package/lib/execution/engine/blockHash.js.map +1 -0
  134. package/lib/execution/engine/http.d.ts +2 -2
  135. package/lib/execution/engine/http.d.ts.map +1 -1
  136. package/lib/execution/engine/http.js +13 -7
  137. package/lib/execution/engine/http.js.map +1 -1
  138. package/lib/execution/engine/interface.d.ts +16 -3
  139. package/lib/execution/engine/interface.d.ts.map +1 -1
  140. package/lib/execution/engine/interface.js +11 -0
  141. package/lib/execution/engine/interface.js.map +1 -1
  142. package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
  143. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  144. package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
  145. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  146. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  147. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  148. package/lib/execution/engine/jsonRpcTransport.js +4 -4
  149. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  150. package/lib/execution/engine/mock.d.ts.map +1 -1
  151. package/lib/execution/engine/mock.js +6 -6
  152. package/lib/execution/engine/mock.js.map +1 -1
  153. package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
  154. package/lib/execution/engine/restHttpClient.js +9 -5
  155. package/lib/execution/engine/restHttpClient.js.map +1 -1
  156. package/lib/execution/engine/restTransport.d.ts +2 -2
  157. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  158. package/lib/execution/engine/restTransport.js +4 -4
  159. package/lib/execution/engine/restTransport.js.map +1 -1
  160. package/lib/execution/engine/signal.d.ts +6 -0
  161. package/lib/execution/engine/signal.d.ts.map +1 -0
  162. package/lib/execution/engine/signal.js +24 -0
  163. package/lib/execution/engine/signal.js.map +1 -0
  164. package/lib/execution/engine/transport.d.ts +2 -2
  165. package/lib/execution/engine/transport.d.ts.map +1 -1
  166. package/lib/index.d.ts +1 -1
  167. package/lib/index.d.ts.map +1 -1
  168. package/lib/index.js +1 -1
  169. package/lib/index.js.map +1 -1
  170. package/lib/metrics/metrics/beacon.d.ts +4 -0
  171. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  172. package/lib/metrics/metrics/beacon.js +11 -2
  173. package/lib/metrics/metrics/beacon.js.map +1 -1
  174. package/lib/metrics/metrics/lodestar.d.ts +3 -0
  175. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  176. package/lib/metrics/metrics/lodestar.js +42 -28
  177. package/lib/metrics/metrics/lodestar.js.map +1 -1
  178. package/lib/network/gossip/gossipsub.d.ts +1 -0
  179. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  180. package/lib/network/gossip/gossipsub.js +5 -2
  181. package/lib/network/gossip/gossipsub.js.map +1 -1
  182. package/lib/network/gossip/topic.d.ts +1 -7
  183. package/lib/network/gossip/topic.d.ts.map +1 -1
  184. package/lib/network/gossip/topic.js +0 -13
  185. package/lib/network/gossip/topic.js.map +1 -1
  186. package/lib/network/network.d.ts +1 -0
  187. package/lib/network/network.d.ts.map +1 -1
  188. package/lib/network/network.js +26 -12
  189. package/lib/network/network.js.map +1 -1
  190. package/lib/network/peers/peerManager.d.ts.map +1 -1
  191. package/lib/network/peers/peerManager.js +22 -2
  192. package/lib/network/peers/peerManager.js.map +1 -1
  193. package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
  194. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  195. package/lib/network/peers/utils/prioritizePeers.js +11 -2
  196. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  197. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  198. package/lib/network/processor/gossipHandlers.js +19 -6
  199. package/lib/network/processor/gossipHandlers.js.map +1 -1
  200. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  201. package/lib/network/processor/gossipValidatorFn.js +4 -1
  202. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  203. package/lib/network/processor/index.d.ts.map +1 -1
  204. package/lib/network/processor/index.js +4 -2
  205. package/lib/network/processor/index.js.map +1 -1
  206. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  207. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  208. package/lib/network/reqresp/utils/collect.js +9 -8
  209. package/lib/network/reqresp/utils/collect.js.map +1 -1
  210. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  211. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  212. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  213. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  214. package/lib/sync/range/batch.d.ts +6 -0
  215. package/lib/sync/range/batch.d.ts.map +1 -1
  216. package/lib/sync/range/batch.js +17 -0
  217. package/lib/sync/range/batch.js.map +1 -1
  218. package/lib/sync/range/chain.d.ts.map +1 -1
  219. package/lib/sync/range/chain.js +8 -1
  220. package/lib/sync/range/chain.js.map +1 -1
  221. package/lib/sync/range/range.d.ts.map +1 -1
  222. package/lib/sync/range/range.js +43 -3
  223. package/lib/sync/range/range.js.map +1 -1
  224. package/lib/sync/types.d.ts +14 -1
  225. package/lib/sync/types.d.ts.map +1 -1
  226. package/lib/sync/types.js +2 -0
  227. package/lib/sync/types.js.map +1 -1
  228. package/lib/sync/unknownBlock.d.ts +28 -1
  229. package/lib/sync/unknownBlock.d.ts.map +1 -1
  230. package/lib/sync/unknownBlock.js +340 -27
  231. package/lib/sync/unknownBlock.js.map +1 -1
  232. package/lib/sync/utils/downloadByRange.d.ts +14 -1
  233. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  234. package/lib/sync/utils/downloadByRange.js +12 -2
  235. package/lib/sync/utils/downloadByRange.js.map +1 -1
  236. package/lib/sync/utils/downloadByRoot.d.ts +24 -2
  237. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  238. package/lib/sync/utils/downloadByRoot.js +48 -5
  239. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  240. package/lib/util/eventLoop.d.ts +3 -3
  241. package/lib/util/eventLoop.d.ts.map +1 -1
  242. package/lib/util/eventLoop.js +3 -3
  243. package/lib/util/eventLoop.js.map +1 -1
  244. package/package.json +27 -27
  245. package/src/api/impl/beacon/blocks/index.ts +74 -47
  246. package/src/api/impl/beacon/pool/index.ts +9 -7
  247. package/src/api/impl/beacon/state/utils.ts +2 -1
  248. package/src/api/impl/debug/index.ts +6 -2
  249. package/src/api/impl/validator/index.ts +21 -11
  250. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  251. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  252. package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
  253. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  254. package/src/chain/blocks/importExecutionPayload.ts +30 -4
  255. package/src/chain/blocks/index.ts +3 -31
  256. package/src/chain/blocks/verifyBlock.ts +24 -17
  257. package/src/chain/blocks/verifyBlocksDataAvailability.ts +4 -4
  258. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +7 -4
  259. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
  260. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +5 -4
  261. package/src/chain/bls/utils.ts +1 -1
  262. package/src/chain/chain.ts +107 -43
  263. package/src/chain/errors/attestationError.ts +11 -1
  264. package/src/chain/errors/executionPayloadBid.ts +9 -2
  265. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  266. package/src/chain/forkChoice/index.ts +1 -4
  267. package/src/chain/forkChoiceExecutionEngine.ts +48 -15
  268. package/src/chain/interface.ts +1 -1
  269. package/src/chain/lightClient/index.ts +108 -142
  270. package/src/chain/opPools/inclusionListStore.ts +5 -2
  271. package/src/chain/opPools/opPool.ts +6 -6
  272. package/src/chain/options.ts +1 -1
  273. package/src/chain/seenCache/seenAttesters.ts +1 -1
  274. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  275. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  276. package/src/chain/shufflingCache.ts +40 -1
  277. package/src/chain/validation/aggregateAndProof.ts +43 -14
  278. package/src/chain/validation/attestation.ts +31 -20
  279. package/src/chain/validation/block.ts +9 -1
  280. package/src/chain/validation/dataColumnSidecar.ts +7 -1
  281. package/src/chain/validation/executionPayloadBid.ts +60 -44
  282. package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
  283. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  284. package/src/execution/engine/blockHash.ts +27 -0
  285. package/src/execution/engine/http.ts +18 -10
  286. package/src/execution/engine/interface.ts +18 -3
  287. package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
  288. package/src/execution/engine/jsonRpcTransport.ts +8 -4
  289. package/src/execution/engine/mock.ts +13 -8
  290. package/src/execution/engine/restHttpClient.ts +17 -11
  291. package/src/execution/engine/restTransport.ts +5 -4
  292. package/src/execution/engine/signal.ts +28 -0
  293. package/src/execution/engine/transport.ts +3 -2
  294. package/src/index.ts +6 -1
  295. package/src/metrics/metrics/beacon.ts +11 -2
  296. package/src/metrics/metrics/lodestar.ts +42 -28
  297. package/src/network/gossip/gossipsub.ts +6 -2
  298. package/src/network/gossip/topic.ts +1 -14
  299. package/src/network/network.ts +39 -13
  300. package/src/network/peers/peerManager.ts +26 -2
  301. package/src/network/peers/utils/prioritizePeers.ts +14 -1
  302. package/src/network/processor/gossipHandlers.ts +25 -13
  303. package/src/network/processor/gossipValidatorFn.ts +4 -0
  304. package/src/network/processor/index.ts +7 -2
  305. package/src/network/reqresp/utils/collect.ts +16 -8
  306. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  307. package/src/sync/range/batch.ts +20 -0
  308. package/src/sync/range/chain.ts +8 -0
  309. package/src/sync/range/range.ts +56 -3
  310. package/src/sync/types.ts +13 -0
  311. package/src/sync/unknownBlock.ts +389 -29
  312. package/src/sync/utils/downloadByRange.ts +29 -3
  313. package/src/sync/utils/downloadByRoot.ts +75 -7
  314. package/src/util/eventLoop.ts +3 -3
@@ -7,6 +7,8 @@ import {
7
7
  AncestorStatus,
8
8
  CheckpointWithHex,
9
9
  EpochDifference,
10
+ ForkChoiceError,
11
+ ForkChoiceErrorCode,
10
12
  ForkChoiceStateGetter,
11
13
  IForkChoice,
12
14
  PayloadStatus,
@@ -91,7 +93,7 @@ import {persistBlockInput} from "./blocks/writeBlockInputToDb.js";
91
93
  import {persistPayloadEnvelopeInput} from "./blocks/writePayloadEnvelopeInputToDb.js";
92
94
  import {BlsMultiThreadWorkerPool, BlsSingleThreadVerifier, IBlsVerifier} from "./bls/index.js";
93
95
  import {BuilderCircuitBreaker} from "./builderCircuitBreaker.js";
94
- import {ColumnReconstructionTracker} from "./ColumnReconstructionTracker.js";
96
+ import {ColumnReconstructionTracker, RECONSTRUCTED_COLUMNS_WAIT_BPS} from "./ColumnReconstructionTracker.js";
95
97
  import {ChainEvent, ChainEventEmitter, ReorgEventData} from "./emitter.js";
96
98
  import {ForkchoiceCaller, initializeForkChoice} from "./forkChoice/index.js";
97
99
  import {ForkChoiceExecutionEngine} from "./forkChoiceExecutionEngine.js";
@@ -699,7 +701,8 @@ export class BeaconChain implements IBeaconChain {
699
701
  const state = await this.regen.getBlockSlotState(block, slot, {dontTransferCache: true}, RegenCaller.restApi);
700
702
  return {
701
703
  state,
702
- executionOptimistic: isOptimisticBlock(block),
704
+ // The canonical variant can be FULL, a state reports the status of the payload its block builds on
705
+ executionOptimistic: isOptimisticBlock(this.forkChoice.getBlockHexDefaultStatus(block.blockRoot) ?? block),
703
706
  finalized: slot === finalizedBlock.slot && finalizedBlock.slot !== GENESIS_SLOT,
704
707
  };
705
708
  }
@@ -715,7 +718,7 @@ export class BeaconChain implements IBeaconChain {
715
718
  return (
716
719
  state && {
717
720
  state,
718
- executionOptimistic: isOptimisticBlock(block),
721
+ executionOptimistic: isOptimisticBlock(this.forkChoice.getBlockHexDefaultStatus(block.blockRoot) ?? block),
719
722
  finalized: slot === finalizedBlock.slot && finalizedBlock.slot !== GENESIS_SLOT,
720
723
  }
721
724
  );
@@ -863,7 +866,9 @@ export class BeaconChain implements IBeaconChain {
863
866
  const finalizedBlock = this.forkChoice.getFinalizedBlock();
864
867
  if (slot > finalizedBlock.slot) {
865
868
  // Unfinalized slot, attempt to find in fork-choice
866
- const block = this.forkChoice.getCanonicalBlockAtSlot(slot);
869
+ const canonicalBlock = this.forkChoice.getCanonicalBlockAtSlot(slot);
870
+ // The canonical variant can be FULL, a block reports the status of the payload it builds on
871
+ const block = canonicalBlock && this.forkChoice.getBlockHexDefaultStatus(canonicalBlock.blockRoot);
867
872
  if (block) {
868
873
  // Block found in fork-choice.
869
874
  // It may be in the block input cache, awaiting full DA reconstruction, check there first
@@ -1124,6 +1129,17 @@ export class BeaconChain implements IBeaconChain {
1124
1129
  // After gloas, columns are tracked in PayloadEnvelopeInput
1125
1130
  const payloadInput = this.seenPayloadEnvelopeInputCache.get(blockRootHex);
1126
1131
  if (payloadInput) {
1132
+ // Available with half the columns, peers that saw it attested expect the reconstructed rest
1133
+ if (
1134
+ !payloadInput.hasComputedAllData() &&
1135
+ payloadInput.hasAllData() &&
1136
+ indices.some((index) => !payloadInput.hasColumn(index))
1137
+ ) {
1138
+ this.columnReconstructionTracker.triggerColumnReconstruction(payloadInput);
1139
+ await payloadInput
1140
+ .waitForComputedAllData(this.config.getSlotComponentDurationMs(fork, RECONSTRUCTED_COLUMNS_WAIT_BPS))
1141
+ .catch(() => this.logger.debug("Columns not reconstructed in time", {slot: blockSlot, root: blockRootHex}));
1142
+ }
1127
1143
  for (let i = 0; i < indices.length; i++) {
1128
1144
  const index = indices[i];
1129
1145
  const sidecar = payloadInput.getColumn(index);
@@ -1145,6 +1161,17 @@ export class BeaconChain implements IBeaconChain {
1145
1161
  if (!isBlockInputColumns(blockInput)) {
1146
1162
  throw new Error(`Expected block input to have columns: slot=${blockSlot} root=${blockRootHex}`);
1147
1163
  }
1164
+ // Available with half the columns, peers that saw it attested expect the reconstructed rest
1165
+ if (
1166
+ !blockInput.hasComputedAllData() &&
1167
+ blockInput.hasAllData() &&
1168
+ indices.some((index) => !blockInput.hasColumn(index))
1169
+ ) {
1170
+ this.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
1171
+ await blockInput
1172
+ .waitForComputedAllData(this.config.getSlotComponentDurationMs(fork, RECONSTRUCTED_COLUMNS_WAIT_BPS))
1173
+ .catch(() => this.logger.debug("Columns not reconstructed in time", {slot: blockSlot, root: blockRootHex}));
1174
+ }
1148
1175
  for (let i = 0; i < indices.length; i++) {
1149
1176
  const index = indices[i];
1150
1177
  const sidecar = blockInput.getColumn(index);
@@ -1471,9 +1498,10 @@ export class BeaconChain implements IBeaconChain {
1471
1498
 
1472
1499
  /**
1473
1500
  * Emit `head` and `head_v2` when the fork choice head differs between two observations. Every caller that
1474
- * can move the head, `updateAndGetHead()` and `updateTime()`, must capture the head before and pass both.
1501
+ * can move the head, `updateAndGetHead()`, `updateTime()` and `onExecutionPayload()`, must capture the head before
1502
+ * and pass both.
1475
1503
  */
1476
- private emitHeadEvents(prevHead: ProtoBlock, head: ProtoBlock): void {
1504
+ emitHeadEvents(prevHead: ProtoBlock, head: ProtoBlock): void {
1477
1505
  const headRootChanged = head.blockRoot !== prevHead.blockRoot;
1478
1506
 
1479
1507
  if (!headRootChanged && prevHead.payloadStatus === head.payloadStatus) {
@@ -1604,38 +1632,76 @@ export class BeaconChain implements IBeaconChain {
1604
1632
  }
1605
1633
 
1606
1634
  /**
1607
- * Invalid state root error is critical and it causes the node to stale most of the time so we want to always
1608
- * persist preState, postState and block for further investigation.
1635
+ * Invalid state root error is critical and it causes the node to stale most of the time so we want to persist
1636
+ * preState, postState and block for further investigation.
1609
1637
  */
1610
1638
  async persistInvalidStateRoot(
1611
1639
  preState: IBeaconStateView,
1612
1640
  postState: IBeaconStateView,
1613
1641
  block: SignedBeaconBlock
1614
1642
  ): Promise<void> {
1643
+ if (!this.opts.persistInvalidSszObjects) {
1644
+ return;
1645
+ }
1615
1646
  const blockSlot = block.message.slot;
1616
- const blockType = this.config.getForkTypes(blockSlot).SignedBeaconBlock;
1617
- const postStateRoot = postState.hashTreeRoot();
1618
- const logStr = `slot_${blockSlot}_invalid_state_root_${toRootHex(postStateRoot)}`;
1619
- await Promise.all([
1620
- this.persistSszObject(
1621
- `SignedBeaconBlock_slot_${blockSlot}`,
1622
- blockType.serialize(block),
1623
- toRootHex(this.config.getForkTypes(blockSlot).BeaconBlock.hashTreeRoot(block.message)),
1624
- `${logStr}_block`
1625
- ),
1626
- this.persistSszObject(
1627
- `preState_slot_${preState.slot}_BeaconState`,
1628
- preState.serialize(),
1629
- toRootHex(preState.hashTreeRoot()),
1630
- `${logStr}_pre_state`
1631
- ),
1632
- this.persistSszObject(
1633
- `postState_slot_${postState.slot}_BeaconState`,
1634
- postState.serialize(),
1635
- toRootHex(postStateRoot),
1636
- `${logStr}_post_state`
1637
- ),
1638
- ]);
1647
+ const forkTypes = this.config.getForkTypes(blockSlot);
1648
+ const preStateRoot = toRootHex(preState.hashTreeRoot());
1649
+ const postStateRoot = toRootHex(postState.hashTreeRoot());
1650
+ const logStr = `slot_${blockSlot}_invalid_state_root_${postStateRoot}`;
1651
+ try {
1652
+ await Promise.all([
1653
+ this.persistSszObject(
1654
+ `SignedBeaconBlock_slot_${blockSlot}`,
1655
+ forkTypes.SignedBeaconBlock.serialize(block),
1656
+ toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
1657
+ `${logStr}_block`
1658
+ ),
1659
+ this.persistSszObject(
1660
+ `preState_slot_${preState.slot}_BeaconState`,
1661
+ preState.serialize(),
1662
+ preStateRoot,
1663
+ `${logStr}_pre_state`
1664
+ ),
1665
+ this.persistSszObject(
1666
+ `postState_slot_${postState.slot}_BeaconState`,
1667
+ postState.serialize(),
1668
+ postStateRoot,
1669
+ `${logStr}_post_state`
1670
+ ),
1671
+ ]);
1672
+ } catch (e) {
1673
+ this.logger.error(
1674
+ "Error persisting invalid state root objects",
1675
+ {slot: blockSlot, preStateRoot, postStateRoot},
1676
+ e as Error
1677
+ );
1678
+ }
1679
+ }
1680
+
1681
+ async persistInvalidSignature(state: IBeaconStateView, block: SignedBeaconBlock): Promise<void> {
1682
+ if (!this.opts.persistInvalidSszObjects) {
1683
+ return;
1684
+ }
1685
+ const blockSlot = block.message.slot;
1686
+ const forkTypes = this.config.getForkTypes(blockSlot);
1687
+ try {
1688
+ await Promise.all([
1689
+ this.persistSszObject(
1690
+ forkTypes.SignedBeaconBlock.typeName,
1691
+ forkTypes.SignedBeaconBlock.serialize(block),
1692
+ toRootHex(forkTypes.BeaconBlock.hashTreeRoot(block.message)),
1693
+ `${blockSlot}_invalid_signature`
1694
+ ),
1695
+ this.persistSszObject(
1696
+ "BeaconState",
1697
+ state.serialize(),
1698
+ toRootHex(state.hashTreeRoot()),
1699
+ `${state.slot}_invalid_signature`
1700
+ ),
1701
+ ]);
1702
+ } catch (e) {
1703
+ this.logger.error("Error persisting invalid signature objects", {slot: blockSlot}, e as Error);
1704
+ }
1639
1705
  }
1640
1706
 
1641
1707
  persistInvalidSszValue<T>(type: Type<T>, sszObject: T, suffix?: string, rootHex?: RootHex): void {
@@ -1650,12 +1716,6 @@ export class BeaconChain implements IBeaconChain {
1650
1716
  }
1651
1717
  }
1652
1718
 
1653
- persistInvalidSszBytes(typeName: string, sszBytes: Uint8Array, rootHex: RootHex, suffix?: string): void {
1654
- if (this.opts.persistInvalidSszObjects) {
1655
- void this.persistSszObject(typeName, sszBytes, rootHex, suffix);
1656
- }
1657
- }
1658
-
1659
1719
  /**
1660
1720
  * Regenerate state for attestation verification, this does not happen with default chain option of maxSkipSlots = 32 .
1661
1721
  * However, need to handle just in case. Lodestar doesn't support multiple regen state requests for attestation verification
@@ -1855,14 +1915,18 @@ export class BeaconChain implements IBeaconChain {
1855
1915
  private onClockSlot(slot: Slot): void {
1856
1916
  this.logger.verbose("Clock slot", {slot});
1857
1917
 
1858
- // CRITICAL UPDATE
1859
- if (this.forkChoice.irrecoverableError) {
1860
- this.processShutdownCallback(this.forkChoice.irrecoverableError);
1861
- }
1862
-
1863
1918
  // updateTime() recomputes the head on epoch-boundary checkpoint pull-up and under fast confirmation
1864
1919
  const prevHead = this.forkChoice.getHead();
1865
- this.forkChoice.updateTime(slot);
1920
+ try {
1921
+ this.forkChoice.updateTime(slot);
1922
+ } catch (e) {
1923
+ // Per optimistic sync the node MAY exit once the justified checkpoint is INVALIDATED, fork choice has no head
1924
+ if (e instanceof ForkChoiceError && e.type.code === ForkChoiceErrorCode.INVALID_JUSTIFIED_EXECUTION_STATUS) {
1925
+ this.processShutdownCallback(e);
1926
+ return;
1927
+ }
1928
+ throw e;
1929
+ }
1866
1930
  this.emitHeadEvents(prevHead, this.forkChoice.getHead());
1867
1931
  this.metrics?.clockSlot.set(slot);
1868
1932
 
@@ -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
- BID_ALREADY_KNOWN = "EXECUTION_PAYLOAD_BID_ERROR_BID_ALREADY_KNOWN",
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",
@@ -23,6 +23,7 @@ export enum ExecutionPayloadBidErrorCode {
23
23
  PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH",
24
24
  INCLUSION_LIST_BITS_NOT_INCLUSIVE = "EXECUTION_PAYLOAD_BID_ERROR_INCLUSION_LIST_BITS_NOT_INCLUSIVE",
25
25
  BEFORE_INCLUSION_LIST_DEADLINE = "EXECUTION_PAYLOAD_BID_ERROR_BEFORE_INCLUSION_LIST_DEADLINE",
26
+ BEFORE_PAYLOAD_ATTESTATION_DEADLINE = "EXECUTION_PAYLOAD_BID_ERROR_BEFORE_PAYLOAD_ATTESTATION_DEADLINE",
26
27
  }
27
28
 
28
29
  export type ExecutionPayloadBidErrorType =
@@ -46,11 +47,12 @@ export type ExecutionPayloadBidErrorType =
46
47
  headBlockRoot: RootHex;
47
48
  }
48
49
  | {
49
- code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN;
50
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED;
50
51
  builderIndex: BuilderIndex;
51
52
  slot: Slot;
52
53
  parentBlockRoot: RootHex;
53
54
  parentBlockHash: RootHex;
55
+ bidLimit: number;
54
56
  }
55
57
  | {code: ExecutionPayloadBidErrorCode.BID_TOO_LOW; bidValue: number; currentHighestBid: number}
56
58
  | {code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH; bidValue: number; builderBalance: number}
@@ -98,6 +100,11 @@ export type ExecutionPayloadBidErrorType =
98
100
  builderIndex: BuilderIndex;
99
101
  slot: Slot;
100
102
  }
103
+ | {
104
+ code: ExecutionPayloadBidErrorCode.BEFORE_PAYLOAD_ATTESTATION_DEADLINE;
105
+ builderIndex: BuilderIndex;
106
+ slot: Slot;
107
+ }
101
108
  | {
102
109
  code: ExecutionPayloadBidErrorCode.PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH;
103
110
  builderIndex: BuilderIndex;
@@ -9,10 +9,18 @@ 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",
23
+ INVALID_BLOCK_HASH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_BLOCK_HASH",
16
24
  INVALID_SIGNATURE = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_SIGNATURE",
17
25
  PAYLOAD_ENVELOPE_INPUT_MISSING = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PAYLOAD_ENVELOPE_INPUT_MISSING",
18
26
  }
@@ -34,6 +42,13 @@ export type ExecutionPayloadEnvelopeErrorType =
34
42
  envelopeSlot: Slot;
35
43
  blockSlot: Slot;
36
44
  }
45
+ | {
46
+ code: ExecutionPayloadEnvelopeErrorCode.PARENT_BEACON_BLOCK_ROOT_MISMATCH;
47
+ slot: Slot;
48
+ root: RootHex;
49
+ envelopeParentBeaconBlockRoot: RootHex;
50
+ blockParentRoot: RootHex;
51
+ }
37
52
  | {
38
53
  code: ExecutionPayloadEnvelopeErrorCode.BUILDER_INDEX_MISMATCH;
39
54
  slot: Slot;
@@ -41,6 +56,20 @@ export type ExecutionPayloadEnvelopeErrorType =
41
56
  envelopeBuilderIndex: BuilderIndex;
42
57
  bidBuilderIndex: BuilderIndex | null;
43
58
  }
59
+ | {
60
+ code: ExecutionPayloadEnvelopeErrorCode.PREV_RANDAO_MISMATCH;
61
+ slot: Slot;
62
+ root: RootHex;
63
+ envelopePrevRandao: RootHex;
64
+ bidPrevRandao: RootHex;
65
+ }
66
+ | {
67
+ code: ExecutionPayloadEnvelopeErrorCode.GAS_LIMIT_MISMATCH;
68
+ slot: Slot;
69
+ root: RootHex;
70
+ envelopeGasLimit: number;
71
+ bidGasLimit: bigint;
72
+ }
44
73
  | {
45
74
  code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH;
46
75
  slot: Slot;
@@ -62,6 +91,35 @@ export type ExecutionPayloadEnvelopeErrorType =
62
91
  transactionCount: number;
63
92
  maxTransactionCount: number;
64
93
  }
94
+ | {
95
+ code: ExecutionPayloadEnvelopeErrorCode.PARENT_HASH_MISMATCH;
96
+ slot: Slot;
97
+ root: RootHex;
98
+ envelopeParentHash: RootHex;
99
+ latestBlockHash: RootHex;
100
+ }
101
+ | {
102
+ code: ExecutionPayloadEnvelopeErrorCode.INCORRECT_TIMESTAMP;
103
+ slot: Slot;
104
+ root: RootHex;
105
+ envelopeTimestamp: number;
106
+ expectedTimestamp: number;
107
+ }
108
+ | {code: ExecutionPayloadEnvelopeErrorCode.EMPTY_TRANSACTION; slot: Slot; root: RootHex; transactionIndex: number}
109
+ | {
110
+ code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_MISMATCH;
111
+ slot: Slot;
112
+ root: RootHex;
113
+ envelopeWithdrawalsRoot: RootHex;
114
+ expectedWithdrawalsRoot: RootHex;
115
+ }
116
+ | {
117
+ code: ExecutionPayloadEnvelopeErrorCode.INVALID_BLOCK_HASH;
118
+ slot: Slot;
119
+ root: RootHex;
120
+ blockHash: RootHex;
121
+ computedBlockHash: RootHex;
122
+ }
65
123
  | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE; slot: Slot; root: RootHex}
66
124
  | {code: ExecutionPayloadEnvelopeErrorCode.PAYLOAD_ENVELOPE_INPUT_MISSING; blockRoot: RootHex};
67
125
 
@@ -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 {ExecutionStatus, IForkChoice, LVHInvalidResponse} from "@lodestar/fork-choice";
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(lvh: LVHInvalidResponse, source: ExecutionInvalidSource): void {
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
- blockRoot: lvh.invalidateFromParentBlockRoot,
128
- blockHash: lvh.invalidateFromParentBlockHash,
140
+ judged: lvh.judged,
141
+ fromBlockRoot: lvh.invalidateFromBlockRoot,
142
+ fromBlockHash: lvh.invalidateFromBlockHash,
129
143
  latestValidHash: lvh.latestValidExecHash ?? "null",
130
144
  };
131
- const applied = this.forkChoice.validateLatestHash(lvh, {strict: source === ExecutionInvalidSource.blockSegment});
132
- if (!applied) {
133
- this.logger.warn("Execution engine INVALID verdict not applied to fork choice", logCtx);
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
- invalidateFromParentBlockRoot: headBlockRoot,
169
- invalidateFromParentBlockHash: headBlockHash,
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
- {executionStatus: ExecutionStatus.Valid, latestValidExecHash: headBlockHash, blockRoot: headBlockRoot},
176
- {strict: false}
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);
@@ -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,