Skip to content

Commit c0a9798

Browse files
authored
Merge pull request #1346 from anoma/tiago/ethbridge/warn-bp-transfer-2
PR #1340 (adjustment 1)
2 parents fd0ef46 + e49f4c8 commit c0a9798

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

apps/src/lib/client/eth_bridge/bridge_pool.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::cmp::Ordering;
12
use std::collections::HashMap;
23
use std::io::Write;
34
use std::sync::Arc;
@@ -313,18 +314,33 @@ pub async fn relay_bridge_pool_proof(args: args::RelayBridgePoolProof) {
313314
let contract_nonce =
314315
bridge.transfer_to_erc_20_nonce().call().await.unwrap();
315316

316-
if contract_nonce != bp_proof.batch_nonce {
317-
let warning = "Warning".on_yellow();
318-
let warning = warning.bold();
319-
let warning = warning.blink();
320-
println!(
321-
"{warning}: The Bridge pool nonce in the smart contract is \
322-
{contract_nonce}, while the nonce in Namada is still {}. A relay \
323-
of the former one has already happened, but a proof has yet to \
324-
be crafted in Namada.",
325-
bp_proof.batch_nonce
326-
);
327-
safe_exit(1)
317+
match bp_proof.batch_nonce.cmp(&contract_nonce) {
318+
Ordering::Equal => {}
319+
Ordering::Less => {
320+
let error = "Error".on_red();
321+
let error = error.bold();
322+
let error = error.blink();
323+
println!(
324+
"{error}: The Bridge pool nonce in the smart contract is \
325+
{contract_nonce}, while the nonce in Namada is still {}. A \
326+
relay of the former one has already happened, but a proof \
327+
has yet to be crafted in Namada.",
328+
bp_proof.batch_nonce
329+
);
330+
safe_exit(1);
331+
}
332+
Ordering::Greater => {
333+
let error = "Error".on_red();
334+
let error = error.bold();
335+
let error = error.blink();
336+
println!(
337+
"{error}: The Bridge pool nonce in the smart contract is \
338+
{contract_nonce}, while the nonce in Namada is still {}. \
339+
Somehow, Namada's nonce is ahead of the contract's nonce!",
340+
bp_proof.batch_nonce
341+
);
342+
safe_exit(1);
343+
}
328344
}
329345

330346
let mut relay_op = bridge.transfer_to_erc(bp_proof);

0 commit comments

Comments
 (0)