From 6a9d522705159f424d27d07ee6c3a5553c074846 Mon Sep 17 00:00:00 2001 From: tersec Date: Fri, 1 Dec 2023 14:44:45 +0000 Subject: [PATCH] Apply EIP-7044 to block signature batch verification (#5637) --- .../consensus_object_pools/block_clearance.nim | 3 ++- beacon_chain/spec/signatures_batch.nim | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/beacon_chain/consensus_object_pools/block_clearance.nim b/beacon_chain/consensus_object_pools/block_clearance.nim index 454da7a90..fa061913e 100644 --- a/beacon_chain/consensus_object_pools/block_clearance.nim +++ b/beacon_chain/consensus_object_pools/block_clearance.nim @@ -284,7 +284,8 @@ proc addHeadBlockWithParent*( var sigs: seq[SignatureSet] if (let e = sigs.collectSignatureSets( signedBlock, dag.db.immutableValidators, - dag.clearanceState, dag.cfg.genesisFork(), cache); e.isErr()): + dag.clearanceState, dag.cfg.genesisFork(), dag.cfg.capellaFork(), + cache); e.isErr()): # A PublicKey or Signature isn't on the BLS12-381 curve info "Unable to load signature sets", err = e.error() diff --git a/beacon_chain/spec/signatures_batch.nim b/beacon_chain/spec/signatures_batch.nim index 4c154d0fa..42a6d7474 100644 --- a/beacon_chain/spec/signatures_batch.nim +++ b/beacon_chain/spec/signatures_batch.nim @@ -231,9 +231,10 @@ func bls_to_execution_change_signature_set*( proc collectSignatureSets*( sigs: var seq[SignatureSet], signed_block: ForkySignedBeaconBlock, - validatorKeys: auto, + validatorKeys: openArray[ImmutableValidatorData2], state: ForkedHashedBeaconState, genesis_fork: Fork, + capella_fork: Fork, cache: var StateCache): Result[void, cstring] = ## Collect all signature verifications that process_block would normally do ## except deposits, in one go. @@ -392,7 +393,13 @@ proc collectSignatureSets*( return err("collectSignatureSets: invalid voluntary exit") sigs.add voluntary_exit_signature_set( - fork, genesis_validators_root, volex.message, key, + # https://eips.ethereum.org/EIPS/eip-7044 + # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/deneb/beacon-chain.md#modified-process_voluntary_exit + (if state.kind >= ConsensusFork.Capella: + capella_fork + else: + fork), + genesis_validators_root, volex.message, key, volex.signature.load.valueOr do: return err( "collectSignatureSets: cannot load voluntary exit signature"))