@lodestar/beacon-node 1.50.0-rc.0 → 1.51.0-dev.13ce72c336

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 (146) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +7 -2
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/validator/index.d.ts.map +1 -1
  5. package/lib/api/impl/validator/index.js +31 -17
  6. package/lib/api/impl/validator/index.js.map +1 -1
  7. package/lib/chain/ColumnReconstructionTracker.d.ts +11 -13
  8. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  9. package/lib/chain/ColumnReconstructionTracker.js +49 -44
  10. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  11. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  12. package/lib/chain/archiveStore/utils/archiveBlocks.js +4 -5
  13. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  14. package/lib/chain/blocks/blockInput/blockInput.d.ts +1 -1
  15. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  16. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  17. package/lib/chain/blocks/blockInput/utils.js +2 -2
  18. package/lib/chain/blocks/blockInput/utils.js.map +1 -1
  19. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  20. package/lib/chain/blocks/importBlock.js +7 -4
  21. package/lib/chain/blocks/importBlock.js.map +1 -1
  22. package/lib/chain/chain.d.ts.map +1 -1
  23. package/lib/chain/chain.js +4 -2
  24. package/lib/chain/chain.js.map +1 -1
  25. package/lib/chain/interface.d.ts +1 -1
  26. package/lib/chain/interface.d.ts.map +1 -1
  27. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  28. package/lib/chain/prepareNextSlot.js +4 -3
  29. package/lib/chain/prepareNextSlot.js.map +1 -1
  30. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  31. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  32. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  33. package/lib/chain/produceBlock/produceBlockBody.js +8 -6
  34. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  35. package/lib/chain/reprocess.d.ts +2 -1
  36. package/lib/chain/reprocess.d.ts.map +1 -1
  37. package/lib/chain/reprocess.js +2 -1
  38. package/lib/chain/reprocess.js.map +1 -1
  39. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  40. package/lib/chain/seenCache/seenGossipBlockInput.js +1 -1
  41. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  42. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  43. package/lib/chain/stateCache/persistentCheckpointsCache.js +1 -1
  44. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  45. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  46. package/lib/chain/validatorMonitor.js +6 -4
  47. package/lib/chain/validatorMonitor.js.map +1 -1
  48. package/lib/constants/constants.d.ts +1 -0
  49. package/lib/constants/constants.d.ts.map +1 -1
  50. package/lib/constants/constants.js +1 -0
  51. package/lib/constants/constants.js.map +1 -1
  52. package/lib/db/repositories/blockArchive.js +2 -2
  53. package/lib/db/repositories/blockArchive.js.map +1 -1
  54. package/lib/db/repositories/blockArchiveIndex.d.ts +1 -1
  55. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
  56. package/lib/db/repositories/blockArchiveIndex.js +1 -2
  57. package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
  58. package/lib/execution/engine/index.d.ts.map +1 -1
  59. package/lib/execution/engine/index.js +1 -1
  60. package/lib/execution/engine/index.js.map +1 -1
  61. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  62. package/lib/execution/engine/jsonRpcHttpClient.js +14 -4
  63. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  64. package/lib/execution/engine/restTransport.d.ts +3 -1
  65. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  66. package/lib/execution/engine/restTransport.js +33 -21
  67. package/lib/execution/engine/restTransport.js.map +1 -1
  68. package/lib/execution/engine/transportMetrics.d.ts +5 -1
  69. package/lib/execution/engine/transportMetrics.d.ts.map +1 -1
  70. package/lib/execution/engine/types.d.ts.map +1 -1
  71. package/lib/execution/engine/types.js +12 -11
  72. package/lib/execution/engine/types.js.map +1 -1
  73. package/lib/metrics/metrics/lodestar.d.ts +11 -0
  74. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  75. package/lib/metrics/metrics/lodestar.js +31 -1
  76. package/lib/metrics/metrics/lodestar.js.map +1 -1
  77. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  78. package/lib/network/gossip/gossipsub.js +3 -1
  79. package/lib/network/gossip/gossipsub.js.map +1 -1
  80. package/lib/network/gossip/topic.d.ts +0 -14
  81. package/lib/network/gossip/topic.d.ts.map +1 -1
  82. package/lib/network/peers/utils/enrSubnetsDeserialize.d.ts.map +1 -1
  83. package/lib/network/peers/utils/enrSubnetsDeserialize.js +5 -2
  84. package/lib/network/peers/utils/enrSubnetsDeserialize.js.map +1 -1
  85. package/lib/network/processor/index.js +3 -3
  86. package/lib/network/processor/index.js.map +1 -1
  87. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  88. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +4 -4
  89. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  90. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +3 -3
  91. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  92. package/lib/network/reqresp/rateLimit.js +2 -2
  93. package/lib/network/reqresp/rateLimit.js.map +1 -1
  94. package/lib/network/subnets/attnetsService.d.ts.map +1 -1
  95. package/lib/network/subnets/attnetsService.js +3 -1
  96. package/lib/network/subnets/attnetsService.js.map +1 -1
  97. package/lib/node/notifier.d.ts.map +1 -1
  98. package/lib/node/notifier.js +12 -13
  99. package/lib/node/notifier.js.map +1 -1
  100. package/lib/sync/unknownBlock.d.ts.map +1 -1
  101. package/lib/sync/unknownBlock.js +3 -2
  102. package/lib/sync/unknownBlock.js.map +1 -1
  103. package/lib/util/clock.d.ts.map +1 -1
  104. package/lib/util/clock.js +3 -4
  105. package/lib/util/clock.js.map +1 -1
  106. package/lib/util/sszBytes.d.ts +2 -2
  107. package/lib/util/sszBytes.d.ts.map +1 -1
  108. package/lib/util/sszBytes.js +22 -14
  109. package/lib/util/sszBytes.js.map +1 -1
  110. package/package.json +15 -15
  111. package/src/api/impl/beacon/blocks/index.ts +10 -3
  112. package/src/api/impl/validator/index.ts +41 -19
  113. package/src/chain/ColumnReconstructionTracker.ts +63 -46
  114. package/src/chain/archiveStore/utils/archiveBlocks.ts +6 -7
  115. package/src/chain/blocks/blockInput/blockInput.ts +1 -1
  116. package/src/chain/blocks/blockInput/utils.ts +2 -2
  117. package/src/chain/blocks/importBlock.ts +8 -4
  118. package/src/chain/chain.ts +4 -2
  119. package/src/chain/interface.ts +2 -1
  120. package/src/chain/prepareNextSlot.ts +7 -3
  121. package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
  122. package/src/chain/produceBlock/produceBlockBody.ts +10 -5
  123. package/src/chain/reprocess.ts +2 -1
  124. package/src/chain/seenCache/seenGossipBlockInput.ts +2 -1
  125. package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
  126. package/src/chain/validatorMonitor.ts +7 -4
  127. package/src/constants/constants.ts +1 -0
  128. package/src/db/repositories/blockArchive.ts +2 -2
  129. package/src/db/repositories/blockArchiveIndex.ts +2 -3
  130. package/src/execution/engine/index.ts +2 -1
  131. package/src/execution/engine/jsonRpcHttpClient.ts +12 -5
  132. package/src/execution/engine/restTransport.ts +53 -22
  133. package/src/execution/engine/transportMetrics.ts +2 -1
  134. package/src/execution/engine/types.ts +13 -11
  135. package/src/metrics/metrics/lodestar.ts +32 -1
  136. package/src/network/gossip/gossipsub.ts +3 -1
  137. package/src/network/peers/utils/enrSubnetsDeserialize.ts +5 -2
  138. package/src/network/processor/index.ts +3 -3
  139. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +4 -10
  140. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +3 -3
  141. package/src/network/reqresp/rateLimit.ts +2 -2
  142. package/src/network/subnets/attnetsService.ts +8 -3
  143. package/src/node/notifier.ts +14 -13
  144. package/src/sync/unknownBlock.ts +3 -2
  145. package/src/util/clock.ts +3 -4
  146. package/src/util/sszBytes.ts +25 -12
@@ -1,6 +1,6 @@
1
1
  import {PeerId} from "@libp2p/interface";
2
2
  import {ResponseOutgoing} from "@lodestar/reqresp";
3
- import {computeEpochAtSlot} from "@lodestar/state-transition";
3
+ import {computeEpochAtSlot, getBlobDataRetentionStartEpoch} from "@lodestar/state-transition";
4
4
  import {ColumnIndex} from "@lodestar/types";
5
5
  import {toRootHex} from "@lodestar/utils";
6
6
  import {IBeaconChain} from "../../../chain/index.js";
@@ -19,10 +19,10 @@ export async function* onDataColumnSidecarsByRoot(
19
19
  peerId: PeerId,
20
20
  peerClient: string
21
21
  ): AsyncIterable<ResponseOutgoing> {
22
- // SPEC: minimum_request_epoch = max(current_epoch - MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS, FULU_FORK_EPOCH)
22
+ // SPEC: minimum_request_epoch = max(compute_blob_data_retention_start_epoch(current_epoch), FULU_FORK_EPOCH)
23
23
  const currentEpoch = chain.clock.currentEpoch;
24
24
  const minimumRequestEpoch = Math.max(
25
- currentEpoch - chain.config.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS,
25
+ getBlobDataRetentionStartEpoch(chain.config, currentEpoch),
26
26
  chain.config.FULU_FORK_EPOCH
27
27
  );
28
28
 
@@ -107,12 +107,12 @@ export const rateLimitQuotas: (fork: ForkName, config: BeaconConfig) => Record<R
107
107
  [ReqRespMethod.LightClientFinalityUpdate]: {
108
108
  // Finality updates should not be requested more than once per epoch.
109
109
  // Allow 2 per slot and a very safe bound until there's more testing of real usage.
110
- byPeer: {quota: 2, quotaTimeMs: 12_000},
110
+ byPeer: {quota: 2, quotaTimeMs: config.getSlotDurationMs(fork)},
111
111
  },
112
112
  [ReqRespMethod.LightClientOptimisticUpdate]: {
113
113
  // Optimistic updates should not be requested more than once per slot.
114
114
  // Allow 2 per slot and a very safe bound until there's more testing of real usage.
115
- byPeer: {quota: 2, quotaTimeMs: 12_000},
115
+ byPeer: {quota: 2, quotaTimeMs: config.getSlotDurationMs(fork)},
116
116
  },
117
117
  });
118
118
 
@@ -3,6 +3,7 @@ import {ATTESTATION_SUBNET_COUNT, SLOTS_PER_EPOCH} from "@lodestar/params";
3
3
  import {computeEpochAtSlot} from "@lodestar/state-transition";
4
4
  import {Epoch, Slot, SubnetID, ssz} from "@lodestar/types";
5
5
  import {Logger, MapDef} from "@lodestar/utils";
6
+ import {HALF_SLOT_BPS} from "../../constants/index.js";
6
7
  import {ClockEvent, IClock} from "../../util/clock.js";
7
8
  import {NetworkCoreMetrics} from "../core/metrics.js";
8
9
  import {getActiveForkBoundaries} from "../forks.js";
@@ -163,9 +164,13 @@ export class AttnetsService implements IAttnetsService {
163
164
  */
164
165
  private onSlot = (clockSlot: Slot): void => {
165
166
  try {
166
- setTimeout(() => {
167
- this.onHalfSlot(clockSlot);
168
- }, this.config.SLOT_DURATION_MS * 0.5);
167
+ const fork = this.config.getForkName(clockSlot);
168
+ setTimeout(
169
+ () => {
170
+ this.onHalfSlot(clockSlot);
171
+ },
172
+ this.config.getSlotComponentDurationMs(fork, HALF_SLOT_BPS)
173
+ );
169
174
 
170
175
  for (const [dutiedSlot, dutiedInfo] of this.aggregatorSlotSubnet.entries()) {
171
176
  if (dutiedSlot === clockSlot + this.opts.slotsToSubscribeBeforeAggregatorDuty) {
@@ -5,6 +5,7 @@ import {
5
5
  IBeaconStateView,
6
6
  computeEpochAtSlot,
7
7
  computeStartSlotAtEpoch,
8
+ computeTimeAtSlot,
8
9
  isStatePostBellatrix,
9
10
  } from "@lodestar/state-transition";
10
11
  import {Epoch} from "@lodestar/types";
@@ -140,21 +141,21 @@ export async function runNodeNotifier(modules: NodeNotifierModules): Promise<voi
140
141
  }
141
142
 
142
143
  function timeToNextHalfSlot(config: BeaconConfig, chain: IBeaconChain, isFirstTime: boolean): number {
143
- const msPerSlot = config.SLOT_DURATION_MS;
144
- const msPerHalfSlot = msPerSlot / 2;
145
- const msFromGenesis = Date.now() - chain.genesisTime * 1000;
146
- const msToNextSlot =
147
- msFromGenesis < 0
148
- ? // For future genesis time, calculate time left in the slot
149
- -msFromGenesis % msPerSlot
150
- : // For past genesis time, calculate time until the next slot
151
- msPerSlot - (msFromGenesis % msPerSlot);
144
+ const currentSlot = chain.clock.currentSlot;
145
+ const nextSlotTimeSec = computeTimeAtSlot(config, currentSlot + 1, chain.genesisTime);
146
+ const nowMs = Date.now();
147
+
152
148
  if (isFirstTime) {
153
- // at the 1st time we may miss middle of the current clock slot
154
- return msToNextSlot > msPerHalfSlot ? msToNextSlot - msPerHalfSlot : msToNextSlot + msPerHalfSlot;
149
+ const currentSlotTimeSec = computeTimeAtSlot(config, currentSlot, chain.genesisTime);
150
+ const currentMidpointMs = ((currentSlotTimeSec + nextSlotTimeSec) / 2) * 1000;
151
+ if (currentMidpointMs > nowMs) {
152
+ return currentMidpointMs - nowMs;
153
+ }
155
154
  }
156
- // after the 1st time always wait until middle of next clock slot
157
- return msToNextSlot + msPerHalfSlot;
155
+
156
+ const nextSlotEndTimeSec = computeTimeAtSlot(config, currentSlot + 2, chain.genesisTime);
157
+ const nextMidpointMs = ((nextSlotTimeSec + nextSlotEndTimeSec) / 2) * 1000;
158
+ return Math.max(0, nextMidpointMs - nowMs);
158
159
  }
159
160
 
160
161
  function getHeadExecutionInfo(
@@ -918,16 +918,17 @@ export class BlockInputSync {
918
918
  * Poll unknown payloads of the current slot.
919
919
  */
920
920
  private async pollPayloadsAtSlot(slot: Slot, signal: AbortSignal): Promise<void> {
921
+ const fork = this.config.getForkName(slot);
921
922
  // fixed tick count so the loop cannot outlive its slot: for mainnet, it's 6 ticks
922
923
  const tickCount = Math.floor(
923
- (this.config.SLOT_DURATION_MS - this.config.getPayloadDueMs()) / PAYLOAD_POLL_INTERVAL_MS
924
+ (this.config.getSlotDurationMs(fork) - this.config.getPayloadDueMs(fork)) / PAYLOAD_POLL_INTERVAL_MS
924
925
  );
925
926
  // a root still missing on several ticks is searched on each of them, recorded once
926
927
  const searchedRoots = new Set<RootHex>();
927
928
  let polls = 0;
928
929
 
929
930
  try {
930
- await sleep(Math.max(0, this.config.getPayloadDueMs() - this.chain.clock.msFromSlot(slot)), signal);
931
+ await sleep(Math.max(0, this.config.getPayloadDueMs(fork) - this.chain.clock.msFromSlot(slot)), signal);
931
932
 
932
933
  for (polls = 0; polls < tickCount; polls++) {
933
934
  let importedCount = 0;
package/src/util/clock.ts CHANGED
@@ -78,9 +78,9 @@ export class Clock extends EventEmitter implements IClock {
78
78
 
79
79
  this.config = config;
80
80
  this.genesisTime = genesisTime;
81
- this.timeoutId = setTimeout(this.onNextSlot, this.msUntilNextSlot());
82
81
  this.signal = signal;
83
82
  this._currentSlot = getCurrentSlot(this.config, this.genesisTime);
83
+ this.timeoutId = setTimeout(this.onNextSlot, this.msUntilNextSlot());
84
84
  this.signal.addEventListener("abort", () => clearTimeout(this.timeoutId), {once: true});
85
85
  }
86
86
 
@@ -204,8 +204,7 @@ export class Clock extends EventEmitter implements IClock {
204
204
  };
205
205
 
206
206
  private msUntilNextSlot(): number {
207
- const milliSecondsPerSlot = this.config.SLOT_DURATION_MS;
208
- const diffInMilliSeconds = Date.now() - this.genesisTime * 1000;
209
- return milliSecondsPerSlot - (diffInMilliSeconds % milliSecondsPerSlot);
207
+ const nextSlotTimeSec = computeTimeAtSlot(this.config, this._currentSlot + 1, this.genesisTime);
208
+ return Math.max(0, nextSlotTimeSec * 1000 - Date.now());
210
209
  }
211
210
  }
@@ -6,10 +6,12 @@ import {
6
6
  FIELD_ELEMENTS_PER_BLOB,
7
7
  ForkName,
8
8
  ForkPostDeneb,
9
+ ForkPostGloas,
9
10
  ForkSeq,
10
11
  MAX_COMMITTEES_PER_SLOT,
11
12
  isForkPostElectra,
12
13
  isForkPostGloas,
14
+ isForkPostHeze,
13
15
  } from "@lodestar/params";
14
16
  import {BLSSignature, CommitteeIndex, RootHex, Slot, ValidatorIndex, ssz} from "@lodestar/types";
15
17
 
@@ -57,6 +59,8 @@ const ATTESTATION_DATA_SIZE = 128;
57
59
  // MAX_COMMITTEES_PER_SLOT is in bit, need to convert to byte
58
60
  const COMMITTEE_BITS_SIZE = Math.max(Math.ceil(MAX_COMMITTEES_PER_SLOT / 8), 1);
59
61
  const SIGNATURE_SIZE = 96;
62
+ // SyncAggregate is a fixed-size container, so minSize is its serialized size
63
+ const SYNC_AGGREGATE_SIZE = ssz.altair.SyncAggregate.minSize;
60
64
  const SINGLE_ATTESTATION_ATTDATA_OFFSET = 8 + 8;
61
65
  const SINGLE_ATTESTATION_SLOT_OFFSET = SINGLE_ATTESTATION_ATTDATA_OFFSET;
62
66
  const SINGLE_ATTESTATION_COMMITTEE_INDEX_OFFSET = 0;
@@ -447,30 +451,39 @@ export function getParentRootFromSignedBeaconBlockSerialized(data: Uint8Array):
447
451
  * BeaconBlockBody (GLOAS) fixed section before signedExecutionPayloadBid offset pointer:
448
452
  * randaoReveal(96) + eth1Data(72) + graffiti(32)
449
453
  * + proposerSlashings(4) + attesterSlashings(4) + attestations(4) + deposits(4) + voluntaryExits(4)
450
- * + syncAggregate(160) + blsToExecutionChanges(4) = 384 bytes
454
+ * + syncAggregate(SyncAggregate.minSize) + blsToExecutionChanges(4) = 384 bytes (mainnet preset)
451
455
  *
452
- * The 4-byte pointer at byte 568 (= 184+384) gives the offset of SignedExecutionPayloadBid
456
+ * Heze body: randaoReveal(96) + graffiti(32) + proposerSlashings(4) + attesterSlashings(4) + attestations(4) + voluntaryExits(4) + syncAggregate(SyncAggregate.minSize) + blsToExecutionChanges(4) = 308 bytes (mainnet preset)
457
+ *
458
+ * The 4-byte pointer at byte 568 (= 184+384) for Gloas and 492 (= 184+308) for Heze (mainnet preset) gives the offset of SignedExecutionPayloadBid
453
459
  * within BeaconBlockBody. parentBlockHash is at that bid's byte 100 (after offset+sig).
454
460
  */
455
461
  // BeaconBlock body starts after: msg_offset(4) + sig(96) + slot(8) + proposer_index(8) + parent_root(32) + state_root(32) + body_offset_ptr(4)
456
462
  const GLOAS_BODY_START_IN_SIGNED_BEACON_BLOCK =
457
463
  VARIABLE_FIELD_OFFSET + SIGNATURE_SIZE + SLOT_SIZE + 8 + ROOT_SIZE + ROOT_SIZE + VARIABLE_FIELD_OFFSET; // = 184
458
- const GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY = 96 + 72 + 32 + 4 + 4 + 4 + 4 + 4 + 160 + 4; // = 384
459
- const GLOAS_SIGNED_BID_OFFSET_POINTER_IN_SIGNED_BEACON_BLOCK =
460
- GLOAS_BODY_START_IN_SIGNED_BEACON_BLOCK + GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY; // = 568
464
+ const GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY = 96 + 72 + 32 + 4 + 4 + 4 + 4 + 4 + SYNC_AGGREGATE_SIZE + 4; // = 384 at mainnet preset
465
+ // Heze removes eth1Data (72 B) and the deposits offset (4 B) from the body fixed section
466
+ const HEZE_SIGNED_BID_OFFSET_POINTER_IN_BODY = GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY - 72 - VARIABLE_FIELD_OFFSET; // = 308
461
467
  // Within SignedExecutionPayloadBid, parentBlockHash is at byte 100 (msg_offset:4 + sig:96)
462
468
  const PARENT_BLOCK_HASH_OFFSET_IN_SIGNED_BID = VARIABLE_FIELD_OFFSET + SIGNATURE_SIZE; // = 100
463
469
 
464
- // CAUTION: update offsets if BeaconBlockBody fixed fields change after Gloas
465
- export function getParentBlockHashFromGloasSignedBeaconBlockSerialized(data: Uint8Array): RootHex | null {
466
- if (data.length < GLOAS_SIGNED_BID_OFFSET_POINTER_IN_SIGNED_BEACON_BLOCK + VARIABLE_FIELD_OFFSET) {
470
+ // CAUTION: update offsets if BeaconBlockBody fixed fields change after Heze
471
+ export function getParentBlockHashFromGloasSignedBeaconBlockSerialized(
472
+ data: Uint8Array,
473
+ fork: ForkPostGloas
474
+ ): RootHex | null {
475
+ const bidOffsetPointer =
476
+ GLOAS_BODY_START_IN_SIGNED_BEACON_BLOCK +
477
+ (isForkPostHeze(fork) ? HEZE_SIGNED_BID_OFFSET_POINTER_IN_BODY : GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY);
478
+ if (data.length < bidOffsetPointer + VARIABLE_FIELD_OFFSET) {
467
479
  return null;
468
480
  }
469
481
  const bidOffset =
470
- data[GLOAS_SIGNED_BID_OFFSET_POINTER_IN_SIGNED_BEACON_BLOCK] |
471
- (data[GLOAS_SIGNED_BID_OFFSET_POINTER_IN_SIGNED_BEACON_BLOCK + 1] << 8) |
472
- (data[GLOAS_SIGNED_BID_OFFSET_POINTER_IN_SIGNED_BEACON_BLOCK + 2] << 16) |
473
- (data[GLOAS_SIGNED_BID_OFFSET_POINTER_IN_SIGNED_BEACON_BLOCK + 3] << 24);
482
+ (data[bidOffsetPointer] |
483
+ (data[bidOffsetPointer + 1] << 8) |
484
+ (data[bidOffsetPointer + 2] << 16) |
485
+ (data[bidOffsetPointer + 3] << 24)) >>>
486
+ 0;
474
487
 
475
488
  const parentBlockHashStart =
476
489
  GLOAS_BODY_START_IN_SIGNED_BEACON_BLOCK + bidOffset + PARENT_BLOCK_HASH_OFFSET_IN_SIGNED_BID;