11import { BeaconConfig } from "@lodestar/config" ;
2- import { IBeaconStateView , getBlockSignatureSets } from "@lodestar/state-transition" ;
3- import { IndexedAttestation , SignedBeaconBlock } from "@lodestar/types" ;
2+ import {
3+ IBeaconStateView ,
4+ PubkeyCache ,
5+ getBlockSignatureSets ,
6+ getExecutionPayloadEnvelopeSignatureSet ,
7+ } from "@lodestar/state-transition" ;
8+ import { IndexedAttestation , SignedBeaconBlock , Slot , gloas } from "@lodestar/types" ;
49import { Logger } from "@lodestar/utils" ;
510import { Metrics } from "../../metrics/metrics.js" ;
611import { nextEventLoop } from "../../util/eventLoop.js" ;
@@ -17,11 +22,13 @@ import {ImportBlockOpts} from "./types.js";
1722 */
1823export async function verifyBlocksSignatures (
1924 config : BeaconConfig ,
25+ pubkeyCache : PubkeyCache ,
2026 bls : IBlsVerifier ,
2127 logger : Logger ,
2228 metrics : Metrics | null ,
2329 preState0 : IBeaconStateView ,
2430 blocks : SignedBeaconBlock [ ] ,
31+ envelopes : Map < Slot , gloas . SignedExecutionPayloadEnvelope > | null ,
2532 indexedAttestationsByBlock : IndexedAttestation [ ] [ ] ,
2633 opts : ImportBlockOpts
2734) : Promise < { verifySignaturesTime : number } > {
@@ -38,13 +45,30 @@ export async function verifyBlocksSignatures(
3845 isValidPromises [ i ] = opts . validSignatures
3946 ? // Skip all signature verification
4047 Promise . resolve ( true )
41- : //
42- // Verify signatures per block to track which block is invalid
43- bls . verifySignatureSets (
44- getBlockSignatureSets ( config , currentSyncCommitteeIndexed , preState0 , block , indexedAttestationsByBlock [ i ] , {
45- skipProposerSignature : opts . validProposerSignature ,
46- } )
47- ) ;
48+ : // Verify signatures per block + envelope to track which block is invalid
49+ ( ( ) => {
50+ const signatureSets = getBlockSignatureSets (
51+ config ,
52+ currentSyncCommitteeIndexed ,
53+ preState0 ,
54+ block ,
55+ indexedAttestationsByBlock [ i ] ,
56+ { skipProposerSignature : opts . validProposerSignature }
57+ ) ;
58+ const envelope = envelopes ?. get ( block . message . slot ) ;
59+ if ( envelope ) {
60+ signatureSets . push (
61+ getExecutionPayloadEnvelopeSignatureSet (
62+ config ,
63+ pubkeyCache ,
64+ preState0 ,
65+ envelope ,
66+ block . message . proposerIndex
67+ )
68+ ) ;
69+ }
70+ return bls . verifySignatureSets ( signatureSets ) ;
71+ } ) ( ) ;
4872
4973 // getBlockSignatureSets() takes 45ms in benchmarks for 2022Q2 mainnet blocks (100 sigs). When syncing a 32 blocks
5074 // segments it will block the event loop for 1400 ms, which is too much. This call will allow the event loop to
0 commit comments