@lodestar/state-transition 1.39.0-dev.84b481ddb5 → 1.39.0-dev.aceb5b7416

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 (89) hide show
  1. package/lib/block/index.d.ts.map +1 -1
  2. package/lib/block/index.js +2 -4
  3. package/lib/block/index.js.map +1 -1
  4. package/lib/block/isValidIndexedAttestation.d.ts +2 -3
  5. package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
  6. package/lib/block/isValidIndexedAttestation.js +4 -4
  7. package/lib/block/isValidIndexedAttestation.js.map +1 -1
  8. package/lib/block/processAttestationPhase0.d.ts.map +1 -1
  9. package/lib/block/processAttestationPhase0.js +1 -1
  10. package/lib/block/processAttestationPhase0.js.map +1 -1
  11. package/lib/block/processAttestationsAltair.d.ts.map +1 -1
  12. package/lib/block/processAttestationsAltair.js +1 -1
  13. package/lib/block/processAttestationsAltair.js.map +1 -1
  14. package/lib/block/processAttesterSlashing.js +1 -1
  15. package/lib/block/processAttesterSlashing.js.map +1 -1
  16. package/lib/block/processExecutionPayload.d.ts.map +1 -1
  17. package/lib/block/processExecutionPayload.js +4 -6
  18. package/lib/block/processExecutionPayload.js.map +1 -1
  19. package/lib/block/processProposerSlashing.d.ts.map +1 -1
  20. package/lib/block/processProposerSlashing.js +1 -1
  21. package/lib/block/processProposerSlashing.js.map +1 -1
  22. package/lib/block/processRandao.js +1 -1
  23. package/lib/block/processRandao.js.map +1 -1
  24. package/lib/block/processSyncCommittee.d.ts +1 -2
  25. package/lib/block/processSyncCommittee.d.ts.map +1 -1
  26. package/lib/block/processSyncCommittee.js +3 -3
  27. package/lib/block/processSyncCommittee.js.map +1 -1
  28. package/lib/block/processVoluntaryExit.d.ts.map +1 -1
  29. package/lib/block/processVoluntaryExit.js +1 -2
  30. package/lib/block/processVoluntaryExit.js.map +1 -1
  31. package/lib/cache/stateCache.d.ts +0 -1
  32. package/lib/cache/stateCache.d.ts.map +1 -1
  33. package/lib/cache/stateCache.js.map +1 -1
  34. package/lib/signatureSets/attesterSlashings.d.ts +3 -4
  35. package/lib/signatureSets/attesterSlashings.d.ts.map +1 -1
  36. package/lib/signatureSets/attesterSlashings.js +6 -6
  37. package/lib/signatureSets/attesterSlashings.js.map +1 -1
  38. package/lib/signatureSets/index.d.ts +1 -2
  39. package/lib/signatureSets/index.d.ts.map +1 -1
  40. package/lib/signatureSets/index.js +8 -8
  41. package/lib/signatureSets/index.js.map +1 -1
  42. package/lib/signatureSets/indexedAttestation.d.ts +4 -5
  43. package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
  44. package/lib/signatureSets/indexedAttestation.js +8 -8
  45. package/lib/signatureSets/indexedAttestation.js.map +1 -1
  46. package/lib/signatureSets/proposer.d.ts +2 -3
  47. package/lib/signatureSets/proposer.d.ts.map +1 -1
  48. package/lib/signatureSets/proposer.js +4 -3
  49. package/lib/signatureSets/proposer.js.map +1 -1
  50. package/lib/signatureSets/proposerSlashings.d.ts +2 -3
  51. package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
  52. package/lib/signatureSets/proposerSlashings.js +4 -4
  53. package/lib/signatureSets/proposerSlashings.js.map +1 -1
  54. package/lib/signatureSets/randao.d.ts +2 -3
  55. package/lib/signatureSets/randao.d.ts.map +1 -1
  56. package/lib/signatureSets/randao.js +4 -4
  57. package/lib/signatureSets/randao.js.map +1 -1
  58. package/lib/signatureSets/voluntaryExits.d.ts +3 -4
  59. package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
  60. package/lib/signatureSets/voluntaryExits.js +6 -6
  61. package/lib/signatureSets/voluntaryExits.js.map +1 -1
  62. package/lib/stateTransition.d.ts.map +1 -1
  63. package/lib/stateTransition.js +1 -2
  64. package/lib/stateTransition.js.map +1 -1
  65. package/lib/util/execution.d.ts +1 -11
  66. package/lib/util/execution.d.ts.map +1 -1
  67. package/lib/util/execution.js +1 -26
  68. package/lib/util/execution.js.map +1 -1
  69. package/package.json +6 -6
  70. package/src/block/index.ts +2 -6
  71. package/src/block/isValidIndexedAttestation.ts +2 -5
  72. package/src/block/processAttestationPhase0.ts +0 -1
  73. package/src/block/processAttestationsAltair.ts +1 -7
  74. package/src/block/processAttesterSlashing.ts +1 -1
  75. package/src/block/processExecutionPayload.ts +8 -14
  76. package/src/block/processProposerSlashing.ts +1 -6
  77. package/src/block/processRandao.ts +1 -1
  78. package/src/block/processSyncCommittee.ts +2 -10
  79. package/src/block/processVoluntaryExit.ts +1 -4
  80. package/src/cache/stateCache.ts +0 -1
  81. package/src/signatureSets/attesterSlashings.ts +3 -7
  82. package/src/signatureSets/index.ts +6 -9
  83. package/src/signatureSets/indexedAttestation.ts +3 -9
  84. package/src/signatureSets/proposer.ts +2 -4
  85. package/src/signatureSets/proposerSlashings.ts +6 -5
  86. package/src/signatureSets/randao.ts +2 -5
  87. package/src/signatureSets/voluntaryExits.ts +3 -7
  88. package/src/stateTransition.ts +1 -4
  89. package/src/util/execution.ts +0 -39
@@ -3,11 +3,7 @@ import {ForkName, ForkSeq, isForkPostDeneb} from "@lodestar/params";
3
3
  import {BeaconBlockBody, BlindedBeaconBlockBody, deneb, isExecutionPayload} from "@lodestar/types";
4
4
  import {toHex, toRootHex} from "@lodestar/utils";
5
5
  import {CachedBeaconStateBellatrix, CachedBeaconStateCapella} from "../types.js";
6
- import {
7
- executionPayloadToPayloadHeader,
8
- getFullOrBlindedPayloadFromBody,
9
- isMergeTransitionComplete,
10
- } from "../util/execution.js";
6
+ import {executionPayloadToPayloadHeader, getFullOrBlindedPayloadFromBody} from "../util/execution.js";
11
7
  import {computeEpochAtSlot, computeTimeAtSlot, getRandaoMix} from "../util/index.js";
12
8
  import {BlockExternalData, ExecutionPayloadStatus} from "./externalData.js";
13
9
 
@@ -21,15 +17,13 @@ export function processExecutionPayload(
21
17
  const forkName = ForkName[ForkSeq[fork] as ForkName];
22
18
  // Verify consistency of the parent hash, block number, base fee per gas and gas limit
23
19
  // with respect to the previous execution payload header
24
- if (isMergeTransitionComplete(state)) {
25
- const {latestExecutionPayloadHeader} = state;
26
- if (!byteArrayEquals(payload.parentHash, latestExecutionPayloadHeader.blockHash)) {
27
- throw Error(
28
- `Invalid execution payload parentHash ${toRootHex(payload.parentHash)} latest blockHash ${toRootHex(
29
- latestExecutionPayloadHeader.blockHash
30
- )}`
31
- );
32
- }
20
+ const {latestExecutionPayloadHeader} = state;
21
+ if (!byteArrayEquals(payload.parentHash, latestExecutionPayloadHeader.blockHash)) {
22
+ throw Error(
23
+ `Invalid execution payload parentHash ${toRootHex(payload.parentHash)} latest blockHash ${toRootHex(
24
+ latestExecutionPayloadHeader.blockHash
25
+ )}`
26
+ );
33
27
  }
34
28
 
35
29
  // Verify random
@@ -77,12 +77,7 @@ export function assertValidProposerSlashing(
77
77
 
78
78
  // verify signatures
79
79
  if (verifySignatures) {
80
- const signatureSets = getProposerSlashingSignatureSets(
81
- state.config,
82
- state.epochCtx.index2pubkey,
83
- state,
84
- proposerSlashing
85
- );
80
+ const signatureSets = getProposerSlashingSignatureSets(state.epochCtx.index2pubkey, state, proposerSlashing);
86
81
  for (let i = 0; i < signatureSets.length; i++) {
87
82
  if (!verifySignatureSet(signatureSets[i])) {
88
83
  throw new Error(`ProposerSlashing header${i + 1} signature invalid`);
@@ -17,7 +17,7 @@ export function processRandao(state: CachedBeaconStateAllForks, block: BeaconBlo
17
17
  const randaoReveal = block.body.randaoReveal;
18
18
 
19
19
  // verify RANDAO reveal
20
- if (verifySignature && !verifyRandaoSignature(state.config, epochCtx.index2pubkey, state, block)) {
20
+ if (verifySignature && !verifyRandaoSignature(epochCtx.index2pubkey, state, block)) {
21
21
  throw new Error("RANDAO reveal is an invalid signature");
22
22
  }
23
23
 
@@ -1,5 +1,4 @@
1
1
  import {byteArrayEquals} from "@chainsafe/ssz";
2
- import {BeaconConfig} from "@lodestar/config";
3
2
  import {DOMAIN_SYNC_COMMITTEE, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
4
3
  import {altair, ssz} from "@lodestar/types";
5
4
  import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
@@ -25,13 +24,7 @@ export function processSyncAggregate(
25
24
  if (verifySignatures) {
26
25
  // This is to conform to the spec - we want the signature to be verified
27
26
  const participantIndices = block.body.syncAggregate.syncCommitteeBits.intersectValues(committeeIndices);
28
- const signatureSet = getSyncCommitteeSignatureSet(
29
- state.config,
30
- state.epochCtx.index2pubkey,
31
- state,
32
- block,
33
- participantIndices
34
- );
27
+ const signatureSet = getSyncCommitteeSignatureSet(state.epochCtx.index2pubkey, state, block, participantIndices);
35
28
  // When there's no participation we consider the signature valid and just ignore i
36
29
  if (signatureSet !== null && !verifySignatureSet(signatureSet)) {
37
30
  throw Error("Sync committee signature invalid");
@@ -71,7 +64,6 @@ export function processSyncAggregate(
71
64
  }
72
65
 
73
66
  export function getSyncCommitteeSignatureSet(
74
- config: BeaconConfig,
75
67
  index2pubkey: Index2PubkeyCache,
76
68
  state: CachedBeaconStateAllForks,
77
69
  block: altair.BeaconBlock,
@@ -115,7 +107,7 @@ export function getSyncCommitteeSignatureSet(
115
107
  throw Error("Empty sync committee signature is not infinity");
116
108
  }
117
109
 
118
- const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE, previousSlot);
110
+ const domain = state.config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE, previousSlot);
119
111
 
120
112
  return {
121
113
  type: SignatureSetType.aggregate,
@@ -74,10 +74,7 @@ export function getVoluntaryExitValidity(
74
74
  return VoluntaryExitValidity.pendingWithdrawals;
75
75
  }
76
76
 
77
- if (
78
- verifySignature &&
79
- !verifyVoluntaryExitSignature(state.config, epochCtx.index2pubkey, state, signedVoluntaryExit)
80
- ) {
77
+ if (verifySignature && !verifyVoluntaryExitSignature(epochCtx.index2pubkey, state, signedVoluntaryExit)) {
81
78
  return VoluntaryExitValidity.invalidSignature;
82
79
  }
83
80
 
@@ -17,7 +17,6 @@ import {
17
17
  } from "./types.js";
18
18
 
19
19
  export type BeaconStateCache = {
20
- /** @deprecated should not access config outside of state-transition package */
21
20
  config: BeaconConfig;
22
21
  epochCtx: EpochCache;
23
22
  /** Count of clones created from this BeaconStateCache instance. readonly to prevent accidental usage downstream */
@@ -1,4 +1,3 @@
1
- import {BeaconConfig} from "@lodestar/config";
2
1
  import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params";
3
2
  import {AttesterSlashing, IndexedAttestationBigint, SignedBeaconBlock, ssz} from "@lodestar/types";
4
3
  import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
@@ -7,36 +6,33 @@ import {ISignatureSet, SignatureSetType, computeSigningRoot, computeStartSlotAtE
7
6
 
8
7
  /** Get signature sets from all AttesterSlashing objects in a block */
9
8
  export function getAttesterSlashingsSignatureSets(
10
- config: BeaconConfig,
11
9
  index2pubkey: Index2PubkeyCache,
12
10
  state: CachedBeaconStateAllForks,
13
11
  signedBlock: SignedBeaconBlock
14
12
  ): ISignatureSet[] {
15
13
  return signedBlock.message.body.attesterSlashings.flatMap((attesterSlashing) =>
16
- getAttesterSlashingSignatureSets(config, index2pubkey, state, attesterSlashing)
14
+ getAttesterSlashingSignatureSets(index2pubkey, state, attesterSlashing)
17
15
  );
18
16
  }
19
17
 
20
18
  /** Get signature sets from a single AttesterSlashing object */
21
19
  export function getAttesterSlashingSignatureSets(
22
- config: BeaconConfig,
23
20
  index2pubkey: Index2PubkeyCache,
24
21
  state: CachedBeaconStateAllForks,
25
22
  attesterSlashing: AttesterSlashing
26
23
  ): ISignatureSet[] {
27
24
  return [attesterSlashing.attestation1, attesterSlashing.attestation2].map((attestation) =>
28
- getIndexedAttestationBigintSignatureSet(config, index2pubkey, state, attestation)
25
+ getIndexedAttestationBigintSignatureSet(index2pubkey, state, attestation)
29
26
  );
30
27
  }
31
28
 
32
29
  export function getIndexedAttestationBigintSignatureSet(
33
- config: BeaconConfig,
34
30
  index2pubkey: Index2PubkeyCache,
35
31
  state: CachedBeaconStateAllForks,
36
32
  indexedAttestation: IndexedAttestationBigint
37
33
  ): ISignatureSet {
38
34
  const slot = computeStartSlotAtEpoch(Number(indexedAttestation.data.target.epoch as bigint));
39
- const domain = config.getDomain(state.slot, DOMAIN_BEACON_ATTESTER, slot);
35
+ const domain = state.config.getDomain(state.slot, DOMAIN_BEACON_ATTESTER, slot);
40
36
 
41
37
  return {
42
38
  type: SignatureSetType.aggregate,
@@ -1,4 +1,3 @@
1
- import {BeaconConfig} from "@lodestar/config";
2
1
  import {ForkSeq} from "@lodestar/params";
3
2
  import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
4
3
  import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
@@ -27,7 +26,6 @@ export * from "./voluntaryExits.js";
27
26
  * Deposits are not included because they can legally have invalid signatures.
28
27
  */
29
28
  export function getBlockSignatureSets(
30
- config: BeaconConfig,
31
29
  index2pubkey: Index2PubkeyCache,
32
30
  state: CachedBeaconStateAllForks,
33
31
  signedBlock: SignedBeaconBlock,
@@ -41,21 +39,20 @@ export function getBlockSignatureSets(
41
39
  const fork = state.config.getForkSeq(signedBlock.message.slot);
42
40
 
43
41
  const signatureSets = [
44
- getRandaoRevealSignatureSet(config, index2pubkey, state, signedBlock.message),
45
- ...getProposerSlashingsSignatureSets(config, index2pubkey, state, signedBlock),
46
- ...getAttesterSlashingsSignatureSets(config, index2pubkey, state, signedBlock),
47
- ...getAttestationsSignatureSets(config, index2pubkey, state, signedBlock, indexedAttestations),
48
- ...getVoluntaryExitsSignatureSets(config, index2pubkey, state, signedBlock),
42
+ getRandaoRevealSignatureSet(index2pubkey, state, signedBlock.message),
43
+ ...getProposerSlashingsSignatureSets(index2pubkey, state, signedBlock),
44
+ ...getAttesterSlashingsSignatureSets(index2pubkey, state, signedBlock),
45
+ ...getAttestationsSignatureSets(index2pubkey, state, signedBlock, indexedAttestations),
46
+ ...getVoluntaryExitsSignatureSets(index2pubkey, state, signedBlock),
49
47
  ];
50
48
 
51
49
  if (!opts?.skipProposerSignature) {
52
- signatureSets.push(getBlockProposerSignatureSet(config, index2pubkey, state, signedBlock));
50
+ signatureSets.push(getBlockProposerSignatureSet(index2pubkey, state, signedBlock));
53
51
  }
54
52
 
55
53
  // Only after altair fork, validate tSyncCommitteeSignature
56
54
  if (fork >= ForkSeq.altair) {
57
55
  const syncCommitteeSignatureSet = getSyncCommitteeSignatureSet(
58
- config,
59
56
  index2pubkey,
60
57
  state as CachedBeaconStateAltair,
61
58
  (signedBlock as altair.SignedBeaconBlock).message
@@ -1,4 +1,3 @@
1
- import {BeaconConfig} from "@lodestar/config";
2
1
  import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params";
3
2
  import {IndexedAttestation, SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
4
3
  import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
@@ -11,18 +10,16 @@ import {
11
10
  } from "../util/index.js";
12
11
 
13
12
  export function getAttestationDataSigningRoot(
14
- config: BeaconConfig,
15
13
  state: CachedBeaconStateAllForks,
16
14
  data: phase0.AttestationData
17
15
  ): Uint8Array {
18
16
  const slot = computeStartSlotAtEpoch(data.target.epoch);
19
- const domain = config.getDomain(state.slot, DOMAIN_BEACON_ATTESTER, slot);
17
+ const domain = state.config.getDomain(state.slot, DOMAIN_BEACON_ATTESTER, slot);
20
18
 
21
19
  return computeSigningRoot(ssz.phase0.AttestationData, data, domain);
22
20
  }
23
21
 
24
22
  export function getAttestationWithIndicesSignatureSet(
25
- config: BeaconConfig,
26
23
  index2pubkey: Index2PubkeyCache,
27
24
  state: CachedBeaconStateAllForks,
28
25
  attestation: Pick<phase0.Attestation, "data" | "signature">,
@@ -30,19 +27,17 @@ export function getAttestationWithIndicesSignatureSet(
30
27
  ): ISignatureSet {
31
28
  return createAggregateSignatureSetFromComponents(
32
29
  attestingIndices.map((i) => index2pubkey[i]),
33
- getAttestationDataSigningRoot(config, state, attestation.data),
30
+ getAttestationDataSigningRoot(state, attestation.data),
34
31
  attestation.signature
35
32
  );
36
33
  }
37
34
 
38
35
  export function getIndexedAttestationSignatureSet(
39
- config: BeaconConfig,
40
36
  index2pubkey: Index2PubkeyCache,
41
37
  state: CachedBeaconStateAllForks,
42
38
  indexedAttestation: IndexedAttestation
43
39
  ): ISignatureSet {
44
40
  return getAttestationWithIndicesSignatureSet(
45
- config,
46
41
  index2pubkey,
47
42
  state,
48
43
  indexedAttestation,
@@ -51,7 +46,6 @@ export function getIndexedAttestationSignatureSet(
51
46
  }
52
47
 
53
48
  export function getAttestationsSignatureSets(
54
- config: BeaconConfig,
55
49
  index2pubkey: Index2PubkeyCache,
56
50
  state: CachedBeaconStateAllForks,
57
51
  signedBlock: SignedBeaconBlock,
@@ -63,6 +57,6 @@ export function getAttestationsSignatureSets(
63
57
  );
64
58
  }
65
59
  return indexedAttestations.map((indexedAttestation) =>
66
- getIndexedAttestationSignatureSet(config, index2pubkey, state, indexedAttestation)
60
+ getIndexedAttestationSignatureSet(index2pubkey, state, indexedAttestation)
67
61
  );
68
62
  }
@@ -1,4 +1,3 @@
1
- import {BeaconConfig} from "@lodestar/config";
2
1
  import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
3
2
  import {SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, isBlindedBeaconBlock, phase0, ssz} from "@lodestar/types";
4
3
  import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
@@ -7,21 +6,20 @@ import {computeSigningRoot} from "../util/index.js";
7
6
  import {ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/signatureSets.js";
8
7
 
9
8
  export function verifyProposerSignature(
10
- config: BeaconConfig,
11
9
  index2pubkey: Index2PubkeyCache,
12
10
  state: CachedBeaconStateAllForks,
13
11
  signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
14
12
  ): boolean {
15
- const signatureSet = getBlockProposerSignatureSet(config, index2pubkey, state, signedBlock);
13
+ const signatureSet = getBlockProposerSignatureSet(index2pubkey, state, signedBlock);
16
14
  return verifySignatureSet(signatureSet);
17
15
  }
18
16
 
19
17
  export function getBlockProposerSignatureSet(
20
- config: BeaconConfig,
21
18
  index2pubkey: Index2PubkeyCache,
22
19
  state: CachedBeaconStateAllForks,
23
20
  signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
24
21
  ): ISignatureSet {
22
+ const {config} = state;
25
23
  const domain = config.getDomain(state.slot, DOMAIN_BEACON_PROPOSER, signedBlock.message.slot);
26
24
 
27
25
  const blockType = isBlindedBeaconBlock(signedBlock.message)
@@ -1,4 +1,3 @@
1
- import {BeaconConfig} from "@lodestar/config";
2
1
  import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
3
2
  import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
4
3
  import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
@@ -9,7 +8,6 @@ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index
9
8
  * Extract signatures to allow validating all block signatures at once
10
9
  */
11
10
  export function getProposerSlashingSignatureSets(
12
- config: BeaconConfig,
13
11
  index2pubkey: Index2PubkeyCache,
14
12
  state: CachedBeaconStateAllForks,
15
13
  proposerSlashing: phase0.ProposerSlashing
@@ -19,7 +17,11 @@ export function getProposerSlashingSignatureSets(
19
17
  // In state transition, ProposerSlashing headers are only partially validated. Their slot could be higher than the
20
18
  // clock and the slashing would still be valid. Must use bigint variants to hash correctly to all possible values
21
19
  return [proposerSlashing.signedHeader1, proposerSlashing.signedHeader2].map((signedHeader): ISignatureSet => {
22
- const domain = config.getDomain(state.slot, DOMAIN_BEACON_PROPOSER, Number(signedHeader.message.slot as bigint));
20
+ const domain = state.config.getDomain(
21
+ state.slot,
22
+ DOMAIN_BEACON_PROPOSER,
23
+ Number(signedHeader.message.slot as bigint)
24
+ );
23
25
 
24
26
  return {
25
27
  type: SignatureSetType.single,
@@ -31,12 +33,11 @@ export function getProposerSlashingSignatureSets(
31
33
  }
32
34
 
33
35
  export function getProposerSlashingsSignatureSets(
34
- config: BeaconConfig,
35
36
  index2pubkey: Index2PubkeyCache,
36
37
  state: CachedBeaconStateAllForks,
37
38
  signedBlock: SignedBeaconBlock
38
39
  ): ISignatureSet[] {
39
40
  return signedBlock.message.body.proposerSlashings.flatMap((proposerSlashing) =>
40
- getProposerSlashingSignatureSets(config, index2pubkey, state, proposerSlashing)
41
+ getProposerSlashingSignatureSets(index2pubkey, state, proposerSlashing)
41
42
  );
42
43
  }
@@ -1,4 +1,3 @@
1
- import {BeaconConfig} from "@lodestar/config";
2
1
  import {DOMAIN_RANDAO} from "@lodestar/params";
3
2
  import {BeaconBlock, ssz} from "@lodestar/types";
4
3
  import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
@@ -12,26 +11,24 @@ import {
12
11
  } from "../util/index.js";
13
12
 
14
13
  export function verifyRandaoSignature(
15
- config: BeaconConfig,
16
14
  index2pubkey: Index2PubkeyCache,
17
15
  state: CachedBeaconStateAllForks,
18
16
  block: BeaconBlock
19
17
  ): boolean {
20
- return verifySignatureSet(getRandaoRevealSignatureSet(config, index2pubkey, state, block));
18
+ return verifySignatureSet(getRandaoRevealSignatureSet(index2pubkey, state, block));
21
19
  }
22
20
 
23
21
  /**
24
22
  * Extract signatures to allow validating all block signatures at once
25
23
  */
26
24
  export function getRandaoRevealSignatureSet(
27
- config: BeaconConfig,
28
25
  index2pubkey: Index2PubkeyCache,
29
26
  state: CachedBeaconStateAllForks,
30
27
  block: BeaconBlock
31
28
  ): ISignatureSet {
32
29
  // should not get epoch from epochCtx
33
30
  const epoch = computeEpochAtSlot(block.slot);
34
- const domain = config.getDomain(state.slot, DOMAIN_RANDAO, block.slot);
31
+ const domain = state.config.getDomain(state.slot, DOMAIN_RANDAO, block.slot);
35
32
 
36
33
  return {
37
34
  type: SignatureSetType.single,
@@ -1,4 +1,3 @@
1
- import {BeaconConfig} from "@lodestar/config";
2
1
  import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
3
2
  import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
4
3
  import {CachedBeaconStateAllForks} from "../types.js";
@@ -11,25 +10,23 @@ import {
11
10
  } from "../util/index.js";
12
11
 
13
12
  export function verifyVoluntaryExitSignature(
14
- config: BeaconConfig,
15
13
  index2pubkey: Index2PubkeyCache,
16
14
  state: CachedBeaconStateAllForks,
17
15
  signedVoluntaryExit: phase0.SignedVoluntaryExit
18
16
  ): boolean {
19
- return verifySignatureSet(getVoluntaryExitSignatureSet(config, index2pubkey, state, signedVoluntaryExit));
17
+ return verifySignatureSet(getVoluntaryExitSignatureSet(index2pubkey, state, signedVoluntaryExit));
20
18
  }
21
19
 
22
20
  /**
23
21
  * Extract signatures to allow validating all block signatures at once
24
22
  */
25
23
  export function getVoluntaryExitSignatureSet(
26
- config: BeaconConfig,
27
24
  index2pubkey: Index2PubkeyCache,
28
25
  state: CachedBeaconStateAllForks,
29
26
  signedVoluntaryExit: phase0.SignedVoluntaryExit
30
27
  ): ISignatureSet {
31
28
  const slot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
32
- const domain = config.getDomainForVoluntaryExit(state.slot, slot);
29
+ const domain = state.config.getDomainForVoluntaryExit(state.slot, slot);
33
30
 
34
31
  return {
35
32
  type: SignatureSetType.single,
@@ -40,12 +37,11 @@ export function getVoluntaryExitSignatureSet(
40
37
  }
41
38
 
42
39
  export function getVoluntaryExitsSignatureSets(
43
- config: BeaconConfig,
44
40
  index2pubkey: Index2PubkeyCache,
45
41
  state: CachedBeaconStateAllForks,
46
42
  signedBlock: SignedBeaconBlock
47
43
  ): ISignatureSet[] {
48
44
  return signedBlock.message.body.voluntaryExits.map((voluntaryExit) =>
49
- getVoluntaryExitSignatureSet(config, index2pubkey, state, voluntaryExit)
45
+ getVoluntaryExitSignatureSet(index2pubkey, state, voluntaryExit)
50
46
  );
51
47
  }
@@ -111,10 +111,7 @@ export function stateTransition(
111
111
  postState = processSlotsWithTransientCache(postState, blockSlot, options, {metrics, validatorMonitor});
112
112
 
113
113
  // Verify proposer signature only
114
- if (
115
- verifyProposer &&
116
- !verifyProposerSignature(postState.config, postState.epochCtx.index2pubkey, postState, signedBlock)
117
- ) {
114
+ if (verifyProposer && !verifyProposerSignature(postState.epochCtx.index2pubkey, postState, signedBlock)) {
118
115
  throw new Error("Invalid block signature");
119
116
  }
120
117
 
@@ -2,7 +2,6 @@ import {ForkName, ForkPostBellatrix, ForkPreGloas, ForkSeq} from "@lodestar/para
2
2
  import {
3
3
  BeaconBlock,
4
4
  BeaconBlockBody,
5
- BlindedBeaconBlock,
6
5
  BlindedBeaconBlockBody,
7
6
  ExecutionPayload,
8
7
  ExecutionPayloadHeader,
@@ -10,54 +9,16 @@ import {
10
9
  capella,
11
10
  deneb,
12
11
  isBlindedBeaconBlockBody,
13
- isExecutionPayload,
14
12
  ssz,
15
13
  } from "@lodestar/types";
16
14
  import {
17
15
  BeaconStateAllForks,
18
- BeaconStateBellatrix,
19
16
  BeaconStateCapella,
20
17
  BeaconStateExecutions,
21
18
  CachedBeaconStateAllForks,
22
19
  CachedBeaconStateExecutions,
23
20
  } from "../types.js";
24
21
 
25
- /**
26
- * Execution enabled = merge is done.
27
- * When (A) state has execution data OR (B) block has execution data
28
- */
29
- export function isExecutionEnabled(state: BeaconStateExecutions, block: BeaconBlock | BlindedBeaconBlock): boolean {
30
- if (isMergeTransitionComplete(state)) {
31
- return true;
32
- }
33
-
34
- // Throws if not post-bellatrix block. A fork-guard before isExecutionEnabled() prevents this from happening
35
- const payload = getFullOrBlindedPayload(block);
36
-
37
- return isExecutionPayload(payload)
38
- ? !ssz.bellatrix.ExecutionPayload.equals(payload, ssz.bellatrix.ExecutionPayload.defaultValue())
39
- : !ssz.bellatrix.ExecutionPayloadHeader.equals(
40
- state.latestExecutionPayloadHeader,
41
- ssz.bellatrix.ExecutionPayloadHeader.defaultValue()
42
- );
43
- }
44
-
45
- /**
46
- * Merge is complete when the state includes execution layer data:
47
- * state.latestExecutionPayloadHeader NOT EMPTY or state is post-capella
48
- */
49
- export function isMergeTransitionComplete(state: BeaconStateExecutions): boolean {
50
- if (isCapellaStateType(state)) {
51
- // All networks have completed the merge transition before capella
52
- return true;
53
- }
54
-
55
- return !ssz.bellatrix.ExecutionPayloadHeader.equals(
56
- (state as BeaconStateBellatrix).latestExecutionPayloadHeader,
57
- ssz.bellatrix.ExecutionPayloadHeader.defaultValue()
58
- );
59
- }
60
-
61
22
  /** Type guard for bellatrix.BeaconState */
62
23
  export function isExecutionStateType(state: BeaconStateAllForks): state is BeaconStateExecutions {
63
24
  return (state as BeaconStateExecutions).latestExecutionPayloadHeader !== undefined;