@lodestar/state-transition 1.38.0 → 1.39.0-dev.39dac0f03d

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 (91) hide show
  1. package/lib/block/index.js +2 -2
  2. package/lib/block/index.js.map +1 -1
  3. package/lib/block/isValidIndexedAttestation.d.ts +4 -2
  4. package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
  5. package/lib/block/isValidIndexedAttestation.js +4 -4
  6. package/lib/block/isValidIndexedAttestation.js.map +1 -1
  7. package/lib/block/processAttestationPhase0.d.ts.map +1 -1
  8. package/lib/block/processAttestationPhase0.js +1 -1
  9. package/lib/block/processAttestationPhase0.js.map +1 -1
  10. package/lib/block/processAttestationsAltair.d.ts.map +1 -1
  11. package/lib/block/processAttestationsAltair.js +1 -1
  12. package/lib/block/processAttestationsAltair.js.map +1 -1
  13. package/lib/block/processAttesterSlashing.d.ts +2 -1
  14. package/lib/block/processAttesterSlashing.d.ts.map +1 -1
  15. package/lib/block/processAttesterSlashing.js +5 -4
  16. package/lib/block/processAttesterSlashing.js.map +1 -1
  17. package/lib/block/processProposerSlashing.d.ts.map +1 -1
  18. package/lib/block/processProposerSlashing.js +1 -1
  19. package/lib/block/processProposerSlashing.js.map +1 -1
  20. package/lib/block/processRandao.js +1 -1
  21. package/lib/block/processRandao.js.map +1 -1
  22. package/lib/block/processSyncCommittee.d.ts +3 -1
  23. package/lib/block/processSyncCommittee.d.ts.map +1 -1
  24. package/lib/block/processSyncCommittee.js +4 -5
  25. package/lib/block/processSyncCommittee.js.map +1 -1
  26. package/lib/block/processVoluntaryExit.d.ts.map +1 -1
  27. package/lib/block/processVoluntaryExit.js +2 -1
  28. package/lib/block/processVoluntaryExit.js.map +1 -1
  29. package/lib/cache/epochCache.d.ts +0 -3
  30. package/lib/cache/epochCache.d.ts.map +1 -1
  31. package/lib/cache/epochCache.js +0 -3
  32. package/lib/cache/epochCache.js.map +1 -1
  33. package/lib/cache/stateCache.d.ts +1 -0
  34. package/lib/cache/stateCache.d.ts.map +1 -1
  35. package/lib/cache/stateCache.js.map +1 -1
  36. package/lib/signatureSets/attesterSlashings.d.ts +5 -3
  37. package/lib/signatureSets/attesterSlashings.d.ts.map +1 -1
  38. package/lib/signatureSets/attesterSlashings.js +7 -7
  39. package/lib/signatureSets/attesterSlashings.js.map +1 -1
  40. package/lib/signatureSets/index.d.ts +4 -2
  41. package/lib/signatureSets/index.d.ts.map +1 -1
  42. package/lib/signatureSets/index.js +8 -8
  43. package/lib/signatureSets/index.js.map +1 -1
  44. package/lib/signatureSets/indexedAttestation.d.ts +6 -4
  45. package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
  46. package/lib/signatureSets/indexedAttestation.js +8 -8
  47. package/lib/signatureSets/indexedAttestation.js.map +1 -1
  48. package/lib/signatureSets/proposer.d.ts +6 -4
  49. package/lib/signatureSets/proposer.d.ts.map +1 -1
  50. package/lib/signatureSets/proposer.js +11 -12
  51. package/lib/signatureSets/proposer.js.map +1 -1
  52. package/lib/signatureSets/proposerSlashings.d.ts +4 -2
  53. package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
  54. package/lib/signatureSets/proposerSlashings.js +5 -6
  55. package/lib/signatureSets/proposerSlashings.js.map +1 -1
  56. package/lib/signatureSets/randao.d.ts +4 -2
  57. package/lib/signatureSets/randao.d.ts.map +1 -1
  58. package/lib/signatureSets/randao.js +5 -6
  59. package/lib/signatureSets/randao.js.map +1 -1
  60. package/lib/signatureSets/voluntaryExits.d.ts +5 -3
  61. package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
  62. package/lib/signatureSets/voluntaryExits.js +7 -8
  63. package/lib/signatureSets/voluntaryExits.js.map +1 -1
  64. package/lib/stateTransition.d.ts.map +1 -1
  65. package/lib/stateTransition.js +2 -1
  66. package/lib/stateTransition.js.map +1 -1
  67. package/lib/util/execution.d.ts +2 -7
  68. package/lib/util/execution.d.ts.map +1 -1
  69. package/lib/util/execution.js +7 -25
  70. package/lib/util/execution.js.map +1 -1
  71. package/package.json +6 -6
  72. package/src/block/index.ts +1 -1
  73. package/src/block/isValidIndexedAttestation.ts +8 -2
  74. package/src/block/processAttestationPhase0.ts +9 -1
  75. package/src/block/processAttestationsAltair.ts +7 -1
  76. package/src/block/processAttesterSlashing.ts +6 -3
  77. package/src/block/processProposerSlashing.ts +6 -1
  78. package/src/block/processRandao.ts +1 -1
  79. package/src/block/processSyncCommittee.ts +13 -4
  80. package/src/block/processVoluntaryExit.ts +4 -1
  81. package/src/cache/epochCache.ts +0 -3
  82. package/src/cache/stateCache.ts +1 -0
  83. package/src/signatureSets/attesterSlashings.ts +12 -4
  84. package/src/signatureSets/index.ts +13 -7
  85. package/src/signatureSets/indexedAttestation.ts +22 -5
  86. package/src/signatureSets/proposer.ts +15 -7
  87. package/src/signatureSets/proposerSlashings.ts +9 -8
  88. package/src/signatureSets/randao.ts +17 -6
  89. package/src/signatureSets/voluntaryExits.ts +12 -5
  90. package/src/stateTransition.ts +4 -1
  91. package/src/util/execution.ts +8 -29
@@ -1,5 +1,7 @@
1
+ import {BeaconConfig} from "@lodestar/config";
1
2
  import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params";
2
3
  import {IndexedAttestation, SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
4
+ import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
3
5
  import {CachedBeaconStateAllForks} from "../types.js";
4
6
  import {
5
7
  ISignatureSet,
@@ -9,35 +11,48 @@ import {
9
11
  } from "../util/index.js";
10
12
 
11
13
  export function getAttestationDataSigningRoot(
14
+ config: BeaconConfig,
12
15
  state: CachedBeaconStateAllForks,
13
16
  data: phase0.AttestationData
14
17
  ): Uint8Array {
15
18
  const slot = computeStartSlotAtEpoch(data.target.epoch);
16
- const domain = state.config.getDomain(state.slot, DOMAIN_BEACON_ATTESTER, slot);
19
+ const domain = config.getDomain(state.slot, DOMAIN_BEACON_ATTESTER, slot);
17
20
 
18
21
  return computeSigningRoot(ssz.phase0.AttestationData, data, domain);
19
22
  }
20
23
 
21
24
  export function getAttestationWithIndicesSignatureSet(
25
+ config: BeaconConfig,
26
+ index2pubkey: Index2PubkeyCache,
22
27
  state: CachedBeaconStateAllForks,
23
28
  attestation: Pick<phase0.Attestation, "data" | "signature">,
24
29
  attestingIndices: number[]
25
30
  ): ISignatureSet {
26
31
  return createAggregateSignatureSetFromComponents(
27
- attestingIndices.map((i) => state.epochCtx.index2pubkey[i]),
28
- getAttestationDataSigningRoot(state, attestation.data),
32
+ attestingIndices.map((i) => index2pubkey[i]),
33
+ getAttestationDataSigningRoot(config, state, attestation.data),
29
34
  attestation.signature
30
35
  );
31
36
  }
32
37
 
33
38
  export function getIndexedAttestationSignatureSet(
39
+ config: BeaconConfig,
40
+ index2pubkey: Index2PubkeyCache,
34
41
  state: CachedBeaconStateAllForks,
35
42
  indexedAttestation: IndexedAttestation
36
43
  ): ISignatureSet {
37
- return getAttestationWithIndicesSignatureSet(state, indexedAttestation, indexedAttestation.attestingIndices);
44
+ return getAttestationWithIndicesSignatureSet(
45
+ config,
46
+ index2pubkey,
47
+ state,
48
+ indexedAttestation,
49
+ indexedAttestation.attestingIndices
50
+ );
38
51
  }
39
52
 
40
53
  export function getAttestationsSignatureSets(
54
+ config: BeaconConfig,
55
+ index2pubkey: Index2PubkeyCache,
41
56
  state: CachedBeaconStateAllForks,
42
57
  signedBlock: SignedBeaconBlock,
43
58
  indexedAttestations: IndexedAttestation[]
@@ -47,5 +62,7 @@ export function getAttestationsSignatureSets(
47
62
  `Indexed attestations length mismatch: got ${indexedAttestations.length}, expected ${signedBlock.message.body.attestations.length}`
48
63
  );
49
64
  }
50
- return indexedAttestations.map((indexedAttestation) => getIndexedAttestationSignatureSet(state, indexedAttestation));
65
+ return indexedAttestations.map((indexedAttestation) =>
66
+ getIndexedAttestationSignatureSet(config, index2pubkey, state, indexedAttestation)
67
+ );
51
68
  }
@@ -1,22 +1,27 @@
1
+ import {BeaconConfig} from "@lodestar/config";
1
2
  import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
2
3
  import {SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, isBlindedBeaconBlock, phase0, ssz} from "@lodestar/types";
4
+ import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
3
5
  import {CachedBeaconStateAllForks} from "../types.js";
4
6
  import {computeSigningRoot} from "../util/index.js";
5
7
  import {ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/signatureSets.js";
6
8
 
7
9
  export function verifyProposerSignature(
10
+ config: BeaconConfig,
11
+ index2pubkey: Index2PubkeyCache,
8
12
  state: CachedBeaconStateAllForks,
9
13
  signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
10
14
  ): boolean {
11
- const signatureSet = getBlockProposerSignatureSet(state, signedBlock);
15
+ const signatureSet = getBlockProposerSignatureSet(config, index2pubkey, state, signedBlock);
12
16
  return verifySignatureSet(signatureSet);
13
17
  }
14
18
 
15
19
  export function getBlockProposerSignatureSet(
20
+ config: BeaconConfig,
21
+ index2pubkey: Index2PubkeyCache,
16
22
  state: CachedBeaconStateAllForks,
17
23
  signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
18
24
  ): ISignatureSet {
19
- const {config, epochCtx} = state;
20
25
  const domain = config.getDomain(state.slot, DOMAIN_BEACON_PROPOSER, signedBlock.message.slot);
21
26
 
22
27
  const blockType = isBlindedBeaconBlock(signedBlock.message)
@@ -25,37 +30,40 @@ export function getBlockProposerSignatureSet(
25
30
 
26
31
  return {
27
32
  type: SignatureSetType.single,
28
- pubkey: epochCtx.index2pubkey[signedBlock.message.proposerIndex],
33
+ pubkey: index2pubkey[signedBlock.message.proposerIndex],
29
34
  signingRoot: computeSigningRoot(blockType, signedBlock.message, domain),
30
35
  signature: signedBlock.signature,
31
36
  };
32
37
  }
33
38
 
34
39
  export function getBlockHeaderProposerSignatureSetByParentStateSlot(
40
+ index2pubkey: Index2PubkeyCache,
35
41
  parentState: CachedBeaconStateAllForks,
36
42
  signedBlockHeader: phase0.SignedBeaconBlockHeader
37
43
  ) {
38
- return getBlockHeaderProposerSignatureSet(parentState, signedBlockHeader, parentState.slot);
44
+ return getBlockHeaderProposerSignatureSet(index2pubkey, parentState, signedBlockHeader, parentState.slot);
39
45
  }
40
46
 
41
47
  export function getBlockHeaderProposerSignatureSetByHeaderSlot(
48
+ index2pubkey: Index2PubkeyCache,
42
49
  headState: CachedBeaconStateAllForks,
43
50
  signedBlockHeader: phase0.SignedBeaconBlockHeader
44
51
  ) {
45
- return getBlockHeaderProposerSignatureSet(headState, signedBlockHeader, signedBlockHeader.message.slot);
52
+ return getBlockHeaderProposerSignatureSet(index2pubkey, headState, signedBlockHeader, signedBlockHeader.message.slot);
46
53
  }
47
54
 
48
55
  function getBlockHeaderProposerSignatureSet(
56
+ index2pubkey: Index2PubkeyCache,
49
57
  state: CachedBeaconStateAllForks,
50
58
  signedBlockHeader: phase0.SignedBeaconBlockHeader,
51
59
  domainSlot: Slot
52
60
  ): ISignatureSet {
53
- const {config, epochCtx} = state;
61
+ const {config} = state;
54
62
  const domain = config.getDomain(domainSlot, DOMAIN_BEACON_PROPOSER, signedBlockHeader.message.slot);
55
63
 
56
64
  return {
57
65
  type: SignatureSetType.single,
58
- pubkey: epochCtx.index2pubkey[signedBlockHeader.message.proposerIndex],
66
+ pubkey: index2pubkey[signedBlockHeader.message.proposerIndex],
59
67
  signingRoot: computeSigningRoot(ssz.phase0.BeaconBlockHeader, signedBlockHeader.message, domain),
60
68
  signature: signedBlockHeader.signature,
61
69
  };
@@ -1,5 +1,7 @@
1
+ import {BeaconConfig} from "@lodestar/config";
1
2
  import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
2
3
  import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
4
+ import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
3
5
  import {CachedBeaconStateAllForks} from "../types.js";
4
6
  import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index.js";
5
7
 
@@ -7,20 +9,17 @@ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index
7
9
  * Extract signatures to allow validating all block signatures at once
8
10
  */
9
11
  export function getProposerSlashingSignatureSets(
12
+ config: BeaconConfig,
13
+ index2pubkey: Index2PubkeyCache,
10
14
  state: CachedBeaconStateAllForks,
11
15
  proposerSlashing: phase0.ProposerSlashing
12
16
  ): ISignatureSet[] {
13
- const {epochCtx} = state;
14
- const pubkey = epochCtx.index2pubkey[proposerSlashing.signedHeader1.message.proposerIndex];
17
+ const pubkey = index2pubkey[proposerSlashing.signedHeader1.message.proposerIndex];
15
18
 
16
19
  // In state transition, ProposerSlashing headers are only partially validated. Their slot could be higher than the
17
20
  // clock and the slashing would still be valid. Must use bigint variants to hash correctly to all possible values
18
21
  return [proposerSlashing.signedHeader1, proposerSlashing.signedHeader2].map((signedHeader): ISignatureSet => {
19
- const domain = state.config.getDomain(
20
- state.slot,
21
- DOMAIN_BEACON_PROPOSER,
22
- Number(signedHeader.message.slot as bigint)
23
- );
22
+ const domain = config.getDomain(state.slot, DOMAIN_BEACON_PROPOSER, Number(signedHeader.message.slot as bigint));
24
23
 
25
24
  return {
26
25
  type: SignatureSetType.single,
@@ -32,10 +31,12 @@ export function getProposerSlashingSignatureSets(
32
31
  }
33
32
 
34
33
  export function getProposerSlashingsSignatureSets(
34
+ config: BeaconConfig,
35
+ index2pubkey: Index2PubkeyCache,
35
36
  state: CachedBeaconStateAllForks,
36
37
  signedBlock: SignedBeaconBlock
37
38
  ): ISignatureSet[] {
38
39
  return signedBlock.message.body.proposerSlashings.flatMap((proposerSlashing) =>
39
- getProposerSlashingSignatureSets(state, proposerSlashing)
40
+ getProposerSlashingSignatureSets(config, index2pubkey, state, proposerSlashing)
40
41
  );
41
42
  }
@@ -1,5 +1,7 @@
1
+ import {BeaconConfig} from "@lodestar/config";
1
2
  import {DOMAIN_RANDAO} from "@lodestar/params";
2
3
  import {BeaconBlock, ssz} from "@lodestar/types";
4
+ import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
3
5
  import {CachedBeaconStateAllForks} from "../types.js";
4
6
  import {
5
7
  ISignatureSet,
@@ -9,22 +11,31 @@ import {
9
11
  verifySignatureSet,
10
12
  } from "../util/index.js";
11
13
 
12
- export function verifyRandaoSignature(state: CachedBeaconStateAllForks, block: BeaconBlock): boolean {
13
- return verifySignatureSet(getRandaoRevealSignatureSet(state, block));
14
+ export function verifyRandaoSignature(
15
+ config: BeaconConfig,
16
+ index2pubkey: Index2PubkeyCache,
17
+ state: CachedBeaconStateAllForks,
18
+ block: BeaconBlock
19
+ ): boolean {
20
+ return verifySignatureSet(getRandaoRevealSignatureSet(config, index2pubkey, state, block));
14
21
  }
15
22
 
16
23
  /**
17
24
  * Extract signatures to allow validating all block signatures at once
18
25
  */
19
- export function getRandaoRevealSignatureSet(state: CachedBeaconStateAllForks, block: BeaconBlock): ISignatureSet {
20
- const {epochCtx} = state;
26
+ export function getRandaoRevealSignatureSet(
27
+ config: BeaconConfig,
28
+ index2pubkey: Index2PubkeyCache,
29
+ state: CachedBeaconStateAllForks,
30
+ block: BeaconBlock
31
+ ): ISignatureSet {
21
32
  // should not get epoch from epochCtx
22
33
  const epoch = computeEpochAtSlot(block.slot);
23
- const domain = state.config.getDomain(state.slot, DOMAIN_RANDAO, block.slot);
34
+ const domain = config.getDomain(state.slot, DOMAIN_RANDAO, block.slot);
24
35
 
25
36
  return {
26
37
  type: SignatureSetType.single,
27
- pubkey: epochCtx.index2pubkey[block.proposerIndex],
38
+ pubkey: index2pubkey[block.proposerIndex],
28
39
  signingRoot: computeSigningRoot(ssz.Epoch, epoch, domain),
29
40
  signature: block.body.randaoReveal,
30
41
  };
@@ -1,4 +1,6 @@
1
+ import {BeaconConfig} from "@lodestar/config";
1
2
  import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
3
+ import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
2
4
  import {CachedBeaconStateAllForks} from "../types.js";
3
5
  import {
4
6
  ISignatureSet,
@@ -9,36 +11,41 @@ import {
9
11
  } from "../util/index.js";
10
12
 
11
13
  export function verifyVoluntaryExitSignature(
14
+ config: BeaconConfig,
15
+ index2pubkey: Index2PubkeyCache,
12
16
  state: CachedBeaconStateAllForks,
13
17
  signedVoluntaryExit: phase0.SignedVoluntaryExit
14
18
  ): boolean {
15
- return verifySignatureSet(getVoluntaryExitSignatureSet(state, signedVoluntaryExit));
19
+ return verifySignatureSet(getVoluntaryExitSignatureSet(config, index2pubkey, state, signedVoluntaryExit));
16
20
  }
17
21
 
18
22
  /**
19
23
  * Extract signatures to allow validating all block signatures at once
20
24
  */
21
25
  export function getVoluntaryExitSignatureSet(
26
+ config: BeaconConfig,
27
+ index2pubkey: Index2PubkeyCache,
22
28
  state: CachedBeaconStateAllForks,
23
29
  signedVoluntaryExit: phase0.SignedVoluntaryExit
24
30
  ): ISignatureSet {
25
- const {epochCtx} = state;
26
31
  const slot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
27
- const domain = state.config.getDomainForVoluntaryExit(state.slot, slot);
32
+ const domain = config.getDomainForVoluntaryExit(state.slot, slot);
28
33
 
29
34
  return {
30
35
  type: SignatureSetType.single,
31
- pubkey: epochCtx.index2pubkey[signedVoluntaryExit.message.validatorIndex],
36
+ pubkey: index2pubkey[signedVoluntaryExit.message.validatorIndex],
32
37
  signingRoot: computeSigningRoot(ssz.phase0.VoluntaryExit, signedVoluntaryExit.message, domain),
33
38
  signature: signedVoluntaryExit.signature,
34
39
  };
35
40
  }
36
41
 
37
42
  export function getVoluntaryExitsSignatureSets(
43
+ config: BeaconConfig,
44
+ index2pubkey: Index2PubkeyCache,
38
45
  state: CachedBeaconStateAllForks,
39
46
  signedBlock: SignedBeaconBlock
40
47
  ): ISignatureSet[] {
41
48
  return signedBlock.message.body.voluntaryExits.map((voluntaryExit) =>
42
- getVoluntaryExitSignatureSet(state, voluntaryExit)
49
+ getVoluntaryExitSignatureSet(config, index2pubkey, state, voluntaryExit)
43
50
  );
44
51
  }
@@ -111,7 +111,10 @@ export function stateTransition(
111
111
  postState = processSlotsWithTransientCache(postState, blockSlot, options, {metrics, validatorMonitor});
112
112
 
113
113
  // Verify proposer signature only
114
- if (verifyProposer && !verifyProposerSignature(postState, signedBlock)) {
114
+ if (
115
+ verifyProposer &&
116
+ !verifyProposerSignature(postState.config, postState.epochCtx.index2pubkey, postState, signedBlock)
117
+ ) {
115
118
  throw new Error("Invalid block signature");
116
119
  }
117
120
 
@@ -31,51 +31,30 @@ export function isExecutionEnabled(state: BeaconStateExecutions, block: BeaconBl
31
31
  return true;
32
32
  }
33
33
 
34
- // Throws if not post-bellatrix block. A fork-guard in isExecutionEnabled() prevents this from happening
34
+ // Throws if not post-bellatrix block. A fork-guard before isExecutionEnabled() prevents this from happening
35
35
  const payload = getFullOrBlindedPayload(block);
36
- // Note: spec says to check all payload is zero-ed. However a state-root cannot be zero for any non-empty payload
37
- // TODO: Consider comparing with the payload root if this assumption is not correct.
38
- // return !byteArrayEquals(payload.stateRoot, ZERO_HASH);
39
36
 
40
- // UPDATE: stateRoot comparision should have been enough with zero hash, but spec tests were failing
41
- // Revisit this later to fix specs and make this efficient
42
37
  return isExecutionPayload(payload)
43
38
  ? !ssz.bellatrix.ExecutionPayload.equals(payload, ssz.bellatrix.ExecutionPayload.defaultValue())
44
39
  : !ssz.bellatrix.ExecutionPayloadHeader.equals(
45
40
  state.latestExecutionPayloadHeader,
46
- // TODO: Performance
47
41
  ssz.bellatrix.ExecutionPayloadHeader.defaultValue()
48
42
  );
49
43
  }
50
44
 
51
- /**
52
- * Merge block is the SINGLE block that transitions from POW to POS.
53
- * state has no execution data AND this block has execution data
54
- */
55
- export function isMergeTransitionBlock(state: BeaconStateExecutions, body: bellatrix.BeaconBlockBody): boolean {
56
- return (
57
- !isMergeTransitionComplete(state) &&
58
- !ssz.bellatrix.ExecutionPayload.equals(body.executionPayload, ssz.bellatrix.ExecutionPayload.defaultValue())
59
- );
60
- }
61
-
62
45
  /**
63
46
  * Merge is complete when the state includes execution layer data:
64
- * state.latestExecutionPayloadHeader NOT EMPTY
47
+ * state.latestExecutionPayloadHeader NOT EMPTY or state is post-capella
65
48
  */
66
49
  export function isMergeTransitionComplete(state: BeaconStateExecutions): boolean {
67
- if (!isCapellaStateType(state)) {
68
- return !ssz.bellatrix.ExecutionPayloadHeader.equals(
69
- (state as BeaconStateBellatrix).latestExecutionPayloadHeader,
70
- // TODO: Performance
71
- ssz.bellatrix.ExecutionPayloadHeader.defaultValue()
72
- );
50
+ if (isCapellaStateType(state)) {
51
+ // All networks have completed the merge transition before capella
52
+ return true;
73
53
  }
74
54
 
75
- return !ssz.capella.ExecutionPayloadHeader.equals(
76
- state.latestExecutionPayloadHeader,
77
- // TODO: Performance
78
- ssz.capella.ExecutionPayloadHeader.defaultValue()
55
+ return !ssz.bellatrix.ExecutionPayloadHeader.equals(
56
+ (state as BeaconStateBellatrix).latestExecutionPayloadHeader,
57
+ ssz.bellatrix.ExecutionPayloadHeader.defaultValue()
79
58
  );
80
59
  }
81
60