@lodestar/state-transition 1.52.0-dev.2252a15492 → 1.52.0-dev.263ed9ded6

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 (45) 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/rewards/blockRewards.d.ts.map +1 -1
  9. package/lib/rewards/blockRewards.js +7 -1
  10. package/lib/rewards/blockRewards.js.map +1 -1
  11. package/lib/signatureSets/index.d.ts.map +1 -1
  12. package/lib/signatureSets/index.js +13 -4
  13. package/lib/signatureSets/index.js.map +1 -1
  14. package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
  15. package/lib/slot/upgradeStateToGloas.js +22 -27
  16. package/lib/slot/upgradeStateToGloas.js.map +1 -1
  17. package/lib/stateView/beaconStateView.d.ts +1 -0
  18. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  19. package/lib/stateView/beaconStateView.js +9 -1
  20. package/lib/stateView/beaconStateView.js.map +1 -1
  21. package/lib/stateView/interface.d.ts +1 -0
  22. package/lib/stateView/interface.d.ts.map +1 -1
  23. package/lib/stateView/interface.js.map +1 -1
  24. package/lib/stateView/nativeBeaconStateView.d.ts +1 -0
  25. package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
  26. package/lib/stateView/nativeBeaconStateView.js +3 -0
  27. package/lib/stateView/nativeBeaconStateView.js.map +1 -1
  28. package/lib/util/gloas.d.ts +5 -0
  29. package/lib/util/gloas.d.ts.map +1 -1
  30. package/lib/util/gloas.js +10 -0
  31. package/lib/util/gloas.js.map +1 -1
  32. package/lib/util/slot.d.ts.map +1 -1
  33. package/lib/util/slot.js +3 -7
  34. package/lib/util/slot.js.map +1 -1
  35. package/package.json +9 -9
  36. package/src/block/index.ts +2 -1
  37. package/src/block/processExecutionPayloadBid.ts +3 -2
  38. package/src/rewards/blockRewards.ts +8 -2
  39. package/src/signatureSets/index.ts +26 -4
  40. package/src/slot/upgradeStateToGloas.ts +23 -31
  41. package/src/stateView/beaconStateView.ts +11 -1
  42. package/src/stateView/interface.ts +1 -0
  43. package/src/stateView/nativeBeaconStateView.ts +4 -0
  44. package/src/util/gloas.ts +11 -0
  45. package/src/util/slot.ts +3 -7
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
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;