-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip: scaffolding for `gorc orchestrator start` * wip: centralize loading deep_space private keys * wip: centralize loading clarity private keys * gorc orchestrator start; parse gravity contract * gorc orchestrator start; read fees_denom from config * gorc orchestrator start that might even work (about to prove with integration tests) * cleanup warnings * gorc: abscissa_tokio::run_with_actix * make gorc a default member too
- Loading branch information
Showing
17 changed files
with
184 additions
and
179 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,4 +87,4 @@ impl Application for GorcApp { | |
trace::Config::default() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
//! `keys` subcommand | ||
|
||
mod cosmos; | ||
mod eth; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
mod start; | ||
|
||
use abscissa_core::{Command, Options, Runnable}; | ||
|
||
/// `orchestator` subcommand | ||
/// | ||
/// The `Options` proc macro generates an option parser based on the struct | ||
/// definition, and is defined in the `gumdrop` crate. See their documentation | ||
/// for a more comprehensive example: | ||
/// | ||
/// <https://docs.rs/gumdrop/> | ||
#[derive(Command, Debug, Options, Runnable)] | ||
pub enum OrchestratorCmd { | ||
#[options(name = "start")] | ||
Start(start::StartCommand), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
use crate::{application::APP, prelude::*}; | ||
use abscissa_core::{Command, Options, Runnable}; | ||
use clarity::address::Address as EthAddress; | ||
use gravity_utils::connection_prep::{ | ||
check_delegate_addresses, check_for_eth, check_for_fee_denom, create_rpc_connections, | ||
wait_for_cosmos_node_ready, | ||
}; | ||
use orchestrator::main_loop::{ | ||
orchestrator_main_loop, ETH_ORACLE_LOOP_SPEED, ETH_SIGNER_LOOP_SPEED, | ||
}; | ||
use relayer::main_loop::LOOP_SPEED as RELAYER_LOOP_SPEED; | ||
use std::cmp::min; | ||
|
||
#[derive(Command, Debug, Options)] | ||
pub struct StartCommand { | ||
#[options(help = "cosmos key name")] | ||
cosmos_key: String, | ||
|
||
#[options(help = "ethereum key name")] | ||
ethereum_key: String, | ||
} | ||
|
||
impl Runnable for StartCommand { | ||
fn run(&self) { | ||
let config = APP.config(); | ||
let cosmos_prefix = config.cosmos.prefix.clone(); | ||
|
||
let cosmos_key = config.load_deep_space_key(self.cosmos_key.clone()); | ||
let cosmos_address = cosmos_key.to_address(&cosmos_prefix).unwrap(); | ||
|
||
let ethereum_key = config.load_clarity_key(self.ethereum_key.clone()); | ||
let ethereum_address = ethereum_key.to_public_key().unwrap(); | ||
|
||
let contract_address: EthAddress = config | ||
.gravity | ||
.contract | ||
.parse() | ||
.expect("Could not parse gravity contract address"); | ||
|
||
let fees_denom = config.gravity.fees_denom.clone(); | ||
|
||
let timeout = min( | ||
min(ETH_SIGNER_LOOP_SPEED, ETH_ORACLE_LOOP_SPEED), | ||
RELAYER_LOOP_SPEED, | ||
); | ||
|
||
abscissa_tokio::run_with_actix(&APP, async { | ||
let connections = create_rpc_connections( | ||
cosmos_prefix, | ||
Some(config.cosmos.grpc.clone()), | ||
Some(config.ethereum.rpc.clone()), | ||
timeout, | ||
) | ||
.await; | ||
|
||
let mut grpc = connections.grpc.clone().unwrap(); | ||
let contact = connections.contact.clone().unwrap(); | ||
let web3 = connections.web3.clone().unwrap(); | ||
|
||
info!("Starting Relayer + Oracle + Ethereum Signer"); | ||
info!("Ethereum Address: {}", ethereum_address); | ||
info!("Cosmos Address {}", cosmos_address); | ||
|
||
// check if the cosmos node is syncing, if so wait for it | ||
// we can't move any steps above this because they may fail on an incorrect | ||
// historic chain state while syncing occurs | ||
wait_for_cosmos_node_ready(&contact).await; | ||
|
||
// check if the delegate addresses are correctly configured | ||
check_delegate_addresses( | ||
&mut grpc, | ||
ethereum_address, | ||
cosmos_address, | ||
&contact.get_prefix(), | ||
) | ||
.await; | ||
|
||
// check if we actually have the promised balance of tokens to pay fees | ||
check_for_fee_denom(&fees_denom, cosmos_address, &contact).await; | ||
check_for_eth(ethereum_address, &web3).await; | ||
|
||
orchestrator_main_loop( | ||
cosmos_key, | ||
ethereum_key, | ||
web3, | ||
contact, | ||
grpc, | ||
contract_address, | ||
fees_denom, | ||
) | ||
.await; | ||
}) | ||
.unwrap_or_else(|e| { | ||
status_err!("executor exited with error: {}", e); | ||
std::process::exit(1); | ||
}); | ||
} | ||
} |
Oops, something went wrong.