|
| 1 | +use std::cmp::Ordering; |
1 | 2 | use std::collections::HashMap; |
2 | 3 | use std::io::Write; |
3 | 4 | use std::sync::Arc; |
@@ -313,18 +314,33 @@ pub async fn relay_bridge_pool_proof(args: args::RelayBridgePoolProof) { |
313 | 314 | let contract_nonce = |
314 | 315 | bridge.transfer_to_erc_20_nonce().call().await.unwrap(); |
315 | 316 |
|
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 | + } |
328 | 344 | } |
329 | 345 |
|
330 | 346 | let mut relay_op = bridge.transfer_to_erc(bp_proof); |
|
0 commit comments