@lodestar/beacon-node 1.51.0-dev.75239241d4 → 1.51.0-dev.782eaff74d

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 (253) hide show
  1. package/lib/api/impl/api.js +1 -1
  2. package/lib/api/impl/api.js.map +1 -1
  3. package/lib/api/impl/beacon/blocks/index.d.ts +2 -1
  4. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/blocks/index.js +12 -7
  6. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  7. package/lib/api/impl/beacon/index.d.ts +2 -1
  8. package/lib/api/impl/beacon/index.d.ts.map +1 -1
  9. package/lib/api/impl/beacon/index.js +2 -2
  10. package/lib/api/impl/beacon/index.js.map +1 -1
  11. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  12. package/lib/api/impl/beacon/state/index.js +8 -2
  13. package/lib/api/impl/beacon/state/index.js.map +1 -1
  14. package/lib/api/impl/beacon/state/utils.d.ts +2 -1
  15. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  16. package/lib/api/impl/beacon/state/utils.js +17 -9
  17. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  18. package/lib/api/impl/debug/index.d.ts.map +1 -1
  19. package/lib/api/impl/debug/index.js +3 -0
  20. package/lib/api/impl/debug/index.js.map +1 -1
  21. package/lib/api/impl/validator/index.d.ts.map +1 -1
  22. package/lib/api/impl/validator/index.js +102 -10
  23. package/lib/api/impl/validator/index.js.map +1 -1
  24. package/lib/api/options.d.ts +2 -0
  25. package/lib/api/options.d.ts.map +1 -1
  26. package/lib/api/options.js +1 -0
  27. package/lib/api/options.js.map +1 -1
  28. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  29. package/lib/chain/archiveStore/utils/archiveBlocks.js +54 -96
  30. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  31. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  32. package/lib/chain/blocks/importBlock.js +9 -7
  33. package/lib/chain/blocks/importBlock.js.map +1 -1
  34. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  35. package/lib/chain/blocks/importExecutionPayload.js +50 -2
  36. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  37. package/lib/chain/blocks/types.d.ts +4 -0
  38. package/lib/chain/blocks/types.d.ts.map +1 -1
  39. package/lib/chain/blocks/types.js +5 -0
  40. package/lib/chain/blocks/types.js.map +1 -1
  41. package/lib/chain/chain.d.ts +2 -1
  42. package/lib/chain/chain.d.ts.map +1 -1
  43. package/lib/chain/chain.js +8 -5
  44. package/lib/chain/chain.js.map +1 -1
  45. package/lib/chain/errors/executionPayloadBid.d.ts +11 -1
  46. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  47. package/lib/chain/errors/executionPayloadBid.js +2 -0
  48. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  49. package/lib/chain/errors/inclusionList.d.ts +60 -0
  50. package/lib/chain/errors/inclusionList.d.ts.map +1 -0
  51. package/lib/chain/errors/inclusionList.js +19 -0
  52. package/lib/chain/errors/inclusionList.js.map +1 -0
  53. package/lib/chain/errors/index.d.ts +1 -0
  54. package/lib/chain/errors/index.d.ts.map +1 -1
  55. package/lib/chain/errors/index.js +1 -0
  56. package/lib/chain/errors/index.js.map +1 -1
  57. package/lib/chain/interface.d.ts +2 -1
  58. package/lib/chain/interface.d.ts.map +1 -1
  59. package/lib/chain/interface.js.map +1 -1
  60. package/lib/chain/opPools/inclusionListStore.d.ts +63 -0
  61. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -0
  62. package/lib/chain/opPools/inclusionListStore.js +171 -0
  63. package/lib/chain/opPools/inclusionListStore.js.map +1 -0
  64. package/lib/chain/opPools/index.d.ts +1 -0
  65. package/lib/chain/opPools/index.d.ts.map +1 -1
  66. package/lib/chain/opPools/index.js +1 -0
  67. package/lib/chain/opPools/index.js.map +1 -1
  68. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -1
  69. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  70. package/lib/chain/produceBlock/produceBlockBody.js +30 -10
  71. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  72. package/lib/chain/regen/interface.d.ts +1 -1
  73. package/lib/chain/regen/interface.d.ts.map +1 -1
  74. package/lib/chain/regen/interface.js +1 -1
  75. package/lib/chain/regen/interface.js.map +1 -1
  76. package/lib/chain/validation/executionPayloadBid.d.ts +0 -15
  77. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  78. package/lib/chain/validation/executionPayloadBid.js +24 -145
  79. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  80. package/lib/chain/validation/inclusionList.d.ts +14 -0
  81. package/lib/chain/validation/inclusionList.d.ts.map +1 -0
  82. package/lib/chain/validation/inclusionList.js +150 -0
  83. package/lib/chain/validation/inclusionList.js.map +1 -0
  84. package/lib/chain/validation/index.d.ts +1 -0
  85. package/lib/chain/validation/index.d.ts.map +1 -1
  86. package/lib/chain/validation/index.js +1 -0
  87. package/lib/chain/validation/index.js.map +1 -1
  88. package/lib/db/beacon.d.ts.map +1 -1
  89. package/lib/db/beacon.js +2 -0
  90. package/lib/db/beacon.js.map +1 -1
  91. package/lib/execution/builder/validateBid.d.ts.map +1 -1
  92. package/lib/execution/builder/validateBid.js +14 -1
  93. package/lib/execution/builder/validateBid.js.map +1 -1
  94. package/lib/execution/engine/blobVersionedHashes.d.ts +1 -1
  95. package/lib/execution/engine/blobVersionedHashes.d.ts.map +1 -1
  96. package/lib/execution/engine/blobVersionedHashes.js.map +1 -1
  97. package/lib/execution/engine/disabled.d.ts +1 -0
  98. package/lib/execution/engine/disabled.d.ts.map +1 -1
  99. package/lib/execution/engine/disabled.js +3 -0
  100. package/lib/execution/engine/disabled.js.map +1 -1
  101. package/lib/execution/engine/http.d.ts +8 -2
  102. package/lib/execution/engine/http.d.ts.map +1 -1
  103. package/lib/execution/engine/http.js +27 -4
  104. package/lib/execution/engine/http.js.map +1 -1
  105. package/lib/execution/engine/interface.d.ts +11 -2
  106. package/lib/execution/engine/interface.d.ts.map +1 -1
  107. package/lib/execution/engine/interface.js.map +1 -1
  108. package/lib/execution/engine/jsonRpcTransport.d.ts +3 -2
  109. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  110. package/lib/execution/engine/jsonRpcTransport.js +33 -9
  111. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  112. package/lib/execution/engine/mock.d.ts +1 -0
  113. package/lib/execution/engine/mock.d.ts.map +1 -1
  114. package/lib/execution/engine/mock.js +31 -7
  115. package/lib/execution/engine/mock.js.map +1 -1
  116. package/lib/execution/engine/payloadIdCache.d.ts +5 -3
  117. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  118. package/lib/execution/engine/payloadIdCache.js +15 -4
  119. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  120. package/lib/execution/engine/restTransport.d.ts +2 -1
  121. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  122. package/lib/execution/engine/restTransport.js +3 -0
  123. package/lib/execution/engine/restTransport.js.map +1 -1
  124. package/lib/execution/engine/sszTypes.d.ts +38 -38
  125. package/lib/execution/engine/transport.d.ts +5 -2
  126. package/lib/execution/engine/transport.d.ts.map +1 -1
  127. package/lib/execution/engine/types.d.ts +25 -1
  128. package/lib/execution/engine/types.d.ts.map +1 -1
  129. package/lib/execution/engine/types.js +17 -4
  130. package/lib/execution/engine/types.js.map +1 -1
  131. package/lib/index.d.ts +1 -0
  132. package/lib/index.d.ts.map +1 -1
  133. package/lib/index.js +2 -0
  134. package/lib/index.js.map +1 -1
  135. package/lib/metrics/metrics/beacon.d.ts +16 -0
  136. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  137. package/lib/metrics/metrics/beacon.js +35 -0
  138. package/lib/metrics/metrics/beacon.js.map +1 -1
  139. package/lib/metrics/metrics/lodestar.d.ts +12 -0
  140. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  141. package/lib/metrics/metrics/lodestar.js +25 -0
  142. package/lib/metrics/metrics/lodestar.js.map +1 -1
  143. package/lib/network/gossip/interface.d.ts +8 -2
  144. package/lib/network/gossip/interface.d.ts.map +1 -1
  145. package/lib/network/gossip/interface.js +1 -0
  146. package/lib/network/gossip/interface.js.map +1 -1
  147. package/lib/network/gossip/topic.d.ts +13 -5
  148. package/lib/network/gossip/topic.d.ts.map +1 -1
  149. package/lib/network/gossip/topic.js +13 -1
  150. package/lib/network/gossip/topic.js.map +1 -1
  151. package/lib/network/interface.d.ts +2 -1
  152. package/lib/network/interface.d.ts.map +1 -1
  153. package/lib/network/network.d.ts +2 -1
  154. package/lib/network/network.d.ts.map +1 -1
  155. package/lib/network/network.js +5 -0
  156. package/lib/network/network.js.map +1 -1
  157. package/lib/network/peers/utils/enrSubnetsDeserialize.d.ts.map +1 -1
  158. package/lib/network/peers/utils/enrSubnetsDeserialize.js +5 -2
  159. package/lib/network/peers/utils/enrSubnetsDeserialize.js.map +1 -1
  160. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  161. package/lib/network/processor/gossipHandlers.js +67 -19
  162. package/lib/network/processor/gossipHandlers.js.map +1 -1
  163. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  164. package/lib/network/processor/gossipQueues/index.js +6 -0
  165. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  166. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  167. package/lib/network/processor/gossipValidatorFn.js +5 -1
  168. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  169. package/lib/network/processor/index.d.ts +5 -0
  170. package/lib/network/processor/index.d.ts.map +1 -1
  171. package/lib/network/processor/index.js +37 -26
  172. package/lib/network/processor/index.js.map +1 -1
  173. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  174. package/lib/network/reqresp/ReqRespBeaconNode.js +6 -0
  175. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  176. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts +10 -0
  177. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts.map +1 -0
  178. package/lib/network/reqresp/handlers/inclusionListsByIndices.js +30 -0
  179. package/lib/network/reqresp/handlers/inclusionListsByIndices.js.map +1 -0
  180. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  181. package/lib/network/reqresp/handlers/index.js +5 -0
  182. package/lib/network/reqresp/handlers/index.js.map +1 -1
  183. package/lib/network/reqresp/protocols.d.ts +1 -0
  184. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  185. package/lib/network/reqresp/protocols.js +5 -0
  186. package/lib/network/reqresp/protocols.js.map +1 -1
  187. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  188. package/lib/network/reqresp/rateLimit.js +4 -0
  189. package/lib/network/reqresp/rateLimit.js.map +1 -1
  190. package/lib/network/reqresp/types.d.ts +5 -2
  191. package/lib/network/reqresp/types.d.ts.map +1 -1
  192. package/lib/network/reqresp/types.js +3 -0
  193. package/lib/network/reqresp/types.js.map +1 -1
  194. package/lib/sync/unknownBlock.d.ts.map +1 -1
  195. package/lib/sync/unknownBlock.js +42 -18
  196. package/lib/sync/unknownBlock.js.map +1 -1
  197. package/package.json +30 -30
  198. package/src/api/impl/api.ts +1 -1
  199. package/src/api/impl/beacon/blocks/index.ts +22 -17
  200. package/src/api/impl/beacon/index.ts +3 -1
  201. package/src/api/impl/beacon/state/index.ts +10 -1
  202. package/src/api/impl/beacon/state/utils.ts +19 -9
  203. package/src/api/impl/debug/index.ts +4 -0
  204. package/src/api/impl/validator/index.ts +132 -10
  205. package/src/api/options.ts +3 -0
  206. package/src/chain/archiveStore/utils/archiveBlocks.ts +64 -126
  207. package/src/chain/blocks/importBlock.ts +11 -14
  208. package/src/chain/blocks/importExecutionPayload.ts +68 -2
  209. package/src/chain/blocks/types.ts +5 -0
  210. package/src/chain/chain.ts +8 -4
  211. package/src/chain/errors/executionPayloadBid.ts +12 -0
  212. package/src/chain/errors/inclusionList.ts +38 -0
  213. package/src/chain/errors/index.ts +1 -0
  214. package/src/chain/interface.ts +2 -0
  215. package/src/chain/opPools/inclusionListStore.ts +208 -0
  216. package/src/chain/opPools/index.ts +1 -0
  217. package/src/chain/produceBlock/produceBlockBody.ts +60 -19
  218. package/src/chain/regen/interface.ts +1 -1
  219. package/src/chain/validation/executionPayloadBid.ts +40 -170
  220. package/src/chain/validation/inclusionList.ts +192 -0
  221. package/src/chain/validation/index.ts +1 -0
  222. package/src/db/beacon.ts +5 -0
  223. package/src/execution/builder/validateBid.ts +23 -2
  224. package/src/execution/engine/blobVersionedHashes.ts +1 -1
  225. package/src/execution/engine/disabled.ts +4 -0
  226. package/src/execution/engine/http.ts +40 -5
  227. package/src/execution/engine/interface.ts +27 -3
  228. package/src/execution/engine/jsonRpcTransport.ts +46 -9
  229. package/src/execution/engine/mock.ts +32 -7
  230. package/src/execution/engine/payloadIdCache.ts +24 -6
  231. package/src/execution/engine/restTransport.ts +15 -1
  232. package/src/execution/engine/transport.ts +7 -2
  233. package/src/execution/engine/types.ts +41 -6
  234. package/src/index.ts +2 -0
  235. package/src/metrics/metrics/beacon.ts +37 -0
  236. package/src/metrics/metrics/lodestar.ts +26 -0
  237. package/src/network/gossip/interface.ts +5 -0
  238. package/src/network/gossip/topic.ts +14 -0
  239. package/src/network/interface.ts +2 -0
  240. package/src/network/network.ts +11 -0
  241. package/src/network/peers/utils/enrSubnetsDeserialize.ts +5 -2
  242. package/src/network/processor/gossipHandlers.ts +87 -21
  243. package/src/network/processor/gossipQueues/index.ts +6 -0
  244. package/src/network/processor/gossipValidatorFn.ts +5 -0
  245. package/src/network/processor/index.ts +33 -24
  246. package/src/network/processor/types.ts +1 -1
  247. package/src/network/reqresp/ReqRespBeaconNode.ts +7 -0
  248. package/src/network/reqresp/handlers/inclusionListsByIndices.ts +44 -0
  249. package/src/network/reqresp/handlers/index.ts +5 -0
  250. package/src/network/reqresp/protocols.ts +6 -0
  251. package/src/network/reqresp/rateLimit.ts +4 -0
  252. package/src/network/reqresp/types.ts +6 -0
  253. package/src/sync/unknownBlock.ts +47 -28
@@ -21,7 +21,7 @@ import {
21
21
  IBeaconStateView,
22
22
  RootCache,
23
23
  computeEpochAtSlot,
24
- computeTimeAtSlot,
24
+ computeTimeAtSlotMs,
25
25
  getBeaconCommittees,
26
26
  isStatePostAltair,
27
27
  isStatePostBellatrix,
@@ -105,8 +105,9 @@ export async function importBlock(
105
105
  const currentEpoch = computeEpochAtSlot(currentSlot);
106
106
  const blockEpoch = computeEpochAtSlot(blockSlot);
107
107
  const prevFinalizedEpoch = this.forkChoice.getFinalizedCheckpoint().epoch;
108
- const receiveDelaySec =
109
- fullyVerifiedBlock.seenTimestampSec - computeTimeAtSlot(this.config, blockSlot, postState.genesisTime);
108
+ const receiveDelayMs =
109
+ Math.round(fullyVerifiedBlock.seenTimestampSec * 1000) -
110
+ computeTimeAtSlotMs(this.config, blockSlot, postState.genesisTime * 1000);
110
111
  const recvToValLatency = Date.now() / 1000 - (opts.seenTimestampSec ?? Date.now() / 1000);
111
112
  const fork = this.config.getForkSeq(blockSlot);
112
113
 
@@ -148,12 +149,12 @@ export async function importBlock(
148
149
  executionStatus = parentBlock.executionStatus;
149
150
  }
150
151
 
151
- const importDelaySec = this.clock.secFromSlot(blockSlot);
152
+ const importDelayMs = this.clock.msFromSlot(blockSlot);
152
153
  const blockSummary = this.forkChoice.onBlock(
153
154
  block.message,
154
155
  postState,
155
- receiveDelaySec,
156
- importDelaySec,
156
+ receiveDelayMs,
157
+ importDelayMs,
157
158
  currentSlot,
158
159
  executionStatus,
159
160
  dataAvailabilityStatus
@@ -417,7 +418,7 @@ export async function importBlock(
417
418
  // 4) Block meets the criteria of being re-orged out (this is also checked inside the function)
418
419
  const result = this.forkChoice.shouldOverrideForkChoiceUpdate(
419
420
  blockSummary,
420
- this.clock.secFromSlot(currentSlot),
421
+ this.clock.msFromSlot(currentSlot),
421
422
  currentSlot
422
423
  );
423
424
  shouldOverrideFcu = result.shouldOverrideFcu;
@@ -458,7 +459,8 @@ export async function importBlock(
458
459
  * - `headBlockHash !== null` -> Pre BELLATRIX_EPOCH
459
460
  * - `headBlockHash !== ZERO_HASH` -> Pre TTD
460
461
  */
461
- const headBlockHash = this.forkChoice.getHead().executionPayloadBlockHash ?? ZERO_HASH_HEX;
462
+ const fcuHead = this.forkChoice.getHead();
463
+ const headBlockHash = fcuHead.executionPayloadBlockHash ?? ZERO_HASH_HEX;
462
464
  /**
463
465
  * After BELLATRIX_EPOCH and TTD it's okay to send a zero hash block hash for the finalized block. This will happen if
464
466
  * the current finalized block does not contain any execution payload at all (pre MERGE_EPOCH) or if it contains a
@@ -468,12 +470,7 @@ export async function importBlock(
468
470
  const finalizedBlockHash = getFinalizedExecutionBlockHash(this.forkChoice);
469
471
  if (headBlockHash !== ZERO_HASH_HEX) {
470
472
  this.executionEngine
471
- .notifyForkchoiceUpdate(
472
- this.config.getForkName(this.forkChoice.getHead().slot),
473
- headBlockHash,
474
- safeBlockHash,
475
- finalizedBlockHash
476
- )
473
+ .notifyForkchoiceUpdate(this.config.getForkName(fcuHead.slot), headBlockHash, safeBlockHash, finalizedBlockHash)
477
474
  .catch((e) => {
478
475
  if (!isErrorAborted(e) && !isQueueErrorAborted(e)) {
479
476
  this.logger.error("Error pushing notifyForkchoiceUpdate()", {headBlockHash, finalizedBlockHash}, e);
@@ -1,3 +1,4 @@
1
+ import {SerializedList} from "@chainsafe/ssz";
1
2
  import {routes} from "@lodestar/api";
2
3
  import {
3
4
  ExecutionStatus,
@@ -5,9 +6,16 @@ import {
5
6
  getFinalizedExecutionBlockHash,
6
7
  getSafeExecutionBlockHash,
7
8
  } from "@lodestar/fork-choice";
8
- import {DataAvailabilityStatus, isStatePostGloas} from "@lodestar/state-transition";
9
+ import {
10
+ DataAvailabilityStatus,
11
+ computeEpochAtSlot,
12
+ isStatePostGloas,
13
+ isStatePostHeze,
14
+ } from "@lodestar/state-transition";
15
+ import {RootHex, bellatrix} from "@lodestar/types";
9
16
  import {isErrorAborted} from "@lodestar/utils";
10
17
  import {ExecutionPayloadStatus} from "../../execution/index.js";
18
+ import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
11
19
  import {isQueueErrorAborted} from "../../util/queue/index.js";
12
20
  import {BeaconChain} from "../chain.js";
13
21
  import {RegenCaller} from "../regen/interface.js";
@@ -172,6 +180,37 @@ export async function importExecutionPayload(
172
180
  );
173
181
  }
174
182
 
183
+ // Timely inclusion lists of the preceding slot, keyed by that slot's dependent root on the block's branch and
184
+ // resolved from the parent, which is at or before that slot. Gossip validation only accepts lists whose dependent
185
+ // block is in fork choice, so a dependent root fork choice cannot resolve (below the anchor after checkpoint sync)
186
+ // keys no stored list
187
+ let inclusionListTransactions: bellatrix.Transactions | undefined;
188
+ if (isStatePostHeze(blockState)) {
189
+ const inclusionListSlot = protoBlock.slot - 1;
190
+ let dependentRoot: RootHex | null = null;
191
+ const parentBlock = this.forkChoice.getBlockHexDefaultStatus(protoBlock.parentRoot);
192
+ if (parentBlock !== null) {
193
+ try {
194
+ dependentRoot = getShufflingDependentRoot(
195
+ this.forkChoice,
196
+ computeEpochAtSlot(inclusionListSlot),
197
+ computeEpochAtSlot(parentBlock.slot),
198
+ parentBlock
199
+ );
200
+ } catch (e) {
201
+ this.logger.debug(
202
+ "Inclusion list dependent root not in fork choice, importing payload without lists",
203
+ {slot, root: blockRootHex},
204
+ e as Error
205
+ );
206
+ }
207
+ }
208
+ inclusionListTransactions =
209
+ dependentRoot === null
210
+ ? SerializedList.empty()
211
+ : this.inclusionListStore.getInclusionListTransactions(inclusionListSlot, dependentRoot, true);
212
+ }
213
+
175
214
  // 4a. Run EL and signature verification in parallel
176
215
  const logCtx = {slot, root: blockRootHex, executionBlock: envelope.payload.blockNumber};
177
216
  this.logger.debug("Call engine api newPayload", logCtx);
@@ -182,7 +221,8 @@ export async function importExecutionPayload(
182
221
  envelope.payload,
183
222
  payloadInput.getVersionedHashes(),
184
223
  envelope.parentBeaconBlockRoot,
185
- envelope.executionRequests
224
+ envelope.executionRequests,
225
+ inclusionListTransactions
186
226
  ),
187
227
 
188
228
  opts.validSignature === true
@@ -250,6 +290,32 @@ export async function importExecutionPayload(
250
290
  }
251
291
  });
252
292
 
293
+ // A VALID payload that does not satisfy the inclusion list constraints is still imported, fork choice
294
+ // only records the verdict so should_extend_payload moves the head to the EMPTY variant, which the next
295
+ // proposer builds on.
296
+ // Recorded before the payload enters fork choice. A VALID response must carry a verdict, an
297
+ // optimistically imported payload counts as satisfied until the engine validates it, anything else as
298
+ // unsatisfied. A VALID response without a verdict violates the engine API, it is logged and treated as
299
+ // satisfied so a non-compliant engine does not orphan every payload
300
+ if (inclusionListTransactions !== undefined) {
301
+ if (execResult.status === ExecutionPayloadStatus.VALID && execResult.inclusionListSatisfied == null) {
302
+ this.logger.warn("Execution engine reported no inclusion list verdict, not enforcing inclusion lists", logCtx);
303
+ }
304
+ const satisfied =
305
+ execResult.status === ExecutionPayloadStatus.VALID
306
+ ? (execResult.inclusionListSatisfied ?? true)
307
+ : execResult.status === ExecutionPayloadStatus.SYNCING || execResult.status === ExecutionPayloadStatus.ACCEPTED;
308
+ this.forkChoice.recordPayloadInclusionListSatisfaction(blockRootHex, satisfied);
309
+ if (!satisfied) {
310
+ this.logger.verbose("Payload did not satisfy inclusion list constraints", {
311
+ ...logCtx,
312
+ blockHash: blockHashHex,
313
+ status: execResult.status,
314
+ inclusionListTransactions: inclusionListTransactions.length,
315
+ });
316
+ }
317
+ }
318
+
253
319
  // 6. Update fork choice, transitions the block's PENDING variant to FULL
254
320
  const execStatus = toForkChoiceExecutionStatus(execResult.status);
255
321
  this.forkChoice.onExecutionPayload(
@@ -12,6 +12,11 @@ export enum GossipedInputType {
12
12
  dataColumn = "data_column",
13
13
  }
14
14
 
15
+ export enum InclusionListSource {
16
+ gossip = "gossip",
17
+ api = "api",
18
+ }
19
+
15
20
  type DataColumnData = {
16
21
  dataColumn: fulu.DataColumnSidecar;
17
22
  dataColumnBytes: Uint8Array | null;
@@ -100,6 +100,7 @@ import {
100
100
  AttestationPool,
101
101
  DeferredVoluntaryExitPool,
102
102
  ExecutionPayloadBidPool,
103
+ InclusionListStore,
103
104
  OpPool,
104
105
  PayloadAttestationPool,
105
106
  ProposerPreferencesPool,
@@ -198,6 +199,7 @@ export class BeaconChain implements IBeaconChain {
198
199
  readonly executionPayloadBidPool: ExecutionPayloadBidPool;
199
200
  readonly payloadAttestationPool: PayloadAttestationPool;
200
201
  readonly proposerPreferencesPool = new ProposerPreferencesPool();
202
+ readonly inclusionListStore: InclusionListStore;
201
203
  readonly opPool: OpPool;
202
204
  readonly deferredVoluntaryExitPool: DeferredVoluntaryExitPool;
203
205
 
@@ -335,6 +337,7 @@ export class BeaconChain implements IBeaconChain {
335
337
  this.payloadAttestationPool = new PayloadAttestationPool(config, clock, metrics);
336
338
  this.opPool = new OpPool(config);
337
339
  this.deferredVoluntaryExitPool = new DeferredVoluntaryExitPool(logger);
340
+ this.inclusionListStore = new InclusionListStore(config);
338
341
 
339
342
  this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
340
343
  this.seenContributionAndProof = new SeenContributionAndProof(metrics);
@@ -1483,10 +1486,10 @@ export class BeaconChain implements IBeaconChain {
1483
1486
  this.metrics?.forkChoice.requests.inc();
1484
1487
  const timer = this.metrics?.forkChoice.findHead.startTimer({caller: FindHeadFnName.predictProposerHead});
1485
1488
  const slot = this.clock.currentSlot;
1486
- const secFromSlot = this.clock.secFromSlot(slot);
1489
+ const msFromSlot = this.clock.msFromSlot(slot);
1487
1490
 
1488
1491
  try {
1489
- return this.forkChoice.updateAndGetHead({mode: UpdateHeadOpt.GetPredictedProposerHead, secFromSlot, slot}).head;
1492
+ return this.forkChoice.updateAndGetHead({mode: UpdateHeadOpt.GetPredictedProposerHead, msFromSlot, slot}).head;
1490
1493
  } catch (e) {
1491
1494
  this.metrics?.forkChoice.errors.inc({entrypoint: UpdateHeadOpt.GetPredictedProposerHead});
1492
1495
  throw e;
@@ -1498,13 +1501,13 @@ export class BeaconChain implements IBeaconChain {
1498
1501
  getProposerHead(slot: Slot): ProtoBlock {
1499
1502
  this.metrics?.forkChoice.requests.inc();
1500
1503
  const timer = this.metrics?.forkChoice.findHead.startTimer({caller: FindHeadFnName.getProposerHead});
1501
- const secFromSlot = this.clock.secFromSlot(slot);
1504
+ const msFromSlot = this.clock.msFromSlot(slot);
1502
1505
 
1503
1506
  try {
1504
1507
  // Do not emit head event here, when proposing we rely on the one emitted when importing our own block
1505
1508
  const {head, isHeadTimely, notReorgedReason} = this.forkChoice.updateAndGetHead({
1506
1509
  mode: UpdateHeadOpt.GetProposerHead,
1507
- secFromSlot,
1510
+ msFromSlot,
1508
1511
  slot,
1509
1512
  });
1510
1513
 
@@ -1832,6 +1835,7 @@ export class BeaconChain implements IBeaconChain {
1832
1835
  this.executionPayloadBidPool.prune(slot);
1833
1836
  this.seenExecutionPayloadBids.prune(slot);
1834
1837
  this.proposerPreferencesPool.prune(slot);
1838
+ this.inclusionListStore.prune(slot);
1835
1839
  this.seenAttestationDatas.onSlot(slot);
1836
1840
  this.reprocessController.onSlot(slot);
1837
1841
 
@@ -21,6 +21,8 @@ export enum ExecutionPayloadBidErrorCode {
21
21
  NO_MATCHING_PROPOSER_PREFERENCES = "EXECUTION_PAYLOAD_BID_ERROR_NO_MATCHING_PROPOSER_PREFERENCES",
22
22
  PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_FEE_RECIPIENT_MISMATCH",
23
23
  PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH = "EXECUTION_PAYLOAD_BID_ERROR_PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH",
24
+ INCLUSION_LIST_BITS_NOT_INCLUSIVE = "EXECUTION_PAYLOAD_BID_ERROR_INCLUSION_LIST_BITS_NOT_INCLUSIVE",
25
+ BEFORE_INCLUSION_LIST_DEADLINE = "EXECUTION_PAYLOAD_BID_ERROR_BEFORE_INCLUSION_LIST_DEADLINE",
24
26
  }
25
27
 
26
28
  export type ExecutionPayloadBidErrorType =
@@ -86,6 +88,16 @@ export type ExecutionPayloadBidErrorType =
86
88
  bidFeeRecipient: string;
87
89
  expectedFeeRecipient: string;
88
90
  }
91
+ | {
92
+ code: ExecutionPayloadBidErrorCode.INCLUSION_LIST_BITS_NOT_INCLUSIVE;
93
+ builderIndex: BuilderIndex;
94
+ slot: Slot;
95
+ }
96
+ | {
97
+ code: ExecutionPayloadBidErrorCode.BEFORE_INCLUSION_LIST_DEADLINE;
98
+ builderIndex: BuilderIndex;
99
+ slot: Slot;
100
+ }
89
101
  | {
90
102
  code: ExecutionPayloadBidErrorCode.PROPOSER_PREFERENCES_GAS_LIMIT_MISMATCH;
91
103
  builderIndex: BuilderIndex;
@@ -0,0 +1,38 @@
1
+ import {Epoch, RootHex, Slot, ValidatorIndex} from "@lodestar/types";
2
+ import {GossipActionError} from "./gossipValidation.js";
3
+
4
+ export enum InclusionListErrorCode {
5
+ EMPTY_TRANSACTIONS = "INCLUSION_LIST_ERROR_EMPTY_TRANSACTIONS",
6
+ MAXIMUM_SIZE_EXCEEDED = "INCLUSION_LIST_ERROR_MAXIMUM_SIZE_EXCEEDED",
7
+ EMPTY_TRANSACTION = "INCLUSION_LIST_ERROR_EMPTY_TRANSACTION",
8
+ INVALID_SLOT = "INCLUSION_LIST_ERROR_INVALID_SLOT",
9
+ MORE_THAN_TWO = "INCLUSION_LIST_ERROR_MORE_THAN_TWO",
10
+ VALIDATOR_NOT_IN_COMMITTEE = "INCLUSION_LIST_ERROR_VALIDATOR_NOT_IN_COMMITTEE",
11
+ UNKNOWN_DEPENDENT_ROOT = "INCLUSION_LIST_ERROR_UNKNOWN_DEPENDENT_ROOT",
12
+ INVALID_DEPENDENT_ROOT_SLOT = "INCLUSION_LIST_ERROR_INVALID_DEPENDENT_ROOT_SLOT",
13
+ INVALID_DEPENDENT_ROOT = "INCLUSION_LIST_ERROR_INVALID_DEPENDENT_ROOT",
14
+ MISSING_SHUFFLING = "INCLUSION_LIST_ERROR_MISSING_SHUFFLING",
15
+ INVALID_SIGNATURE = "INCLUSION_LIST_ERROR_INVALID_SIGNATURE",
16
+ PRE_HEZE_SLOT = "INCLUSION_LIST_ERROR_PRE_HEZE_SLOT",
17
+ }
18
+
19
+ export type InclusionListErrorType =
20
+ | {code: InclusionListErrorCode.EMPTY_TRANSACTIONS}
21
+ | {code: InclusionListErrorCode.MAXIMUM_SIZE_EXCEEDED; totalBytes: number; maxBytes: number}
22
+ | {code: InclusionListErrorCode.EMPTY_TRANSACTION; transactionIndex: number}
23
+ | {code: InclusionListErrorCode.INVALID_SLOT; inclusionListSlot: Slot; currentSlot: Slot}
24
+ | {code: InclusionListErrorCode.MORE_THAN_TWO; validatorIndex: ValidatorIndex}
25
+ | {code: InclusionListErrorCode.VALIDATOR_NOT_IN_COMMITTEE; validatorIndex: ValidatorIndex}
26
+ | {code: InclusionListErrorCode.UNKNOWN_DEPENDENT_ROOT; dependentRoot: RootHex}
27
+ | {
28
+ code: InclusionListErrorCode.INVALID_DEPENDENT_ROOT_SLOT;
29
+ dependentRoot: RootHex;
30
+ dependentSlot: Slot;
31
+ maxSlot: Slot;
32
+ }
33
+ | {code: InclusionListErrorCode.INVALID_DEPENDENT_ROOT; dependentRoot: RootHex; epoch: Epoch}
34
+ | {code: InclusionListErrorCode.MISSING_SHUFFLING; dependentRoot: RootHex; epoch: Epoch}
35
+ | {code: InclusionListErrorCode.INVALID_SIGNATURE}
36
+ | {code: InclusionListErrorCode.PRE_HEZE_SLOT; inclusionListSlot: Slot};
37
+
38
+ export class InclusionListError extends GossipActionError<InclusionListErrorType> {}
@@ -8,6 +8,7 @@ export * from "./envelopeReconstructionError.js";
8
8
  export * from "./executionPayloadBid.js";
9
9
  export * from "./executionPayloadEnvelope.js";
10
10
  export * from "./gossipValidation.js";
11
+ export * from "./inclusionList.js";
11
12
  export * from "./payloadAttestation.js";
12
13
  export * from "./proposerPreferences.js";
13
14
  export * from "./proposerSlashingError.js";
@@ -49,6 +49,7 @@ import {
49
49
  AttestationPool,
50
50
  DeferredVoluntaryExitPool,
51
51
  ExecutionPayloadBidPool,
52
+ InclusionListStore,
52
53
  OpPool,
53
54
  PayloadAttestationPool,
54
55
  ProposerPreferencesPool,
@@ -131,6 +132,7 @@ export interface IBeaconChain {
131
132
  readonly executionPayloadBidPool: ExecutionPayloadBidPool;
132
133
  readonly payloadAttestationPool: PayloadAttestationPool;
133
134
  readonly proposerPreferencesPool: ProposerPreferencesPool;
135
+ readonly inclusionListStore: InclusionListStore;
134
136
  readonly opPool: OpPool;
135
137
  readonly deferredVoluntaryExitPool: DeferredVoluntaryExitPool;
136
138
 
@@ -0,0 +1,208 @@
1
+ import {BitArray, SerializedList} from "@chainsafe/ssz";
2
+ import {BeaconConfig} from "@lodestar/config";
3
+ import {INCLUSION_LIST_COMMITTEE_SIZE} from "@lodestar/params";
4
+ import {RootHex, Slot, ValidatorIndex, bellatrix, heze, ssz} from "@lodestar/types";
5
+ import {MapDef, toHex, toRootHex} from "@lodestar/utils";
6
+
7
+ export enum InclusionListInsertOutcome {
8
+ /** Stored as a new entry. */
9
+ New = "New",
10
+ /** Slot is older than the prune horizon. */
11
+ Old = "Old",
12
+ /** Identical inclusion list already stored. */
13
+ Seen = "Seen",
14
+ /** New equivocation evidence: this validator already has a different inclusion list stored. */
15
+ Equivocating = "Equivocating",
16
+ /** Validator was already marked as an equivocator for this `(slot, dependent_root)`. */
17
+ SubsequentEquivocation = "SubsequentEquivocation",
18
+ }
19
+
20
+ type InclusionListEntry = {
21
+ signedInclusionList: heze.SignedInclusionList;
22
+ /** Positions of the validator in `get_inclusion_list_committee(state, slot)`, several when the committee cycles */
23
+ committeeIndices: number[];
24
+ /** Received before the inclusion list deadline of its slot. */
25
+ timely: boolean;
26
+ };
27
+
28
+ /**
29
+ * Spec `InclusionListStore`: inclusion lists keyed by `(slot, dependent_root)`, one per validator index.
30
+ * The committee position is recorded at insert time (gossip validation resolves it) so the bit-oriented
31
+ * reads need no shuffling lookup. Signed lists are kept so InclusionListsByIndices can serve them.
32
+ * A validator's first list stays stored and an equivocation marks the validator so reads skip it.
33
+ */
34
+ export class InclusionListStore {
35
+ /** slot -> dependent_root -> validator index -> entry */
36
+ private readonly inclusionLists = new MapDef<Slot, MapDef<RootHex, Map<ValidatorIndex, InclusionListEntry>>>(
37
+ () => new MapDef<RootHex, Map<ValidatorIndex, InclusionListEntry>>(() => new Map())
38
+ );
39
+ /** slot -> dependent_root -> equivocating validator indices */
40
+ private readonly equivocators = new MapDef<Slot, MapDef<RootHex, Set<ValidatorIndex>>>(
41
+ () => new MapDef<RootHex, Set<ValidatorIndex>>(() => new Set())
42
+ );
43
+ /** slot -> dependent_root -> validator index -> count, for the p2p "first or second message" rule */
44
+ private readonly seenCounts = new MapDef<Slot, MapDef<RootHex, Map<ValidatorIndex, number>>>(
45
+ () => new MapDef<RootHex, Map<ValidatorIndex, number>>(() => new Map())
46
+ );
47
+
48
+ private lowestPermissibleSlot = 0;
49
+
50
+ constructor(private readonly config: BeaconConfig) {}
51
+
52
+ get size(): number {
53
+ let count = 0;
54
+ for (const byDependentRoot of this.inclusionLists.values()) {
55
+ for (const entries of byDependentRoot.values()) {
56
+ count += entries.size;
57
+ }
58
+ }
59
+ return count;
60
+ }
61
+
62
+ /**
63
+ * Late lists are stored with `timely=false` rather than dropped: they still count toward the
64
+ * non-timely view used to validate another node's `inclusion_list_bits`.
65
+ */
66
+ process(
67
+ signedInclusionList: heze.SignedInclusionList,
68
+ committeeIndices: number[],
69
+ timely: boolean
70
+ ): InclusionListInsertOutcome {
71
+ const inclusionList = signedInclusionList.message;
72
+ const {slot, validatorIndex} = inclusionList;
73
+
74
+ if (slot < this.lowestPermissibleSlot) {
75
+ return InclusionListInsertOutcome.Old;
76
+ }
77
+
78
+ const dependentRoot = toRootHex(inclusionList.dependentRoot);
79
+ const stored = this.inclusionLists.getOrDefault(slot).getOrDefault(dependentRoot);
80
+
81
+ const entry = stored.get(validatorIndex);
82
+ if (entry !== undefined) {
83
+ if (ssz.heze.InclusionList.equals(entry.signedInclusionList.message, inclusionList)) {
84
+ return InclusionListInsertOutcome.Seen;
85
+ }
86
+ const equivocators = this.equivocators.getOrDefault(slot).getOrDefault(dependentRoot);
87
+ if (equivocators.has(validatorIndex)) {
88
+ return InclusionListInsertOutcome.SubsequentEquivocation;
89
+ }
90
+ equivocators.add(validatorIndex);
91
+ return InclusionListInsertOutcome.Equivocating;
92
+ }
93
+
94
+ stored.set(validatorIndex, {signedInclusionList, committeeIndices, timely});
95
+ return InclusionListInsertOutcome.New;
96
+ }
97
+
98
+ /** Count a valid message of `validatorIndex` for the first-or-second message gossip rule */
99
+ markSeen(slot: Slot, dependentRoot: RootHex, validatorIndex: ValidatorIndex): void {
100
+ const counts = this.seenCounts.getOrDefault(slot).getOrDefault(dependentRoot);
101
+ counts.set(validatorIndex, (counts.get(validatorIndex) ?? 0) + 1);
102
+ }
103
+
104
+ /** Gossip rule: at most two valid messages per validator for a `(slot, dependent_root)` */
105
+ seenTwice(slot: Slot, dependentRoot: RootHex, validatorIndex: ValidatorIndex): boolean {
106
+ return (this.seenCounts.get(slot)?.get(dependentRoot)?.get(validatorIndex) ?? 0) >= 2;
107
+ }
108
+
109
+ /** Deduplicated transactions from valid, non-equivocating inclusion lists at `(slot, dependentRoot)`. */
110
+ getInclusionListTransactions(slot: Slot, dependentRoot: RootHex, onlyTimely = true): bellatrix.Transactions {
111
+ const transactions: Uint8Array[] = [];
112
+ const seen = new Set<string>();
113
+
114
+ for (const {signedInclusionList} of this.getEligible(slot, dependentRoot, onlyTimely)) {
115
+ for (const transaction of signedInclusionList.message.transactions) {
116
+ const key = toHex(transaction);
117
+ if (!seen.has(key)) {
118
+ seen.add(key);
119
+ transactions.push(transaction);
120
+ }
121
+ }
122
+ }
123
+
124
+ return SerializedList.fromArray(transactions);
125
+ }
126
+
127
+ /** Bit `i` is set when committee member `i` submitted a valid, non-equivocating inclusion list */
128
+ getInclusionListBits(slot: Slot, dependentRoot: RootHex, onlyTimely = true): BitArray {
129
+ const bits = BitArray.fromBitLen(INCLUSION_LIST_COMMITTEE_SIZE);
130
+ for (const {committeeIndices} of this.getEligible(slot, dependentRoot, onlyTimely)) {
131
+ for (const committeeIndex of committeeIndices) {
132
+ bits.set(committeeIndex, true);
133
+ }
134
+ }
135
+ return bits;
136
+ }
137
+
138
+ /**
139
+ * True if `bits` has a bit set for every bit set in the local inclusion list bits.
140
+ *
141
+ * Intentionally deviates from the spec by only checking against timely lists, where the proposer would check
142
+ * against every list it observed (only_timely=False in
143
+ * https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.4/specs/heze/validator.md#signed-execution-payload-bid).
144
+ * A bid that passed gossip must stay eligible, otherwise a list released after the deadline voids every bid and
145
+ * a high early bid with empty bits crowds out the rest without ever paying.
146
+ */
147
+ isInclusionListBitsInclusive(slot: Slot, dependentRoot: RootHex, bits: BitArray): boolean {
148
+ for (const {committeeIndices} of this.getEligible(slot, dependentRoot, true)) {
149
+ if (committeeIndices.some((committeeIndex) => !bits.get(committeeIndex))) {
150
+ return false;
151
+ }
152
+ }
153
+ return true;
154
+ }
155
+
156
+ /** Inclusion lists for the given committee positions, to serve InclusionListsByIndices. */
157
+ getByIndices(slot: Slot, dependentRoot: RootHex, indices: BitArray): heze.SignedInclusionList[] {
158
+ const out: heze.SignedInclusionList[] = [];
159
+ for (const {signedInclusionList, committeeIndices} of this.getEligible(slot, dependentRoot, false)) {
160
+ if (committeeIndices.some((committeeIndex) => indices.get(committeeIndex))) {
161
+ out.push(signedInclusionList);
162
+ }
163
+ }
164
+ return out;
165
+ }
166
+
167
+ /** Lists are retained for MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS slots so InclusionListsByIndices can serve them */
168
+ prune(clockSlot: Slot): void {
169
+ const horizon = clockSlot - this.config.MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS;
170
+
171
+ for (const slot of this.inclusionLists.keys()) {
172
+ if (slot < horizon) {
173
+ this.inclusionLists.delete(slot);
174
+ }
175
+ }
176
+ for (const slot of this.equivocators.keys()) {
177
+ if (slot < horizon) {
178
+ this.equivocators.delete(slot);
179
+ }
180
+ }
181
+ for (const slot of this.seenCounts.keys()) {
182
+ if (slot < horizon) {
183
+ this.seenCounts.delete(slot);
184
+ }
185
+ }
186
+
187
+ this.lowestPermissibleSlot = Math.max(horizon, 0);
188
+ }
189
+
190
+ /** Entries at `(slot, dependentRoot)` from non-equivocating validators, timely when required. */
191
+ private *getEligible(slot: Slot, dependentRoot: RootHex, onlyTimely: boolean): Generator<InclusionListEntry> {
192
+ const stored = this.inclusionLists.get(slot)?.get(dependentRoot);
193
+ if (!stored || stored.size === 0) {
194
+ return;
195
+ }
196
+ const equivocators = this.equivocators.get(slot)?.get(dependentRoot);
197
+
198
+ for (const [validatorIndex, entry] of stored) {
199
+ if (equivocators?.has(validatorIndex)) {
200
+ continue;
201
+ }
202
+ if (onlyTimely && !entry.timely) {
203
+ continue;
204
+ }
205
+ yield entry;
206
+ }
207
+ }
208
+ }
@@ -2,6 +2,7 @@ export {AggregatedAttestationPool} from "./aggregatedAttestationPool.js";
2
2
  export {AttestationPool} from "./attestationPool.js";
3
3
  export {DeferredVoluntaryExitPool} from "./deferredVoluntaryExitPool.js";
4
4
  export {ExecutionPayloadBidPool, type PooledExecutionPayloadBid} from "./executionPayloadBidPool.js";
5
+ export {InclusionListInsertOutcome, InclusionListStore} from "./inclusionListStore.js";
5
6
  export {OpPool} from "./opPool.js";
6
7
  export {PayloadAttestationPool} from "./payloadAttestationPool.js";
7
8
  export {ProposerPreferencesPool} from "./proposerPreferencesPool.js";