Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Relayer cli #339

Merged
merged 9 commits into from
Oct 17, 2023
Merged

Relayer cli #339

merged 9 commits into from
Oct 17, 2023

Conversation

cryptoAtwill
Copy link
Contributor

Adding relayer cli plus some small fixes.

@github-actions github-actions bot changed the base branch from main to dev October 17, 2023 11:32
@github-actions
Copy link

Your PR was set to target main. PRs should be target dev.
The base branch of this PR has been automatically changed to dev.
If you really intend to target main, edit the PR.

@cryptoAtwill cryptoAtwill requested a review from adlrocha October 17, 2023 11:32
@cryptoAtwill cryptoAtwill changed the base branch from dev to chain-reorg-detection October 17, 2023 11:33
Copy link
Contributor

@adlrocha adlrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments and suggestion. Something worth fixing in this PR and the previous is the use of validator for the relayerrole. As mentioned we don't need to be validators to relay a checkpoint, and this may lead to confusion.

ipc/cli/src/commands/checkpoint/relayer.rs Outdated Show resolved Hide resolved
#[arg(long, short, help = "The number of seconds to submit checkpoint")]
pub checkpoint_interval_sec: Option<u64>,
#[arg(long, short, help = "The hex encoded address of the validator")]
pub validator: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, relayers don't need to be validators in the subnet, let's call this address as we do for the rest of the subnet.

I also don't understand why we need the PubKey here, I think we should pass the address and leverage the wallet to sign or any interactions required with the parent network.

Suggested change
pub validator: Option<String>,
pub address: Option<String>,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I think the public key side of things is actually a typo due to the copy-pasta, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have the impresseion that only validators can submit, I will change it to submitter


let mut keystore = new_evm_keystore_from_path(&config_path)?;
let validator = match (arguments.validator.as_ref(), keystore.get_default()?) {
(Some(validator), _) => Address::from_str(validator)?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned below, let's call this the address.

use std::sync::{Arc, RwLock};
use std::time::Duration;

const DEFAULT_CHECKPOINT_INTERVAL: u64 = 15;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the checkpoint interval but the polling time in the process loop, right? I think we should rename it and clarify in a comment.

Suggested change
const DEFAULT_CHECKPOINT_INTERVAL: u64 = 15;
const DEFAULT_POLLING_INTERVAL: u64 = 15;

.checkpoint_interval_sec
.unwrap_or(DEFAULT_CHECKPOINT_INTERVAL),
);
manager.run(validator, interval).await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of a curiosity, how are we handling killing the process? We should ensure that ctrl-c here gracefully kills the process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, ctrl+c should be able to kill the process.

});

tokio::time::sleep(submission_interval).await;
}
}

/// Submit the checkpoint from the target validator address
pub async fn submit_checkpoint(&self, validator: &Address) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove validator from all the functions as the argument (I think I missed it in my previous review). We don't need to be a validator to act as a relayer in the system.

Suggested change
pub async fn submit_checkpoint(&self, validator: &Address) -> Result<()> {
pub async fn submit_checkpoint(&self, relayer: &Address) -> Result<()> {

ipc/cli/src/commands/checkpoint/relayer.rs Outdated Show resolved Hide resolved
@adlrocha adlrocha merged commit fa880c1 into chain-reorg-detection Oct 17, 2023
1 check passed
@adlrocha adlrocha deleted the relayer-cli branch October 17, 2023 14:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants