Default to not allowing LocalStorage checkpoint syncers in relayer (#1900)

### Description

Open to better names

Adds a setting to the relayer, `allow_local_checkpoint_syncers`, which
determines whether local storage based checkpoint syncers will be
allowed by the metadata builder.

Originally, I wanted something a bit more clever, like being able to
specify `HYP_RELAYER_VALIDCHECKPOINTSYNCERS=LocalStorage,S3` or
something, where I'd like those variants to be matched to the variants
found in
https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/hyperlane-base/src/types/checkpoint_syncer.rs#L14.
But that enum requires values, so things get ugly. One option would be
to create a new enum like:
```
enum CheckpointSyncerTypes {
  LocalStorage,
  S3,
}
```
And another option is to use something like strum's
[EnumString](https://docs.rs/strum/latest/strum/derive.EnumString.html)
(shoutout to @mattiecnvr). But this still is a bit clunky, so for now
just making this a bool and we can figure out something more elegant
later if we ever get to a point where we're supporting multiple types of
checkpoint syncers

### Drive-by changes

none

### Related issues

- Fixes https://github.com/hyperlane-xyz/issues/issues/402

### Backward compatibility

_Are these changes backward compatible?_

Yes - although if you ever want to run a relayer that uses local storage
now, you'll need to set `HYP_RELAYER_ALLOWLOCALCHECKPOINTSYNCERS=true`

_Are there any infrastructure implications, e.g. changes that would
prohibit deploying older commits using this infra tooling?_

None - we always expect to not be reading from the local fs in deployed
relayers


### Testing

_What kind of testing have these changes undergone?_

Ran e2e tests
pull/1910/head
Trevor Porter 2 years ago committed by GitHub
parent 07f91490fc
commit 59a90b1bb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      rust/agents/relayer/src/msg/metadata_builder.rs
  2. 5
      rust/agents/relayer/src/relayer.rs
  3. 3
      rust/agents/relayer/src/settings/mod.rs
  4. 1
      rust/utils/run-locally/src/main.rs

@ -5,7 +5,7 @@ use std::sync::Arc;
use derive_new::new;
use tokio::sync::RwLock;
use tracing::{debug, info, instrument};
use tracing::{debug, info, instrument, trace};
use hyperlane_base::{
CachingMailbox, ChainSetup, CheckpointSyncer, CheckpointSyncerConf, CoreMetrics,
@ -22,6 +22,7 @@ pub struct MetadataBuilder {
chain_setup: ChainSetup,
prover_sync: Arc<RwLock<MerkleTreeBuilder>>,
validator_announce: Arc<dyn ValidatorAnnounce>,
allow_local_checkpoint_syncers: bool,
metrics: Arc<CoreMetrics>,
}
@ -127,6 +128,18 @@ impl MetadataBuilder {
for (i, validator_storage_locations) in storage_locations.iter().enumerate() {
for storage_location in validator_storage_locations.iter().rev() {
if let Ok(conf) = CheckpointSyncerConf::from_str(storage_location) {
// If this is a LocalStorage based checkpoint syncer and it's not
// allowed, ignore it
if matches!(conf, CheckpointSyncerConf::LocalStorage { .. })
&& !self.allow_local_checkpoint_syncers
{
trace!(
?conf,
"Ignoring disallowed LocalStorage based checkpoint syncer"
);
continue;
}
if let Ok(checkpoint_syncer) = conf.build(None) {
checkpoint_syncers
.insert(H160::from(validators[i]), checkpoint_syncer.into());

@ -44,6 +44,7 @@ pub struct Relayer {
blacklist: Arc<MatchingList>,
transaction_gas_limit: Option<U256>,
skip_transaction_gas_limit_for: HashSet<u32>,
allow_local_checkpoint_syncers: bool,
}
impl AsRef<HyperlaneAgentCore> for Relayer {
@ -133,6 +134,8 @@ impl BaseAgent for Relayer {
mailboxes.get(&origin_chain).unwrap().db().clone(),
));
let allow_local_checkpoint_syncers = settings.allowlocalcheckpointsyncers.unwrap_or(false);
Ok(Self {
origin_chain,
core,
@ -144,6 +147,7 @@ impl BaseAgent for Relayer {
blacklist,
transaction_gas_limit,
skip_transaction_gas_limit_for,
allow_local_checkpoint_syncers,
})
}
@ -183,6 +187,7 @@ impl BaseAgent for Relayer {
chain_setup,
prover_sync.clone(),
self.validator_announce.clone(),
self.allow_local_checkpoint_syncers,
self.core.metrics.clone(),
);
tasks.push(self.run_destination_mailbox(

@ -53,4 +53,7 @@ decl_settings!(Relayer {
transactiongaslimit: Option<String>,
/// Comma separated List of domain ids to skip transaction gas for.
skiptransactiongaslimitfor: Option<String>,
/// If true, allows local storage based checkpoint syncers.
/// Not intended for production use. Defaults to false.
allowlocalcheckpointsyncers: Option<bool>,
});

@ -160,6 +160,7 @@ fn main() -> ExitCode {
"HYP_RELAYER_ORIGINCHAINNAME" => "test1",
"HYP_RELAYER_DESTINATIONCHAINNAMES" => "test2,test3",
"HYP_RELAYER_WHITELIST" => r#"[{"senderAddress": "*", "destinationDomain": ["13372", "13373"], "recipientAddress": "*"}]"#,
"HYP_RELAYER_ALLOWLOCALCHECKPOINTSYNCERS" => "true",
};
let validator_env = hashmap! {

Loading…
Cancel
Save