@lodestar/state-transition 1.41.0 → 1.42.0-dev.2f0347050b

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 (69) hide show
  1. package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
  2. package/lib/block/isValidIndexedAttestation.js +2 -3
  3. package/lib/block/isValidIndexedAttestation.js.map +1 -1
  4. package/lib/block/processAttestationsAltair.d.ts +2 -1
  5. package/lib/block/processAttestationsAltair.d.ts.map +1 -1
  6. package/lib/block/processAttestationsAltair.js +5 -3
  7. package/lib/block/processAttestationsAltair.js.map +1 -1
  8. package/lib/block/processExecutionPayloadEnvelope.d.ts +3 -1
  9. package/lib/block/processExecutionPayloadEnvelope.d.ts.map +1 -1
  10. package/lib/block/processExecutionPayloadEnvelope.js +11 -28
  11. package/lib/block/processExecutionPayloadEnvelope.js.map +1 -1
  12. package/lib/block/processVoluntaryExit.d.ts.map +1 -1
  13. package/lib/block/processVoluntaryExit.js +49 -47
  14. package/lib/block/processVoluntaryExit.js.map +1 -1
  15. package/lib/signatureSets/executionPayloadEnvelope.d.ts +5 -1
  16. package/lib/signatureSets/executionPayloadEnvelope.d.ts.map +1 -1
  17. package/lib/signatureSets/executionPayloadEnvelope.js +10 -1
  18. package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
  19. package/lib/signatureSets/index.d.ts +2 -1
  20. package/lib/signatureSets/index.d.ts.map +1 -1
  21. package/lib/signatureSets/index.js +2 -2
  22. package/lib/signatureSets/index.js.map +1 -1
  23. package/lib/signatureSets/voluntaryExits.d.ts +7 -3
  24. package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
  25. package/lib/signatureSets/voluntaryExits.js +30 -9
  26. package/lib/signatureSets/voluntaryExits.js.map +1 -1
  27. package/lib/slot/upgradeStateToAltair.d.ts.map +1 -1
  28. package/lib/slot/upgradeStateToAltair.js +2 -1
  29. package/lib/slot/upgradeStateToAltair.js.map +1 -1
  30. package/lib/stateView/beaconStateView.d.ts +8 -10
  31. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  32. package/lib/stateView/beaconStateView.js +11 -34
  33. package/lib/stateView/beaconStateView.js.map +1 -1
  34. package/lib/stateView/index.d.ts +1 -0
  35. package/lib/stateView/index.d.ts.map +1 -1
  36. package/lib/stateView/index.js +1 -0
  37. package/lib/stateView/index.js.map +1 -1
  38. package/lib/stateView/interface.d.ts +14 -9
  39. package/lib/stateView/interface.d.ts.map +1 -1
  40. package/lib/stateView/stateViewFactory.d.ts +40 -0
  41. package/lib/stateView/stateViewFactory.d.ts.map +1 -0
  42. package/lib/stateView/stateViewFactory.js +46 -0
  43. package/lib/stateView/stateViewFactory.js.map +1 -0
  44. package/lib/util/execution.js +1 -1
  45. package/lib/util/execution.js.map +1 -1
  46. package/lib/util/rootCache.d.ts +2 -2
  47. package/lib/util/rootCache.d.ts.map +1 -1
  48. package/lib/util/rootCache.js +2 -3
  49. package/lib/util/rootCache.js.map +1 -1
  50. package/lib/util/shuffling.d.ts +2 -1
  51. package/lib/util/shuffling.d.ts.map +1 -1
  52. package/lib/util/shuffling.js +2 -2
  53. package/lib/util/shuffling.js.map +1 -1
  54. package/package.json +7 -7
  55. package/src/block/isValidIndexedAttestation.ts +2 -3
  56. package/src/block/processAttestationsAltair.ts +7 -4
  57. package/src/block/processExecutionPayloadEnvelope.ts +18 -35
  58. package/src/block/processVoluntaryExit.ts +77 -54
  59. package/src/signatureSets/executionPayloadEnvelope.ts +26 -2
  60. package/src/signatureSets/index.ts +3 -1
  61. package/src/signatureSets/voluntaryExits.ts +51 -9
  62. package/src/slot/upgradeStateToAltair.ts +2 -1
  63. package/src/stateView/beaconStateView.ts +27 -50
  64. package/src/stateView/index.ts +1 -0
  65. package/src/stateView/interface.ts +15 -6
  66. package/src/stateView/stateViewFactory.ts +78 -0
  67. package/src/util/execution.ts +1 -1
  68. package/src/util/rootCache.ts +4 -5
  69. package/src/util/shuffling.ts +5 -4
@@ -1,4 +1,3 @@
1
- import { getBlockRoot, getBlockRootAtSlot } from "./blockRoot.js";
2
1
  /**
3
2
  * Cache to prevent accessing the state tree to fetch block roots repeteadly.
4
3
  * In normal network conditions the same root is read multiple times, specially the target.
@@ -17,7 +16,7 @@ export class RootCache {
17
16
  getBlockRoot(epoch) {
18
17
  let root = this.blockRootEpochCache.get(epoch);
19
18
  if (!root) {
20
- root = getBlockRoot(this.state, epoch);
19
+ root = this.state.getBlockRootAtEpoch(epoch);
21
20
  this.blockRootEpochCache.set(epoch, root);
22
21
  }
23
22
  return root;
@@ -25,7 +24,7 @@ export class RootCache {
25
24
  getBlockRootAtSlot(slot) {
26
25
  let root = this.blockRootSlotCache.get(slot);
27
26
  if (!root) {
28
- root = getBlockRootAtSlot(this.state, slot);
27
+ root = this.state.getBlockRootAtSlot(slot);
29
28
  this.blockRootSlotCache.set(slot, root);
30
29
  }
31
30
  return root;
@@ -1 +1 @@
1
- {"version":3,"file":"rootCache.js","sourceRoot":"","sources":["../../src/util/rootCache.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,SAAS;IAMS,KAAK;IALzB,0BAA0B,CAAoB;IAC9C,2BAA2B,CAAoB;IACvC,mBAAmB,GAAG,IAAI,GAAG,EAAe,CAAC;IAC7C,kBAAkB,GAAG,IAAI,GAAG,EAAc,CAAC;IAE5D,YAA6B,KAAgC,EAAE;qBAAlC,KAAK;QAChC,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC,0BAA0B,CAAC;QACnE,IAAI,CAAC,2BAA2B,GAAG,KAAK,CAAC,2BAA2B,CAAC;IAAA,CACtE;IAED,YAAY,CAAC,KAAY,EAAQ;QAC/B,IAAI,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,YA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AE,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACb;IAED,kBAAkB,CAAC,IAAU,EAAQ;QACnC,IAAI,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACb;CACF"}
@@ -2,6 +2,7 @@ import { ForkName, ForkSeq } from "@lodestar/params";
2
2
  import { Attestation, CommitteeIndex, Epoch, IndexedAttestation, Root, Slot, ValidatorIndex } from "@lodestar/types";
3
3
  import { LodestarError } from "@lodestar/utils";
4
4
  import { CachedBeaconStateAllForks } from "../cache/stateCache.js";
5
+ import { IBeaconStateView } from "../stateView/interface.js";
5
6
  import { EpochShuffling } from "./epochShuffling.js";
6
7
  /**
7
8
  * Returns the block root which decided the proposer shuffling for the current epoch. This root
@@ -10,7 +11,7 @@ import { EpochShuffling } from "./epochShuffling.js";
10
11
  * Returns `null` on the one-off scenario where the genesis block decides its own shuffling.
11
12
  * It should be set to the latest block applied to this `state` or the genesis block root.
12
13
  */
13
- export declare function proposerShufflingDecisionRoot(fork: ForkName, state: CachedBeaconStateAllForks): Root | null;
14
+ export declare function proposerShufflingDecisionRoot(fork: ForkName, state: IBeaconStateView): Root | null;
14
15
  /**
15
16
  * Returns the block root which decided the attester shuffling for the given `requestedEpoch`.
16
17
  * This root can be used to key that attester shuffling.
@@ -1 +1 @@
1
- {"version":3,"file":"shuffling.d.ts","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAkC,MAAM,kBAAkB,CAAC;AACpF,O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EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,MAAM,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,cAAc,EAC9B,yBAAyB,EAAE,cAAc,EAAE,GAC1C,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,CAyBnC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,WAAW,GACvB,kBAAkB,CAWpB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE,CA6BrH;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,GAAG,WAAW,CAEjH;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,EAAE,GACxB,WAAW,EAAE,CAoBf;AAED,oBAAY,kBAAkB;IAC5B,4BAA4B,iDAAiD;CAC9E;AAED,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,kBAAkB,CAAC,4BAA4B,CAAC;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,cAAe,SAAQ,aAAa,CAAC,kBAAkB,CAAC;CAAG"}
@@ -14,7 +14,7 @@ export function proposerShufflingDecisionRoot(fork, state) {
14
14
  if (state.slot === decisionSlot) {
15
15
  return null;
16
16
  }
17
- return getBlockRootAtSlot(state, decisionSlot);
17
+ return state.getBlockRootAtSlot(decisionSlot);
18
18
  }
19
19
  /**
20
20
  * Returns the slot at which the proposer shuffling was decided. The block root at this slot
@@ -22,7 +22,7 @@ export function proposerShufflingDecisionRoot(fork, state) {
22
22
  */
23
23
  function proposerShufflingDecisionSlot(fork, state) {
24
24
  // After fulu, the decision slot is in previous epoch due to deterministic proposer lookahead
25
- const epoch = isForkPostFulu(fork) ? state.epochCtx.epoch - 1 : state.epochCtx.epoch;
25
+ const epoch = isForkPostFulu(fork) ? state.epoch - 1 : state.epoch;
26
26
  const startSlot = computeStartSlotAtEpoch(epoch);
27
27
  return Math.max(startSlot - 1, 0);
28
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shuffling.js","sourceRoot":"","sources":["../../src/util/shuffling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,OAAO,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAWpF,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAGnD;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAAC,IAAc,EAAE,KAAgC,EAAe;IAC3G,MAAM,YAAY,GAAG,6BAA6B,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChE,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,kBAAkB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAAA,CAChD;AAED;;;GAGG;AACH,SAAS,6BAA6B,CAAC,IAAc,EAAE,KAAgC,EAAQ;IAC7F,6FAA6F;IAC7F,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;IACrF,MAAM,SAAS,GAAG,uBAAuB,CAA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AAe,SAAQ,aAAiC;CAAG"}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/ChainSafe/lodestar/issues"
13
13
  },
14
- "version": "1.41.0",
14
+ "version": "1.42.0-dev.2f0347050b",
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -67,14 +67,14 @@
67
67
  "@chainsafe/pubkey-index-map": "^3.0.0",
68
68
  "@chainsafe/ssz": "^1.2.2",
69
69
  "@chainsafe/swap-or-not-shuffle": "^1.2.1",
70
- "@lodestar/config": "^1.41.0",
71
- "@lodestar/params": "^1.41.0",
72
- "@lodestar/types": "^1.41.0",
73
- "@lodestar/utils": "^1.41.0",
70
+ "@lodestar/config": "^1.42.0-dev.2f0347050b",
71
+ "@lodestar/params": "^1.42.0-dev.2f0347050b",
72
+ "@lodestar/types": "^1.42.0-dev.2f0347050b",
73
+ "@lodestar/utils": "^1.42.0-dev.2f0347050b",
74
74
  "@vekexasia/bigint-buffer2": "^1.1.1"
75
75
  },
76
76
  "devDependencies": {
77
- "@lodestar/api": "^1.41.0"
77
+ "@lodestar/api": "^1.42.0-dev.2f0347050b"
78
78
  },
79
79
  "keywords": [
80
80
  "ethereum",
@@ -82,5 +82,5 @@
82
82
  "beacon",
83
83
  "blockchain"
84
84
  ],
85
- "gitHead": "13e882a3a430d6df25a408b61b24954277e1f8e8"
85
+ "gitHead": "f88e072911f96dcfae1dc565204d276481769846"
86
86
  }
@@ -74,9 +74,8 @@ export function isValidIndexedAttestationIndices(
74
74
  prev = index;
75
75
  }
76
76
 
77
- // check if indices are out of bounds, by checking the highest index (since it is sorted)
78
- const lastIndex = indices.at(-1);
79
- if (lastIndex && lastIndex >= validatorsLen) {
77
+ // check if indices are out of bounds, `prev` is the highest index since indices are sorted
78
+ if (prev >= validatorsLen) {
80
79
  return false;
81
80
  }
82
81
 
@@ -1,3 +1,4 @@
1
+ import {BitArray} from "@chainsafe/ssz";
1
2
  import {
2
3
  EFFECTIVE_BALANCE_INCREMENT,
3
4
  ForkSeq,
@@ -17,6 +18,7 @@ import {Attestation, Epoch, phase0} from "@lodestar/types";
17
18
  import {byteArrayEquals, intSqrt} from "@lodestar/utils";
18
19
  import {BeaconStateTransitionMetrics} from "../metrics.js";
19
20
  import {getAttestationWithIndicesSignatureSet} from "../signatureSets/indexedAttestation.js";
21
+ import {BeaconStateView} from "../stateView/beaconStateView.js";
20
22
  import {CachedBeaconStateAltair, CachedBeaconStateGloas} from "../types.js";
21
23
  import {isAttestationSameSlot, isAttestationSameSlotRootCache} from "../util/gloas.js";
22
24
  import {increaseBalance, verifySignatureSet} from "../util/index.js";
@@ -41,7 +43,7 @@ export function processAttestationsAltair(
41
43
  const {epochCtx} = state;
42
44
  const {effectiveBalanceIncrements} = epochCtx;
43
45
  const stateSlot = state.slot;
44
- const rootCache = new RootCache(state);
46
+ const rootCache = new RootCache(new BeaconStateView(state));
45
47
  const currentEpoch = epochCtx.epoch;
46
48
 
47
49
  // Process all attestations first and then increase the balance of the proposer once
@@ -80,7 +82,7 @@ export function processAttestationsAltair(
80
82
  stateSlot - data.slot,
81
83
  epochCtx.epoch,
82
84
  rootCache,
83
- fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability.toBoolArray() : null
85
+ fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability : null
84
86
  );
85
87
 
86
88
  // For each participant, update their participation
@@ -177,7 +179,7 @@ export function getAttestationParticipationStatus(
177
179
  inclusionDelay: number,
178
180
  currentEpoch: Epoch,
179
181
  rootCache: RootCache,
180
- executionPayloadAvailability: boolean[] | null
182
+ executionPayloadAvailability: BitArray | null
181
183
  ): number {
182
184
  const justifiedCheckpoint =
183
185
  data.target.epoch === currentEpoch ? rootCache.currentJustifiedCheckpoint : rootCache.previousJustifiedCheckpoint;
@@ -221,7 +223,8 @@ export function getAttestationParticipationStatus(
221
223
  throw new Error(`data index must be 0 or 1 index=${data.index}`);
222
224
  }
223
225
 
224
- isMatchingPayload = Boolean(data.index) === executionPayloadAvailability[data.slot % SLOTS_PER_HISTORICAL_ROOT];
226
+ isMatchingPayload =
227
+ Boolean(data.index) === executionPayloadAvailability.get(data.slot % SLOTS_PER_HISTORICAL_ROOT);
225
228
  }
226
229
 
227
230
  isMatchingHead = isMatchingHead && isMatchingPayload;
@@ -1,19 +1,18 @@
1
- import {PublicKey, Signature, verify} from "@chainsafe/blst";
2
- import {
3
- BUILDER_INDEX_SELF_BUILD,
4
- DOMAIN_BEACON_BUILDER,
5
- SLOTS_PER_EPOCH,
6
- SLOTS_PER_HISTORICAL_ROOT,
7
- } from "@lodestar/params";
1
+ import {SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
8
2
  import {gloas, ssz} from "@lodestar/types";
9
3
  import {byteArrayEquals, toHex, toRootHex} from "@lodestar/utils";
4
+ import {getExecutionPayloadEnvelopeSignatureSet} from "../signatureSets/executionPayloadEnvelope.js";
5
+ import {BeaconStateView} from "../stateView/beaconStateView.js";
10
6
  import {CachedBeaconStateGloas} from "../types.js";
11
- import {computeSigningRoot, computeTimeAtSlot} from "../util/index.js";
7
+ import {computeTimeAtSlot} from "../util/index.js";
8
+ import {verifySignatureSet} from "../util/signatureSets.js";
12
9
  import {processConsolidationRequest} from "./processConsolidationRequest.js";
13
10
  import {processDepositRequest} from "./processDepositRequest.js";
14
11
  import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
15
12
 
16
13
  export type ProcessExecutionPayloadEnvelopeOpts = {
14
+ verifySignature?: boolean;
15
+ verifyStateRoot?: boolean;
17
16
  dontTransferCache?: boolean;
18
17
  };
19
18
 
@@ -23,14 +22,14 @@ export type ProcessExecutionPayloadEnvelopeOpts = {
23
22
  export function processExecutionPayloadEnvelope(
24
23
  state: CachedBeaconStateGloas,
25
24
  signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
26
- verify: boolean,
27
25
  opts?: ProcessExecutionPayloadEnvelopeOpts
28
26
  ): CachedBeaconStateGloas {
27
+ const {verifySignature = true, verifyStateRoot = true} = opts ?? {};
29
28
  const envelope = signedEnvelope.message;
30
29
  const payload = envelope.payload;
31
30
  const fork = state.config.getForkSeq(envelope.slot);
32
31
 
33
- if (verify && !verifyExecutionPayloadEnvelopeSignature(state, signedEnvelope)) {
32
+ if (verifySignature && !verifyExecutionPayloadEnvelopeSignature(state, signedEnvelope)) {
34
33
  throw Error(`Execution payload envelope has invalid signature builderIndex=${envelope.builderIndex}`);
35
34
  }
36
35
 
@@ -70,7 +69,7 @@ export function processExecutionPayloadEnvelope(
70
69
 
71
70
  postState.commit();
72
71
 
73
- if (verify && !byteArrayEquals(envelope.stateRoot, postState.hashTreeRoot())) {
72
+ if (verifyStateRoot && !byteArrayEquals(envelope.stateRoot, postState.hashTreeRoot())) {
74
73
  throw new Error(
75
74
  `Envelope's state root does not match state envelope=${toRootHex(envelope.stateRoot)} state=${toRootHex(postState.hashTreeRoot())}`
76
75
  );
@@ -160,28 +159,12 @@ function verifyExecutionPayloadEnvelopeSignature(
160
159
  state: CachedBeaconStateGloas,
161
160
  signedEnvelope: gloas.SignedExecutionPayloadEnvelope
162
161
  ): boolean {
163
- const builderIndex = signedEnvelope.message.builderIndex;
164
-
165
- const domain = state.config.getDomain(state.slot, DOMAIN_BEACON_BUILDER);
166
- const signingRoot = computeSigningRoot(ssz.gloas.ExecutionPayloadEnvelope, signedEnvelope.message, domain);
167
-
168
- try {
169
- let publicKey: PublicKey;
170
-
171
- if (builderIndex === BUILDER_INDEX_SELF_BUILD) {
172
- const validatorIndex = state.latestBlockHeader.proposerIndex;
173
- const proposerPubkey = state.epochCtx.pubkeyCache.get(validatorIndex);
174
- if (!proposerPubkey) {
175
- return false;
176
- }
177
- publicKey = proposerPubkey;
178
- } else {
179
- publicKey = PublicKey.fromBytes(state.builders.getReadonly(builderIndex).pubkey);
180
- }
181
- const signature = Signature.fromBytes(signedEnvelope.signature, true);
182
-
183
- return verify(signingRoot, publicKey, signature);
184
- } catch (_e) {
185
- return false; // Catch all BLS errors: failed key validation, failed signature validation, invalid signature
186
- }
162
+ const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
163
+ state.config,
164
+ state.epochCtx.pubkeyCache,
165
+ new BeaconStateView(state),
166
+ signedEnvelope,
167
+ state.latestBlockHeader.proposerIndex
168
+ );
169
+ return verifySignatureSet(signatureSet);
187
170
  }
@@ -1,7 +1,7 @@
1
- import {PublicKey, Signature, verify} from "@chainsafe/blst";
2
1
  import {FAR_FUTURE_EPOCH, ForkSeq} from "@lodestar/params";
3
- import {phase0, ssz} from "@lodestar/types";
2
+ import {phase0} from "@lodestar/types";
4
3
  import {verifyVoluntaryExitSignature} from "../signatureSets/index.js";
4
+ import {BeaconStateView} from "../stateView/beaconStateView.js";
5
5
  import {CachedBeaconStateAllForks, CachedBeaconStateElectra, CachedBeaconStateGloas} from "../types.js";
6
6
  import {
7
7
  convertValidatorIndexToBuilderIndex,
@@ -10,7 +10,7 @@ import {
10
10
  isActiveBuilder,
11
11
  isBuilderIndex,
12
12
  } from "../util/gloas.js";
13
- import {computeSigningRoot, getCurrentEpoch, getPendingBalanceToWithdraw, isActiveValidator} from "../util/index.js";
13
+ import {getPendingBalanceToWithdraw, isActiveValidator} from "../util/index.js";
14
14
  import {initiateValidatorExit} from "./index.js";
15
15
 
16
16
  export enum VoluntaryExitValidity {
@@ -35,57 +35,20 @@ export function processVoluntaryExit(
35
35
  verifySignature = true
36
36
  ): void {
37
37
  const voluntaryExit = signedVoluntaryExit.message;
38
- const currentEpoch = getCurrentEpoch(state);
39
38
 
40
- // Exits must specify an epoch when they become valid; they are not valid before then
41
- if (currentEpoch < voluntaryExit.epoch) {
42
- throw Error(`Voluntary exit epoch ${voluntaryExit.epoch} is after current epoch ${currentEpoch}`);
39
+ const validity = getVoluntaryExitValidity(fork, state, signedVoluntaryExit, verifySignature);
40
+ if (validity !== VoluntaryExitValidity.valid) {
41
+ throw Error(`Invalid voluntary exit at forkSeq=${fork} reason=${validity}`);
43
42
  }
44
43
 
45
- // Check if this is a builder exit
46
44
  if (fork >= ForkSeq.gloas && isBuilderIndex(voluntaryExit.validatorIndex)) {
47
- const stateGloas = state as CachedBeaconStateGloas;
48
- const builderIndex = convertValidatorIndexToBuilderIndex(voluntaryExit.validatorIndex);
49
- const builder = stateGloas.builders.getReadonly(builderIndex);
50
-
51
- // Verify the builder is active
52
- if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
53
- throw Error(`Builder ${builderIndex} is not active`);
54
- }
55
-
56
- // Only exit builder if it has no pending withdrawals in the queue
57
- if (getPendingBalanceToWithdrawForBuilder(stateGloas, builderIndex) !== 0) {
58
- throw Error(`Builder ${builderIndex} has pending withdrawals`);
59
- }
60
-
61
- // Verify signature
62
- if (verifySignature) {
63
- const domain = state.config.getDomainForVoluntaryExit(state.slot);
64
- const signingRoot = computeSigningRoot(ssz.phase0.VoluntaryExit, voluntaryExit, domain);
65
-
66
- try {
67
- const publicKey = PublicKey.fromBytes(builder.pubkey);
68
- const signature = Signature.fromBytes(signedVoluntaryExit.signature, true);
69
-
70
- if (!verify(signingRoot, publicKey, signature)) {
71
- throw Error("BLS verify failed");
72
- }
73
- } catch (e) {
74
- throw Error(`Builder ${builderIndex} invalid exit signature reason=${(e as Error).message}`);
75
- }
76
- }
77
-
78
- // Initiate builder exit
79
- initiateBuilderExit(stateGloas, builderIndex);
45
+ initiateBuilderExit(
46
+ state as CachedBeaconStateGloas,
47
+ convertValidatorIndexToBuilderIndex(voluntaryExit.validatorIndex)
48
+ );
80
49
  return;
81
50
  }
82
51
 
83
- // Handle validator exit
84
- const validity = getVoluntaryExitValidity(fork, state, signedVoluntaryExit, verifySignature);
85
- if (validity !== VoluntaryExitValidity.valid) {
86
- throw Error(`Invalid voluntary exit at forkSeq=${fork} reason=${validity}`);
87
- }
88
-
89
52
  const validator = state.validators.get(signedVoluntaryExit.message.validatorIndex);
90
53
  initiateValidatorExit(fork, state, validator);
91
54
  }
@@ -95,10 +58,74 @@ export function getVoluntaryExitValidity(
95
58
  state: CachedBeaconStateAllForks,
96
59
  signedVoluntaryExit: phase0.SignedVoluntaryExit,
97
60
  verifySignature = true
61
+ ): VoluntaryExitValidity {
62
+ const currentEpoch = state.epochCtx.epoch;
63
+ const voluntaryExit = signedVoluntaryExit.message;
64
+
65
+ // Exits must specify an epoch when they become valid; they are not valid before then
66
+ if (currentEpoch < voluntaryExit.epoch) {
67
+ return VoluntaryExitValidity.earlyEpoch;
68
+ }
69
+
70
+ // Check if this is a builder exit
71
+ if (fork >= ForkSeq.gloas && isBuilderIndex(voluntaryExit.validatorIndex)) {
72
+ return getBuilderVoluntaryExitValidity(state as CachedBeaconStateGloas, signedVoluntaryExit, verifySignature);
73
+ }
74
+
75
+ return getValidatorVoluntaryExitValidity(fork, state, signedVoluntaryExit, verifySignature);
76
+ }
77
+
78
+ function getBuilderVoluntaryExitValidity(
79
+ state: CachedBeaconStateGloas,
80
+ signedVoluntaryExit: phase0.SignedVoluntaryExit,
81
+ verifySignature: boolean
82
+ ): VoluntaryExitValidity {
83
+ const {config, epochCtx} = state;
84
+ const builderIndex = convertValidatorIndexToBuilderIndex(signedVoluntaryExit.message.validatorIndex);
85
+
86
+ if (builderIndex >= state.builders.length) {
87
+ return VoluntaryExitValidity.inactive;
88
+ }
89
+
90
+ const builder = state.builders.getReadonly(builderIndex);
91
+
92
+ // Verify the builder is active
93
+ if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
94
+ return builder.withdrawableEpoch !== FAR_FUTURE_EPOCH
95
+ ? VoluntaryExitValidity.alreadyExited
96
+ : VoluntaryExitValidity.inactive;
97
+ }
98
+
99
+ // Only exit builder if it has no pending withdrawals in the queue
100
+ if (getPendingBalanceToWithdrawForBuilder(state, builderIndex) !== 0) {
101
+ return VoluntaryExitValidity.pendingWithdrawals;
102
+ }
103
+
104
+ // Verify signature
105
+ if (
106
+ verifySignature &&
107
+ !verifyVoluntaryExitSignature(config, epochCtx.pubkeyCache, new BeaconStateView(state), signedVoluntaryExit)
108
+ ) {
109
+ return VoluntaryExitValidity.invalidSignature;
110
+ }
111
+
112
+ return VoluntaryExitValidity.valid;
113
+ }
114
+
115
+ function getValidatorVoluntaryExitValidity(
116
+ fork: ForkSeq,
117
+ state: CachedBeaconStateAllForks,
118
+ signedVoluntaryExit: phase0.SignedVoluntaryExit,
119
+ verifySignature: boolean
98
120
  ): VoluntaryExitValidity {
99
121
  const {config, epochCtx} = state;
100
122
  const voluntaryExit = signedVoluntaryExit.message;
101
- const validator = state.validators.get(voluntaryExit.validatorIndex);
123
+
124
+ if (voluntaryExit.validatorIndex >= state.validators.length) {
125
+ return VoluntaryExitValidity.inactive;
126
+ }
127
+
128
+ const validator = state.validators.getReadonly(voluntaryExit.validatorIndex);
102
129
  const currentEpoch = epochCtx.epoch;
103
130
 
104
131
  // verify the validator is active
@@ -111,11 +138,6 @@ export function getVoluntaryExitValidity(
111
138
  return VoluntaryExitValidity.alreadyExited;
112
139
  }
113
140
 
114
- // exits must specify an epoch when they become valid; they are not valid before then
115
- if (currentEpoch < voluntaryExit.epoch) {
116
- return VoluntaryExitValidity.earlyEpoch;
117
- }
118
-
119
141
  // verify the validator had been active long enough
120
142
  if (currentEpoch < validator.activationEpoch + config.SHARD_COMMITTEE_PERIOD) {
121
143
  return VoluntaryExitValidity.shortTimeActive;
@@ -129,9 +151,10 @@ export function getVoluntaryExitValidity(
129
151
  return VoluntaryExitValidity.pendingWithdrawals;
130
152
  }
131
153
 
154
+ // Verify signature
132
155
  if (
133
156
  verifySignature &&
134
- !verifyVoluntaryExitSignature(state.config, epochCtx.pubkeyCache, state.slot, signedVoluntaryExit)
157
+ !verifyVoluntaryExitSignature(config, epochCtx.pubkeyCache, new BeaconStateView(state), signedVoluntaryExit)
135
158
  ) {
136
159
  return VoluntaryExitValidity.invalidSignature;
137
160
  }
@@ -1,7 +1,11 @@
1
+ import {PublicKey} from "@chainsafe/blst";
1
2
  import {BeaconConfig} from "@lodestar/config";
2
- import {DOMAIN_BEACON_BUILDER} from "@lodestar/params";
3
- import {gloas, ssz} from "@lodestar/types";
3
+ import {BUILDER_INDEX_SELF_BUILD, DOMAIN_BEACON_BUILDER} from "@lodestar/params";
4
+ import {ValidatorIndex, gloas, ssz} from "@lodestar/types";
5
+ import {PubkeyCache} from "../cache/pubkeyCache.js";
6
+ import {IBeaconStateView} from "../stateView/interface.js";
4
7
  import {computeSigningRoot} from "../util/index.js";
8
+ import {type SingleSignatureSet, createSingleSignatureSetFromComponents} from "../util/signatureSets.js";
5
9
 
6
10
  export function getExecutionPayloadEnvelopeSigningRoot(
7
11
  config: BeaconConfig,
@@ -11,3 +15,23 @@ export function getExecutionPayloadEnvelopeSigningRoot(
11
15
 
12
16
  return computeSigningRoot(ssz.gloas.ExecutionPayloadEnvelope, envelope, domain);
13
17
  }
18
+
19
+ export function getExecutionPayloadEnvelopeSignatureSet(
20
+ config: BeaconConfig,
21
+ pubkeyCache: PubkeyCache,
22
+ state: IBeaconStateView,
23
+ signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
24
+ proposerIndex: ValidatorIndex
25
+ ): SingleSignatureSet {
26
+ const envelope = signedEnvelope.message;
27
+ const pubkey =
28
+ envelope.builderIndex === BUILDER_INDEX_SELF_BUILD
29
+ ? pubkeyCache.getOrThrow(proposerIndex)
30
+ : PublicKey.fromBytes(state.getBuilder(envelope.builderIndex).pubkey);
31
+
32
+ return createSingleSignatureSetFromComponents(
33
+ pubkey,
34
+ getExecutionPayloadEnvelopeSigningRoot(config, envelope),
35
+ signedEnvelope.signature
36
+ );
37
+ }
@@ -3,6 +3,7 @@ import {ForkSeq} from "@lodestar/params";
3
3
  import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
4
4
  import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
5
5
  import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
6
+ import {IBeaconStateView} from "../stateView/interface.js";
6
7
  import {ISignatureSet} from "../util/index.js";
7
8
  import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
8
9
  import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js";
@@ -30,6 +31,7 @@ export * from "./voluntaryExits.js";
30
31
  export function getBlockSignatureSets(
31
32
  config: BeaconConfig,
32
33
  currentSyncCommitteeIndexed: SyncCommitteeCache,
34
+ state: IBeaconStateView,
33
35
  signedBlock: SignedBeaconBlock,
34
36
  indexedAttestations: IndexedAttestation[],
35
37
  opts?: {
@@ -45,7 +47,7 @@ export function getBlockSignatureSets(
45
47
  ...getProposerSlashingsSignatureSets(config, signedBlock),
46
48
  ...getAttesterSlashingsSignatureSets(config, signedBlock),
47
49
  ...getAttestationsSignatureSets(config, signedBlock, indexedAttestations),
48
- ...getVoluntaryExitsSignatureSets(config, signedBlock),
50
+ ...getVoluntaryExitsSignatureSets(config, state, signedBlock),
49
51
  ];
50
52
 
51
53
  if (!opts?.skipProposerSignature) {
@@ -1,27 +1,56 @@
1
+ import {PublicKey} from "@chainsafe/blst";
1
2
  import {BeaconConfig} from "@lodestar/config";
3
+ import {ForkSeq} from "@lodestar/params";
2
4
  import {SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
3
5
  import {PubkeyCache} from "../cache/pubkeyCache.js";
6
+ import {IBeaconStateView} from "../stateView/interface.js";
4
7
  import {
5
8
  ISignatureSet,
6
9
  SignatureSetType,
7
10
  computeSigningRoot,
8
11
  computeStartSlotAtEpoch,
12
+ convertValidatorIndexToBuilderIndex,
13
+ isBuilderIndex,
9
14
  verifySignatureSet,
10
15
  } from "../util/index.js";
11
16
 
12
17
  export function verifyVoluntaryExitSignature(
13
18
  config: BeaconConfig,
14
19
  pubkeyCache: PubkeyCache,
15
- stateSlot: Slot,
20
+ state: IBeaconStateView,
16
21
  signedVoluntaryExit: phase0.SignedVoluntaryExit
17
22
  ): boolean {
18
- return verifySignatureSet(getVoluntaryExitSignatureSet(config, stateSlot, signedVoluntaryExit), pubkeyCache);
23
+ return verifySignatureSet(getVoluntaryExitSignatureSet(config, state, signedVoluntaryExit), pubkeyCache);
19
24
  }
20
25
 
21
26
  /**
22
27
  * Extract signatures to allow validating all block signatures at once
23
28
  */
24
29
  export function getVoluntaryExitSignatureSet(
30
+ config: BeaconConfig,
31
+ state: IBeaconStateView,
32
+ signedVoluntaryExit: phase0.SignedVoluntaryExit
33
+ ): ISignatureSet {
34
+ const fork = config.getForkSeq(state.slot);
35
+
36
+ if (fork >= ForkSeq.gloas && isBuilderVoluntaryExit(signedVoluntaryExit)) {
37
+ return getBuilderVoluntaryExitSignatureSet(config, state, signedVoluntaryExit);
38
+ }
39
+
40
+ return getValidatorVoluntaryExitSignatureSet(config, state.slot, signedVoluntaryExit);
41
+ }
42
+
43
+ export function getVoluntaryExitsSignatureSets(
44
+ config: BeaconConfig,
45
+ state: IBeaconStateView,
46
+ signedBlock: SignedBeaconBlock
47
+ ): ISignatureSet[] {
48
+ return signedBlock.message.body.voluntaryExits.map((voluntaryExit) =>
49
+ getVoluntaryExitSignatureSet(config, state, voluntaryExit)
50
+ );
51
+ }
52
+
53
+ export function getValidatorVoluntaryExitSignatureSet(
25
54
  config: BeaconConfig,
26
55
  stateSlot: Slot,
27
56
  signedVoluntaryExit: phase0.SignedVoluntaryExit
@@ -37,11 +66,24 @@ export function getVoluntaryExitSignatureSet(
37
66
  };
38
67
  }
39
68
 
40
- export function getVoluntaryExitsSignatureSets(config: BeaconConfig, signedBlock: SignedBeaconBlock): ISignatureSet[] {
41
- // the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
42
- // and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
43
- const blockSlot = signedBlock.message.slot;
44
- return signedBlock.message.body.voluntaryExits.map((voluntaryExit) =>
45
- getVoluntaryExitSignatureSet(config, blockSlot, voluntaryExit)
46
- );
69
+ export function getBuilderVoluntaryExitSignatureSet(
70
+ config: BeaconConfig,
71
+ state: IBeaconStateView,
72
+ signedVoluntaryExit: phase0.SignedVoluntaryExit
73
+ ): ISignatureSet {
74
+ const messageSlot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
75
+ const domain = config.getDomainForVoluntaryExit(state.slot, messageSlot);
76
+ const builderIndex = convertValidatorIndexToBuilderIndex(signedVoluntaryExit.message.validatorIndex);
77
+ const builder = state.getBuilder(builderIndex);
78
+
79
+ return {
80
+ type: SignatureSetType.single,
81
+ pubkey: PublicKey.fromBytes(builder.pubkey),
82
+ signingRoot: computeSigningRoot(ssz.phase0.VoluntaryExit, signedVoluntaryExit.message, domain),
83
+ signature: signedVoluntaryExit.signature,
84
+ };
85
+ }
86
+
87
+ export function isBuilderVoluntaryExit(signedVoluntaryExit: phase0.SignedVoluntaryExit): boolean {
88
+ return isBuilderIndex(signedVoluntaryExit.message.validatorIndex);
47
89
  }
@@ -3,6 +3,7 @@ import {ForkSeq} from "@lodestar/params";
3
3
  import {ssz} from "@lodestar/types";
4
4
  import {getAttestationParticipationStatus} from "../block/processAttestationsAltair.js";
5
5
  import {getCachedBeaconState} from "../cache/stateCache.js";
6
+ import {BeaconStateView} from "../stateView/beaconStateView.js";
6
7
  import {CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../types.js";
7
8
  import {RootCache, newZeroedArray} from "../util/index.js";
8
9
  import {getNextSyncCommittee} from "../util/syncCommittee.js";
@@ -125,7 +126,7 @@ function translateParticipation(
125
126
  pendingAttesations: CompositeViewDU<typeof ssz.phase0.EpochAttestations>
126
127
  ): void {
127
128
  const {epochCtx} = state;
128
- const rootCache = new RootCache(state);
129
+ const rootCache = new RootCache(new BeaconStateView(state));
129
130
  const epochParticipation = state.previousEpochParticipation;
130
131
 
131
132
  for (const attestation of pendingAttesations.getAllReadonly()) {