@lodestar/state-transition 1.40.0-dev.1cab20c166 → 1.40.0-dev.2d390f92ac
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.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +2 -2
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.js +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.js.map +1 -1
- package/lib/block/processAttestationsAltair.d.ts.map +1 -1
- package/lib/block/processAttestationsAltair.js +2 -2
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processExecutionPayloadBid.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadBid.js +5 -5
- package/lib/block/processExecutionPayloadBid.js.map +1 -1
- package/lib/block/processProposerSlashing.js +2 -2
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/processSyncCommittee.d.ts +1 -2
- package/lib/block/processSyncCommittee.d.ts.map +1 -1
- package/lib/block/processSyncCommittee.js +5 -5
- package/lib/block/processSyncCommittee.js.map +1 -1
- package/lib/block/processVoluntaryExit.js +1 -1
- package/lib/block/processVoluntaryExit.js.map +1 -1
- package/lib/signatureSets/attesterSlashings.d.ts +3 -4
- 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/blsToExecutionChange.d.ts +3 -3
- package/lib/signatureSets/blsToExecutionChange.d.ts.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.js.map +1 -1
- package/lib/signatureSets/executionPayloadBid.d.ts +4 -0
- package/lib/signatureSets/executionPayloadBid.d.ts.map +1 -0
- package/lib/signatureSets/executionPayloadBid.js +8 -0
- package/lib/signatureSets/executionPayloadBid.js.map +1 -0
- package/lib/signatureSets/executionPayloadEnvelope.d.ts +4 -0
- package/lib/signatureSets/executionPayloadEnvelope.d.ts.map +1 -0
- package/lib/signatureSets/executionPayloadEnvelope.js +8 -0
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -0
- package/lib/signatureSets/index.d.ts +3 -2
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +10 -8
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/indexedAttestation.d.ts +3 -4
- package/lib/signatureSets/indexedAttestation.d.ts.map +1 -1
- package/lib/signatureSets/indexedAttestation.js +6 -6
- package/lib/signatureSets/indexedAttestation.js.map +1 -1
- package/lib/signatureSets/indexedPayloadAttestation.d.ts +5 -4
- package/lib/signatureSets/indexedPayloadAttestation.d.ts.map +1 -1
- package/lib/signatureSets/indexedPayloadAttestation.js +3 -3
- package/lib/signatureSets/indexedPayloadAttestation.js.map +1 -1
- package/lib/signatureSets/proposer.d.ts +3 -3
- package/lib/signatureSets/proposer.d.ts.map +1 -1
- package/lib/signatureSets/proposer.js +12 -12
- package/lib/signatureSets/proposer.js.map +1 -1
- package/lib/signatureSets/proposerSlashings.d.ts +2 -3
- package/lib/signatureSets/proposerSlashings.d.ts.map +1 -1
- package/lib/signatureSets/proposerSlashings.js +6 -6
- package/lib/signatureSets/proposerSlashings.js.map +1 -1
- package/lib/signatureSets/randao.d.ts +1 -1
- 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 +2 -2
- 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/util/gloas.d.ts +10 -9
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +1 -3
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/interop.js +1 -1
- package/lib/util/interop.js.map +1 -1
- package/lib/util/signatureSets.d.ts +38 -5
- package/lib/util/signatureSets.d.ts.map +1 -1
- package/lib/util/signatureSets.js +48 -6
- package/lib/util/signatureSets.js.map +1 -1
- package/package.json +8 -8
- package/src/block/isValidIndexedAttestation.ts +3 -2
- package/src/block/isValidIndexedPayloadAttestation.ts +4 -1
- package/src/block/processAttestationsAltair.ts +2 -8
- package/src/block/processExecutionPayloadBid.ts +5 -5
- package/src/block/processProposerSlashing.ts +2 -2
- package/src/block/processSyncCommittee.ts +3 -6
- package/src/block/processVoluntaryExit.ts +1 -1
- package/src/signatureSets/attesterSlashings.ts +3 -7
- package/src/signatureSets/blsToExecutionChange.ts +3 -3
- package/src/signatureSets/executionPayloadBid.ts +14 -0
- package/src/signatureSets/executionPayloadEnvelope.ts +13 -0
- package/src/signatureSets/index.ts +8 -9
- package/src/signatureSets/indexedAttestation.ts +2 -7
- package/src/signatureSets/indexedPayloadAttestation.ts +9 -7
- package/src/signatureSets/proposer.ts +8 -12
- package/src/signatureSets/proposerSlashings.ts +4 -7
- package/src/signatureSets/randao.ts +4 -8
- package/src/signatureSets/voluntaryExits.ts +5 -10
- package/src/util/gloas.ts +19 -14
- package/src/util/index.ts +1 -0
- package/src/util/interop.ts +1 -1
- package/src/util/signatureSets.ts +84 -8
|
@@ -1,17 +1,51 @@
|
|
|
1
|
-
import { Signature, fastAggregateVerify, verify } from "@chainsafe/blst";
|
|
1
|
+
import { Signature, aggregatePublicKeys, fastAggregateVerify, verify } from "@chainsafe/blst";
|
|
2
2
|
export var SignatureSetType;
|
|
3
3
|
(function (SignatureSetType) {
|
|
4
4
|
SignatureSetType["single"] = "single";
|
|
5
5
|
SignatureSetType["aggregate"] = "aggregate";
|
|
6
|
+
/**
|
|
7
|
+
* Single signature with validator index instead of pubkey.
|
|
8
|
+
* Pubkey lookup is deferred to verification time.
|
|
9
|
+
*/
|
|
10
|
+
SignatureSetType["indexed"] = "indexed";
|
|
6
11
|
})(SignatureSetType || (SignatureSetType = {}));
|
|
7
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Get the pubkey for a signature set, performing aggregation if necessary.
|
|
14
|
+
* Requires index2pubkey cache for indexed and aggregate sets.
|
|
15
|
+
*/
|
|
16
|
+
export function getSignatureSetPubkey(signatureSet, index2pubkey) {
|
|
17
|
+
switch (signatureSet.type) {
|
|
18
|
+
case SignatureSetType.single:
|
|
19
|
+
return signatureSet.pubkey;
|
|
20
|
+
case SignatureSetType.indexed:
|
|
21
|
+
return index2pubkey[signatureSet.index];
|
|
22
|
+
case SignatureSetType.aggregate: {
|
|
23
|
+
const pubkeys = signatureSet.indices.map((i) => index2pubkey[i]);
|
|
24
|
+
return aggregatePublicKeys(pubkeys);
|
|
25
|
+
}
|
|
26
|
+
default:
|
|
27
|
+
throw Error("Unknown signature set type");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function verifySignatureSet(signatureSet, index2pubkey) {
|
|
8
31
|
// All signatures are not trusted and must be group checked (p2.subgroup_check)
|
|
9
32
|
const signature = Signature.fromBytes(signatureSet.signature, true);
|
|
10
33
|
switch (signatureSet.type) {
|
|
11
34
|
case SignatureSetType.single:
|
|
12
35
|
return verify(signatureSet.signingRoot, signatureSet.pubkey, signature);
|
|
13
|
-
case SignatureSetType.
|
|
14
|
-
|
|
36
|
+
case SignatureSetType.indexed: {
|
|
37
|
+
if (!index2pubkey) {
|
|
38
|
+
throw Error("index2pubkey required for indexed signature set");
|
|
39
|
+
}
|
|
40
|
+
return verify(signatureSet.signingRoot, index2pubkey[signatureSet.index], signature);
|
|
41
|
+
}
|
|
42
|
+
case SignatureSetType.aggregate: {
|
|
43
|
+
if (!index2pubkey) {
|
|
44
|
+
throw Error("index2pubkey required for aggregate signature set");
|
|
45
|
+
}
|
|
46
|
+
const pubkeys = signatureSet.indices.map((i) => index2pubkey[i]);
|
|
47
|
+
return fastAggregateVerify(signatureSet.signingRoot, pubkeys, signature);
|
|
48
|
+
}
|
|
15
49
|
default:
|
|
16
50
|
throw Error("Unknown signature set type");
|
|
17
51
|
}
|
|
@@ -24,10 +58,18 @@ export function createSingleSignatureSetFromComponents(pubkey, signingRoot, sign
|
|
|
24
58
|
signature,
|
|
25
59
|
};
|
|
26
60
|
}
|
|
27
|
-
export function
|
|
61
|
+
export function createIndexedSignatureSetFromComponents(index, signingRoot, signature) {
|
|
62
|
+
return {
|
|
63
|
+
type: SignatureSetType.indexed,
|
|
64
|
+
index,
|
|
65
|
+
signingRoot,
|
|
66
|
+
signature,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function createAggregateSignatureSetFromComponents(indices, signingRoot, signature) {
|
|
28
70
|
return {
|
|
29
71
|
type: SignatureSetType.aggregate,
|
|
30
|
-
|
|
72
|
+
indices,
|
|
31
73
|
signingRoot,
|
|
32
74
|
signature,
|
|
33
75
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signatureSets.js","sourceRoot":"","sources":["../../src/util/signatureSets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"signatureSets.js","sourceRoot":"","sources":["../../src/util/signatureSets.ts"],"names":[],"mappings":"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"}
|
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.40.0-dev.
|
|
14
|
+
"version": "1.40.0-dev.2d390f92ac",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -62,14 +62,14 @@
|
|
|
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.40.0-dev.
|
|
66
|
-
"@lodestar/params": "^1.40.0-dev.
|
|
67
|
-
"@lodestar/types": "^1.40.0-dev.
|
|
68
|
-
"@lodestar/utils": "^1.40.0-dev.
|
|
69
|
-
"bigint-
|
|
65
|
+
"@lodestar/config": "^1.40.0-dev.2d390f92ac",
|
|
66
|
+
"@lodestar/params": "^1.40.0-dev.2d390f92ac",
|
|
67
|
+
"@lodestar/types": "^1.40.0-dev.2d390f92ac",
|
|
68
|
+
"@lodestar/utils": "^1.40.0-dev.2d390f92ac",
|
|
69
|
+
"@vekexasia/bigint-buffer2": "^1.0.4"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@lodestar/api": "^1.40.0-dev.
|
|
72
|
+
"@lodestar/api": "^1.40.0-dev.2d390f92ac"
|
|
73
73
|
},
|
|
74
74
|
"keywords": [
|
|
75
75
|
"ethereum",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"beacon",
|
|
78
78
|
"blockchain"
|
|
79
79
|
],
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "48834a0eb4cc074bb1fa8f518337e23ab47f6b3c"
|
|
81
81
|
}
|
|
@@ -21,7 +21,7 @@ export function isValidIndexedAttestation(
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (verifySignature) {
|
|
24
|
-
return verifySignatureSet(getIndexedAttestationSignatureSet(config,
|
|
24
|
+
return verifySignatureSet(getIndexedAttestationSignatureSet(config, stateSlot, indexedAttestation), index2pubkey);
|
|
25
25
|
}
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
@@ -40,7 +40,8 @@ export function isValidIndexedAttestationBigint(
|
|
|
40
40
|
|
|
41
41
|
if (verifySignature) {
|
|
42
42
|
return verifySignatureSet(
|
|
43
|
-
getIndexedAttestationBigintSignatureSet(config,
|
|
43
|
+
getIndexedAttestationBigintSignatureSet(config, stateSlot, indexedAttestation),
|
|
44
|
+
index2pubkey
|
|
44
45
|
);
|
|
45
46
|
}
|
|
46
47
|
return true;
|
|
@@ -16,7 +16,10 @@ export function isValidIndexedPayloadAttestation(
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
if (verifySignature) {
|
|
19
|
-
return verifySignatureSet(
|
|
19
|
+
return verifySignatureSet(
|
|
20
|
+
getIndexedPayloadAttestationSignatureSet(state, indexedPayloadAttestation),
|
|
21
|
+
state.epochCtx.index2pubkey
|
|
22
|
+
);
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
return true;
|
|
@@ -64,14 +64,8 @@ export function processAttestationsAltair(
|
|
|
64
64
|
// TODO: Why should we verify an indexed attestation that we just created? If it's just for the signature
|
|
65
65
|
// we can verify only that and nothing else.
|
|
66
66
|
if (verifySignature) {
|
|
67
|
-
const sigSet = getAttestationWithIndicesSignatureSet(
|
|
68
|
-
|
|
69
|
-
epochCtx.index2pubkey,
|
|
70
|
-
state.slot,
|
|
71
|
-
attestation,
|
|
72
|
-
attestingIndices
|
|
73
|
-
);
|
|
74
|
-
if (!verifySignatureSet(sigSet)) {
|
|
67
|
+
const sigSet = getAttestationWithIndicesSignatureSet(state.config, state.slot, attestation, attestingIndices);
|
|
68
|
+
if (!verifySignatureSet(sigSet, state.epochCtx.index2pubkey)) {
|
|
75
69
|
throw new Error("Attestation signature is not valid");
|
|
76
70
|
}
|
|
77
71
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {PublicKey, Signature, verify} from "@chainsafe/blst";
|
|
2
2
|
import {byteArrayEquals} from "@chainsafe/ssz";
|
|
3
|
-
import {BUILDER_INDEX_SELF_BUILD,
|
|
3
|
+
import {BUILDER_INDEX_SELF_BUILD, ForkPostGloas, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
4
4
|
import {BeaconBlock, gloas, ssz} from "@lodestar/types";
|
|
5
5
|
import {toHex, toRootHex} from "@lodestar/utils";
|
|
6
6
|
import {G2_POINT_AT_INFINITY} from "../constants/constants.ts";
|
|
7
|
+
import {getExecutionPayloadBidSigningRoot} from "../signatureSets/executionPayloadBid.js";
|
|
7
8
|
import {CachedBeaconStateGloas} from "../types.ts";
|
|
8
9
|
import {canBuilderCoverBid, isActiveBuilder} from "../util/gloas.ts";
|
|
9
|
-
import {
|
|
10
|
+
import {getCurrentEpoch, getRandaoMix} from "../util/index.ts";
|
|
10
11
|
|
|
11
12
|
export function processExecutionPayloadBid(state: CachedBeaconStateGloas, block: BeaconBlock<ForkPostGloas>): void {
|
|
12
13
|
const signedBid = block.body.signedExecutionPayloadBid;
|
|
@@ -27,7 +28,7 @@ export function processExecutionPayloadBid(state: CachedBeaconStateGloas, block:
|
|
|
27
28
|
const builder = state.builders.getReadonly(builderIndex);
|
|
28
29
|
|
|
29
30
|
// Verify that the builder is active
|
|
30
|
-
if (!isActiveBuilder(
|
|
31
|
+
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
31
32
|
throw Error(`Invalid execution payload bid: builder ${builderIndex} is not active`);
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -84,8 +85,7 @@ function verifyExecutionPayloadBidSignature(
|
|
|
84
85
|
pubkey: Uint8Array,
|
|
85
86
|
signedBid: gloas.SignedExecutionPayloadBid
|
|
86
87
|
): boolean {
|
|
87
|
-
const
|
|
88
|
-
const signingRoot = computeSigningRoot(ssz.gloas.ExecutionPayloadBid, signedBid.message, domain);
|
|
88
|
+
const signingRoot = getExecutionPayloadBidSigningRoot(state.config, state.slot, signedBid.message);
|
|
89
89
|
|
|
90
90
|
try {
|
|
91
91
|
const publicKey = PublicKey.fromBytes(pubkey);
|
|
@@ -92,9 +92,9 @@ export function assertValidProposerSlashing(
|
|
|
92
92
|
|
|
93
93
|
// verify signatures
|
|
94
94
|
if (verifySignatures) {
|
|
95
|
-
const signatureSets = getProposerSlashingSignatureSets(config,
|
|
95
|
+
const signatureSets = getProposerSlashingSignatureSets(config, stateSlot, proposerSlashing);
|
|
96
96
|
for (let i = 0; i < signatureSets.length; i++) {
|
|
97
|
-
if (!verifySignatureSet(signatureSets[i])) {
|
|
97
|
+
if (!verifySignatureSet(signatureSets[i], index2pubkey)) {
|
|
98
98
|
throw new Error(`ProposerSlashing header${i + 1} signature invalid`);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -2,7 +2,6 @@ import {byteArrayEquals} from "@chainsafe/ssz";
|
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
3
|
import {DOMAIN_SYNC_COMMITTEE, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
|
|
4
4
|
import {altair, ssz} from "@lodestar/types";
|
|
5
|
-
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
5
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
7
6
|
import {G2_POINT_AT_INFINITY} from "../constants/index.js";
|
|
8
7
|
import {CachedBeaconStateAllForks} from "../types.js";
|
|
@@ -28,13 +27,12 @@ export function processSyncAggregate(
|
|
|
28
27
|
const participantIndices = block.body.syncAggregate.syncCommitteeBits.intersectValues(committeeIndices);
|
|
29
28
|
const signatureSet = getSyncCommitteeSignatureSet(
|
|
30
29
|
state.config,
|
|
31
|
-
state.epochCtx.index2pubkey,
|
|
32
30
|
state.epochCtx.currentSyncCommitteeIndexed,
|
|
33
31
|
block,
|
|
34
32
|
participantIndices
|
|
35
33
|
);
|
|
36
|
-
// When there's no participation we consider the signature valid and just ignore
|
|
37
|
-
if (signatureSet !== null && !verifySignatureSet(signatureSet)) {
|
|
34
|
+
// When there's no participation we consider the signature valid and just ignore it
|
|
35
|
+
if (signatureSet !== null && !verifySignatureSet(signatureSet, state.epochCtx.index2pubkey)) {
|
|
38
36
|
throw Error("Sync committee signature invalid");
|
|
39
37
|
}
|
|
40
38
|
}
|
|
@@ -73,7 +71,6 @@ export function processSyncAggregate(
|
|
|
73
71
|
|
|
74
72
|
export function getSyncCommitteeSignatureSet(
|
|
75
73
|
config: BeaconConfig,
|
|
76
|
-
index2pubkey: Index2PubkeyCache,
|
|
77
74
|
currentSyncCommitteeIndexed: SyncCommitteeCache,
|
|
78
75
|
block: altair.BeaconBlock,
|
|
79
76
|
/** Optional parameter to prevent computing it twice */
|
|
@@ -122,7 +119,7 @@ export function getSyncCommitteeSignatureSet(
|
|
|
122
119
|
|
|
123
120
|
return {
|
|
124
121
|
type: SignatureSetType.aggregate,
|
|
125
|
-
|
|
122
|
+
indices: participantIndices,
|
|
126
123
|
signingRoot: computeSigningRoot(ssz.Root, rootSigned, domain),
|
|
127
124
|
signature,
|
|
128
125
|
};
|
|
@@ -49,7 +49,7 @@ export function processVoluntaryExit(
|
|
|
49
49
|
const builder = stateGloas.builders.getReadonly(builderIndex);
|
|
50
50
|
|
|
51
51
|
// Verify the builder is active
|
|
52
|
-
if (!isActiveBuilder(
|
|
52
|
+
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
53
53
|
throw Error(`Builder ${builderIndex} is not active`);
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params";
|
|
3
3
|
import {AttesterSlashing, IndexedAttestationBigint, SignedBeaconBlock, Slot, ssz} from "@lodestar/types";
|
|
4
|
-
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
5
4
|
import {ISignatureSet, SignatureSetType, computeSigningRoot, computeStartSlotAtEpoch} from "../util/index.js";
|
|
6
5
|
|
|
7
6
|
/** Get signature sets from all AttesterSlashing objects in a block */
|
|
8
7
|
export function getAttesterSlashingsSignatureSets(
|
|
9
8
|
config: BeaconConfig,
|
|
10
|
-
index2pubkey: Index2PubkeyCache,
|
|
11
9
|
signedBlock: SignedBeaconBlock
|
|
12
10
|
): ISignatureSet[] {
|
|
13
11
|
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
14
12
|
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
15
13
|
const blockSlot = signedBlock.message.slot;
|
|
16
14
|
return signedBlock.message.body.attesterSlashings.flatMap((attesterSlashing) =>
|
|
17
|
-
getAttesterSlashingSignatureSets(config,
|
|
15
|
+
getAttesterSlashingSignatureSets(config, blockSlot, attesterSlashing)
|
|
18
16
|
);
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
/** Get signature sets from a single AttesterSlashing object */
|
|
22
20
|
export function getAttesterSlashingSignatureSets(
|
|
23
21
|
config: BeaconConfig,
|
|
24
|
-
index2pubkey: Index2PubkeyCache,
|
|
25
22
|
stateSlot: Slot,
|
|
26
23
|
attesterSlashing: AttesterSlashing
|
|
27
24
|
): ISignatureSet[] {
|
|
28
25
|
return [attesterSlashing.attestation1, attesterSlashing.attestation2].map((attestation) =>
|
|
29
|
-
getIndexedAttestationBigintSignatureSet(config,
|
|
26
|
+
getIndexedAttestationBigintSignatureSet(config, stateSlot, attestation)
|
|
30
27
|
);
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
export function getIndexedAttestationBigintSignatureSet(
|
|
34
31
|
config: BeaconConfig,
|
|
35
|
-
index2pubkey: Index2PubkeyCache,
|
|
36
32
|
stateSlot: Slot,
|
|
37
33
|
indexedAttestation: IndexedAttestationBigint
|
|
38
34
|
): ISignatureSet {
|
|
@@ -41,7 +37,7 @@ export function getIndexedAttestationBigintSignatureSet(
|
|
|
41
37
|
|
|
42
38
|
return {
|
|
43
39
|
type: SignatureSetType.aggregate,
|
|
44
|
-
|
|
40
|
+
indices: indexedAttestation.attestingIndices.map((i) => Number(i)),
|
|
45
41
|
signingRoot: computeSigningRoot(ssz.phase0.AttestationDataBigint, indexedAttestation.data, domain),
|
|
46
42
|
signature: indexedAttestation.signature,
|
|
47
43
|
};
|
|
@@ -2,7 +2,7 @@ import {PublicKey} from "@chainsafe/blst";
|
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
3
|
import {DOMAIN_BLS_TO_EXECUTION_CHANGE, ForkName} from "@lodestar/params";
|
|
4
4
|
import {capella, ssz} from "@lodestar/types";
|
|
5
|
-
import {
|
|
5
|
+
import {SignatureSetType, SingleSignatureSet, computeSigningRoot, verifySignatureSet} from "../util/index.js";
|
|
6
6
|
|
|
7
7
|
export function verifyBlsToExecutionChangeSignature(
|
|
8
8
|
config: BeaconConfig,
|
|
@@ -17,7 +17,7 @@ export function verifyBlsToExecutionChangeSignature(
|
|
|
17
17
|
export function getBlsToExecutionChangeSignatureSet(
|
|
18
18
|
config: BeaconConfig,
|
|
19
19
|
signedBLSToExecutionChange: capella.SignedBLSToExecutionChange
|
|
20
|
-
):
|
|
20
|
+
): SingleSignatureSet {
|
|
21
21
|
// signatureFork for signing domain is fixed
|
|
22
22
|
const signatureFork = ForkName.phase0;
|
|
23
23
|
const domain = config.getDomainAtFork(signatureFork, DOMAIN_BLS_TO_EXECUTION_CHANGE);
|
|
@@ -35,7 +35,7 @@ export function getBlsToExecutionChangeSignatureSet(
|
|
|
35
35
|
export function getBlsToExecutionChangeSignatureSets(
|
|
36
36
|
config: BeaconConfig,
|
|
37
37
|
signedBlock: capella.SignedBeaconBlock
|
|
38
|
-
):
|
|
38
|
+
): SingleSignatureSet[] {
|
|
39
39
|
return signedBlock.message.body.blsToExecutionChanges.map((blsToExecutionChange) =>
|
|
40
40
|
getBlsToExecutionChangeSignatureSet(config, blsToExecutionChange)
|
|
41
41
|
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
+
import {DOMAIN_BEACON_BUILDER} from "@lodestar/params";
|
|
3
|
+
import {Slot, gloas, ssz} from "@lodestar/types";
|
|
4
|
+
import {computeSigningRoot} from "../util/index.js";
|
|
5
|
+
|
|
6
|
+
export function getExecutionPayloadBidSigningRoot(
|
|
7
|
+
config: BeaconConfig,
|
|
8
|
+
stateSlot: Slot,
|
|
9
|
+
bid: gloas.ExecutionPayloadBid
|
|
10
|
+
): Uint8Array {
|
|
11
|
+
const domain = config.getDomain(stateSlot, DOMAIN_BEACON_BUILDER);
|
|
12
|
+
|
|
13
|
+
return computeSigningRoot(ssz.gloas.ExecutionPayloadBid, bid, domain);
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
+
import {DOMAIN_BEACON_BUILDER} from "@lodestar/params";
|
|
3
|
+
import {gloas, ssz} from "@lodestar/types";
|
|
4
|
+
import {computeSigningRoot} from "../util/index.js";
|
|
5
|
+
|
|
6
|
+
export function getExecutionPayloadEnvelopeSigningRoot(
|
|
7
|
+
config: BeaconConfig,
|
|
8
|
+
envelope: gloas.ExecutionPayloadEnvelope
|
|
9
|
+
): Uint8Array {
|
|
10
|
+
const domain = config.getDomain(envelope.slot, DOMAIN_BEACON_BUILDER);
|
|
11
|
+
|
|
12
|
+
return computeSigningRoot(ssz.gloas.ExecutionPayloadEnvelope, envelope, domain);
|
|
13
|
+
}
|
|
@@ -2,7 +2,6 @@ import {BeaconConfig} from "@lodestar/config";
|
|
|
2
2
|
import {ForkSeq} from "@lodestar/params";
|
|
3
3
|
import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
|
|
4
4
|
import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
|
|
5
|
-
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
5
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
7
6
|
import {ISignatureSet} from "../util/index.js";
|
|
8
7
|
import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
|
|
@@ -15,6 +14,8 @@ import {getVoluntaryExitsSignatureSets} from "./voluntaryExits.js";
|
|
|
15
14
|
|
|
16
15
|
export * from "./attesterSlashings.js";
|
|
17
16
|
export * from "./blsToExecutionChange.js";
|
|
17
|
+
export * from "./executionPayloadBid.js";
|
|
18
|
+
export * from "./executionPayloadEnvelope.js";
|
|
18
19
|
export * from "./indexedAttestation.js";
|
|
19
20
|
export * from "./indexedPayloadAttestation.js";
|
|
20
21
|
export * from "./proposer.js";
|
|
@@ -28,7 +29,6 @@ export * from "./voluntaryExits.js";
|
|
|
28
29
|
*/
|
|
29
30
|
export function getBlockSignatureSets(
|
|
30
31
|
config: BeaconConfig,
|
|
31
|
-
index2pubkey: Index2PubkeyCache,
|
|
32
32
|
currentSyncCommitteeIndexed: SyncCommitteeCache,
|
|
33
33
|
signedBlock: SignedBeaconBlock,
|
|
34
34
|
indexedAttestations: IndexedAttestation[],
|
|
@@ -41,22 +41,21 @@ export function getBlockSignatureSets(
|
|
|
41
41
|
const fork = config.getForkSeq(signedBlock.message.slot);
|
|
42
42
|
|
|
43
43
|
const signatureSets = [
|
|
44
|
-
getRandaoRevealSignatureSet(config,
|
|
45
|
-
...getProposerSlashingsSignatureSets(config,
|
|
46
|
-
...getAttesterSlashingsSignatureSets(config,
|
|
47
|
-
...getAttestationsSignatureSets(config,
|
|
48
|
-
...getVoluntaryExitsSignatureSets(config,
|
|
44
|
+
getRandaoRevealSignatureSet(config, signedBlock.message),
|
|
45
|
+
...getProposerSlashingsSignatureSets(config, signedBlock),
|
|
46
|
+
...getAttesterSlashingsSignatureSets(config, signedBlock),
|
|
47
|
+
...getAttestationsSignatureSets(config, signedBlock, indexedAttestations),
|
|
48
|
+
...getVoluntaryExitsSignatureSets(config, signedBlock),
|
|
49
49
|
];
|
|
50
50
|
|
|
51
51
|
if (!opts?.skipProposerSignature) {
|
|
52
|
-
signatureSets.push(getBlockProposerSignatureSet(config,
|
|
52
|
+
signatureSets.push(getBlockProposerSignatureSet(config, signedBlock));
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// Only after altair fork, validate tSyncCommitteeSignature
|
|
56
56
|
if (fork >= ForkSeq.altair) {
|
|
57
57
|
const syncCommitteeSignatureSet = getSyncCommitteeSignatureSet(
|
|
58
58
|
config,
|
|
59
|
-
index2pubkey,
|
|
60
59
|
currentSyncCommitteeIndexed,
|
|
61
60
|
(signedBlock as altair.SignedBeaconBlock).message
|
|
62
61
|
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_BEACON_ATTESTER} from "@lodestar/params";
|
|
3
3
|
import {IndexedAttestation, SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
|
|
4
|
-
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
5
4
|
import {
|
|
6
5
|
ISignatureSet,
|
|
7
6
|
computeSigningRoot,
|
|
@@ -22,13 +21,12 @@ export function getAttestationDataSigningRoot(
|
|
|
22
21
|
|
|
23
22
|
export function getAttestationWithIndicesSignatureSet(
|
|
24
23
|
config: BeaconConfig,
|
|
25
|
-
index2pubkey: Index2PubkeyCache,
|
|
26
24
|
stateSlot: Slot,
|
|
27
25
|
attestation: Pick<phase0.Attestation, "data" | "signature">,
|
|
28
26
|
attestingIndices: number[]
|
|
29
27
|
): ISignatureSet {
|
|
30
28
|
return createAggregateSignatureSetFromComponents(
|
|
31
|
-
attestingIndices
|
|
29
|
+
attestingIndices,
|
|
32
30
|
getAttestationDataSigningRoot(config, stateSlot, attestation.data),
|
|
33
31
|
attestation.signature
|
|
34
32
|
);
|
|
@@ -36,13 +34,11 @@ export function getAttestationWithIndicesSignatureSet(
|
|
|
36
34
|
|
|
37
35
|
export function getIndexedAttestationSignatureSet(
|
|
38
36
|
config: BeaconConfig,
|
|
39
|
-
index2pubkey: Index2PubkeyCache,
|
|
40
37
|
stateSlot: Slot,
|
|
41
38
|
indexedAttestation: IndexedAttestation
|
|
42
39
|
): ISignatureSet {
|
|
43
40
|
return getAttestationWithIndicesSignatureSet(
|
|
44
41
|
config,
|
|
45
|
-
index2pubkey,
|
|
46
42
|
stateSlot,
|
|
47
43
|
indexedAttestation,
|
|
48
44
|
indexedAttestation.attestingIndices
|
|
@@ -51,7 +47,6 @@ export function getIndexedAttestationSignatureSet(
|
|
|
51
47
|
|
|
52
48
|
export function getAttestationsSignatureSets(
|
|
53
49
|
config: BeaconConfig,
|
|
54
|
-
index2pubkey: Index2PubkeyCache,
|
|
55
50
|
signedBlock: SignedBeaconBlock,
|
|
56
51
|
indexedAttestations: IndexedAttestation[]
|
|
57
52
|
): ISignatureSet[] {
|
|
@@ -64,6 +59,6 @@ export function getAttestationsSignatureSets(
|
|
|
64
59
|
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
65
60
|
const blockSlot = signedBlock.message.slot;
|
|
66
61
|
return indexedAttestations.map((indexedAttestation) =>
|
|
67
|
-
getIndexedAttestationSignatureSet(config,
|
|
62
|
+
getIndexedAttestationSignatureSet(config, blockSlot, indexedAttestation)
|
|
68
63
|
);
|
|
69
64
|
}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {DOMAIN_PTC_ATTESTER} from "@lodestar/params";
|
|
2
|
-
import {gloas, ssz} from "@lodestar/types";
|
|
3
|
-
import {CachedBeaconStateGloas} from "../types.
|
|
4
|
-
import {ISignatureSet, computeSigningRoot, createAggregateSignatureSetFromComponents} from "../util/index.
|
|
3
|
+
import {Slot, gloas, ssz} from "@lodestar/types";
|
|
4
|
+
import {CachedBeaconStateGloas} from "../types.js";
|
|
5
|
+
import {ISignatureSet, computeSigningRoot, createAggregateSignatureSetFromComponents} from "../util/index.js";
|
|
5
6
|
|
|
6
7
|
export function getIndexedPayloadAttestationSignatureSet(
|
|
7
8
|
state: CachedBeaconStateGloas,
|
|
8
9
|
indexedPayloadAttestation: gloas.IndexedPayloadAttestation
|
|
9
10
|
): ISignatureSet {
|
|
10
11
|
return createAggregateSignatureSetFromComponents(
|
|
11
|
-
indexedPayloadAttestation.attestingIndices
|
|
12
|
-
getPayloadAttestationDataSigningRoot(state, indexedPayloadAttestation.data),
|
|
12
|
+
indexedPayloadAttestation.attestingIndices,
|
|
13
|
+
getPayloadAttestationDataSigningRoot(state.config, state.slot, indexedPayloadAttestation.data),
|
|
13
14
|
indexedPayloadAttestation.signature
|
|
14
15
|
);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function getPayloadAttestationDataSigningRoot(
|
|
18
|
-
|
|
19
|
+
config: BeaconConfig,
|
|
20
|
+
stateSlot: Slot,
|
|
19
21
|
data: gloas.PayloadAttestationData
|
|
20
22
|
): Uint8Array {
|
|
21
|
-
const domain =
|
|
23
|
+
const domain = config.getDomain(stateSlot, DOMAIN_PTC_ATTESTER);
|
|
22
24
|
|
|
23
25
|
return computeSigningRoot(ssz.gloas.PayloadAttestationData, data, domain);
|
|
24
26
|
}
|
|
@@ -10,13 +10,12 @@ export function verifyProposerSignature(
|
|
|
10
10
|
index2pubkey: Index2PubkeyCache,
|
|
11
11
|
signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
|
|
12
12
|
): boolean {
|
|
13
|
-
const signatureSet = getBlockProposerSignatureSet(config,
|
|
14
|
-
return verifySignatureSet(signatureSet);
|
|
13
|
+
const signatureSet = getBlockProposerSignatureSet(config, signedBlock);
|
|
14
|
+
return verifySignatureSet(signatureSet, index2pubkey);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function getBlockProposerSignatureSet(
|
|
18
18
|
config: BeaconConfig,
|
|
19
|
-
index2pubkey: Index2PubkeyCache,
|
|
20
19
|
signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
|
|
21
20
|
): ISignatureSet {
|
|
22
21
|
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
@@ -29,8 +28,8 @@ export function getBlockProposerSignatureSet(
|
|
|
29
28
|
: config.getForkTypes(signedBlock.message.slot).BeaconBlock;
|
|
30
29
|
|
|
31
30
|
return {
|
|
32
|
-
type: SignatureSetType.
|
|
33
|
-
|
|
31
|
+
type: SignatureSetType.indexed,
|
|
32
|
+
index: signedBlock.message.proposerIndex,
|
|
34
33
|
signingRoot: computeSigningRoot(blockType, signedBlock.message, domain),
|
|
35
34
|
signature: signedBlock.signature,
|
|
36
35
|
};
|
|
@@ -38,32 +37,29 @@ export function getBlockProposerSignatureSet(
|
|
|
38
37
|
|
|
39
38
|
export function getBlockHeaderProposerSignatureSetByParentStateSlot(
|
|
40
39
|
config: BeaconConfig,
|
|
41
|
-
index2pubkey: Index2PubkeyCache,
|
|
42
40
|
parentStateSlot: Slot,
|
|
43
41
|
signedBlockHeader: phase0.SignedBeaconBlockHeader
|
|
44
42
|
) {
|
|
45
|
-
return getBlockHeaderProposerSignatureSet(config,
|
|
43
|
+
return getBlockHeaderProposerSignatureSet(config, signedBlockHeader, parentStateSlot);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
export function getBlockHeaderProposerSignatureSetByHeaderSlot(
|
|
49
47
|
config: BeaconConfig,
|
|
50
|
-
index2pubkey: Index2PubkeyCache,
|
|
51
48
|
signedBlockHeader: phase0.SignedBeaconBlockHeader
|
|
52
49
|
) {
|
|
53
|
-
return getBlockHeaderProposerSignatureSet(config,
|
|
50
|
+
return getBlockHeaderProposerSignatureSet(config, signedBlockHeader, signedBlockHeader.message.slot);
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
function getBlockHeaderProposerSignatureSet(
|
|
57
54
|
config: BeaconConfig,
|
|
58
|
-
index2pubkey: Index2PubkeyCache,
|
|
59
55
|
signedBlockHeader: phase0.SignedBeaconBlockHeader,
|
|
60
56
|
domainSlot: Slot
|
|
61
57
|
): ISignatureSet {
|
|
62
58
|
const domain = config.getDomain(domainSlot, DOMAIN_BEACON_PROPOSER, signedBlockHeader.message.slot);
|
|
63
59
|
|
|
64
60
|
return {
|
|
65
|
-
type: SignatureSetType.
|
|
66
|
-
|
|
61
|
+
type: SignatureSetType.indexed,
|
|
62
|
+
index: signedBlockHeader.message.proposerIndex,
|
|
67
63
|
signingRoot: computeSigningRoot(ssz.phase0.BeaconBlockHeader, signedBlockHeader.message, domain),
|
|
68
64
|
signature: signedBlockHeader.signature,
|
|
69
65
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
|
|
3
3
|
import {SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
|
|
4
|
-
import {Index2PubkeyCache} from "../cache/pubkeyCache.js";
|
|
5
4
|
import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index.js";
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -9,11 +8,10 @@ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index
|
|
|
9
8
|
*/
|
|
10
9
|
export function getProposerSlashingSignatureSets(
|
|
11
10
|
config: BeaconConfig,
|
|
12
|
-
index2pubkey: Index2PubkeyCache,
|
|
13
11
|
stateSlot: Slot,
|
|
14
12
|
proposerSlashing: phase0.ProposerSlashing
|
|
15
13
|
): ISignatureSet[] {
|
|
16
|
-
const
|
|
14
|
+
const proposerIndex = proposerSlashing.signedHeader1.message.proposerIndex;
|
|
17
15
|
|
|
18
16
|
// In state transition, ProposerSlashing headers are only partially validated. Their slot could be higher than the
|
|
19
17
|
// clock and the slashing would still be valid. Must use bigint variants to hash correctly to all possible values
|
|
@@ -21,8 +19,8 @@ export function getProposerSlashingSignatureSets(
|
|
|
21
19
|
const domain = config.getDomain(stateSlot, DOMAIN_BEACON_PROPOSER, Number(signedHeader.message.slot as bigint));
|
|
22
20
|
|
|
23
21
|
return {
|
|
24
|
-
type: SignatureSetType.
|
|
25
|
-
|
|
22
|
+
type: SignatureSetType.indexed,
|
|
23
|
+
index: proposerIndex,
|
|
26
24
|
signingRoot: computeSigningRoot(ssz.phase0.BeaconBlockHeaderBigint, signedHeader.message, domain),
|
|
27
25
|
signature: signedHeader.signature,
|
|
28
26
|
};
|
|
@@ -31,13 +29,12 @@ export function getProposerSlashingSignatureSets(
|
|
|
31
29
|
|
|
32
30
|
export function getProposerSlashingsSignatureSets(
|
|
33
31
|
config: BeaconConfig,
|
|
34
|
-
index2pubkey: Index2PubkeyCache,
|
|
35
32
|
signedBlock: SignedBeaconBlock
|
|
36
33
|
): ISignatureSet[] {
|
|
37
34
|
// the getDomain() api requires the state slot as 1st param, however it's the same to block.slot in state-transition
|
|
38
35
|
// and the same epoch when we verify blocks in batch in beacon-node. So we can safely use block.slot here.
|
|
39
36
|
const blockSlot = signedBlock.message.slot;
|
|
40
37
|
return signedBlock.message.body.proposerSlashings.flatMap((proposerSlashing) =>
|
|
41
|
-
getProposerSlashingSignatureSets(config,
|
|
38
|
+
getProposerSlashingSignatureSets(config, blockSlot, proposerSlashing)
|
|
42
39
|
);
|
|
43
40
|
}
|