Validator announce signers (#2617)

### Description

This handles a bug where we did not default the chain signer to the
validator signature for EVM chains and also handles the case where we
might try to announce without setting a chain signer for other chains.

### Drive-by changes

Not really a change but I looked into #2457 and I noticed the validators
already check that signers are set for all destination chains so I think
the error was just for validators which this PR fixes.

### Related issues

- Fixes #2458
- Fixes  #2457

### Backward compatibility

Yes

### Testing

Unit Tests
pull/2633/head
Mattie Conover 1 year ago committed by GitHub
parent a5e1815746
commit 5d8a2e568c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      rust/agents/validator/src/settings.rs
  2. 8
      rust/agents/validator/src/validator.rs

@ -10,7 +10,7 @@ use hyperlane_base::{
SignerConf, SignerConf,
}; };
use hyperlane_core::config::*; use hyperlane_core::config::*;
use hyperlane_core::HyperlaneDomain; use hyperlane_core::{HyperlaneDomain, HyperlaneDomainProtocol};
decl_settings!(Validator, decl_settings!(Validator,
Parsed { Parsed {
@ -54,7 +54,7 @@ impl FromRawConf<'_, RawValidatorSettings> for ValidatorSettings {
let validator = raw let validator = raw
.validator .validator
.parse_config(&cwp.join("validator")) .parse_config::<SignerConf>(&cwp.join("validator"))
.take_config_err(&mut err); .take_config_err(&mut err);
let checkpoint_syncer = raw let checkpoint_syncer = raw
@ -112,11 +112,26 @@ impl FromRawConf<'_, RawValidatorSettings> for ValidatorSettings {
}); });
err.into_result()?; err.into_result()?;
let mut base = base.unwrap();
let origin_chain = origin_chain.unwrap();
let validator = validator.unwrap();
if origin_chain.domain_protocol() == HyperlaneDomainProtocol::Ethereum {
// if an EVM chain we can assume the chain signer is the validator signer when not
// specified
base.chains
.get_mut(origin_chain.name())
.unwrap()
.signer
.get_or_insert_with(|| validator.clone());
}
Ok(Self { Ok(Self {
base: base.unwrap(), base,
db, db,
origin_chain: origin_chain.unwrap(), origin_chain,
validator: validator.unwrap(), validator,
checkpoint_syncer: checkpoint_syncer.unwrap(), checkpoint_syncer: checkpoint_syncer.unwrap(),
reorg_period: reorg_period.unwrap(), reorg_period: reorg_period.unwrap(),
interval, interval,

@ -226,6 +226,14 @@ impl Validator {
} }
async fn announce(&self) -> Result<()> { async fn announce(&self) -> Result<()> {
if self.core.settings.chains[self.origin_chain.name()]
.signer
.is_none()
{
warn!(origin_chain=%self.origin_chain, "Cannot announce validator without a signer; make sure a signer is set for the origin chain");
return Ok(());
}
// Sign and post the validator announcement // Sign and post the validator announcement
let announcement = Announcement { let announcement = Announcement {
validator: self.signer.eth_address(), validator: self.signer.eth_address(),

Loading…
Cancel
Save