Skip to content

Commit

Permalink
add retries to mobilecoind when it submits transactions (#3308)
Browse files Browse the repository at this point in the history
* add retries to mobilecoind when it submits transactions

i'm finding that sometimes it fails with attestation permission
denied errors otherwise

---

feel free to leave comments about how you would like this to be
more configurable or use exponential backoff or something, let's
decide exactly how it should work during review

* make it match full-service retries

* tweak retry timings per review

* unused import

* fix build

* clippy
  • Loading branch information
cbeck88 authored Apr 11, 2023
1 parent b377b75 commit e9f4280
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mobilecoind/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ use rand::Rng;
use std::{
cmp::{max, Reverse},
collections::BTreeMap,
iter::empty,
str::FromStr,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
},
time::Duration,
};

/// Default number of blocks used for calculating transaction tombstone block
Expand Down Expand Up @@ -826,12 +826,22 @@ impl<T: BlockchainConnection + UserTxConnection + 'static, FPR: FogPubkeyResolve
let idx = self.submit_node_offset.fetch_add(1, Ordering::SeqCst);
let responder_id = &responder_ids[idx % responder_ids.len()];

// The rationale for these retries is:
// * Quite often, the attested connetion was closed and we need to retry once to
// re-attest, and this attestation is successful. So that takes 50 ms.
// * After that, we back off to 500 ms, because there are rate limits of about
// 100 / min in place in production.
let retry_iterator = [50, 500, 500, 750, 1000]
.iter()
.cloned()
.map(Duration::from_millis);

// Try and submit.
let block_height = self
.peer_manager
.conn(responder_id)
.ok_or(Error::NodeNotFound)?
.propose_tx(&tx_proposal.tx, empty())
.propose_tx(&tx_proposal.tx, retry_iterator)
.map_err(Error::from)?;

log::info!(
Expand Down

0 comments on commit e9f4280

Please sign in to comment.