Add Merge support to web3signer validators (#3318)
## Issue Addressed Web3signer validators can't produce post-Bellatrix blocks. ## Proposed Changes Add support for Bellatrix to web3signer validators. ## Additional Info I am running validators with this code on Ropsten, but it may be a while for them to get a proposal.
This commit is contained in:
parent
2940783a9c
commit
4f58c555a9
@ -612,6 +612,28 @@ mod tests {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test all the Merge types.
|
||||||
|
async fn test_merge_types(network: &str, listen_port: u16) {
|
||||||
|
let network_config = Eth2NetworkConfig::constant(network).unwrap().unwrap();
|
||||||
|
let spec = &network_config.chain_spec::<E>().unwrap();
|
||||||
|
let merge_fork_slot = spec
|
||||||
|
.bellatrix_fork_epoch
|
||||||
|
.unwrap()
|
||||||
|
.start_slot(E::slots_per_epoch());
|
||||||
|
|
||||||
|
TestingRig::new(network, spec.clone(), listen_port)
|
||||||
|
.await
|
||||||
|
.assert_signatures_match("beacon_block_merge", |pubkey, validator_store| async move {
|
||||||
|
let mut merge_block = BeaconBlockMerge::empty(spec);
|
||||||
|
merge_block.slot = merge_fork_slot;
|
||||||
|
validator_store
|
||||||
|
.sign_block(pubkey, BeaconBlock::Merge(merge_block), merge_fork_slot)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn mainnet_base_types() {
|
async fn mainnet_base_types() {
|
||||||
test_base_types("mainnet", 4242).await
|
test_base_types("mainnet", 4242).await
|
||||||
@ -631,4 +653,19 @@ mod tests {
|
|||||||
async fn prater_altair_types() {
|
async fn prater_altair_types() {
|
||||||
test_altair_types("prater", 4247).await
|
test_altair_types("prater", 4247).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn ropsten_base_types() {
|
||||||
|
test_base_types("ropsten", 4250).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn ropsten_altair_types() {
|
||||||
|
test_altair_types("ropsten", 4251).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn ropsten_merge_types() {
|
||||||
|
test_merge_types("ropsten", 4252).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ pub enum MessageType {
|
|||||||
pub enum ForkName {
|
pub enum ForkName {
|
||||||
Phase0,
|
Phase0,
|
||||||
Altair,
|
Altair,
|
||||||
|
Bellatrix,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize)]
|
#[derive(Debug, PartialEq, Serialize)]
|
||||||
@ -43,7 +44,10 @@ pub enum Web3SignerObject<'a, T: EthSpec, Payload: ExecPayload<T>> {
|
|||||||
Attestation(&'a AttestationData),
|
Attestation(&'a AttestationData),
|
||||||
BeaconBlock {
|
BeaconBlock {
|
||||||
version: ForkName,
|
version: ForkName,
|
||||||
block: &'a BeaconBlock<T, Payload>,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
block: Option<&'a BeaconBlock<T, Payload>>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
block_header: Option<BeaconBlockHeader>,
|
||||||
},
|
},
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
Deposit {
|
Deposit {
|
||||||
@ -70,13 +74,23 @@ pub enum Web3SignerObject<'a, T: EthSpec, Payload: ExecPayload<T>> {
|
|||||||
|
|
||||||
impl<'a, T: EthSpec, Payload: ExecPayload<T>> Web3SignerObject<'a, T, Payload> {
|
impl<'a, T: EthSpec, Payload: ExecPayload<T>> Web3SignerObject<'a, T, Payload> {
|
||||||
pub fn beacon_block(block: &'a BeaconBlock<T, Payload>) -> Result<Self, Error> {
|
pub fn beacon_block(block: &'a BeaconBlock<T, Payload>) -> Result<Self, Error> {
|
||||||
let version = match block {
|
match block {
|
||||||
BeaconBlock::Base(_) => ForkName::Phase0,
|
BeaconBlock::Base(_) => Ok(Web3SignerObject::BeaconBlock {
|
||||||
BeaconBlock::Altair(_) => ForkName::Altair,
|
version: ForkName::Phase0,
|
||||||
BeaconBlock::Merge(_) => return Err(Error::MergeForkNotSupported),
|
block: Some(block),
|
||||||
};
|
block_header: None,
|
||||||
|
}),
|
||||||
Ok(Web3SignerObject::BeaconBlock { version, block })
|
BeaconBlock::Altair(_) => Ok(Web3SignerObject::BeaconBlock {
|
||||||
|
version: ForkName::Altair,
|
||||||
|
block: Some(block),
|
||||||
|
block_header: None,
|
||||||
|
}),
|
||||||
|
BeaconBlock::Merge(_) => Ok(Web3SignerObject::BeaconBlock {
|
||||||
|
version: ForkName::Bellatrix,
|
||||||
|
block: None,
|
||||||
|
block_header: Some(block.block_header()),
|
||||||
|
}),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn message_type(&self) -> MessageType {
|
pub fn message_type(&self) -> MessageType {
|
||||||
|
Loading…
Reference in New Issue
Block a user