Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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