Skip to content

Commit

Permalink
Handle merge fork in web3signer (#2631)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Dec 2, 2021
1 parent 10b263f commit 18eee2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion validator_client/src/signing_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum Error {
Web3SignerJsonParsingFailed(String),
ShuttingDown,
TokioJoin(String),
MergeForkNotSupported,
}

/// Enumerates all messages that can be signed by a validator.
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions validator_client/src/signing_method/web3signer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Contains the types required to make JSON requests to Web3Signer servers.
use super::Error;
use serde::{Deserialize, Serialize};
use types::*;

Expand Down Expand Up @@ -66,13 +67,14 @@ pub enum Web3SignerObject<'a, T: EthSpec> {
}

impl<'a, T: EthSpec> Web3SignerObject<'a, T> {
pub fn beacon_block(block: &'a BeaconBlock<T>) -> Self {
pub fn beacon_block(block: &'a BeaconBlock<T>) -> Result<Self, Error> {
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 {
Expand Down

0 comments on commit 18eee2d

Please sign in to comment.