Skip to content

Commit

Permalink
adding retry logic for attestation errors (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
briancorbin authored Nov 30, 2022
1 parent 4ea47c2 commit 0597e86
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
6 changes: 5 additions & 1 deletion full-service/src/service/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use mc_blockchain_types::{Block, BlockContents, BlockVersion, BlockVersionError}
use mc_common::HashSet;
use mc_connection::{
BlockInfo, BlockchainConnection, RetryableBlockchainConnection, UserTxConnection,
_retry::delay::Fibonacci,
};
use mc_crypto_keys::CompressedRistrettoPublic;
use mc_fog_report_validation::FogPubkeyResolver;
Expand Down Expand Up @@ -202,7 +203,10 @@ where
.peer_manager
.conns()
.par_iter()
.filter_map(|conn| conn.fetch_block_info(std::iter::empty()).ok())
.filter_map(|conn| {
conn.fetch_block_info(Fibonacci::from_millis(10).take(5))
.ok()
})
.collect::<Vec<_>>();

// Ensure that all nodes agree on the latest block version and network fees.
Expand Down
8 changes: 5 additions & 3 deletions full-service/src/service/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use crate::{
use mc_account_keys::AccountKey;
use mc_blockchain_types::BlockVersion;
use mc_common::logger::log;
use mc_connection::{BlockchainConnection, RetryableUserTxConnection, UserTxConnection};
use mc_connection::{
BlockchainConnection, RetryableUserTxConnection, UserTxConnection, _retry::delay::Fibonacci,
};
use mc_fog_report_validation::FogPubkeyResolver;
use mc_transaction_builder::{
BurnRedemptionMemoBuilder, EmptyMemoBuilder, MemoBuilder, RTHMemoBuilder,
Expand All @@ -39,7 +41,7 @@ use crate::service::address::{AddressService, AddressServiceError};
use displaydoc::Display;
use serde::{Deserialize, Serialize};
use serde_big_array::BigArray;
use std::{convert::TryFrom, iter::empty, sync::atomic::Ordering};
use std::{convert::TryFrom, sync::atomic::Ordering};

use super::models::tx_proposal::UnsignedTxProposal;

Expand Down Expand Up @@ -475,7 +477,7 @@ where
.peer_manager
.conn(responder_id)
.ok_or(TransactionServiceError::NodeNotFound)?
.propose_tx(&tx_proposal.tx, empty())
.propose_tx(&tx_proposal.tx, Fibonacci::from_millis(10).take(5))
.map_err(TransactionServiceError::from)?;

log::trace!(
Expand Down
10 changes: 8 additions & 2 deletions validator/service/src/blockchain_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
use grpcio::{RpcContext, RpcStatus, Service, UnarySink};
use mc_common::logger::Logger;
use mc_connection::{BlockchainConnection, ConnectionManager, RetryableBlockchainConnection};
use mc_connection::{
BlockchainConnection, ConnectionManager, RetryableBlockchainConnection,
_retry::delay::Fibonacci,
};
use mc_ledger_db::{Ledger, LedgerDB};
use mc_transaction_core::{tokens::Mob, Token};
use mc_util_grpc::{rpc_database_err, rpc_logger, rpc_precondition_error, send_result};
Expand Down Expand Up @@ -64,7 +67,10 @@ impl<BC: BlockchainConnection + 'static> BlockchainApi<BC> {
.conn_manager
.conns()
.par_iter()
.filter_map(|conn| conn.fetch_block_info(std::iter::empty()).ok())
.filter_map(|conn| {
conn.fetch_block_info(Fibonacci::from_millis(10).take(5))
.ok()
})
.collect::<Vec<_>>();

// Must have at least one node to get the last block info from.
Expand Down
4 changes: 2 additions & 2 deletions validator/service/src/validator_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use grpcio::{EnvBuilder, RpcContext, RpcStatus, Service, UnarySink};
use mc_common::logger::{log, Logger};
use mc_connection::{
ConnectionManager, Error as ConnectionError, RetryError, RetryableUserTxConnection,
UserTxConnection,
UserTxConnection, _retry::delay::Fibonacci,
};
use mc_fog_report_connection::{Error as FogConnectionError, GrpcFogReportConnection};
use mc_ledger_db::{Ledger, LedgerDB};
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<UTC: UserTxConnection + 'static> ValidatorApi<UTC> {
.conn_manager
.conn(responder_id)
.ok_or_else(|| rpc_internal_error("propose_tx", "conn not found", logger))?
.propose_tx(&tx, std::iter::empty());
.propose_tx(&tx, Fibonacci::from_millis(10).take(5));

// Convert to GRPC response.
let mut result = ProposeTxResponse::new();
Expand Down

0 comments on commit 0597e86

Please sign in to comment.