Handle merge fork in web3signer (#2631)

This commit is contained in:
Paul Hauner 2021-09-27 10:49:14 +10:00
parent 10b263fed4
commit 18eee2dc82
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
2 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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<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 {