Handle merge fork in web3signer (#2631)
This commit is contained in:
parent
10b263fed4
commit
18eee2dc82
@ -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)
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user