Skip to content

Commit

Permalink
Add Ethereum bridge mode for using a remote endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
james-chf committed Sep 22, 2022
1 parent 25f5283 commit 3681490
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 4 additions & 1 deletion apps/src/lib/config/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ pub enum Mode {
/// oracle is configured to listen for events from the Ethereum bridge
/// smart contracts using this endpoint.
Managed,
/// Do not run `geth`. The oracle will listen to the Ethereum JSON-RPC
/// endpoint as specified in the `oracle_rpc_endpoint` setting.
Remote,
/// Do not start a managed `geth` subprocess. Instead of the oracle
/// listening for events using a Ethereum JSON-RPC endpoint, an endpoint
/// will be exposed by the ledger itself for submission of Borsh-
/// serialized [`EthereumEvent`]s. Mostly useful for testing purposes.
EventsEndpoint,
/// Do not run any components of the Ethereum bridge
/// Do not run any components of the Ethereum bridge.
Off,
}

Expand Down
20 changes: 11 additions & 9 deletions apps/src/lib/node/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ async fn run_aux(config: config::Ledger, wasm_dir: PathBuf) {
TendermintMode::Validator
) {
// boot up the ethereum node process and wait for it to finish syncing
let (eth_sender, eth_receiver) = unbounded_channel();
let (eth_event_sender, eth_event_receiver) = unbounded_channel();
let url = ethereum_url.clone();
let start_managed_eth_node =
matches!(config.ethereum.mode, ethereum::Mode::Managed);
Expand Down Expand Up @@ -345,20 +345,22 @@ async fn run_aux(config: config::Ledger, wasm_dir: PathBuf) {
});

let oracle = match config.ethereum.mode {
ethereum::Mode::Managed => ethereum_node::oracle::run_oracle(
ethereum_url,
eth_sender,
abort_sender,
),
ethereum::Mode::Managed | ethereum::Mode::Remote => {
ethereum_node::oracle::run_oracle(
ethereum_url,
eth_event_sender,
abort_sender,
)
}
ethereum::Mode::EventsEndpoint => {
ethereum_node::test_tools::event_endpoint::start_oracle(
eth_sender,
eth_event_sender,
)
}
ethereum::Mode::Off => {
ethereum_node::test_tools::mock_oracle::run_oracle(
ethereum_url,
eth_sender,
eth_event_sender,
abort_sender,
)
}
Expand All @@ -381,7 +383,7 @@ async fn run_aux(config: config::Ledger, wasm_dir: PathBuf) {
eth_abort_resp_send,
eth_abort_resp_recv,
)),
Some((oracle, eth_receiver)),
Some((oracle, eth_event_receiver)),
Some((
tokio::spawn(async move {
// Construct a service for broadcasting protocol txs from
Expand Down

0 comments on commit 3681490

Please sign in to comment.