From 18eee2dc825de6fc6ffebed676e90c7a8fb82114 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 27 Sep 2021 10:49:14 +1000 Subject: [PATCH] Handle merge fork in web3signer (#2631) --- validator_client/src/signing_method.rs | 3 ++- validator_client/src/signing_method/web3signer.rs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/validator_client/src/signing_method.rs b/validator_client/src/signing_method.rs index 561cda161..7f28700a2 100644 --- a/validator_client/src/signing_method.rs +++ b/validator_client/src/signing_method.rs @@ -28,6 +28,7 @@ pub enum Error { Web3SignerJsonParsingFailed(String), ShuttingDown, TokioJoin(String), + MergeForkNotSupported, } /// Enumerates all messages that can be signed by a validator. @@ -158,7 +159,7 @@ impl SigningMethod { SignableMessage::RandaoReveal(epoch) => { Web3SignerObject::RandaoReveal { epoch } } - SignableMessage::BeaconBlock(block) => Web3SignerObject::beacon_block(block), + SignableMessage::BeaconBlock(block) => Web3SignerObject::beacon_block(block)?, SignableMessage::AttestationData(a) => Web3SignerObject::Attestation(a), SignableMessage::SignedAggregateAndProof(a) => { Web3SignerObject::AggregateAndProof(a) diff --git a/validator_client/src/signing_method/web3signer.rs b/validator_client/src/signing_method/web3signer.rs index 6ffe2a1ee..b632986c9 100644 --- a/validator_client/src/signing_method/web3signer.rs +++ b/validator_client/src/signing_method/web3signer.rs @@ -1,5 +1,6 @@ //! Contains the types required to make JSON requests to Web3Signer servers. +use super::Error; use serde::{Deserialize, Serialize}; use types::*; @@ -66,13 +67,14 @@ pub enum Web3SignerObject<'a, T: EthSpec> { } impl<'a, T: EthSpec> Web3SignerObject<'a, T> { - pub fn beacon_block(block: &'a BeaconBlock) -> Self { + pub fn beacon_block(block: &'a BeaconBlock) -> Result { let version = match block { BeaconBlock::Base(_) => ForkName::Phase0, BeaconBlock::Altair(_) => ForkName::Altair, + BeaconBlock::Merge(_) => return Err(Error::MergeForkNotSupported), }; - Web3SignerObject::BeaconBlock { version, block } + Ok(Web3SignerObject::BeaconBlock { version, block }) } pub fn message_type(&self) -> MessageType {