@lodestar/state-transition 1.39.0-dev.aceb5b7416 → 1.39.0-dev.c151a164f2
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.
- package/lib/block/isValidIndexedAttestation.d.ts +3 -2
- package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +4 -4
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/processAttestationPhase0.d.ts.map +1 -1
- package/lib/block/processAttestationPhase0.js +1 -1
- package/lib/block/processAttestationPhase0.js.map +1 -1
- package/lib/block/processAttestationsAltair.d.ts.map +1 -1
- package/lib/block/processAttestationsAltair.js +1 -1
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processAttesterSlashing.js +1 -1
- package/lib/block/processAttesterSlashing.js.map +1 -1
- package/lib/block/processProposerSlashing.d.ts.map +1 -1
- package/lib/block/processProposerSlashing.js +1 -1
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/processRandao.js +1 -1
- package/lib/block/processRandao.js.map +1 -1
- package/lib/block/processSyncCommittee.d.ts +2 -1
- package/lib/block/processSyncCommittee.d.ts.map +1 -1
- package/lib/block/processSyncCommittee.js +3 -3
- package/lib/block/processSyncCommittee.js.map +1 -1
- package/lib/block/processVoluntaryExit.d.ts.map +1 -1
- package/lib/block/processVoluntaryExit.js +2 -1
- package/lib/block/processVoluntaryExit.js.map +1 -1
- package/lib/cache/stateCache.d.ts +1 -0
- package/lib/cache/stateCache.d.ts.map +1 -1
- package/lib/cache/stateCache.js.map +1 -1
- package/lib/signatureSets/attesterSlashings.d.ts +4 -3
- package/lib/signatureSets/attesterSlashings.d.ts.map +1 -1
- package/lib/signatureSets/attesterSlashings.js +6 -6
- package/lib/signatureSets/attesterSlashings.js.map +1 -1
- package/lib/signatureSets/index.d.ts +2 -1
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +8 -8
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/indexedAttestation.d.ts +5 -4
- package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
- package/lib/signatureSets/indexedAttestation.js +8 -8
- package/lib/signatureSets/indexedAttestation.js.map +1 -1
- package/lib/signatureSets/proposer.d.ts +3 -2
- package/lib/signatureSets/proposer.d.ts.map +1 -1
- package/lib/signatureSets/proposer.js +3 -4
- package/lib/signatureSets/proposer.js.map +1 -1
- package/lib/signatureSets/proposerSlashings.d.ts +3 -2
- package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
- package/lib/signatureSets/proposerSlashings.js +4 -4
- package/lib/signatureSets/proposerSlashings.js.map +1 -1
- package/lib/signatureSets/randao.d.ts +3 -2
- package/lib/signatureSets/randao.d.ts.map +1 -1
- package/lib/signatureSets/randao.js +4 -4
- package/lib/signatureSets/randao.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +4 -3
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +6 -6
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/stateTransition.d.ts.map +1 -1
- package/lib/stateTransition.js +2 -1
- package/lib/stateTransition.js.map +1 -1
- package/package.json +6 -6
- package/src/block/isValidIndexedAttestation.ts +5 -2
- package/src/block/processAttestationPhase0.ts +1 -0
- package/src/block/processAttestationsAltair.ts +7 -1
- package/src/block/processAttesterSlashing.ts +1 -1
- package/src/block/processProposerSlashing.ts +6 -1
- package/src/block/processRandao.ts +1 -1
- package/src/block/processSyncCommittee.ts +10 -2
- package/src/block/processVoluntaryExit.ts +4 -1
- package/src/cache/stateCache.ts +1 -0
- package/src/signatureSets/attesterSlashings.ts +7 -3
- package/src/signatureSets/index.ts +9 -6
- package/src/signatureSets/indexedAttestation.ts +9 -3
- package/src/signatureSets/proposer.ts +4 -2
- package/src/signatureSets/proposerSlashings.ts +5 -6
- package/src/signatureSets/randao.ts +5 -2
- package/src/signatureSets/voluntaryExits.ts +7 -3
- package/src/stateTransition.ts +4 -1
|
@@ -1,3 +1,4 @@
|
|
|
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";
|
|
3
4
|
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
@@ -6,20 +7,21 @@ import {computeSigningRoot} from "../util/index.js";
|
|
|
6
7
|
import {ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/signatureSets.js";
|
|
7
8
|
|
|
8
9
|
export function verifyProposerSignature(
|
|
10
|
+
config: BeaconConfig,
|
|
9
11
|
index2pubkey: Index2PubkeyCache,
|
|
10
12
|
state: CachedBeaconStateAllForks,
|
|
11
13
|
signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
|
|
12
14
|
): boolean {
|
|
13
|
-
const signatureSet = getBlockProposerSignatureSet(index2pubkey, state, signedBlock);
|
|
15
|
+
const signatureSet = getBlockProposerSignatureSet(config, index2pubkey, state, signedBlock);
|
|
14
16
|
return verifySignatureSet(signatureSet);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export function getBlockProposerSignatureSet(
|
|
20
|
+
config: BeaconConfig,
|
|
18
21
|
index2pubkey: Index2PubkeyCache,
|
|
19
22
|
state: CachedBeaconStateAllForks,
|
|
20
23
|
signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
|
|
21
24
|
): ISignatureSet {
|
|
22
|
-
const {config} = state;
|
|
23
25
|
const domain = config.getDomain(state.slot, DOMAIN_BEACON_PROPOSER, signedBlock.message.slot);
|
|
24
26
|
|
|
25
27
|
const blockType = isBlindedBeaconBlock(signedBlock.message)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
|
|
2
3
|
import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
|
|
3
4
|
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
@@ -8,6 +9,7 @@ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index
|
|
|
8
9
|
* Extract signatures to allow validating all block signatures at once
|
|
9
10
|
*/
|
|
10
11
|
export function getProposerSlashingSignatureSets(
|
|
12
|
+
config: BeaconConfig,
|
|
11
13
|
index2pubkey: Index2PubkeyCache,
|
|
12
14
|
state: CachedBeaconStateAllForks,
|
|
13
15
|
proposerSlashing: phase0.ProposerSlashing
|
|
@@ -17,11 +19,7 @@ export function getProposerSlashingSignatureSets(
|
|
|
17
19
|
// In state transition, ProposerSlashing headers are only partially validated. Their slot could be higher than the
|
|
18
20
|
// clock and the slashing would still be valid. Must use bigint variants to hash correctly to all possible values
|
|
19
21
|
return [proposerSlashing.signedHeader1, proposerSlashing.signedHeader2].map((signedHeader): ISignatureSet => {
|
|
20
|
-
const domain =
|
|
21
|
-
state.slot,
|
|
22
|
-
DOMAIN_BEACON_PROPOSER,
|
|
23
|
-
Number(signedHeader.message.slot as bigint)
|
|
24
|
-
);
|
|
22
|
+
const domain = config.getDomain(state.slot, DOMAIN_BEACON_PROPOSER, Number(signedHeader.message.slot as bigint));
|
|
25
23
|
|
|
26
24
|
return {
|
|
27
25
|
type: SignatureSetType.single,
|
|
@@ -33,11 +31,12 @@ export function getProposerSlashingSignatureSets(
|
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export function getProposerSlashingsSignatureSets(
|
|
34
|
+
config: BeaconConfig,
|
|
36
35
|
index2pubkey: Index2PubkeyCache,
|
|
37
36
|
state: CachedBeaconStateAllForks,
|
|
38
37
|
signedBlock: SignedBeaconBlock
|
|
39
38
|
): ISignatureSet[] {
|
|
40
39
|
return signedBlock.message.body.proposerSlashings.flatMap((proposerSlashing) =>
|
|
41
|
-
getProposerSlashingSignatureSets(index2pubkey, state, proposerSlashing)
|
|
40
|
+
getProposerSlashingSignatureSets(config, index2pubkey, state, proposerSlashing)
|
|
42
41
|
);
|
|
43
42
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {DOMAIN_RANDAO} from "@lodestar/params";
|
|
2
3
|
import {BeaconBlock, ssz} from "@lodestar/types";
|
|
3
4
|
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
@@ -11,24 +12,26 @@ import {
|
|
|
11
12
|
} from "../util/index.js";
|
|
12
13
|
|
|
13
14
|
export function verifyRandaoSignature(
|
|
15
|
+
config: BeaconConfig,
|
|
14
16
|
index2pubkey: Index2PubkeyCache,
|
|
15
17
|
state: CachedBeaconStateAllForks,
|
|
16
18
|
block: BeaconBlock
|
|
17
19
|
): boolean {
|
|
18
|
-
return verifySignatureSet(getRandaoRevealSignatureSet(index2pubkey, state, block));
|
|
20
|
+
return verifySignatureSet(getRandaoRevealSignatureSet(config, index2pubkey, state, block));
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Extract signatures to allow validating all block signatures at once
|
|
23
25
|
*/
|
|
24
26
|
export function getRandaoRevealSignatureSet(
|
|
27
|
+
config: BeaconConfig,
|
|
25
28
|
index2pubkey: Index2PubkeyCache,
|
|
26
29
|
state: CachedBeaconStateAllForks,
|
|
27
30
|
block: BeaconBlock
|
|
28
31
|
): ISignatureSet {
|
|
29
32
|
// should not get epoch from epochCtx
|
|
30
33
|
const epoch = computeEpochAtSlot(block.slot);
|
|
31
|
-
const domain =
|
|
34
|
+
const domain = config.getDomain(state.slot, DOMAIN_RANDAO, block.slot);
|
|
32
35
|
|
|
33
36
|
return {
|
|
34
37
|
type: SignatureSetType.single,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {SignedBeaconBlock, phase0, ssz} from "@lodestar/types";
|
|
2
3
|
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
3
4
|
import {CachedBeaconStateAllForks} from "../types.js";
|
|
@@ -10,23 +11,25 @@ import {
|
|
|
10
11
|
} from "../util/index.js";
|
|
11
12
|
|
|
12
13
|
export function verifyVoluntaryExitSignature(
|
|
14
|
+
config: BeaconConfig,
|
|
13
15
|
index2pubkey: Index2PubkeyCache,
|
|
14
16
|
state: CachedBeaconStateAllForks,
|
|
15
17
|
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
16
18
|
): boolean {
|
|
17
|
-
return verifySignatureSet(getVoluntaryExitSignatureSet(index2pubkey, state, signedVoluntaryExit));
|
|
19
|
+
return verifySignatureSet(getVoluntaryExitSignatureSet(config, index2pubkey, state, signedVoluntaryExit));
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Extract signatures to allow validating all block signatures at once
|
|
22
24
|
*/
|
|
23
25
|
export function getVoluntaryExitSignatureSet(
|
|
26
|
+
config: BeaconConfig,
|
|
24
27
|
index2pubkey: Index2PubkeyCache,
|
|
25
28
|
state: CachedBeaconStateAllForks,
|
|
26
29
|
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
27
30
|
): ISignatureSet {
|
|
28
31
|
const slot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
|
|
29
|
-
const domain =
|
|
32
|
+
const domain = config.getDomainForVoluntaryExit(state.slot, slot);
|
|
30
33
|
|
|
31
34
|
return {
|
|
32
35
|
type: SignatureSetType.single,
|
|
@@ -37,11 +40,12 @@ export function getVoluntaryExitSignatureSet(
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export function getVoluntaryExitsSignatureSets(
|
|
43
|
+
config: BeaconConfig,
|
|
40
44
|
index2pubkey: Index2PubkeyCache,
|
|
41
45
|
state: CachedBeaconStateAllForks,
|
|
42
46
|
signedBlock: SignedBeaconBlock
|
|
43
47
|
): ISignatureSet[] {
|
|
44
48
|
return signedBlock.message.body.voluntaryExits.map((voluntaryExit) =>
|
|
45
|
-
getVoluntaryExitSignatureSet(index2pubkey, state, voluntaryExit)
|
|
49
|
+
getVoluntaryExitSignatureSet(config, index2pubkey, state, voluntaryExit)
|
|
46
50
|
);
|
|
47
51
|
}
|
package/src/stateTransition.ts
CHANGED
|
@@ -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 (
|
|
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
|
|