feat(fortuna): add a cli arg to run keeper (#1517)
* optional run keeper * update comment * instead of flag use the keeper key file * update version * rename method
This commit is contained in:
parent
2095da34e9
commit
d2ce2ecd33
|
@ -1488,7 +1488,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fortuna"
|
name = "fortuna"
|
||||||
version = "5.0.0"
|
version = "5.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "fortuna"
|
name = "fortuna"
|
||||||
version = "5.0.0"
|
version = "5.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -127,7 +127,6 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
|
||||||
.provider_config
|
.provider_config
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|path| ProviderConfig::load(&path).expect("Failed to load provider config"));
|
.map(|path| ProviderConfig::load(&path).expect("Failed to load provider config"));
|
||||||
let private_key = opts.load_private_key()?;
|
|
||||||
let secret = opts.randomness.load_secret()?;
|
let secret = opts.randomness.load_secret()?;
|
||||||
let (tx_exit, rx_exit) = watch::channel(false);
|
let (tx_exit, rx_exit) = watch::channel(false);
|
||||||
|
|
||||||
|
@ -141,7 +140,6 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|c| c.get_sorted_commitments())
|
.map(|c| c.get_sorted_commitments())
|
||||||
.unwrap_or_else(|| Vec::new());
|
.unwrap_or_else(|| Vec::new());
|
||||||
println!("{} {:?}", chain_id, provider_commitments);
|
|
||||||
|
|
||||||
let provider_info = contract.get_provider_info(opts.provider).call().await?;
|
let provider_info = contract.get_provider_info(opts.provider).call().await?;
|
||||||
let latest_metadata =
|
let latest_metadata =
|
||||||
|
@ -212,7 +210,10 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
|
||||||
|
|
||||||
Ok::<(), Error>(())
|
Ok::<(), Error>(())
|
||||||
});
|
});
|
||||||
spawn(run_keeper(chains.clone(), config, private_key));
|
|
||||||
|
if let Some(keeper_private_key) = opts.load_keeper_private_key()? {
|
||||||
|
spawn(run_keeper(chains.clone(), config, keeper_private_key));
|
||||||
|
}
|
||||||
|
|
||||||
run_api(opts.addr.clone(), chains, rx_exit).await?;
|
run_api(opts.addr.clone(), chains, rx_exit).await?;
|
||||||
|
|
||||||
|
|
|
@ -36,16 +36,20 @@ pub struct RunOptions {
|
||||||
#[arg(env = "FORTUNA_PROVIDER")]
|
#[arg(env = "FORTUNA_PROVIDER")]
|
||||||
pub provider: Address,
|
pub provider: Address,
|
||||||
|
|
||||||
/// Path to a file containing a 20-byte (40 char) hex encoded Ethereum private key.
|
/// If provided, the keeper will run alongside the Fortuna API service.
|
||||||
|
/// It should be a path to a file containing a 20-byte (40 char) hex encoded Ethereum private key.
|
||||||
/// This key is required to submit transactions for entropy callback requests.
|
/// This key is required to submit transactions for entropy callback requests.
|
||||||
/// This key should not be a registered provider.
|
/// This key should not be a registered provider.
|
||||||
#[arg(long = "keeper-private-key")]
|
#[arg(long = "keeper-private-key")]
|
||||||
#[arg(env = "KEEPER_PRIVATE_KEY")]
|
#[arg(env = "KEEPER_PRIVATE_KEY")]
|
||||||
pub keeper_private_key_file: String,
|
pub keeper_private_key_file: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RunOptions {
|
impl RunOptions {
|
||||||
pub fn load_private_key(&self) -> Result<String> {
|
pub fn load_keeper_private_key(&self) -> Result<Option<String>> {
|
||||||
return Ok((fs::read_to_string(&self.keeper_private_key_file))?);
|
if let Some(ref keeper_private_key_file) = self.keeper_private_key_file {
|
||||||
|
return Ok(Some(fs::read_to_string(keeper_private_key_file)?));
|
||||||
|
}
|
||||||
|
return Ok(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue