@lodestar/state-transition 1.38.0 → 1.39.0-dev.0321dbcf04
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.js +2 -2
- package/lib/block/index.js.map +1 -1
- package/lib/block/isValidIndexedAttestation.d.ts +6 -5
- package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +9 -10
- 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.d.ts +4 -2
- package/lib/block/processAttesterSlashing.d.ts.map +1 -1
- package/lib/block/processAttesterSlashing.js +5 -4
- package/lib/block/processAttesterSlashing.js.map +1 -1
- package/lib/block/processBlsToExecutionChange.d.ts +3 -1
- package/lib/block/processBlsToExecutionChange.d.ts.map +1 -1
- package/lib/block/processBlsToExecutionChange.js +7 -11
- package/lib/block/processBlsToExecutionChange.js.map +1 -1
- package/lib/block/processProposerSlashing.d.ts +5 -2
- package/lib/block/processProposerSlashing.d.ts.map +1 -1
- package/lib/block/processProposerSlashing.js +7 -5
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/processRandao.js +2 -2
- package/lib/block/processRandao.js.map +1 -1
- package/lib/block/processSyncCommittee.d.ts +4 -1
- package/lib/block/processSyncCommittee.d.ts.map +1 -1
- package/lib/block/processSyncCommittee.js +7 -6
- 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/block/processWithdrawals.d.ts +3 -3
- package/lib/block/processWithdrawals.d.ts.map +1 -1
- package/lib/block/processWithdrawals.js +152 -105
- package/lib/block/processWithdrawals.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/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/rewards/attestationsRewards.d.ts +6 -0
- package/lib/rewards/attestationsRewards.d.ts.map +1 -0
- package/lib/rewards/attestationsRewards.js +113 -0
- package/lib/rewards/attestationsRewards.js.map +1 -0
- package/lib/rewards/blockRewards.d.ts +13 -0
- package/lib/rewards/blockRewards.d.ts.map +1 -0
- package/lib/rewards/blockRewards.js +95 -0
- package/lib/rewards/blockRewards.js.map +1 -0
- package/lib/rewards/index.d.ts +4 -0
- package/lib/rewards/index.d.ts.map +1 -0
- package/lib/rewards/index.js +4 -0
- package/lib/rewards/index.js.map +1 -0
- package/lib/rewards/syncCommitteeRewards.d.ts +6 -0
- package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -0
- package/lib/rewards/syncCommitteeRewards.js +36 -0
- package/lib/rewards/syncCommitteeRewards.js.map +1 -0
- package/lib/signatureSets/attesterSlashings.d.ts +6 -5
- package/lib/signatureSets/attesterSlashings.d.ts.map +1 -1
- package/lib/signatureSets/attesterSlashings.js +11 -8
- package/lib/signatureSets/attesterSlashings.js.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.d.ts +1 -2
- package/lib/signatureSets/blsToExecutionChange.d.ts.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.js +2 -2
- package/lib/signatureSets/blsToExecutionChange.js.map +1 -1
- package/lib/signatureSets/index.d.ts +5 -3
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +10 -10
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/indexedAttestation.d.ts +7 -6
- package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
- package/lib/signatureSets/indexedAttestation.js +12 -9
- package/lib/signatureSets/indexedAttestation.js.map +1 -1
- package/lib/signatureSets/proposer.d.ts +7 -6
- package/lib/signatureSets/proposer.d.ts.map +1 -1
- package/lib/signatureSets/proposer.js +14 -13
- package/lib/signatureSets/proposer.js.map +1 -1
- package/lib/signatureSets/proposerSlashings.d.ts +5 -4
- package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
- package/lib/signatureSets/proposerSlashings.js +8 -6
- package/lib/signatureSets/proposerSlashings.js.map +1 -1
- package/lib/signatureSets/randao.d.ts +4 -3
- package/lib/signatureSets/randao.d.ts.map +1 -1
- package/lib/signatureSets/randao.js +7 -6
- package/lib/signatureSets/randao.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +6 -5
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +11 -9
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/stateTransition.js +1 -1
- package/lib/stateTransition.js.map +1 -1
- package/lib/util/execution.d.ts +2 -7
- package/lib/util/execution.d.ts.map +1 -1
- package/lib/util/execution.js +7 -25
- package/lib/util/execution.js.map +1 -1
- package/package.json +14 -11
- package/src/block/index.ts +1 -1
- package/src/block/isValidIndexedAttestation.ts +25 -12
- package/src/block/processAttestationPhase0.ts +10 -1
- package/src/block/processAttestationsAltair.ts +7 -1
- package/src/block/processAttesterSlashing.ts +20 -5
- package/src/block/processBlsToExecutionChange.ts +13 -14
- package/src/block/processProposerSlashing.ts +21 -6
- package/src/block/processRandao.ts +2 -2
- package/src/block/processSyncCommittee.ts +18 -6
- package/src/block/processVoluntaryExit.ts +4 -1
- package/src/block/processWithdrawals.ts +230 -135
- package/src/cache/epochCache.ts +0 -3
- package/src/cache/stateCache.ts +1 -0
- package/src/index.ts +2 -2
- package/src/rewards/attestationsRewards.ts +200 -0
- package/src/rewards/blockRewards.ts +147 -0
- package/src/rewards/index.ts +3 -0
- package/src/rewards/syncCommitteeRewards.ts +59 -0
- package/src/signatureSets/attesterSlashings.ts +19 -10
- package/src/signatureSets/blsToExecutionChange.ts +2 -3
- package/src/signatureSets/index.ts +18 -12
- package/src/signatureSets/indexedAttestation.ts +30 -12
- package/src/signatureSets/proposer.ts +22 -14
- package/src/signatureSets/proposerSlashings.ts +14 -12
- package/src/signatureSets/randao.ts +17 -7
- package/src/signatureSets/voluntaryExits.ts +19 -11
- package/src/stateTransition.ts +1 -1
- package/src/util/execution.ts +8 -29
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
2
|
+
import { IndexedAttestation, SignedBeaconBlock, Slot, phase0 } from "@lodestar/types";
|
|
3
|
+
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
4
|
import { ISignatureSet } from "../util/index.js";
|
|
4
|
-
export declare function getAttestationDataSigningRoot(
|
|
5
|
-
export declare function getAttestationWithIndicesSignatureSet(
|
|
6
|
-
export declare function getIndexedAttestationSignatureSet(
|
|
7
|
-
export declare function getAttestationsSignatureSets(
|
|
5
|
+
export declare function getAttestationDataSigningRoot(config: BeaconConfig, stateSlot: Slot, data: phase0.AttestationData): Uint8Array;
|
|
6
|
+
export declare function getAttestationWithIndicesSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, attestation: Pick<phase0.Attestation, "data" | "signature">, attestingIndices: number[]): ISignatureSet;
|
|
7
|
+
export declare function getIndexedAttestationSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, indexedAttestation: IndexedAttestation): ISignatureSet;
|
|
8
|
+
export declare function getAttestationsSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock, indexedAttestations: IndexedAttestation[]): ISignatureSet[];
|
|
8
9
|
//# sourceMappingURL=indexedAttestation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexedAttestation.d.ts","sourceRoot":"","sources":["../../src/signatureSets/indexedAttestation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"indexedAttestation.d.ts","sourceRoot":"","sources":["../../src/signatureSets/indexedAttestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAId,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,IAAI,EACf,IAAI,EAAE,MAAM,CAAC,eAAe,GAC3B,UAAU,CAKZ;AAED,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,CAAC,EAC3D,gBAAgB,EAAE,MAAM,EAAE,GACzB,aAAa,CAMf;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,kBAAkB,EAAE,kBAAkB,GACrC,aAAa,CAQf;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,EAAE,kBAAkB,EAAE,GACxC,aAAa,EAAE,CAYjB"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { DOMAIN_BEACON_ATTESTER } from "@lodestar/params";
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
3
|
import { computeSigningRoot, computeStartSlotAtEpoch, createAggregateSignatureSetFromComponents, } from "../util/index.js";
|
|
4
|
-
export function getAttestationDataSigningRoot(
|
|
5
|
-
const
|
|
6
|
-
const domain =
|
|
4
|
+
export function getAttestationDataSigningRoot(config, stateSlot, data) {
|
|
5
|
+
const messageSlot = computeStartSlotAtEpoch(data.target.epoch);
|
|
6
|
+
const domain = config.getDomain(stateSlot, DOMAIN_BEACON_ATTESTER, messageSlot);
|
|
7
7
|
return computeSigningRoot(ssz.phase0.AttestationData, data, domain);
|
|
8
8
|
}
|
|
9
|
-
export function getAttestationWithIndicesSignatureSet(
|
|
10
|
-
return createAggregateSignatureSetFromComponents(attestingIndices.map((i) =>
|
|
9
|
+
export function getAttestationWithIndicesSignatureSet(config, index2pubkey, stateSlot, attestation, attestingIndices) {
|
|
10
|
+
return createAggregateSignatureSetFromComponents(attestingIndices.map((i) => index2pubkey[i]), getAttestationDataSigningRoot(config, stateSlot, attestation.data), attestation.signature);
|
|
11
11
|
}
|
|
12
|
-
export function getIndexedAttestationSignatureSet(
|
|
13
|
-
return getAttestationWithIndicesSignatureSet(
|
|
12
|
+
export function getIndexedAttestationSignatureSet(config, index2pubkey, stateSlot, indexedAttestation) {
|
|
13
|
+
return getAttestationWithIndicesSignatureSet(config, index2pubkey, stateSlot, indexedAttestation, indexedAttestation.attestingIndices);
|
|
14
14
|
}
|
|
15
|
-
export function getAttestationsSignatureSets(
|
|
15
|
+
export function getAttestationsSignatureSets(config, index2pubkey, signedBlock, indexedAttestations) {
|
|
16
16
|
if (indexedAttestations.length !== signedBlock.message.body.attestations.length) {
|
|
17
17
|
throw Error(`Indexed attestations length mismatch: got ${indexedAttestations.length}, expected ${signedBlock.message.body.attestations.length}`);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
20
|
+
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
21
|
+
const blockSlot = signedBlock.message.slot;
|
|
22
|
+
return indexedAttestations.map((indexedAttestation) => getIndexedAttestationSignatureSet(config, index2pubkey, blockSlot, indexedAttestation));
|
|
20
23
|
}
|
|
21
24
|
//# sourceMappingURL=indexedAttestation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexedAttestation.js","sourceRoot":"","sources":["../../src/signatureSets/indexedAttestation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"indexedAttestation.js","sourceRoot":"","sources":["../../src/signatureSets/indexedAttestation.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAsD,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EAEL,kBAAkB,EAClB,uBAAuB,EACvB,yCAAyC,GAC1C,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,6BAA6B,CAC3C,MAAoB,EACpB,SAAe,EACf,IAA4B;IAE5B,MAAM,WAAW,GAAG,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,sBAAsB,EAAE,WAAW,CAAC,CAAC;IAEhF,OAAO,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,qCAAqC,CACnD,MAAoB,EACpB,YAA+B,EAC/B,SAAe,EACf,WAA2D,EAC3D,gBAA0B;IAE1B,OAAO,yCAAyC,CAC9C,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAC5C,6BAA6B,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,EAClE,WAAW,CAAC,SAAS,CACtB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,MAAoB,EACpB,YAA+B,EAC/B,SAAe,EACf,kBAAsC;IAEtC,OAAO,qCAAqC,CAC1C,MAAM,EACN,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,kBAAkB,CAAC,gBAAgB,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,MAAoB,EACpB,YAA+B,EAC/B,WAA8B,EAC9B,mBAAyC;IAEzC,IAAI,mBAAmB,CAAC,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QAChF,MAAM,KAAK,CACT,6CAA6C,mBAAmB,CAAC,MAAM,cAAc,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CACpI,CAAC;IACJ,CAAC;IACD,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3C,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,kBAAkB,EAAE,EAAE,CACpD,iCAAiC,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,kBAAkB,CAAC,CACvF,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
2
|
+
import { SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, phase0 } from "@lodestar/types";
|
|
3
|
+
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
4
|
import { ISignatureSet } from "../util/signatureSets.js";
|
|
4
|
-
export declare function verifyProposerSignature(
|
|
5
|
-
export declare function getBlockProposerSignatureSet(
|
|
6
|
-
export declare function getBlockHeaderProposerSignatureSetByParentStateSlot(
|
|
7
|
-
export declare function getBlockHeaderProposerSignatureSetByHeaderSlot(
|
|
5
|
+
export declare function verifyProposerSignature(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock): boolean;
|
|
6
|
+
export declare function getBlockProposerSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock): ISignatureSet;
|
|
7
|
+
export declare function getBlockHeaderProposerSignatureSetByParentStateSlot(config: BeaconConfig, index2pubkey: Index2PubkeyCache, parentStateSlot: Slot, signedBlockHeader: phase0.SignedBeaconBlockHeader): ISignatureSet;
|
|
8
|
+
export declare function getBlockHeaderProposerSignatureSetByHeaderSlot(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlockHeader: phase0.SignedBeaconBlockHeader): ISignatureSet;
|
|
8
9
|
//# sourceMappingURL=proposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposer.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proposer.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,wBAAwB,EAAE,IAAI,EAAwB,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAC,aAAa,EAAuC,MAAM,0BAA0B,CAAC;AAE7F,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,GAAG,wBAAwB,GACxD,OAAO,CAGT;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,GAAG,wBAAwB,GACxD,aAAa,CAgBf;AAED,wBAAgB,mDAAmD,CACjE,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,eAAe,EAAE,IAAI,EACrB,iBAAiB,EAAE,MAAM,CAAC,uBAAuB,iBAGlD;AAED,wBAAgB,8CAA8C,CAC5D,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,iBAAiB,EAAE,MAAM,CAAC,uBAAuB,iBAGlD"}
|
|
@@ -2,35 +2,36 @@ import { DOMAIN_BEACON_PROPOSER } from "@lodestar/params";
|
|
|
2
2
|
import { isBlindedBeaconBlock, ssz } from "@lodestar/types";
|
|
3
3
|
import { computeSigningRoot } from "../util/index.js";
|
|
4
4
|
import { SignatureSetType, verifySignatureSet } from "../util/signatureSets.js";
|
|
5
|
-
export function verifyProposerSignature(
|
|
6
|
-
const signatureSet = getBlockProposerSignatureSet(
|
|
5
|
+
export function verifyProposerSignature(config, index2pubkey, signedBlock) {
|
|
6
|
+
const signatureSet = getBlockProposerSignatureSet(config, index2pubkey, signedBlock);
|
|
7
7
|
return verifySignatureSet(signatureSet);
|
|
8
8
|
}
|
|
9
|
-
export function getBlockProposerSignatureSet(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export function getBlockProposerSignatureSet(config, index2pubkey, signedBlock) {
|
|
10
|
+
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
11
|
+
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
12
|
+
const blockSlot = signedBlock.message.slot;
|
|
13
|
+
const domain = config.getDomain(blockSlot, DOMAIN_BEACON_PROPOSER, blockSlot);
|
|
12
14
|
const blockType = isBlindedBeaconBlock(signedBlock.message)
|
|
13
15
|
? config.getPostBellatrixForkTypes(signedBlock.message.slot).BlindedBeaconBlock
|
|
14
16
|
: config.getForkTypes(signedBlock.message.slot).BeaconBlock;
|
|
15
17
|
return {
|
|
16
18
|
type: SignatureSetType.single,
|
|
17
|
-
pubkey:
|
|
19
|
+
pubkey: index2pubkey[signedBlock.message.proposerIndex],
|
|
18
20
|
signingRoot: computeSigningRoot(blockType, signedBlock.message, domain),
|
|
19
21
|
signature: signedBlock.signature,
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
|
-
export function getBlockHeaderProposerSignatureSetByParentStateSlot(
|
|
23
|
-
return getBlockHeaderProposerSignatureSet(
|
|
24
|
+
export function getBlockHeaderProposerSignatureSetByParentStateSlot(config, index2pubkey, parentStateSlot, signedBlockHeader) {
|
|
25
|
+
return getBlockHeaderProposerSignatureSet(config, index2pubkey, signedBlockHeader, parentStateSlot);
|
|
24
26
|
}
|
|
25
|
-
export function getBlockHeaderProposerSignatureSetByHeaderSlot(
|
|
26
|
-
return getBlockHeaderProposerSignatureSet(
|
|
27
|
+
export function getBlockHeaderProposerSignatureSetByHeaderSlot(config, index2pubkey, signedBlockHeader) {
|
|
28
|
+
return getBlockHeaderProposerSignatureSet(config, index2pubkey, signedBlockHeader, signedBlockHeader.message.slot);
|
|
27
29
|
}
|
|
28
|
-
function getBlockHeaderProposerSignatureSet(
|
|
29
|
-
const { config, epochCtx } = state;
|
|
30
|
+
function getBlockHeaderProposerSignatureSet(config, index2pubkey, signedBlockHeader, domainSlot) {
|
|
30
31
|
const domain = config.getDomain(domainSlot, DOMAIN_BEACON_PROPOSER, signedBlockHeader.message.slot);
|
|
31
32
|
return {
|
|
32
33
|
type: SignatureSetType.single,
|
|
33
|
-
pubkey:
|
|
34
|
+
pubkey: index2pubkey[signedBlockHeader.message.proposerIndex],
|
|
34
35
|
signingRoot: computeSigningRoot(ssz.phase0.BeaconBlockHeader, signedBlockHeader.message, domain),
|
|
35
36
|
signature: signedBlockHeader.signature,
|
|
36
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposer.js","sourceRoot":"","sources":["../../src/signatureSets/proposer.ts"],"names":[],"mappings":"
|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AC;QACvE,SAAS,EAAE,WAAW,CAAC,SAAS;KACjC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mDAAmD,CACjE,MAAoB,EACpB,YAA+B,EAC/B,eAAqB,EACrB,iBAAiD;IAEjD,OAAO,kCAAkC,CAAC,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;AACtG,CAAC;AAED,MAAM,UAAU,8CAA8C,CAC5D,MAAoB,EACpB,YAA+B,EAC/B,iBAAiD;IAEjD,OAAO,kCAAkC,CAAC,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACrH,CAAC;AAED,SAAS,kCAAkC,CACzC,MAAoB,EACpB,YAA+B,EAC/B,iBAAiD,EACjD,UAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpG,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,MAAM;QAC7B,MAAM,EAAE,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,aAAa,CAAC;QAC7D,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC;QAChG,SAAS,EAAE,iBAAiB,CAAC,SAAS;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
2
|
+
import { SignedBeaconBlock, Slot, phase0 } from "@lodestar/types";
|
|
3
|
+
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
4
|
import { ISignatureSet } from "../util/index.js";
|
|
4
5
|
/**
|
|
5
6
|
* Extract signatures to allow validating all block signatures at once
|
|
6
7
|
*/
|
|
7
|
-
export declare function getProposerSlashingSignatureSets(
|
|
8
|
-
export declare function getProposerSlashingsSignatureSets(
|
|
8
|
+
export declare function getProposerSlashingSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, proposerSlashing: phase0.ProposerSlashing): ISignatureSet[];
|
|
9
|
+
export declare function getProposerSlashingsSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock): ISignatureSet[];
|
|
9
10
|
//# sourceMappingURL=proposerSlashings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposerSlashings.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proposerSlashings.d.ts","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,aAAa,EAAuC,MAAM,kBAAkB,CAAC;AAErF;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,GACxC,aAAa,EAAE,CAejB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,GAC7B,aAAa,EAAE,CAOjB"}
|
|
@@ -4,13 +4,12 @@ import { SignatureSetType, computeSigningRoot } from "../util/index.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Extract signatures to allow validating all block signatures at once
|
|
6
6
|
*/
|
|
7
|
-
export function getProposerSlashingSignatureSets(
|
|
8
|
-
const
|
|
9
|
-
const pubkey = epochCtx.index2pubkey[proposerSlashing.signedHeader1.message.proposerIndex];
|
|
7
|
+
export function getProposerSlashingSignatureSets(config, index2pubkey, stateSlot, proposerSlashing) {
|
|
8
|
+
const pubkey = index2pubkey[proposerSlashing.signedHeader1.message.proposerIndex];
|
|
10
9
|
// In state transition, ProposerSlashing headers are only partially validated. Their slot could be higher than the
|
|
11
10
|
// clock and the slashing would still be valid. Must use bigint variants to hash correctly to all possible values
|
|
12
11
|
return [proposerSlashing.signedHeader1, proposerSlashing.signedHeader2].map((signedHeader) => {
|
|
13
|
-
const domain =
|
|
12
|
+
const domain = config.getDomain(stateSlot, DOMAIN_BEACON_PROPOSER, Number(signedHeader.message.slot));
|
|
14
13
|
return {
|
|
15
14
|
type: SignatureSetType.single,
|
|
16
15
|
pubkey,
|
|
@@ -19,7 +18,10 @@ export function getProposerSlashingSignatureSets(state, proposerSlashing) {
|
|
|
19
18
|
};
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
|
-
export function getProposerSlashingsSignatureSets(
|
|
23
|
-
|
|
21
|
+
export function getProposerSlashingsSignatureSets(config, index2pubkey, signedBlock) {
|
|
22
|
+
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
23
|
+
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
24
|
+
const blockSlot = signedBlock.message.slot;
|
|
25
|
+
return signedBlock.message.body.proposerSlashings.flatMap((proposerSlashing) => getProposerSlashingSignatureSets(config, index2pubkey, blockSlot, proposerSlashing));
|
|
24
26
|
}
|
|
25
27
|
//# sourceMappingURL=proposerSlashings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposerSlashings.js","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"proposerSlashings.js","sourceRoot":"","sources":["../../src/signatureSets/proposerSlashings.ts"],"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AC,CACpF,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
1
2
|
import { BeaconBlock } from "@lodestar/types";
|
|
2
|
-
import {
|
|
3
|
+
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
4
|
import { ISignatureSet } from "../util/index.js";
|
|
4
|
-
export declare function verifyRandaoSignature(
|
|
5
|
+
export declare function verifyRandaoSignature(config: BeaconConfig, index2pubkey: Index2PubkeyCache, block: BeaconBlock): boolean;
|
|
5
6
|
/**
|
|
6
7
|
* Extract signatures to allow validating all block signatures at once
|
|
7
8
|
*/
|
|
8
|
-
export declare function getRandaoRevealSignatureSet(
|
|
9
|
+
export declare function getRandaoRevealSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, block: BeaconBlock): ISignatureSet;
|
|
9
10
|
//# sourceMappingURL=randao.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randao.d.ts","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"randao.d.ts","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAC,WAAW,EAAM,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,WAAW,GACjB,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,WAAW,GACjB,aAAa,CAaf"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { DOMAIN_RANDAO } from "@lodestar/params";
|
|
2
2
|
import { ssz } from "@lodestar/types";
|
|
3
3
|
import { SignatureSetType, computeEpochAtSlot, computeSigningRoot, verifySignatureSet, } from "../util/index.js";
|
|
4
|
-
export function verifyRandaoSignature(
|
|
5
|
-
return verifySignatureSet(getRandaoRevealSignatureSet(
|
|
4
|
+
export function verifyRandaoSignature(config, index2pubkey, block) {
|
|
5
|
+
return verifySignatureSet(getRandaoRevealSignatureSet(config, index2pubkey, block));
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Extract signatures to allow validating all block signatures at once
|
|
9
9
|
*/
|
|
10
|
-
export function getRandaoRevealSignatureSet(
|
|
11
|
-
const { epochCtx } = state;
|
|
10
|
+
export function getRandaoRevealSignatureSet(config, index2pubkey, block) {
|
|
12
11
|
// should not get epoch from epochCtx
|
|
13
12
|
const epoch = computeEpochAtSlot(block.slot);
|
|
14
|
-
|
|
13
|
+
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
14
|
+
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
15
|
+
const domain = config.getDomain(block.slot, DOMAIN_RANDAO, block.slot);
|
|
15
16
|
return {
|
|
16
17
|
type: SignatureSetType.single,
|
|
17
|
-
pubkey:
|
|
18
|
+
pubkey: index2pubkey[block.proposerIndex],
|
|
18
19
|
signingRoot: computeSigningRoot(ssz.Epoch, epoch, domain),
|
|
19
20
|
signature: block.body.randaoReveal,
|
|
20
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randao.js","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"randao.js","sourceRoot":"","sources":["../../src/signatureSets/randao.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAc,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAEL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,qBAAqB,CACnC,MAAoB,EACpB,YAA+B,EAC/B,KAAkB;IAElB,OAAO,kBAAkB,CAAC,2BAA2B,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAoB,EACpB,YAA+B,EAC/B,KAAkB;IAElB,qCAAqC;IACrC,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7C,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEvE,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,MAAM;QAC7B,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC;QACzC,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC;QACzD,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BeaconConfig } from "@lodestar/config";
|
|
2
|
+
import { SignedBeaconBlock, Slot, phase0 } from "@lodestar/types";
|
|
3
|
+
import { Index2PubkeyCache } from "../cache/pubkeyCache.js";
|
|
3
4
|
import { ISignatureSet } from "../util/index.js";
|
|
4
|
-
export declare function verifyVoluntaryExitSignature(
|
|
5
|
+
export declare function verifyVoluntaryExitSignature(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, signedVoluntaryExit: phase0.SignedVoluntaryExit): boolean;
|
|
5
6
|
/**
|
|
6
7
|
* Extract signatures to allow validating all block signatures at once
|
|
7
8
|
*/
|
|
8
|
-
export declare function getVoluntaryExitSignatureSet(
|
|
9
|
-
export declare function getVoluntaryExitsSignatureSets(
|
|
9
|
+
export declare function getVoluntaryExitSignatureSet(config: BeaconConfig, index2pubkey: Index2PubkeyCache, stateSlot: Slot, signedVoluntaryExit: phase0.SignedVoluntaryExit): ISignatureSet;
|
|
10
|
+
export declare function getVoluntaryExitsSignatureSets(config: BeaconConfig, index2pubkey: Index2PubkeyCache, signedBlock: SignedBeaconBlock): ISignatureSet[];
|
|
10
11
|
//# sourceMappingURL=voluntaryExits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voluntaryExits.d.ts","sourceRoot":"","sources":["../../src/signatureSets/voluntaryExits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"voluntaryExits.d.ts","sourceRoot":"","sources":["../../src/signatureSets/voluntaryExits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAM,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EACL,aAAa,EAKd,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,GAC9C,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,IAAI,EACf,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,GAC9C,aAAa,CAUf;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,iBAAiB,GAC7B,aAAa,EAAE,CAOjB"}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { ssz } from "@lodestar/types";
|
|
2
2
|
import { SignatureSetType, computeSigningRoot, computeStartSlotAtEpoch, verifySignatureSet, } from "../util/index.js";
|
|
3
|
-
export function verifyVoluntaryExitSignature(
|
|
4
|
-
return verifySignatureSet(getVoluntaryExitSignatureSet(
|
|
3
|
+
export function verifyVoluntaryExitSignature(config, index2pubkey, stateSlot, signedVoluntaryExit) {
|
|
4
|
+
return verifySignatureSet(getVoluntaryExitSignatureSet(config, index2pubkey, stateSlot, signedVoluntaryExit));
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Extract signatures to allow validating all block signatures at once
|
|
8
8
|
*/
|
|
9
|
-
export function getVoluntaryExitSignatureSet(
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const domain = state.config.getDomainForVoluntaryExit(state.slot, slot);
|
|
9
|
+
export function getVoluntaryExitSignatureSet(config, index2pubkey, stateSlot, signedVoluntaryExit) {
|
|
10
|
+
const messageSlot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
|
|
11
|
+
const domain = config.getDomainForVoluntaryExit(stateSlot, messageSlot);
|
|
13
12
|
return {
|
|
14
13
|
type: SignatureSetType.single,
|
|
15
|
-
pubkey:
|
|
14
|
+
pubkey: index2pubkey[signedVoluntaryExit.message.validatorIndex],
|
|
16
15
|
signingRoot: computeSigningRoot(ssz.phase0.VoluntaryExit, signedVoluntaryExit.message, domain),
|
|
17
16
|
signature: signedVoluntaryExit.signature,
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
|
-
export function getVoluntaryExitsSignatureSets(
|
|
21
|
-
|
|
19
|
+
export function getVoluntaryExitsSignatureSets(config, index2pubkey, signedBlock) {
|
|
20
|
+
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
21
|
+
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
22
|
+
const blockSlot = signedBlock.message.slot;
|
|
23
|
+
return signedBlock.message.body.voluntaryExits.map((voluntaryExit) => getVoluntaryExitSignatureSet(config, index2pubkey, blockSlot, voluntaryExit));
|
|
22
24
|
}
|
|
23
25
|
//# sourceMappingURL=voluntaryExits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"voluntaryExits.js","sourceRoot":"","sources":["../../src/signatureSets/voluntaryExits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"voluntaryExits.js","sourceRoot":"","sources":["../../src/signatureSets/voluntaryExits.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAEL,gBAAgB,EAChB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,UAAU,4BAA4B,CAC1C,MAAoB,EACpB,YAA+B,EAC/B,SAAe,EACf,mBAA+C;IAE/C,OAAO,kBAAkB,CAAC,4BAA4B,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAChH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAAoB,EACpB,YAA+B,EAC/B,SAAe,EACf,mBAA+C;IAE/C,MAAM,WAAW,GAAG,uBAAuB,CAAC,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,MAAM,CAAC,yBAAyB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAExE,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,MAAM;QAC7B,MAAM,EAAE,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,cAAc,CAAC;QAChE,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC;QAC9F,SAAS,EAAE,mBAAmB,CAAC,SAAS;KACzC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,MAAoB,EACpB,YAA+B,EAC/B,WAA8B;IAE9B,oHAAoH;IACpH,0GAA0G;IAC1G,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3C,OAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CACnE,4BAA4B,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,CAAC,CAC7E,CAAC;AACJ,CAAC"}
|
package/lib/stateTransition.js
CHANGED
|
@@ -52,7 +52,7 @@ export function stateTransition(state, signedBlock, options = {
|
|
|
52
52
|
// Includes state upgrades
|
|
53
53
|
postState = processSlotsWithTransientCache(postState, blockSlot, options, { metrics, validatorMonitor });
|
|
54
54
|
// Verify proposer signature only
|
|
55
|
-
if (verifyProposer && !verifyProposerSignature(postState, signedBlock)) {
|
|
55
|
+
if (verifyProposer && !verifyProposerSignature(postState.config, postState.epochCtx.index2pubkey, signedBlock)) {
|
|
56
56
|
throw new Error("Invalid block signature");
|
|
57
57
|
}
|
|
58
58
|
// Process block
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stateTransition.js","sourceRoot":"","sources":["../src/stateTransition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAA2D,GAAG,EAAC,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAoB,sBAAsB,EAAE,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAC1G,OAAO,EAAC,Y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AAM,KAAK,GAAG,OAAO,EAAE,yBAAyB,CAAC,UAAU,EAAE,CAAC;gBAC9D,SAAS,CAAC,MAAM,EAAE,CAAC;gBACnB,KAAK,EAAE,EAAE,CAAC;YACZ,CAAC;YAED,oIAAoI;YACpI,oBAAoB,EAAE,EAAE,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/util/execution.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { ForkName, ForkPostBellatrix, ForkPreGloas, ForkSeq } from "@lodestar/params";
|
|
2
|
-
import { BeaconBlock, BeaconBlockBody, BlindedBeaconBlock, BlindedBeaconBlockBody, ExecutionPayload, ExecutionPayloadHeader,
|
|
2
|
+
import { BeaconBlock, BeaconBlockBody, BlindedBeaconBlock, BlindedBeaconBlockBody, ExecutionPayload, ExecutionPayloadHeader, capella } from "@lodestar/types";
|
|
3
3
|
import { BeaconStateAllForks, BeaconStateCapella, BeaconStateExecutions, CachedBeaconStateAllForks, CachedBeaconStateExecutions } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Execution enabled = merge is done.
|
|
6
6
|
* When (A) state has execution data OR (B) block has execution data
|
|
7
7
|
*/
|
|
8
8
|
export declare function isExecutionEnabled(state: BeaconStateExecutions, block: BeaconBlock | BlindedBeaconBlock): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Merge block is the SINGLE block that transitions from POW to POS.
|
|
11
|
-
* state has no execution data AND this block has execution data
|
|
12
|
-
*/
|
|
13
|
-
export declare function isMergeTransitionBlock(state: BeaconStateExecutions, body: bellatrix.BeaconBlockBody): boolean;
|
|
14
9
|
/**
|
|
15
10
|
* Merge is complete when the state includes execution layer data:
|
|
16
|
-
* state.latestExecutionPayloadHeader NOT EMPTY
|
|
11
|
+
* state.latestExecutionPayloadHeader NOT EMPTY or state is post-capella
|
|
17
12
|
*/
|
|
18
13
|
export declare function isMergeTransitionComplete(state: BeaconStateExecutions): boolean;
|
|
19
14
|
/** Type guard for bellatrix.BeaconState */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/util/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/util/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EAEtB,OAAO,EAKR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EAEnB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAE,WAAW,GAAG,kBAAkB,GAAG,OAAO,CAcjH;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAU/E;AAED,2CAA2C;AAC3C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,KAAK,IAAI,qBAAqB,CAE/F;AAED,yCAAyC;AACzC,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,KAAK,IAAI,kBAAkB,CAK1F;AAED,iDAAiD;AACjD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,yBAAyB,GAAG,KAAK,IAAI,2BAA2B,CAEjH;AAED,wCAAwC;AACxC,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,eAAe,GACzB,SAAS,IAAI,eAAe,CAAC,iBAAiB,GAAG,YAAY,CAAC,CAEhE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,GAAG,sBAAsB,CAErG;AAED,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,eAAe,GAAG,sBAAsB,GAC7C,gBAAgB,GAAG,sBAAsB,CAU3C;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,GAAG,sBAAsB,GACjD,OAAO,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAK1F;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,CAAC,6BAA6B,GAC7C,OAAO,IAAI,OAAO,CAAC,sBAAsB,CAE3C;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,sBAAsB,CAuChH"}
|
package/lib/util/execution.js
CHANGED
|
@@ -8,40 +8,22 @@ export function isExecutionEnabled(state, block) {
|
|
|
8
8
|
if (isMergeTransitionComplete(state)) {
|
|
9
9
|
return true;
|
|
10
10
|
}
|
|
11
|
-
// Throws if not post-bellatrix block. A fork-guard
|
|
11
|
+
// Throws if not post-bellatrix block. A fork-guard before isExecutionEnabled() prevents this from happening
|
|
12
12
|
const payload = getFullOrBlindedPayload(block);
|
|
13
|
-
// Note: spec says to check all payload is zero-ed. However a state-root cannot be zero for any non-empty payload
|
|
14
|
-
// TODO: Consider comparing with the payload root if this assumption is not correct.
|
|
15
|
-
// return !byteArrayEquals(payload.stateRoot, ZERO_HASH);
|
|
16
|
-
// UPDATE: stateRoot comparision should have been enough with zero hash, but spec tests were failing
|
|
17
|
-
// Revisit this later to fix specs and make this efficient
|
|
18
13
|
return isExecutionPayload(payload)
|
|
19
14
|
? !ssz.bellatrix.ExecutionPayload.equals(payload, ssz.bellatrix.ExecutionPayload.defaultValue())
|
|
20
|
-
: !ssz.bellatrix.ExecutionPayloadHeader.equals(state.latestExecutionPayloadHeader,
|
|
21
|
-
// TODO: Performance
|
|
22
|
-
ssz.bellatrix.ExecutionPayloadHeader.defaultValue());
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Merge block is the SINGLE block that transitions from POW to POS.
|
|
26
|
-
* state has no execution data AND this block has execution data
|
|
27
|
-
*/
|
|
28
|
-
export function isMergeTransitionBlock(state, body) {
|
|
29
|
-
return (!isMergeTransitionComplete(state) &&
|
|
30
|
-
!ssz.bellatrix.ExecutionPayload.equals(body.executionPayload, ssz.bellatrix.ExecutionPayload.defaultValue()));
|
|
15
|
+
: !ssz.bellatrix.ExecutionPayloadHeader.equals(state.latestExecutionPayloadHeader, ssz.bellatrix.ExecutionPayloadHeader.defaultValue());
|
|
31
16
|
}
|
|
32
17
|
/**
|
|
33
18
|
* Merge is complete when the state includes execution layer data:
|
|
34
|
-
* state.latestExecutionPayloadHeader NOT EMPTY
|
|
19
|
+
* state.latestExecutionPayloadHeader NOT EMPTY or state is post-capella
|
|
35
20
|
*/
|
|
36
21
|
export function isMergeTransitionComplete(state) {
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ssz.bellatrix.ExecutionPayloadHeader.defaultValue());
|
|
22
|
+
if (isCapellaStateType(state)) {
|
|
23
|
+
// All networks have completed the merge transition before capella
|
|
24
|
+
return true;
|
|
41
25
|
}
|
|
42
|
-
return !ssz.
|
|
43
|
-
// TODO: Performance
|
|
44
|
-
ssz.capella.ExecutionPayloadHeader.defaultValue());
|
|
26
|
+
return !ssz.bellatrix.ExecutionPayloadHeader.equals(state.latestExecutionPayloadHeader, ssz.bellatrix.ExecutionPayloadHeader.defaultValue());
|
|
45
27
|
}
|
|
46
28
|
/** Type guard for bellatrix.BeaconState */
|
|
47
29
|
export function isExecutionStateType(state) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/util/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAUL,wBAAwB,EACxB,kBAAkB,EAClB,GAAG,GACJ,MAAM,iBAAiB,CAAC;AAUzB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA4B,EAAE,KAAuC;IACtG,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/util/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAUL,wBAAwB,EACxB,kBAAkB,EAClB,GAAG,GACJ,MAAM,iBAAiB,CAAC;AAUzB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA4B,EAAE,KAAuC;IACtG,IAAI,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4GAA4G;IAC5G,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAE/C,OAAO,kBAAkB,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC;QAChG,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAC,MAAM,CAC1C,KAAK,CAAC,4BAA4B,EAClC,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAC,YAAY,EAAE,CACpD,CAAC;AACR,CAAC;AAED;;;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;QAC9G,sBAAuD,CAAC,WAAW,GAClE,OACD,CAAC,WAAW,CAAC;QACb,sBAAuD,CAAC,aAAa,GACpE,OACD,CAAC,aAAa,CAAC;IAClB,CAAC;IAED,uBAAuB;IAEvB,OAAO,sBAAsB,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.39.0-dev.0321dbcf04",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"scripts": {
|
|
44
44
|
"clean": "rm -rf lib && rm -f *.tsbuildinfo",
|
|
45
45
|
"build": "tsc -p tsconfig.build.json",
|
|
46
|
-
"build:watch": "
|
|
47
|
-
"build:release": "
|
|
46
|
+
"build:watch": "pnpm run build --watch",
|
|
47
|
+
"build:release": "pnpm clean && pnpm build",
|
|
48
48
|
"check-build": "node -e \"(async function() { await import('./lib/index.js') })()\"",
|
|
49
49
|
"check-types": "tsc",
|
|
50
50
|
"lint": "biome check src/ test/",
|
|
51
|
-
"lint:fix": "
|
|
52
|
-
"test": "
|
|
51
|
+
"lint:fix": "pnpm run lint --write",
|
|
52
|
+
"test": "pnpm test:unit",
|
|
53
53
|
"test:unit": "vitest run --project unit --project unit-minimal",
|
|
54
|
-
"check-readme": "
|
|
54
|
+
"check-readme": "pnpm exec ts-node ../../scripts/check_readme.ts"
|
|
55
55
|
},
|
|
56
56
|
"types": "lib/index.d.ts",
|
|
57
57
|
"dependencies": {
|
|
@@ -62,17 +62,20 @@
|
|
|
62
62
|
"@chainsafe/pubkey-index-map": "^3.0.0",
|
|
63
63
|
"@chainsafe/ssz": "^1.2.2",
|
|
64
64
|
"@chainsafe/swap-or-not-shuffle": "^1.2.1",
|
|
65
|
-
"@lodestar/config": "^1.
|
|
66
|
-
"@lodestar/params": "^1.
|
|
67
|
-
"@lodestar/types": "^1.
|
|
68
|
-
"@lodestar/utils": "^1.
|
|
65
|
+
"@lodestar/config": "^1.39.0-dev.0321dbcf04",
|
|
66
|
+
"@lodestar/params": "^1.39.0-dev.0321dbcf04",
|
|
67
|
+
"@lodestar/types": "^1.39.0-dev.0321dbcf04",
|
|
68
|
+
"@lodestar/utils": "^1.39.0-dev.0321dbcf04",
|
|
69
69
|
"bigint-buffer": "^1.1.5"
|
|
70
70
|
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@lodestar/api": "^1.39.0-dev.0321dbcf04"
|
|
73
|
+
},
|
|
71
74
|
"keywords": [
|
|
72
75
|
"ethereum",
|
|
73
76
|
"eth-consensus",
|
|
74
77
|
"beacon",
|
|
75
78
|
"blockchain"
|
|
76
79
|
],
|
|
77
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "ad062d807edb3a6d39ca07122d51a3db06f2302f"
|
|
78
81
|
}
|
package/src/block/index.ts
CHANGED
|
@@ -68,8 +68,8 @@ export function processBlock(
|
|
|
68
68
|
// on the randao_mix computed with the reveal of the previous block.
|
|
69
69
|
// TODO GLOAS: We call processExecutionPayload somewhere else post-gloas
|
|
70
70
|
if (
|
|
71
|
-
fork >= ForkSeq.bellatrix &&
|
|
72
71
|
fork < ForkSeq.gloas &&
|
|
72
|
+
fork >= ForkSeq.bellatrix &&
|
|
73
73
|
isExecutionEnabled(state as CachedBeaconStateBellatrix, block)
|
|
74
74
|
) {
|
|
75
75
|
processExecutionPayload(fork, state as CachedBeaconStateBellatrix, block.body, externalData);
|