@lodestar/state-transition 1.39.0-dev.3bf4734ba9 → 1.39.0-dev.493cc12d2f
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/index.d.ts.map +1 -1
- package/lib/block/index.js +4 -2
- package/lib/block/index.js.map +1 -1
- 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/processExecutionPayload.d.ts.map +1 -1
- package/lib/block/processExecutionPayload.js +6 -4
- package/lib/block/processExecutionPayload.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/epochCache.d.ts +0 -3
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +0 -3
- package/lib/cache/epochCache.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/lib/util/execution.d.ts +11 -1
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +26 -1
- package/lib/util/execution.js.map +1 -1
- package/package.json +6 -6
- package/src/block/index.ts +6 -2
- 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/processExecutionPayload.ts +14 -8
- 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/epochCache.ts +0 -3
- 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
- package/src/util/execution.ts +39 -0
|
@@ -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
|
|
package/src/util/execution.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {ForkName, ForkPostBellatrix, ForkPreGloas, ForkSeq} from "@lodestar/para
|
|
|
2
2
|
import {
|
|
3
3
|
BeaconBlock,
|
|
4
4
|
BeaconBlockBody,
|
|
5
|
+
BlindedBeaconBlock,
|
|
5
6
|
BlindedBeaconBlockBody,
|
|
6
7
|
ExecutionPayload,
|
|
7
8
|
ExecutionPayloadHeader,
|
|
@@ -9,16 +10,54 @@ import {
|
|
|
9
10
|
capella,
|
|
10
11
|
deneb,
|
|
11
12
|
isBlindedBeaconBlockBody,
|
|
13
|
+
isExecutionPayload,
|
|
12
14
|
ssz,
|
|
13
15
|
} from "@lodestar/types";
|
|
14
16
|
import {
|
|
15
17
|
BeaconStateAllForks,
|
|
18
|
+
BeaconStateBellatrix,
|
|
16
19
|
BeaconStateCapella,
|
|
17
20
|
BeaconStateExecutions,
|
|
18
21
|
CachedBeaconStateAllForks,
|
|
19
22
|
CachedBeaconStateExecutions,
|
|
20
23
|
} from "../types.js";
|
|
21
24
|
|
|
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
|
+
|
|
22
61
|
/** Type guard for bellatrix.BeaconState */
|
|
23
62
|
export function isExecutionStateType(state: BeaconStateAllForks): state is BeaconStateExecutions {
|
|
24
63
|
return (state as BeaconStateExecutions).latestExecutionPayloadHeader !== undefined;
|