Skip to content

Commit

Permalink
Merge pull request #1351 from anoma/tiago/ethbridge/warn-bp-transfer-3
Browse files Browse the repository at this point in the history
PR #1340 (adjustment 2)
  • Loading branch information
sug0 authored May 11, 2023
2 parents 4f45eff + 2cbfc7a commit 2e1b7bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 9 additions & 0 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2499,10 +2499,14 @@ pub mod args {
/// Synchronize with the network, or exit immediately,
/// if the Ethereum node has fallen behind.
pub sync: bool,
/// Safe mode overrides keyboard interrupt signals, to ensure
/// Ethereum transfers aren't canceled midway through.
pub safe_mode: bool,
}

impl Args for RelayBridgePoolProof {
fn parse(matches: &ArgMatches) -> Self {
let safe_mode = SAFE_MODE.parse(matches);
let query = Query::parse(matches);
let hashes = HASH_LIST.parse(matches);
let relayer = RELAYER.parse(matches);
Expand Down Expand Up @@ -2533,11 +2537,16 @@ pub mod args {
eth_rpc_endpoint,
eth_addr,
confirmations,
safe_mode,
}
}

fn def(app: App) -> App {
app.add_args::<Query>()
.arg(SAFE_MODE.def().about(
"Safe mode overrides keyboard interrupt signals, to \
ensure Ethereum transfers aren't canceled midway through.",
))
.arg(HASH_LIST.def().about(
"List of Keccak hashes of transfers in the bridge pool.",
))
Expand Down
9 changes: 6 additions & 3 deletions apps/src/lib/client/eth_bridge/bridge_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use super::super::tx::process_tx;
use super::{block_on_eth_sync, eth_sync_or_exit};
use crate::cli::{args, safe_exit, Context};
use crate::client::eth_bridge::BlockOnEthSync;
use crate::control_flow::install_shutdown_signal;
use crate::facade::tendermint_rpc::HttpClient;

const ADD_TRANSFER_WASM: &str = "tx_bridge_pool.wasm";
Expand Down Expand Up @@ -180,9 +181,9 @@ async fn construct_bridge_pool_proof(
println!(
"{warning}: The following hashes correspond to transfers that \
have surpassed the security threshold in Namada, therefore have \
likely been relayed, but do not yet have a quorum of validator \
signatures behind them; thus they are still in the Bridge \
pool:\n{warnings:?}",
likely been relayed to Ethereum, but do not yet have a quorum of \
validator signatures behind them in Namada; thus they are still \
in the Bridge pool:\n{warnings:?}",
);
print!("\nDo you wish to proceed? (y/n): ");
std::io::stdout().flush().unwrap();
Expand Down Expand Up @@ -263,6 +264,8 @@ pub async fn construct_proof(args: args::BridgePoolProof) {

/// Relay a validator set update, signed off for a given epoch.
pub async fn relay_bridge_pool_proof(args: args::RelayBridgePoolProof) {
let _signal_receiver = args.safe_mode.then(install_shutdown_signal);

if args.sync {
block_on_eth_sync(BlockOnEthSync {
url: &args.eth_rpc_endpoint,
Expand Down

0 comments on commit 2e1b7bd

Please sign in to comment.