@lodestar/beacon-node 1.43.0-dev.e341cdc614 → 1.43.0-dev.f758dd5f38

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 (144) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +1 -4
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/state/utils.d.ts +2 -2
  5. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  6. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  7. package/lib/api/impl/validator/index.d.ts.map +1 -1
  8. package/lib/api/impl/validator/index.js +0 -4
  9. package/lib/api/impl/validator/index.js.map +1 -1
  10. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  11. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  12. package/lib/chain/archiveStore/interface.d.ts +4 -4
  13. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  14. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  15. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  16. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  17. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
  18. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
  20. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  21. package/lib/chain/blocks/importExecutionPayload.d.ts +14 -13
  22. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  23. package/lib/chain/blocks/importExecutionPayload.js +59 -83
  24. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  25. package/lib/chain/blocks/index.d.ts.map +1 -1
  26. package/lib/chain/blocks/index.js +0 -1
  27. package/lib/chain/blocks/index.js.map +1 -1
  28. package/lib/chain/blocks/types.d.ts +14 -20
  29. package/lib/chain/blocks/types.d.ts.map +1 -1
  30. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
  31. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
  32. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +76 -0
  33. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
  34. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
  35. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
  36. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
  37. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
  38. package/lib/chain/chain.d.ts +5 -4
  39. package/lib/chain/chain.d.ts.map +1 -1
  40. package/lib/chain/chain.js +9 -2
  41. package/lib/chain/chain.js.map +1 -1
  42. package/lib/chain/emitter.d.ts +3 -3
  43. package/lib/chain/emitter.d.ts.map +1 -1
  44. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  45. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  46. package/lib/chain/errors/executionPayloadBid.js +1 -0
  47. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  48. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  49. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  50. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  51. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  52. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  53. package/lib/chain/forkChoice/index.js +11 -19
  54. package/lib/chain/forkChoice/index.js.map +1 -1
  55. package/lib/chain/interface.d.ts +4 -3
  56. package/lib/chain/interface.d.ts.map +1 -1
  57. package/lib/chain/interface.js.map +1 -1
  58. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  59. package/lib/chain/prepareNextSlot.js +46 -16
  60. package/lib/chain/prepareNextSlot.js.map +1 -1
  61. package/lib/chain/produceBlock/produceBlockBody.d.ts +4 -2
  62. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  63. package/lib/chain/produceBlock/produceBlockBody.js +48 -23
  64. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  65. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +11 -4
  66. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  67. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +20 -18
  68. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  69. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  70. package/lib/chain/stateCache/persistentCheckpointsCache.js +4 -1
  71. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  72. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  73. package/lib/chain/validation/executionPayloadBid.js +13 -1
  74. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  75. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  76. package/lib/chain/validation/executionPayloadEnvelope.js +19 -9
  77. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  78. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  79. package/lib/chain/validation/payloadAttestationMessage.js +4 -3
  80. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  81. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  82. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  83. package/lib/execution/engine/http.d.ts.map +1 -1
  84. package/lib/execution/engine/http.js +21 -14
  85. package/lib/execution/engine/http.js.map +1 -1
  86. package/lib/execution/engine/interface.d.ts +1 -0
  87. package/lib/execution/engine/interface.d.ts.map +1 -1
  88. package/lib/execution/engine/mock.d.ts.map +1 -1
  89. package/lib/execution/engine/mock.js +6 -0
  90. package/lib/execution/engine/mock.js.map +1 -1
  91. package/lib/execution/engine/types.d.ts +20 -0
  92. package/lib/execution/engine/types.d.ts.map +1 -1
  93. package/lib/execution/engine/types.js +18 -0
  94. package/lib/execution/engine/types.js.map +1 -1
  95. package/lib/network/gossip/topic.d.ts +3 -2
  96. package/lib/network/gossip/topic.d.ts.map +1 -1
  97. package/lib/network/network.js +1 -1
  98. package/lib/network/network.js.map +1 -1
  99. package/lib/network/processor/gossipHandlers.js +3 -3
  100. package/lib/network/processor/gossipHandlers.js.map +1 -1
  101. package/lib/node/nodejs.d.ts.map +1 -1
  102. package/lib/node/nodejs.js +4 -2
  103. package/lib/node/nodejs.js.map +1 -1
  104. package/lib/node/notifier.js +7 -1
  105. package/lib/node/notifier.js.map +1 -1
  106. package/lib/util/sszBytes.d.ts.map +1 -1
  107. package/lib/util/sszBytes.js +16 -3
  108. package/lib/util/sszBytes.js.map +1 -1
  109. package/package.json +17 -16
  110. package/src/api/impl/beacon/blocks/index.ts +1 -4
  111. package/src/api/impl/beacon/state/utils.ts +2 -2
  112. package/src/api/impl/validator/index.ts +0 -4
  113. package/src/chain/archiveStore/archiveStore.ts +5 -5
  114. package/src/chain/archiveStore/interface.ts +4 -4
  115. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
  116. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  117. package/src/chain/blocks/importExecutionPayload.ts +73 -103
  118. package/src/chain/blocks/index.ts +0 -1
  119. package/src/chain/blocks/types.ts +14 -25
  120. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +129 -0
  121. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  122. package/src/chain/chain.ts +22 -16
  123. package/src/chain/emitter.ts +3 -3
  124. package/src/chain/errors/executionPayloadBid.ts +6 -0
  125. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  126. package/src/chain/forkChoice/index.ts +8 -24
  127. package/src/chain/interface.ts +4 -2
  128. package/src/chain/prepareNextSlot.ts +60 -17
  129. package/src/chain/produceBlock/produceBlockBody.ts +66 -20
  130. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +22 -20
  131. package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
  132. package/src/chain/validation/executionPayloadBid.ts +14 -0
  133. package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
  134. package/src/chain/validation/payloadAttestationMessage.ts +5 -3
  135. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  136. package/src/execution/engine/http.ts +21 -14
  137. package/src/execution/engine/interface.ts +1 -0
  138. package/src/execution/engine/mock.ts +8 -1
  139. package/src/execution/engine/types.ts +41 -0
  140. package/src/network/network.ts +1 -1
  141. package/src/network/processor/gossipHandlers.ts +3 -3
  142. package/src/node/nodejs.ts +4 -2
  143. package/src/node/notifier.ts +8 -1
  144. package/src/util/sszBytes.ts +21 -3
@@ -4,8 +4,8 @@ import {
4
4
  getExecutionPayloadEnvelopeSignatureSet,
5
5
  isStatePostGloas,
6
6
  } from "@lodestar/state-transition";
7
- import {gloas} from "@lodestar/types";
8
- import {toRootHex} from "@lodestar/utils";
7
+ import {gloas, ssz} from "@lodestar/types";
8
+ import {byteArrayEquals, toRootHex} from "@lodestar/utils";
9
9
  import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js";
10
10
  import {IBeaconChain} from "../index.js";
11
11
  import {RegenCaller} from "../regen/index.js";
@@ -53,7 +53,7 @@ async function validateExecutionPayloadEnvelope(
53
53
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
54
54
  code: ExecutionPayloadEnvelopeErrorCode.ENVELOPE_ALREADY_KNOWN,
55
55
  blockRoot: blockRootHex,
56
- slot: envelope.slot,
56
+ slot: payload.slotNumber,
57
57
  });
58
58
  }
59
59
 
@@ -65,13 +65,13 @@ async function validateExecutionPayloadEnvelope(
65
65
  });
66
66
  }
67
67
 
68
- // [IGNORE] The envelope is from a slot greater than or equal to the latest finalized slot -- i.e. validate that `envelope.slot >= compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)`
68
+ // [IGNORE] The envelope is from a slot greater than or equal to the latest finalized slot -- i.e. validate that `payload.slotNumber >= compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)`
69
69
  const finalizedCheckpoint = chain.forkChoice.getFinalizedCheckpoint();
70
70
  const finalizedSlot = computeStartSlotAtEpoch(finalizedCheckpoint.epoch);
71
- if (envelope.slot < finalizedSlot) {
71
+ if (payload.slotNumber < finalizedSlot) {
72
72
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
73
73
  code: ExecutionPayloadEnvelopeErrorCode.BELONG_TO_FINALIZED_BLOCK,
74
- envelopeSlot: envelope.slot,
74
+ envelopeSlot: payload.slotNumber,
75
75
  finalizedSlot,
76
76
  });
77
77
  }
@@ -80,11 +80,11 @@ async function validateExecutionPayloadEnvelope(
80
80
  // TODO GLOAS: implement this. Technically if we cannot get proto block from fork choice,
81
81
  // it is possible that the block didn't pass the validation
82
82
 
83
- // [REJECT] `block.slot` equals `envelope.slot`.
84
- if (block.slot !== envelope.slot) {
83
+ // [REJECT] `block.slot` equals `payload.slotNumber`.
84
+ if (block.slot !== payload.slotNumber) {
85
85
  throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
86
86
  code: ExecutionPayloadEnvelopeErrorCode.SLOT_MISMATCH,
87
- envelopeSlot: envelope.slot,
87
+ envelopeSlot: payload.slotNumber,
88
88
  blockSlot: block.slot,
89
89
  });
90
90
  }
@@ -107,6 +107,16 @@ async function validateExecutionPayloadEnvelope(
107
107
  });
108
108
  }
109
109
 
110
+ // [REJECT] `hash_tree_root(envelope.execution_requests) == bid.execution_requests_root`
111
+ const requestsRoot = ssz.electra.ExecutionRequests.hashTreeRoot(envelope.executionRequests);
112
+ if (!byteArrayEquals(requestsRoot, payloadInput.getBid().executionRequestsRoot)) {
113
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
114
+ code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_ROOT_MISMATCH,
115
+ envelopeRequestsRoot: toRootHex(requestsRoot),
116
+ bidRequestsRoot: toRootHex(payloadInput.getBid().executionRequestsRoot),
117
+ });
118
+ }
119
+
110
120
  // Get the block state to verify the builder's signature.
111
121
  const blockState = await chain.regen
112
122
  .getState(block.stateRoot, RegenCaller.validateGossipPayloadEnvelope)
@@ -114,7 +124,7 @@ async function validateExecutionPayloadEnvelope(
114
124
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
115
125
  code: ExecutionPayloadEnvelopeErrorCode.UNKNOWN_BLOCK_STATE,
116
126
  blockRoot: blockRootHex,
117
- slot: envelope.slot,
127
+ slot: payload.slotNumber,
118
128
  });
119
129
  });
120
130
  if (!isStatePostGloas(blockState)) {
@@ -18,7 +18,8 @@ export async function validateApiPayloadAttestationMessage(
18
18
  chain: IBeaconChain,
19
19
  payloadAttestationMessage: gloas.PayloadAttestationMessage
20
20
  ): Promise<PayloadAttestationValidationResult> {
21
- return validatePayloadAttestationMessage(chain, payloadAttestationMessage);
21
+ const prioritizeBls = true;
22
+ return validatePayloadAttestationMessage(chain, payloadAttestationMessage, prioritizeBls);
22
23
  }
23
24
 
24
25
  export async function validateGossipPayloadAttestationMessage(
@@ -30,7 +31,8 @@ export async function validateGossipPayloadAttestationMessage(
30
31
 
31
32
  async function validatePayloadAttestationMessage(
32
33
  chain: IBeaconChain,
33
- payloadAttestationMessage: gloas.PayloadAttestationMessage
34
+ payloadAttestationMessage: gloas.PayloadAttestationMessage,
35
+ prioritizeBls = false
34
36
  ): Promise<PayloadAttestationValidationResult> {
35
37
  const {data, validatorIndex} = payloadAttestationMessage;
36
38
  const epoch = computeEpochAtSlot(data.slot);
@@ -102,7 +104,7 @@ async function validatePayloadAttestationMessage(
102
104
  payloadAttestationMessage.signature
103
105
  );
104
106
 
105
- if (!(await chain.bls.verifySignatureSets([signatureSet]))) {
107
+ if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
106
108
  throw new PayloadAttestationError(GossipAction.REJECT, {
107
109
  code: PayloadAttestationErrorCode.INVALID_SIGNATURE,
108
110
  });
@@ -19,7 +19,7 @@ export class ExecutionPayloadEnvelopeArchiveRepository extends Repository<Slot,
19
19
  * Id is the slot from the envelope
20
20
  */
21
21
  getId(value: gloas.SignedExecutionPayloadEnvelope): Slot {
22
- return value.message.slot;
22
+ return value.message.payload.slotNumber;
23
23
  }
24
24
 
25
25
  encodeKey(id: Slot): Uint8Array {
@@ -216,13 +216,15 @@ export class ExecutionEngineHttp implements IExecutionEngine {
216
216
  executionRequests?: ExecutionRequests
217
217
  ): Promise<ExecutePayloadResponse> {
218
218
  const method =
219
- ForkSeq[fork] >= ForkSeq.electra
220
- ? "engine_newPayloadV4"
221
- : ForkSeq[fork] >= ForkSeq.deneb
222
- ? "engine_newPayloadV3"
223
- : ForkSeq[fork] >= ForkSeq.capella
224
- ? "engine_newPayloadV2"
225
- : "engine_newPayloadV1";
219
+ ForkSeq[fork] >= ForkSeq.gloas
220
+ ? "engine_newPayloadV5"
221
+ : ForkSeq[fork] >= ForkSeq.electra
222
+ ? "engine_newPayloadV4"
223
+ : ForkSeq[fork] >= ForkSeq.deneb
224
+ ? "engine_newPayloadV3"
225
+ : ForkSeq[fork] >= ForkSeq.capella
226
+ ? "engine_newPayloadV2"
227
+ : "engine_newPayloadV1";
226
228
 
227
229
  const serializedExecutionPayload = serializeExecutionPayload(fork, executionPayload);
228
230
 
@@ -244,7 +246,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
244
246
  }
245
247
  const serializedExecutionRequests = serializeExecutionRequests(executionRequests);
246
248
  engineRequest = {
247
- method: "engine_newPayloadV4",
249
+ method: ForkSeq[fork] >= ForkSeq.gloas ? "engine_newPayloadV5" : "engine_newPayloadV4",
248
250
  params: [
249
251
  serializedExecutionPayload,
250
252
  serializedVersionedHashes,
@@ -348,11 +350,13 @@ export class ExecutionEngineHttp implements IExecutionEngine {
348
350
  // Once on capella, should this need to be permanently switched to v2 when payload attrs
349
351
  // not provided
350
352
  const method =
351
- ForkSeq[fork] >= ForkSeq.deneb
352
- ? "engine_forkchoiceUpdatedV3"
353
- : ForkSeq[fork] >= ForkSeq.capella
354
- ? "engine_forkchoiceUpdatedV2"
355
- : "engine_forkchoiceUpdatedV1";
353
+ ForkSeq[fork] >= ForkSeq.gloas
354
+ ? "engine_forkchoiceUpdatedV4"
355
+ : ForkSeq[fork] >= ForkSeq.deneb
356
+ ? "engine_forkchoiceUpdatedV3"
357
+ : ForkSeq[fork] >= ForkSeq.capella
358
+ ? "engine_forkchoiceUpdatedV2"
359
+ : "engine_forkchoiceUpdatedV1";
356
360
  const payloadAttributesRpc = payloadAttributes ? serializePayloadAttributes(payloadAttributes) : undefined;
357
361
  // If we are just fcUing and not asking execution for payload, retry is not required
358
362
  // and we can move on, as the next fcU will be issued soon on the new slot
@@ -438,9 +442,12 @@ export class ExecutionEngineHttp implements IExecutionEngine {
438
442
  case ForkName.electra:
439
443
  method = "engine_getPayloadV4";
440
444
  break;
441
- default:
445
+ case ForkName.fulu:
442
446
  method = "engine_getPayloadV5";
443
447
  break;
448
+ default:
449
+ method = "engine_getPayloadV6";
450
+ break;
444
451
  }
445
452
  const payloadResponse = await this.rpc.fetchWithRetries<
446
453
  EngineApiRpcReturnTypes[typeof method],
@@ -87,6 +87,7 @@ export type PayloadAttributes = {
87
87
  suggestedFeeRecipient: string;
88
88
  withdrawals?: capella.Withdrawal[];
89
89
  parentBeaconBlockRoot?: Uint8Array;
90
+ slotNumber?: number; // EIP-7843
90
91
  };
91
92
 
92
93
  export type VersionedHashes = Uint8Array[];
@@ -11,7 +11,7 @@ import {
11
11
  SLOTS_PER_EPOCH,
12
12
  } from "@lodestar/params";
13
13
  import {computeTimeAtSlot} from "@lodestar/state-transition";
14
- import {ExecutionPayload, RootHex, bellatrix, deneb, ssz} from "@lodestar/types";
14
+ import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz} from "@lodestar/types";
15
15
  import {fromHex, toRootHex} from "@lodestar/utils";
16
16
  import {ZERO_HASH_HEX} from "../../constants/index.js";
17
17
  import {INTEROP_BLOCK_HASH} from "../../node/utils/interop/state.js";
@@ -132,14 +132,17 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
132
132
  engine_newPayloadV2: this.notifyNewPayload.bind(this),
133
133
  engine_newPayloadV3: this.notifyNewPayload.bind(this),
134
134
  engine_newPayloadV4: this.notifyNewPayload.bind(this),
135
+ engine_newPayloadV5: this.notifyNewPayload.bind(this),
135
136
  engine_forkchoiceUpdatedV1: this.notifyForkchoiceUpdate.bind(this),
136
137
  engine_forkchoiceUpdatedV2: this.notifyForkchoiceUpdate.bind(this),
137
138
  engine_forkchoiceUpdatedV3: this.notifyForkchoiceUpdate.bind(this),
139
+ engine_forkchoiceUpdatedV4: this.notifyForkchoiceUpdate.bind(this),
138
140
  engine_getPayloadV1: this.getPayloadV1.bind(this),
139
141
  engine_getPayloadV2: this.getPayloadV5.bind(this),
140
142
  engine_getPayloadV3: this.getPayloadV5.bind(this),
141
143
  engine_getPayloadV4: this.getPayloadV5.bind(this),
142
144
  engine_getPayloadV5: this.getPayloadV5.bind(this),
145
+ engine_getPayloadV6: this.getPayloadV5.bind(this),
143
146
  engine_getPayloadBodiesByHashV1: this.getPayloadBodiesByHash.bind(this),
144
147
  engine_getPayloadBodiesByRangeV1: this.getPayloadBodiesByRange.bind(this),
145
148
  engine_getClientVersionV1: this.getClientVersionV1.bind(this),
@@ -379,6 +382,10 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
379
382
  (executionPayload as ExecutionPayload<ForkPostCapella>).withdrawals = ssz.capella.Withdrawals.defaultValue();
380
383
  }
381
384
 
385
+ if (ForkSeq[fork] >= ForkSeq.gloas && payloadAttributes.slotNumber != null) {
386
+ (executionPayload as gloas.ExecutionPayload).slotNumber = payloadAttributes.slotNumber;
387
+ }
388
+
382
389
  this.preparingPayloads.set(payloadId, {
383
390
  executionPayload: serializeExecutionPayload(fork, executionPayload),
384
391
  blobsBundle: serializeBlobsBundle({
@@ -19,6 +19,7 @@ import {
19
19
  capella,
20
20
  deneb,
21
21
  electra,
22
+ gloas,
22
23
  ssz,
23
24
  } from "@lodestar/types";
24
25
  import {BlobAndProof} from "@lodestar/types/deneb";
@@ -50,6 +51,7 @@ export type EngineApiRpcParamTypes = {
50
51
  engine_newPayloadV2: [ExecutionPayloadRpc];
51
52
  engine_newPayloadV3: [ExecutionPayloadRpc, VersionedHashesRpc, DATA];
52
53
  engine_newPayloadV4: [ExecutionPayloadRpc, VersionedHashesRpc, DATA, ExecutionRequestsRpc];
54
+ engine_newPayloadV5: [ExecutionPayloadRpc, VersionedHashesRpc, DATA, ExecutionRequestsRpc];
53
55
  /**
54
56
  * 1. Object - Payload validity status with respect to the consensus rules:
55
57
  * - blockHash: DATA, 32 Bytes - block hash value of the payload
@@ -67,6 +69,10 @@ export type EngineApiRpcParamTypes = {
67
69
  forkChoiceData: {headBlockHash: DATA; safeBlockHash: DATA; finalizedBlockHash: DATA},
68
70
  payloadAttributes?: PayloadAttributesRpc,
69
71
  ];
72
+ engine_forkchoiceUpdatedV4: [
73
+ forkChoiceData: {headBlockHash: DATA; safeBlockHash: DATA; finalizedBlockHash: DATA},
74
+ payloadAttributes?: PayloadAttributesRpc,
75
+ ];
70
76
  /**
71
77
  * 1. payloadId: QUANTITY, 64 Bits - Identifier of the payload building process
72
78
  */
@@ -75,6 +81,7 @@ export type EngineApiRpcParamTypes = {
75
81
  engine_getPayloadV3: [QUANTITY];
76
82
  engine_getPayloadV4: [QUANTITY];
77
83
  engine_getPayloadV5: [QUANTITY];
84
+ engine_getPayloadV6: [QUANTITY];
78
85
 
79
86
  /**
80
87
  * 1. Array of DATA - Array of block_hash field values of the ExecutionPayload structure
@@ -111,6 +118,7 @@ export type EngineApiRpcReturnTypes = {
111
118
  engine_newPayloadV2: PayloadStatus;
112
119
  engine_newPayloadV3: PayloadStatus;
113
120
  engine_newPayloadV4: PayloadStatus;
121
+ engine_newPayloadV5: PayloadStatus;
114
122
  engine_forkchoiceUpdatedV1: {
115
123
  payloadStatus: PayloadStatus;
116
124
  payloadId: QUANTITY | null;
@@ -123,6 +131,10 @@ export type EngineApiRpcReturnTypes = {
123
131
  payloadStatus: PayloadStatus;
124
132
  payloadId: QUANTITY | null;
125
133
  };
134
+ engine_forkchoiceUpdatedV4: {
135
+ payloadStatus: PayloadStatus;
136
+ payloadId: QUANTITY | null;
137
+ };
126
138
  /**
127
139
  * payloadId | Error: QUANTITY, 64 Bits - Identifier of the payload building process
128
140
  */
@@ -131,6 +143,7 @@ export type EngineApiRpcReturnTypes = {
131
143
  engine_getPayloadV3: ExecutionPayloadResponse;
132
144
  engine_getPayloadV4: ExecutionPayloadResponse;
133
145
  engine_getPayloadV5: ExecutionPayloadResponse;
146
+ engine_getPayloadV6: ExecutionPayloadResponse;
134
147
 
135
148
  engine_getPayloadBodiesByHashV1: (ExecutionPayloadBodyRpc | null)[];
136
149
 
@@ -180,6 +193,8 @@ export type ExecutionPayloadRpc = {
180
193
  withdrawals?: WithdrawalRpc[]; // Capella hardfork
181
194
  blobGasUsed?: QUANTITY; // DENEB
182
195
  excessBlobGas?: QUANTITY; // DENEB
196
+ blockAccessList?: DATA; // GLOAS:EIP-7928
197
+ slotNumber?: QUANTITY; // GLOAS:EIP-7843
183
198
  };
184
199
 
185
200
  export type WithdrawalRpc = {
@@ -228,6 +243,8 @@ export type PayloadAttributesRpc = {
228
243
  withdrawals?: WithdrawalRpc[];
229
244
  /** DATA, 32 Bytes - value for the parentBeaconBlockRoot to be used for building block */
230
245
  parentBeaconBlockRoot?: DATA;
246
+ /** QUANTITY, 64 Bits - value for the slot number field of the new payload (EIP-7843) */
247
+ slotNumber?: QUANTITY;
231
248
  };
232
249
 
233
250
  export type ClientVersionRpc = {
@@ -280,6 +297,12 @@ export function serializeExecutionPayload(fork: ForkName, data: ExecutionPayload
280
297
 
281
298
  // No changes in Electra
282
299
 
300
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
301
+ const {blockAccessList, slotNumber} = data as gloas.ExecutionPayload;
302
+ payload.blockAccessList = bytesToData(blockAccessList);
303
+ payload.slotNumber = numToQuantity(slotNumber);
304
+ }
305
+
283
306
  return payload;
284
307
  }
285
308
 
@@ -375,6 +398,22 @@ export function parseExecutionPayload(
375
398
 
376
399
  // No changes in Electra
377
400
 
401
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
402
+ const {blockAccessList, slotNumber} = data;
403
+ if (blockAccessList == null) {
404
+ throw Error(
405
+ `blockAccessList missing for ${fork} >= gloas executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}`
406
+ );
407
+ }
408
+ if (slotNumber == null) {
409
+ throw Error(
410
+ `slotNumber missing for ${fork} >= gloas executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}`
411
+ );
412
+ }
413
+ (executionPayload as gloas.ExecutionPayload).blockAccessList = dataToBytes(blockAccessList, null);
414
+ (executionPayload as gloas.ExecutionPayload).slotNumber = quantityToNum(slotNumber);
415
+ }
416
+
378
417
  return {executionPayload, executionPayloadValue, blobsBundle, executionRequests, shouldOverrideBuilder};
379
418
  }
380
419
 
@@ -385,6 +424,7 @@ export function serializePayloadAttributes(data: PayloadAttributes): PayloadAttr
385
424
  suggestedFeeRecipient: data.suggestedFeeRecipient,
386
425
  withdrawals: data.withdrawals?.map(serializeWithdrawal),
387
426
  parentBeaconBlockRoot: data.parentBeaconBlockRoot ? bytesToData(data.parentBeaconBlockRoot) : undefined,
427
+ slotNumber: data.slotNumber !== undefined ? numToQuantity(data.slotNumber) : undefined,
388
428
  };
389
429
  }
390
430
 
@@ -401,6 +441,7 @@ export function deserializePayloadAttributes(data: PayloadAttributesRpc): Payloa
401
441
  suggestedFeeRecipient: data.suggestedFeeRecipient,
402
442
  withdrawals: data.withdrawals?.map((withdrawal) => deserializeWithdrawal(withdrawal)),
403
443
  parentBeaconBlockRoot: data.parentBeaconBlockRoot ? dataToBytes(data.parentBeaconBlockRoot, 32) : undefined,
444
+ slotNumber: data.slotNumber !== undefined ? quantityToNum(data.slotNumber) : undefined,
404
445
  };
405
446
  }
406
447
 
@@ -505,7 +505,7 @@ export class Network implements INetwork {
505
505
  }
506
506
 
507
507
  async publishSignedExecutionPayloadEnvelope(signedEnvelope: gloas.SignedExecutionPayloadEnvelope): Promise<number> {
508
- const epoch = computeEpochAtSlot(signedEnvelope.message.slot);
508
+ const epoch = computeEpochAtSlot(signedEnvelope.message.payload.slotNumber);
509
509
  const boundary = this.config.getForkBoundaryAtEpoch(epoch);
510
510
 
511
511
  return this.publishGossip<GossipType.execution_payload>(
@@ -1065,7 +1065,8 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1065
1065
  await validateGossipExecutionPayloadEnvelope(chain, signedEnvelope);
1066
1066
  } catch (e) {
1067
1067
  if (e instanceof ExecutionPayloadEnvelopeError) {
1068
- const {slot, beaconBlockRoot} = signedEnvelope.message;
1068
+ const {beaconBlockRoot} = signedEnvelope.message;
1069
+ const slot = signedEnvelope.message.payload.slotNumber;
1069
1070
  logger.debug("Gossip envelope has error", {slot, root: toRootHex(beaconBlockRoot), code: e.type.code});
1070
1071
  if (e.type.code === ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN) {
1071
1072
  // TODO GLOAS: UnknownBlockSync to handle this
@@ -1088,7 +1089,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1088
1089
  throw e;
1089
1090
  }
1090
1091
 
1091
- const slot = envelope.slot;
1092
+ const slot = envelope.payload.slotNumber;
1092
1093
  const delaySec = seenTimestampSec - computeTimeAtSlot(config, slot, chain.genesisTime);
1093
1094
  metrics?.gossipExecutionPayloadEnvelope.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
1094
1095
  chain.validatorMonitor?.registerExecutionPayloadEnvelope(OpSource.gossip, delaySec, signedEnvelope);
@@ -1118,7 +1119,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1118
1119
  builderIndex: envelope.builderIndex,
1119
1120
  blockHash: toRootHex(envelope.payload.blockHash),
1120
1121
  blockRoot: blockRootHex,
1121
- stateRoot: toRootHex(envelope.stateRoot),
1122
1122
  });
1123
1123
 
1124
1124
  chain.processExecutionPayload(payloadInput, {validSignature: true}).catch((e) => {
@@ -6,7 +6,7 @@ import {BeaconApiMethods} from "@lodestar/api/beacon/server";
6
6
  import {BeaconConfig} from "@lodestar/config";
7
7
  import type {LoggerNode} from "@lodestar/logger/node";
8
8
  import {ZERO_HASH_HEX} from "@lodestar/params";
9
- import {IBeaconStateView, PubkeyCache, isStatePostBellatrix} from "@lodestar/state-transition";
9
+ import {IBeaconStateView, PubkeyCache, isStatePostBellatrix, isStatePostGloas} from "@lodestar/state-transition";
10
10
  import {phase0} from "@lodestar/types";
11
11
  import {sleep, toRootHex} from "@lodestar/utils";
12
12
  import {ProcessShutdownCallback} from "@lodestar/validator";
@@ -223,7 +223,9 @@ export class BeaconNode {
223
223
  if (opts.executionEngine.mode === "mock") {
224
224
  const eth1BlockHash =
225
225
  isStatePostBellatrix(anchorState) && anchorState.isExecutionStateType
226
- ? toRootHex(anchorState.latestBlockHash)
226
+ ? isStatePostGloas(anchorState)
227
+ ? toRootHex(anchorState.latestBlockHash)
228
+ : toRootHex(anchorState.latestExecutionPayloadHeader.blockHash)
227
229
  : undefined;
228
230
  executionEngineOpts = {
229
231
  ...opts.executionEngine,
@@ -167,7 +167,14 @@ function getHeadExecutionInfo(
167
167
  return [];
168
168
  }
169
169
 
170
- const executionStatusStr = headInfo.executionStatus.toLowerCase();
170
+ // A PayloadSeparated head is a gloas beacon block imported before its payload envelope
171
+ // arrives, in that case the exec-block row surfaces the inherited parent anchor (from the
172
+ // bid), which is already validated. Normalize to "valid" to avoid leaking internal
173
+ // fork-choice bookkeeping into the log. Once the payload envelope arrives and the FULL
174
+ // variant becomes head, executionStatus is Valid/Syncing naturally.
175
+ // TODO GLOAS: revisit once optimistic sync is implemented
176
+ const executionStatusStr =
177
+ headInfo.executionStatus === ExecutionStatus.PayloadSeparated ? "valid" : headInfo.executionStatus.toLowerCase();
171
178
 
172
179
  // Add execution status to notifier only if head is on/post bellatrix
173
180
  if (isStatePostBellatrix(headState) && headState.isExecutionStateType) {
@@ -560,8 +560,8 @@ export function getBeaconBlockRootFromDataColumnSidecarSerialized(data: Uint8Arr
560
560
  * ├─ 4 bytes: executionRequests offset
561
561
  * ├─ 8 bytes: builderIndex (offset 108-115)
562
562
  * ├─ 32 bytes: beaconBlockRoot (offset 116-147)
563
- * ├─ 8 bytes: slot (offset 148-155)
564
- * └─ 32 bytes: stateRoot (offset 156-187)
563
+ * └─ variable: payload data (starts at envelope + 48)
564
+ * └─ ExecutionPayload fixed portion includes slotNumber at offset 532
565
565
  */
566
566
  const SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MESSAGE_OFFSET = 4;
567
567
  const SIGNED_EXECUTION_PAYLOAD_ENVELOPE_SIGNATURE_SIZE = 96;
@@ -576,8 +576,26 @@ const BEACON_BLOCK_ROOT_OFFSET_IN_SIGNED_EXECUTION_PAYLOAD_ENVELOPE =
576
576
  EXECUTION_PAYLOAD_ENVELOPE_REQUESTS_OFFSET +
577
577
  EXECUTION_PAYLOAD_ENVELOPE_BUILDER_INDEX_SIZE; // 116
578
578
 
579
+ // Envelope fixed portion (without slot): payload_offset(4) + requests_offset(4) + builderIndex(8) + beaconBlockRoot(32) = 48
580
+ const EXECUTION_PAYLOAD_ENVELOPE_FIXED_SIZE =
581
+ EXECUTION_PAYLOAD_ENVELOPE_PAYLOAD_OFFSET +
582
+ EXECUTION_PAYLOAD_ENVELOPE_REQUESTS_OFFSET +
583
+ EXECUTION_PAYLOAD_ENVELOPE_BUILDER_INDEX_SIZE +
584
+ ROOT_SIZE; // 48
585
+
586
+ // slotNumber offset within ExecutionPayload fixed portion:
587
+ // parentHash(32) + feeRecipient(20) + stateRoot(32) + receiptsRoot(32) + logsBloom(256) +
588
+ // prevRandao(32) + blockNumber(8) + gasLimit(8) + gasUsed(8) + timestamp(8) +
589
+ // extraData_offset(4) + baseFeePerGas(32) + blockHash(32) + transactions_offset(4) +
590
+ // withdrawals_offset(4) + blobGasUsed(8) + excessBlobGas(8) + blockAccessList_offset(4) = 532
591
+ const SLOT_NUMBER_OFFSET_IN_EXECUTION_PAYLOAD = 532;
592
+
593
+ // Payload data starts right after the envelope's fixed portion
594
+ const ENVELOPE_START_IN_SIGNED =
595
+ SIGNED_EXECUTION_PAYLOAD_ENVELOPE_MESSAGE_OFFSET + SIGNED_EXECUTION_PAYLOAD_ENVELOPE_SIGNATURE_SIZE; // 100
596
+
579
597
  const SLOT_OFFSET_IN_SIGNED_EXECUTION_PAYLOAD_ENVELOPE =
580
- BEACON_BLOCK_ROOT_OFFSET_IN_SIGNED_EXECUTION_PAYLOAD_ENVELOPE + ROOT_SIZE; // 148
598
+ ENVELOPE_START_IN_SIGNED + EXECUTION_PAYLOAD_ENVELOPE_FIXED_SIZE + SLOT_NUMBER_OFFSET_IN_EXECUTION_PAYLOAD; // 100 + 48 + 532 = 680
581
599
 
582
600
  export function getSlotFromExecutionPayloadEnvelopeSerialized(data: Uint8Array): Slot | null {
583
601
  if (data.length < SLOT_OFFSET_IN_SIGNED_EXECUTION_PAYLOAD_ENVELOPE + SLOT_SIZE) {