@lodestar/state-transition 1.39.0-dev.c151a164f2 → 1.39.0-dev.f4236afdba

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 (76) hide show
  1. package/lib/block/isValidIndexedAttestation.d.ts +2 -3
  2. package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
  3. package/lib/block/isValidIndexedAttestation.js +4 -4
  4. package/lib/block/isValidIndexedAttestation.js.map +1 -1
  5. package/lib/block/processAttestationPhase0.d.ts.map +1 -1
  6. package/lib/block/processAttestationPhase0.js +1 -1
  7. package/lib/block/processAttestationPhase0.js.map +1 -1
  8. package/lib/block/processAttestationsAltair.d.ts.map +1 -1
  9. package/lib/block/processAttestationsAltair.js +1 -1
  10. package/lib/block/processAttestationsAltair.js.map +1 -1
  11. package/lib/block/processAttesterSlashing.js +1 -1
  12. package/lib/block/processAttesterSlashing.js.map +1 -1
  13. package/lib/block/processProposerSlashing.d.ts.map +1 -1
  14. package/lib/block/processProposerSlashing.js +1 -1
  15. package/lib/block/processProposerSlashing.js.map +1 -1
  16. package/lib/block/processRandao.js +1 -1
  17. package/lib/block/processRandao.js.map +1 -1
  18. package/lib/block/processSyncCommittee.d.ts +1 -2
  19. package/lib/block/processSyncCommittee.d.ts.map +1 -1
  20. package/lib/block/processSyncCommittee.js +3 -3
  21. package/lib/block/processSyncCommittee.js.map +1 -1
  22. package/lib/block/processVoluntaryExit.d.ts.map +1 -1
  23. package/lib/block/processVoluntaryExit.js +1 -2
  24. package/lib/block/processVoluntaryExit.js.map +1 -1
  25. package/lib/cache/stateCache.d.ts +0 -1
  26. package/lib/cache/stateCache.d.ts.map +1 -1
  27. package/lib/cache/stateCache.js.map +1 -1
  28. package/lib/signatureSets/attesterSlashings.d.ts +3 -4
  29. package/lib/signatureSets/attesterSlashings.d.ts.map +1 -1
  30. package/lib/signatureSets/attesterSlashings.js +6 -6
  31. package/lib/signatureSets/attesterSlashings.js.map +1 -1
  32. package/lib/signatureSets/index.d.ts +1 -2
  33. package/lib/signatureSets/index.d.ts.map +1 -1
  34. package/lib/signatureSets/index.js +8 -8
  35. package/lib/signatureSets/index.js.map +1 -1
  36. package/lib/signatureSets/indexedAttestation.d.ts +4 -5
  37. package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
  38. package/lib/signatureSets/indexedAttestation.js +8 -8
  39. package/lib/signatureSets/indexedAttestation.js.map +1 -1
  40. package/lib/signatureSets/proposer.d.ts +2 -3
  41. package/lib/signatureSets/proposer.d.ts.map +1 -1
  42. package/lib/signatureSets/proposer.js +4 -3
  43. package/lib/signatureSets/proposer.js.map +1 -1
  44. package/lib/signatureSets/proposerSlashings.d.ts +2 -3
  45. package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
  46. package/lib/signatureSets/proposerSlashings.js +4 -4
  47. package/lib/signatureSets/proposerSlashings.js.map +1 -1
  48. package/lib/signatureSets/randao.d.ts +2 -3
  49. package/lib/signatureSets/randao.d.ts.map +1 -1
  50. package/lib/signatureSets/randao.js +4 -4
  51. package/lib/signatureSets/randao.js.map +1 -1
  52. package/lib/signatureSets/voluntaryExits.d.ts +3 -4
  53. package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
  54. package/lib/signatureSets/voluntaryExits.js +6 -6
  55. package/lib/signatureSets/voluntaryExits.js.map +1 -1
  56. package/lib/stateTransition.d.ts.map +1 -1
  57. package/lib/stateTransition.js +1 -2
  58. package/lib/stateTransition.js.map +1 -1
  59. package/package.json +6 -6
  60. package/src/block/isValidIndexedAttestation.ts +2 -5
  61. package/src/block/processAttestationPhase0.ts +0 -1
  62. package/src/block/processAttestationsAltair.ts +1 -7
  63. package/src/block/processAttesterSlashing.ts +1 -1
  64. package/src/block/processProposerSlashing.ts +1 -6
  65. package/src/block/processRandao.ts +1 -1
  66. package/src/block/processSyncCommittee.ts +2 -10
  67. package/src/block/processVoluntaryExit.ts +1 -4
  68. package/src/cache/stateCache.ts +0 -1
  69. package/src/signatureSets/attesterSlashings.ts +3 -7
  70. package/src/signatureSets/index.ts +6 -9
  71. package/src/signatureSets/indexedAttestation.ts +3 -9
  72. package/src/signatureSets/proposer.ts +2 -4
  73. package/src/signatureSets/proposerSlashings.ts +6 -5
  74. package/src/signatureSets/randao.ts +2 -5
  75. package/src/signatureSets/voluntaryExits.ts +3 -7
  76. package/src/stateTransition.ts +1 -4
@@ -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