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;
|
||||
}
|
||||
|
||||
/// 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]
|
||||
async fn mainnet_base_types() {
|
||||
test_base_types("mainnet", 4242).await
|
||||
@ -631,4 +653,19 @@ mod tests {
|
||||
async fn prater_altair_types() {
|
||||
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 {
|
||||
Phase0,
|
||||
Altair,
|
||||
Bellatrix,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize)]
|
||||
@ -43,7 +44,10 @@ pub enum Web3SignerObject<'a, T: EthSpec, Payload: ExecPayload<T>> {
|
||||
Attestation(&'a AttestationData),
|
||||
BeaconBlock {
|
||||
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)]
|
||||
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> {
|
||||
pub fn beacon_block(block: &'a BeaconBlock<T, Payload>) -> Result<Self, Error> {
|
||||
let version = match block {
|
||||
BeaconBlock::Base(_) => ForkName::Phase0,
|
||||
BeaconBlock::Altair(_) => ForkName::Altair,
|
||||
BeaconBlock::Merge(_) => return Err(Error::MergeForkNotSupported),
|
||||
};
|
||||
|
||||
Ok(Web3SignerObject::BeaconBlock { version, block })
|
||||
match block {
|
||||
BeaconBlock::Base(_) => Ok(Web3SignerObject::BeaconBlock {
|
||||
version: ForkName::Phase0,
|
||||
block: Some(block),
|
||||
block_header: None,
|
||||
}),
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user