From 5f9d64f14546b93e511e0199e06ec0ab827bfa48 Mon Sep 17 00:00:00 2001 From: andymck Date: Fri, 26 Jul 2024 16:17:39 +0100 Subject: [PATCH] switch providers and txn submits to use finalized commit level (#848) * switch providers and txn submits to use finalized commit level * keep latest clippy happy * remove the unused code --- custom_tracing/src/lib.rs | 2 +- iot_config/src/org.rs | 5 ----- iot_config/src/route.rs | 11 ----------- iot_packet_verifier/src/pending.rs | 4 ++-- solana/src/burn.rs | 8 ++++---- solana/src/start_boost.rs | 4 ++-- 6 files changed, 9 insertions(+), 25 deletions(-) diff --git a/custom_tracing/src/lib.rs b/custom_tracing/src/lib.rs index 3d6ec0813..44ef00af3 100644 --- a/custom_tracing/src/lib.rs +++ b/custom_tracing/src/lib.rs @@ -51,7 +51,7 @@ pub fn record(field: &str, value: T) where T: std::fmt::Display, { - Span::current().record(field, &tracing::field::display(value)); + Span::current().record(field, tracing::field::display(value)); } pub fn record_b58(key: &str, pub_key: &[u8]) { diff --git a/iot_config/src/org.rs b/iot_config/src/org.rs index 5f1fd54b6..d3c6cd603 100644 --- a/iot_config/src/org.rs +++ b/iot_config/src/org.rs @@ -27,11 +27,6 @@ pub struct Org { pub constraints: Option>, } -#[derive(Debug, Serialize)] -pub struct OrgList { - orgs: Vec, -} - impl FromRow<'_, PgRow> for Org { fn from_row(row: &PgRow) -> sqlx::Result { let delegate_keys = row diff --git a/iot_config/src/route.rs b/iot_config/src/route.rs index fc5424208..f050f1324 100644 --- a/iot_config/src/route.rs +++ b/iot_config/src/route.rs @@ -849,17 +849,6 @@ async fn remove_skfs(skfs: &[Skf], db: impl sqlx::PgExecutor<'_>) -> anyhow::Res Ok(query_builder.build_query_as::().fetch_all(db).await?) } -#[derive(Debug, Serialize)] -pub struct RouteList { - routes: Vec, -} - -impl RouteList { - pub fn count(&self) -> usize { - self.routes.len() - } -} - impl From for Route { fn from(route: proto::RouteV1) -> Self { let net_id: NetIdField = route.net_id.into(); diff --git a/iot_packet_verifier/src/pending.rs b/iot_packet_verifier/src/pending.rs index 362ef9c13..bbfd74fa8 100644 --- a/iot_packet_verifier/src/pending.rs +++ b/iot_packet_verifier/src/pending.rs @@ -154,7 +154,7 @@ impl PendingTables for PgPool { VALUES ($1, $2, $3, $4) "#, ) - .bind(&signature.to_string()) + .bind(signature.to_string()) .bind(payer) .bind(amount as i64) .bind(Utc::now()) @@ -195,7 +195,7 @@ impl<'a> PendingTablesTransaction<'a> for Transaction<'a, Postgres> { signature: &Signature, ) -> Result<(), sqlx::Error> { sqlx::query("DELETE FROM pending_txns WHERE signature = $1") - .bind(&signature.to_string()) + .bind(signature.to_string()) .execute(self) .await?; Ok(()) diff --git a/solana/src/burn.rs b/solana/src/burn.rs index 1041ab000..e2b9c306a 100644 --- a/solana/src/burn.rs +++ b/solana/src/burn.rs @@ -94,7 +94,7 @@ impl SolanaRpc { return Err(SolanaRpcError::FailedToReadKeypairError); }; let provider = - RpcClient::new_with_commitment(settings.rpc_url.clone(), CommitmentConfig::confirmed()); + RpcClient::new_with_commitment(settings.rpc_url.clone(), CommitmentConfig::finalized()); let program_cache = BurnProgramCache::new(&provider, dc_mint, dnt_mint).await?; if program_cache.dc_burn_authority != keypair.pubkey() { return Err(SolanaRpcError::InvalidKeypair); @@ -219,7 +219,7 @@ impl SolanaNetwork for SolanaRpc { data_credits::id(), &self.cluster, std::rc::Rc::new(Keypair::from_bytes(&self.keypair).unwrap()), - Some(CommitmentConfig::confirmed()), + Some(CommitmentConfig::finalized()), ); let args = instruction::BurnDelegatedDataCreditsV0 { @@ -261,7 +261,7 @@ impl SolanaNetwork for SolanaRpc { .provider .send_and_confirm_transaction_with_spinner_and_config( tx, - CommitmentConfig::confirmed(), + CommitmentConfig::finalized(), config, )) { Ok(signature) => { @@ -287,7 +287,7 @@ impl SolanaNetwork for SolanaRpc { self.provider .get_signature_status_with_commitment_and_history( txn, - CommitmentConfig::confirmed(), + CommitmentConfig::finalized(), true, ) .await?, diff --git a/solana/src/start_boost.rs b/solana/src/start_boost.rs index a83acec09..632a69e0b 100644 --- a/solana/src/start_boost.rs +++ b/solana/src/start_boost.rs @@ -78,7 +78,7 @@ impl SolanaNetwork for SolanaRpc { hexboosting::id(), &self.cluster, std::rc::Rc::new(Keypair::from_bytes(&self.keypair).unwrap()), - Some(CommitmentConfig::confirmed()), + Some(CommitmentConfig::finalized()), ); for update in batch { let account = accounts::StartBoostV0 { @@ -138,7 +138,7 @@ impl SolanaNetwork for SolanaRpc { self.provider .get_signature_status_with_commitment_and_history( &txn, - CommitmentConfig::confirmed(), + CommitmentConfig::finalized(), true, ) .await?,