@lodestar/state-transition 1.52.0-dev.6ab73fec0a → 1.52.0-dev.6c1c955421

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 (60) hide show
  1. package/lib/block/index.d.ts.map +1 -1
  2. package/lib/block/index.js +1 -1
  3. package/lib/block/index.js.map +1 -1
  4. package/lib/block/processExecutionPayloadBid.d.ts +1 -1
  5. package/lib/block/processExecutionPayloadBid.d.ts.map +1 -1
  6. package/lib/block/processExecutionPayloadBid.js +2 -2
  7. package/lib/block/processExecutionPayloadBid.js.map +1 -1
  8. package/lib/signatureSets/index.d.ts +3 -1
  9. package/lib/signatureSets/index.d.ts.map +1 -1
  10. package/lib/signatureSets/index.js +14 -5
  11. package/lib/signatureSets/index.js.map +1 -1
  12. package/lib/signatureSets/indexedAttestation.d.ts +6 -2
  13. package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
  14. package/lib/signatureSets/indexedAttestation.js +27 -4
  15. package/lib/signatureSets/indexedAttestation.js.map +1 -1
  16. package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
  17. package/lib/slot/upgradeStateToGloas.js +22 -27
  18. package/lib/slot/upgradeStateToGloas.js.map +1 -1
  19. package/lib/slot/upgradeStateToHeze.d.ts.map +1 -1
  20. package/lib/slot/upgradeStateToHeze.js +0 -4
  21. package/lib/slot/upgradeStateToHeze.js.map +1 -1
  22. package/lib/stateView/beaconStateView.d.ts +1 -0
  23. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  24. package/lib/stateView/beaconStateView.js +7 -1
  25. package/lib/stateView/beaconStateView.js.map +1 -1
  26. package/lib/stateView/interface.d.ts +1 -0
  27. package/lib/stateView/interface.d.ts.map +1 -1
  28. package/lib/stateView/interface.js.map +1 -1
  29. package/lib/stateView/nativeBeaconStateView.d.ts +1 -0
  30. package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
  31. package/lib/stateView/nativeBeaconStateView.js +3 -0
  32. package/lib/stateView/nativeBeaconStateView.js.map +1 -1
  33. package/lib/util/epochShuffling.d.ts +4 -0
  34. package/lib/util/epochShuffling.d.ts.map +1 -1
  35. package/lib/util/epochShuffling.js.map +1 -1
  36. package/lib/util/gloas.d.ts +5 -0
  37. package/lib/util/gloas.d.ts.map +1 -1
  38. package/lib/util/gloas.js +10 -0
  39. package/lib/util/gloas.js.map +1 -1
  40. package/lib/util/signatureSets.d.ts +23 -3
  41. package/lib/util/signatureSets.d.ts.map +1 -1
  42. package/lib/util/signatureSets.js +25 -0
  43. package/lib/util/signatureSets.js.map +1 -1
  44. package/lib/util/slot.d.ts.map +1 -1
  45. package/lib/util/slot.js +3 -7
  46. package/lib/util/slot.js.map +1 -1
  47. package/package.json +9 -9
  48. package/src/block/index.ts +2 -1
  49. package/src/block/processExecutionPayloadBid.ts +3 -2
  50. package/src/signatureSets/index.ts +29 -5
  51. package/src/signatureSets/indexedAttestation.ts +32 -6
  52. package/src/slot/upgradeStateToGloas.ts +23 -31
  53. package/src/slot/upgradeStateToHeze.ts +0 -6
  54. package/src/stateView/beaconStateView.ts +9 -1
  55. package/src/stateView/interface.ts +1 -0
  56. package/src/stateView/nativeBeaconStateView.ts +4 -0
  57. package/src/util/epochShuffling.ts +5 -0
  58. package/src/util/gloas.ts +11 -0
  59. package/src/util/signatureSets.ts +45 -2
  60. package/src/util/slot.ts +3 -7
package/lib/util/slot.js CHANGED
@@ -1,15 +1,11 @@
1
- import { GENESIS_EPOCH, GENESIS_SLOT } from "@lodestar/params";
1
+ import { GENESIS_EPOCH, GENESIS_SLOT, SLOTS_PER_EPOCH } from "@lodestar/params";
2
2
  import { computeEpochAtSlot, computeStartSlotAtEpoch } from "./epoch.js";
3
3
  /**
4
4
  * Slot durations with their activation epochs, derived from the configuration.
5
5
  * A fork that changes the slot duration must add an entry here and in `ForkConfig.getSlotDurationMs`.
6
6
  */
7
7
  export function getSlotDurations(config) {
8
- const durations = [[GENESIS_EPOCH, config.SLOT_DURATION_MS]];
9
- if (config.HEZE_FORK_EPOCH !== Infinity) {
10
- durations.push([config.HEZE_FORK_EPOCH, config.SLOT_DURATION_MS_HEZE]);
11
- }
12
- return durations;
8
+ return [[GENESIS_EPOCH, config.SLOT_DURATION_MS]];
13
9
  }
14
10
  /** Slot duration in ms in effect at a given epoch */
15
11
  export function getSlotDurationMsAtEpoch(config, epoch) {
@@ -67,7 +63,7 @@ export function getCurrentSlot(config, genesisTime) {
67
63
  * across slot duration changes
68
64
  */
69
65
  export function getBlobDataRetentionStartEpoch(config, epoch) {
70
- const windowMs = config.MIN_BLOB_DATA_RETENTION_MS;
66
+ const windowMs = config.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS * SLOTS_PER_EPOCH * config.SLOT_DURATION_MS;
71
67
  const currentStartMs = computeTimeAtSlotMs(config, computeStartSlotAtEpoch(epoch), 0);
72
68
  if (currentStartMs < windowMs) {
73
69
  return GENESIS_EPOCH;
@@ -1 +1 @@
1
- {"version":3,"file":"slot.js","sourceRoot":"","sources":["../../src/util/slot.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAC,kBAAkB,EAAE,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAEvE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAmB;IAClD,MAAM,SAAS,GAAsB,CAAC,CAAC,aAAa,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAChF,IAAI,MAAM,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;QACxC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,wBAAwB,CAAC,MAAmB,EAAE,KAAY;IACxE,IAAI,cAAc,GAAG,MAAM,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ainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.52.0-dev.6ab73fec0a",
14
+ "version": "1.52.0-dev.6c1c955421",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -67,16 +67,16 @@
67
67
  "dependencies": {
68
68
  "@chainsafe/as-sha256": "^1.2.5",
69
69
  "@chainsafe/persistent-merkle-tree": "^1.3.1",
70
- "@chainsafe/ssz": "^1.9.0",
71
- "@lodestar/config": "^1.52.0-dev.6ab73fec0a",
72
- "@lodestar/native": "^1.52.0-dev.6ab73fec0a",
73
- "@lodestar/params": "^1.52.0-dev.6ab73fec0a",
74
- "@lodestar/types": "^1.52.0-dev.6ab73fec0a",
75
- "@lodestar/utils": "^1.52.0-dev.6ab73fec0a",
70
+ "@chainsafe/ssz": "^1.9.1",
71
+ "@lodestar/config": "^1.52.0-dev.6c1c955421",
72
+ "@lodestar/native": "^1.52.0-dev.6c1c955421",
73
+ "@lodestar/params": "^1.52.0-dev.6c1c955421",
74
+ "@lodestar/types": "^1.52.0-dev.6c1c955421",
75
+ "@lodestar/utils": "^1.52.0-dev.6c1c955421",
76
76
  "@vekexasia/bigint-buffer2": "^1.1.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@lodestar/test-utils": "^1.52.0-dev.6ab73fec0a"
79
+ "@lodestar/test-utils": "^1.52.0-dev.6c1c955421"
80
80
  },
81
81
  "keywords": [
82
82
  "ethereum",
@@ -84,5 +84,5 @@
84
84
  "beacon",
85
85
  "blockchain"
86
86
  ],
87
- "gitHead": "ffe9d2fa3670b5ef29d269def50bf552d3cabc42"
87
+ "gitHead": "cfcfb9ff806acc3fd2b3036f77285c4208a61325"
88
88
  }
@@ -106,7 +106,8 @@ export function processBlock(
106
106
  const timer = metrics?.processBlockStepTime.startTimer({step: BlockProcessStep.processExecutionPayloadBid});
107
107
  processExecutionPayloadBid(
108
108
  state as CachedBeaconStateGloas,
109
- (block as BeaconBlock<ForkPostGloas>).body.signedExecutionPayloadBid
109
+ (block as BeaconBlock<ForkPostGloas>).body.signedExecutionPayloadBid,
110
+ verifySignatures
110
111
  );
111
112
  timer?.();
112
113
  }
@@ -21,7 +21,8 @@ import {
21
21
 
22
22
  export function processExecutionPayloadBid(
23
23
  state: CachedBeaconStateGloas | CachedBeaconStateHeze,
24
- signedBid: gloas.SignedExecutionPayloadBid
24
+ signedBid: gloas.SignedExecutionPayloadBid,
25
+ verifySignature = true
25
26
  ): void {
26
27
  const bid = signedBid.message;
27
28
  const {builderIndex, value: amount} = bid;
@@ -57,7 +58,7 @@ export function processExecutionPayloadBid(
57
58
  }
58
59
 
59
60
  // Verify that the bid signature is valid
60
- if (!verifyExecutionPayloadBidSignature(state, builder.pubkey, signedBid)) {
61
+ if (verifySignature && !verifyExecutionPayloadBidSignature(state, builder.pubkey, signedBid)) {
61
62
  throw Error(`Invalid execution payload bid: invalid signature for builder ${builderIndex}`);
62
63
  }
63
64
  }
@@ -1,12 +1,18 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {ForkSeq} from "@lodestar/params";
2
+ import {BUILDER_INDEX_SELF_BUILD, ForkSeq} from "@lodestar/params";
3
3
  import {IndexedAttestation, SignedBeaconBlock, altair, capella, gloas} from "@lodestar/types";
4
4
  import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
5
5
  import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
6
6
  import {IBeaconStateView, IBeaconStateViewGloas} from "../stateView/interface.js";
7
- import {ISignatureSet, createAggregateSignatureSetFromComponents} from "../util/index.js";
7
+ import {
8
+ EpochShuffling,
9
+ ISignatureSet,
10
+ createAggregateSignatureSetFromComponents,
11
+ createSingleSignatureSetFromComponents,
12
+ } from "../util/index.js";
8
13
  import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
9
14
  import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js";
15
+ import {getExecutionPayloadBidSigningRoot} from "./executionPayloadBid.js";
10
16
  import {getAttestationsSignatureSets} from "./indexedAttestation.js";
11
17
  import {getPayloadAttestationDataSigningRoot} from "./indexedPayloadAttestation.js";
12
18
  import {getBlockProposerSignatureSet} from "./proposer.js";
@@ -40,6 +46,8 @@ export function getBlockSignatureSets(
40
46
  opts?: {
41
47
  /** Useful since block proposer signature is verified beforehand on gossip validation */
42
48
  skipProposerSignature?: boolean;
49
+ /** Shuffling of each attestation, see `getAttestationsSignatureSets()` */
50
+ attestationShufflings?: EpochShuffling[];
43
51
  }
44
52
  ): ISignatureSet[] {
45
53
  // fork based validations
@@ -49,7 +57,7 @@ export function getBlockSignatureSets(
49
57
  getRandaoRevealSignatureSet(config, signedBlock.message),
50
58
  ...getProposerSlashingsSignatureSets(config, signedBlock),
51
59
  ...getAttesterSlashingsSignatureSets(config, signedBlock),
52
- ...getAttestationsSignatureSets(config, signedBlock, indexedAttestations),
60
+ ...getAttestationsSignatureSets(config, signedBlock, indexedAttestations, opts?.attestationShufflings),
53
61
  ...signedBlock.message.body.voluntaryExits.map((voluntaryExit) =>
54
62
  getVoluntaryExitSignatureSet(config, state, voluntaryExit)
55
63
  ),
@@ -84,8 +92,24 @@ export function getBlockSignatureSets(
84
92
  }
85
93
 
86
94
  if (fork >= ForkSeq.gloas) {
87
- for (const payloadAttestation of (signedBlock as gloas.SignedBeaconBlock).message.body.payloadAttestations) {
88
- const ptc = (state as IBeaconStateViewGloas).getPayloadTimelinessCommittee(payloadAttestation.data.slot);
95
+ const gloasState = state as IBeaconStateViewGloas;
96
+ const {payloadAttestations, signedExecutionPayloadBid} = (signedBlock as gloas.SignedBeaconBlock).message.body;
97
+
98
+ const {builderIndex} = signedExecutionPayloadBid.message;
99
+ // `state` may be the pre-state of an earlier block in the epoch. An active builder was deposited before the
100
+ // finalized epoch, so `state` already has its pubkey. Block processing rejects a bid from any other builder.
101
+ if (builderIndex !== BUILDER_INDEX_SELF_BUILD && builderIndex < gloasState.getBuildersLength()) {
102
+ signatureSets.push(
103
+ createSingleSignatureSetFromComponents(
104
+ gloasState.getBuilder(builderIndex).pubkey,
105
+ getExecutionPayloadBidSigningRoot(config, signedExecutionPayloadBid.message),
106
+ signedExecutionPayloadBid.signature
107
+ )
108
+ );
109
+ }
110
+
111
+ for (const payloadAttestation of payloadAttestations) {
112
+ const ptc = gloasState.getPayloadTimelinessCommittee(payloadAttestation.data.slot);
89
113
  signatureSets.push(
90
114
  createAggregateSignatureSetFromComponents(
91
115
  payloadAttestation.aggregationBits.intersectValues(ptc),
@@ -1,8 +1,10 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params";
3
- import {IndexedAttestation, SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
2
+ import {DOMAIN_BEACON_ATTESTER, ForkSeq} from "@lodestar/params";
3
+ import {IndexedAttestation, SignedBeaconBlock, Slot, electra, phase0, ssz} from "@lodestar/types";
4
4
  import {
5
+ EpochShuffling,
5
6
  ISignatureSet,
7
+ SignatureSetType,
6
8
  computeSigningRoot,
7
9
  computeStartSlotAtEpoch,
8
10
  createAggregateSignatureSetFromComponents,
@@ -45,10 +47,15 @@ export function getIndexedAttestationSignatureSet(
45
47
  );
46
48
  }
47
49
 
50
+ /**
51
+ * `shufflings[i]` is the shuffling of attestation `i`. Attestations whose shuffling has committee pubkeys get a
52
+ * committee signature set.
53
+ */
48
54
  export function getAttestationsSignatureSets(
49
55
  config: BeaconConfig,
50
56
  signedBlock: SignedBeaconBlock,
51
- indexedAttestations: IndexedAttestation[]
57
+ indexedAttestations: IndexedAttestation[],
58
+ shufflings?: EpochShuffling[]
52
59
  ): ISignatureSet[] {
53
60
  if (indexedAttestations.length !== signedBlock.message.body.attestations.length) {
54
61
  throw Error(
@@ -58,7 +65,26 @@ export function getAttestationsSignatureSets(
58
65
  // the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
59
66
  // and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
60
67
  const blockSlot = signedBlock.message.slot;
61
- return indexedAttestations.map((indexedAttestation) =>
62
- getIndexedAttestationSignatureSet(config, blockSlot, indexedAttestation)
63
- );
68
+ const fork = config.getForkSeq(blockSlot);
69
+ return indexedAttestations.map((indexedAttestation, i) => {
70
+ const committeePubkeysId = shufflings?.[i]?.committeePubkeysId;
71
+ if (committeePubkeysId === undefined) {
72
+ return getIndexedAttestationSignatureSet(config, blockSlot, indexedAttestation);
73
+ }
74
+
75
+ const attestation = signedBlock.message.body.attestations[i];
76
+ return {
77
+ type: SignatureSetType.committee,
78
+ indices: indexedAttestation.attestingIndices,
79
+ committeePubkeysId,
80
+ slot: attestation.data.slot,
81
+ committeeIndices:
82
+ fork >= ForkSeq.electra
83
+ ? (attestation as electra.Attestation).committeeBits.getTrueBitIndexes()
84
+ : [attestation.data.index],
85
+ aggregationBits: attestation.aggregationBits,
86
+ signingRoot: getAttestationDataSigningRoot(config, blockSlot, attestation.data),
87
+ signature: attestation.signature,
88
+ };
89
+ });
64
90
  }
@@ -115,6 +115,8 @@ export function upgradeStateToGloas(
115
115
  for (let i = 0; i < SLOTS_PER_HISTORICAL_ROOT; i++) {
116
116
  stateGloasView.executionPayloadAvailability.set(i, true);
117
117
  }
118
+ // process_slot of the last pre-fork slot ran with Fulu rules and did not unset the fork slot
119
+ stateGloasView.executionPayloadAvailability.set(stateFulu.slot % SLOTS_PER_HISTORICAL_ROOT, false);
118
120
  stateGloasView.latestBlockHash = stateFulu.latestExecutionPayloadHeader.blockHash;
119
121
 
120
122
  const stateGloas = getCachedBeaconState(stateGloasView, stateFulu);
@@ -176,7 +178,7 @@ function migrateBasicListToGloas<ElementType extends BasicType<unknown>>(
176
178
 
177
179
  /**
178
180
  * Applies any pending deposits for builders to onboard builders during the fork transition
179
- * Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.8/specs/gloas/fork.md#new-onboard_builders_from_pending_deposits
181
+ * Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.5/specs/gloas/fork.md#new-onboard_builders_from_pending_deposits
180
182
  */
181
183
  function onboardBuildersFromPendingDeposits(
182
184
  state: CachedBeaconStateGloas,
@@ -188,8 +190,8 @@ function onboardBuildersFromPendingDeposits(
188
190
  // deposit queue, and its cost is dominated by whichever branch the queue happens to
189
191
  // hit. `verified` signature checks are the ones the pre-verify cache missed, i.e. BLS
190
192
  // running inline on the fork transition's critical path. The signature totals include
191
- // the checks hasPendingValidator() does internally, which dominate when a builder
192
- // deposit is preceded by same-pubkey validator deposits.
193
+ // the checks hasPendingValidator() does internally for invalid builder deposits that are
194
+ // preceded by same-pubkey validator deposits.
193
195
  let onboarded = 0;
194
196
  let topups = 0;
195
197
  let kept = 0;
@@ -207,12 +209,11 @@ function onboardBuildersFromPendingDeposits(
207
209
 
208
210
  for (const deposit of state.pendingDeposits.getAllReadonly()) {
209
211
  const depositValue = deposit.toValue();
210
-
211
- const validatorIndex = state.epochCtx.getValidatorIndex(deposit.pubkey);
212
212
  const pubkeyHex = toPubkeyHex(deposit.pubkey);
213
213
 
214
- // Deposits for existing validators stay in the pending queue
215
- if (isValidatorKnown(state, validatorIndex)) {
214
+ // Only builder-credential deposits can fund builders at the fork, everything else stays in
215
+ // the pending queue even if a builder uses the same pubkey
216
+ if (!isBuilderWithdrawalCredential(deposit.withdrawalCredentials)) {
216
217
  pendingDeposits.push(deposit);
217
218
  pendingDepositsLookup.add(depositValue, pubkeyHex);
218
219
  kept++;
@@ -227,29 +228,9 @@ function onboardBuildersFromPendingDeposits(
227
228
  continue;
228
229
  }
229
230
 
230
- // Deposits for non-builders stay in the pending queue. If there is a valid pending
231
- // deposit for a new validator with this pubkey, keep this deposit pending so the validator
232
- // can pick it up later.
233
- if (!isBuilderWithdrawalCredential(deposit.withdrawalCredentials)) {
234
- pendingDeposits.push(deposit);
235
- pendingDepositsLookup.add(depositValue, pubkeyHex);
236
- kept++;
237
- continue;
238
- }
239
- if (
240
- pendingDepositsLookup.hasPendingValidator(state.config, pubkeyHex, state.epochCtx.builderDepositSignatureCache)
241
- ) {
242
- pendingDeposits.push(deposit);
243
- pendingDepositsLookup.add(depositValue, pubkeyHex);
244
- kept++;
245
- continue;
246
- }
247
-
248
- // Verify the deposit signature (proof of possession). If invalid the deposit is silently
249
- // dropped — stake is forfeited, matching the validator deposit contract behavior.
250
- //
251
- // The prepareNextSlot scheduler pre-verifies these signatures in the epochs before the fork
252
- // A cache miss falls back to verifying this one deposit — no worse than pre-cache.
231
+ // Verify the deposit signature (proof of possession). The prepareNextSlot scheduler
232
+ // pre-verifies these signatures in the epochs before the fork, a cache miss falls back to
233
+ // verifying this one deposit
253
234
  const cached = state.epochCtx.builderDepositSignatureCache.getSignatureValidity(depositValue);
254
235
  if (cached === null) {
255
236
  sigVerified++;
@@ -266,7 +247,18 @@ function onboardBuildersFromPendingDeposits(
266
247
  deposit.signature
267
248
  );
268
249
  if (!isValid) {
269
- dropped++;
250
+ // Keep the deposit as a validator top-up if a validator with this pubkey exists or a valid
251
+ // pending deposit will create one, otherwise it is dropped and the stake is forfeited
252
+ if (
253
+ isValidatorKnown(state, state.epochCtx.getValidatorIndex(deposit.pubkey)) ||
254
+ pendingDepositsLookup.hasPendingValidator(state.config, pubkeyHex, state.epochCtx.builderDepositSignatureCache)
255
+ ) {
256
+ pendingDeposits.push(deposit);
257
+ pendingDepositsLookup.add(depositValue, pubkeyHex);
258
+ kept++;
259
+ } else {
260
+ dropped++;
261
+ }
270
262
  continue;
271
263
  }
272
264
 
@@ -7,12 +7,6 @@ import {CachedBeaconStateGloas, CachedBeaconStateHeze} from "../types.js";
7
7
  * Spec: heze/fork.md `upgrade_to_heze`.
8
8
  */
9
9
  export function upgradeStateToHeze(stateGloas: CachedBeaconStateGloas): CachedBeaconStateHeze {
10
- // In Heze, the old deposit mechanism must be fully drained before the fork
11
- if (BigInt(stateGloas.eth1DepositIndex) !== stateGloas.depositRequestsStartIndex) {
12
- throw new Error(
13
- `Cannot upgrade to Heze: legacy deposit mechanism still active eth1DepositIndex=${stateGloas.eth1DepositIndex} depositRequestsStartIndex=${stateGloas.depositRequestsStartIndex}`
14
- );
15
- }
16
10
  const {config} = stateGloas;
17
11
 
18
12
  ssz.gloas.BeaconState.commitViewDU(stateGloas);
@@ -63,7 +63,7 @@ import {
63
63
  isGloasStateType,
64
64
  isMergeTransitionComplete,
65
65
  } from "../util/execution.js";
66
- import {canBuilderCoverBid} from "../util/gloas.js";
66
+ import {canBuilderCoverBid, getBuilderBidLimit} from "../util/gloas.js";
67
67
  import {loadState} from "../util/loadState/loadState.js";
68
68
  import {PreVerifyBuilderDepositsResult, preVerifyBuilderDepositsPreGloas} from "../util/preVerifyBuilderDeposits.js";
69
69
  import {getRandaoMix} from "../util/seed.js";
@@ -469,6 +469,14 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
469
469
  return canBuilderCoverBid(this.cachedState as CachedBeaconStateGloas, builderIndex, bidAmount);
470
470
  }
471
471
 
472
+ getBuilderBidLimit(builderIndex: BuilderIndex): number {
473
+ if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
474
+ throw new Error("Builders are not supported before Gloas");
475
+ }
476
+
477
+ return getBuilderBidLimit(this.cachedState as CachedBeaconStateGloas, builderIndex);
478
+ }
479
+
472
480
  /**
473
481
  * Return the PTCs for an epoch
474
482
  */
@@ -293,6 +293,7 @@ export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
293
293
  getBuilder(index: BuilderIndex): gloas.Builder;
294
294
  getBuildersLength(): number;
295
295
  canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
296
+ getBuilderBidLimit(builderIndex: BuilderIndex): number;
296
297
  getEpochPTCs(epoch: Epoch): Uint32Array[];
297
298
  getPayloadTimelinessCommittee(slot: Slot): Uint32Array;
298
299
  getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[];
@@ -958,6 +958,10 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
958
958
  return this.binding.canBuilderCoverBid(builderIndex, bidAmount);
959
959
  }
960
960
 
961
+ getBuilderBidLimit(builderIndex: BuilderIndex): number {
962
+ return this.binding.getBuilderBidLimit(builderIndex);
963
+ }
964
+
961
965
  getEpochPTCs(epoch: Epoch): Uint32Array[] {
962
966
  return this.binding.getEpochPTCs(epoch);
963
967
  }
@@ -54,6 +54,11 @@ export type EpochShuffling = {
54
54
  * Committees per slot, for fast attestation verification
55
55
  */
56
56
  committeesPerSlot: number;
57
+
58
+ /**
59
+ * Native committee aggregate pubkeys of this shuffling, set once `computeCommitteePubkeys()` resolves
60
+ */
61
+ committeePubkeysId?: number;
57
62
  };
58
63
 
59
64
  export function computeCommitteeCount(activeValidatorCount: number): number {
package/src/util/gloas.ts CHANGED
@@ -25,6 +25,7 @@ import {computePayloadTimelinessCommitteesForEpoch} from "./seed.js";
25
25
  import {createSingleSignatureSetFromComponents, verifySignatureSet} from "./signatureSets.js";
26
26
  import {computeSigningRoot} from "./signingRoot.js";
27
27
  import {getActiveValidatorIndices} from "./validator.js";
28
+ import {ETH_TO_GWEI} from "./weakSubjectivity.js";
28
29
 
29
30
  export function isBuilderWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean {
30
31
  return withdrawalCredentials[0] === BUILDER_WITHDRAWAL_PREFIX;
@@ -161,6 +162,16 @@ export function canBuilderCoverBid(
161
162
  return builder.balance - minBalance >= bidAmount;
162
163
  }
163
164
 
165
+ /**
166
+ * Return the number of bids the builder may submit for each slot and parent.
167
+ * Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.5/specs/gloas/p2p-interface.md#new-get_builder_bid_limit
168
+ */
169
+ export function getBuilderBidLimit(state: CachedBeaconStateGloas, builderIndex: BuilderIndex): number {
170
+ const builder = state.builders.getReadonly(builderIndex);
171
+ const pendingBalance = getPendingBalanceToWithdrawForBuilder(state, builderIndex);
172
+ return Math.floor(Math.max(builder.balance - pendingBalance, 0) / ETH_TO_GWEI);
173
+ }
174
+
164
175
  /**
165
176
  * Initiate a builder exit by setting their withdrawable epoch.
166
177
  * Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.1/specs/gloas/beacon-chain.md#new-initiate_builder_exit
@@ -1,5 +1,6 @@
1
+ import {BitArray} from "@chainsafe/ssz";
1
2
  import {BLS_VERIFIER_SET_TYPE, type BlsSignatureSet, verifySignatureSets} from "@lodestar/native/bls-verifier";
2
- import {Root} from "@lodestar/types";
3
+ import {Root, Slot} from "@lodestar/types";
3
4
 
4
5
  export enum SignatureSetType {
5
6
  single = "single",
@@ -9,6 +10,11 @@ export enum SignatureSetType {
9
10
  * Pubkey lookup is deferred to verification time.
10
11
  */
11
12
  indexed = "indexed",
13
+ /**
14
+ * Aggregate signature of an attestation over whole committees of one slot.
15
+ * Pubkeys come from the committee aggregates of the shuffling, see `computeCommitteePubkeys()`.
16
+ */
17
+ committee = "committee",
12
18
  }
13
19
 
14
20
  /**
@@ -44,7 +50,22 @@ export type AggregatedSignatureSet = {
44
50
  signature: Uint8Array;
45
51
  };
46
52
 
47
- export type ISignatureSet = SingleSignatureSet | IndexedSignatureSet | AggregatedSignatureSet;
53
+ /**
54
+ * Aggregate signature of an attestation over the committees `committeeIndices` of `slot`.
55
+ * `indices` lists the participants, aggregated instead when the committee pubkeys are not cached.
56
+ */
57
+ export type CommitteeSignatureSet = {
58
+ type: SignatureSetType.committee;
59
+ indices: number[];
60
+ committeePubkeysId: number;
61
+ slot: Slot;
62
+ committeeIndices: number[];
63
+ aggregationBits: BitArray;
64
+ signingRoot: Root;
65
+ signature: Uint8Array;
66
+ };
67
+
68
+ export type ISignatureSet = SingleSignatureSet | IndexedSignatureSet | AggregatedSignatureSet | CommitteeSignatureSet;
48
69
 
49
70
  export function toBlsSignatureSet(signatureSet: ISignatureSet): BlsSignatureSet {
50
71
  switch (signatureSet.type) {
@@ -81,6 +102,28 @@ export function toBlsSignatureSet(signatureSet: ISignatureSet): BlsSignatureSet
81
102
  };
82
103
  }
83
104
 
105
+ case SignatureSetType.committee: {
106
+ const indices = new Uint32Array(signatureSet.indices.length);
107
+ for (const [i, index] of signatureSet.indices.entries()) {
108
+ if (!Number.isInteger(index) || index < 0 || index > 0xffffffff) {
109
+ throw new RangeError(`Invalid validator index ${index}`);
110
+ }
111
+ indices[i] = index;
112
+ }
113
+
114
+ return {
115
+ type: BLS_VERIFIER_SET_TYPE.committee,
116
+ indices,
117
+ committeePubkeysId: signatureSet.committeePubkeysId,
118
+ slot: signatureSet.slot,
119
+ committeeIndices: Uint32Array.from(signatureSet.committeeIndices),
120
+ aggregationBits: signatureSet.aggregationBits.uint8Array,
121
+ bitLen: signatureSet.aggregationBits.bitLen,
122
+ message: signatureSet.signingRoot,
123
+ signature: signatureSet.signature,
124
+ };
125
+ }
126
+
84
127
  default:
85
128
  throw Error("Unknown signature set type");
86
129
  }
package/src/util/slot.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {ChainConfig, ChainForkConfig} from "@lodestar/config";
2
- import {GENESIS_EPOCH, GENESIS_SLOT} from "@lodestar/params";
2
+ import {GENESIS_EPOCH, GENESIS_SLOT, SLOTS_PER_EPOCH} from "@lodestar/params";
3
3
  import {Epoch, Slot, TimeSeconds} from "@lodestar/types";
4
4
  import {computeEpochAtSlot, computeStartSlotAtEpoch} from "./epoch.js";
5
5
 
@@ -8,11 +8,7 @@ import {computeEpochAtSlot, computeStartSlotAtEpoch} from "./epoch.js";
8
8
  * A fork that changes the slot duration must add an entry here and in `ForkConfig.getSlotDurationMs`.
9
9
  */
10
10
  export function getSlotDurations(config: ChainConfig): [Epoch, number][] {
11
- const durations: [Epoch, number][] = [[GENESIS_EPOCH, config.SLOT_DURATION_MS]];
12
- if (config.HEZE_FORK_EPOCH !== Infinity) {
13
- durations.push([config.HEZE_FORK_EPOCH, config.SLOT_DURATION_MS_HEZE]);
14
- }
15
- return durations;
11
+ return [[GENESIS_EPOCH, config.SLOT_DURATION_MS]];
16
12
  }
17
13
 
18
14
  /** Slot duration in ms in effect at a given epoch */
@@ -78,7 +74,7 @@ export function getCurrentSlot(config: ChainConfig, genesisTime: TimeSeconds): S
78
74
  * across slot duration changes
79
75
  */
80
76
  export function getBlobDataRetentionStartEpoch(config: ChainConfig, epoch: Epoch): Epoch {
81
- const windowMs = config.MIN_BLOB_DATA_RETENTION_MS;
77
+ const windowMs = config.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS * SLOTS_PER_EPOCH * config.SLOT_DURATION_MS;
82
78
  const currentStartMs = computeTimeAtSlotMs(config, computeStartSlotAtEpoch(epoch), 0);
83
79
  if (currentStartMs < windowMs) {
84
80
  return GENESIS_EPOCH;