Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #1340 (adjustment 1) #1346

Merged
merged 1 commit into from
May 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions apps/src/lib/client/eth_bridge/bridge_pool.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cmp::Ordering;
use std::collections::HashMap;
use std::io::Write;
use std::sync::Arc;
Expand Down Expand Up @@ -313,18 +314,33 @@ pub async fn relay_bridge_pool_proof(args: args::RelayBridgePoolProof) {
let contract_nonce =
bridge.transfer_to_erc_20_nonce().call().await.unwrap();

if contract_nonce != bp_proof.batch_nonce {
let warning = "Warning".on_yellow();
let warning = warning.bold();
let warning = warning.blink();
println!(
"{warning}: The Bridge pool nonce in the smart contract is \
{contract_nonce}, while the nonce in Namada is still {}. A relay \
of the former one has already happened, but a proof has yet to \
be crafted in Namada.",
bp_proof.batch_nonce
);
safe_exit(1)
match bp_proof.batch_nonce.cmp(&contract_nonce) {
Ordering::Equal => {}
Ordering::Less => {
let error = "Error".on_red();
let error = error.bold();
let error = error.blink();
println!(
"{error}: The Bridge pool nonce in the smart contract is \
{contract_nonce}, while the nonce in Namada is still {}. A \
relay of the former one has already happened, but a proof \
has yet to be crafted in Namada.",
bp_proof.batch_nonce
);
safe_exit(1);
}
Ordering::Greater => {
let error = "Error".on_red();
let error = error.bold();
let error = error.blink();
println!(
"{error}: The Bridge pool nonce in the smart contract is \
{contract_nonce}, while the nonce in Namada is still {}. \
Somehow, Namada's nonce is ahead of the contract's nonce!",
bp_proof.batch_nonce
);
safe_exit(1);
}
}

let mut relay_op = bridge.transfer_to_erc(bp_proof);
Expand Down