Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ iroh = "0.34.1"
rand_v8 = { package = "rand", version = "0.8.5", features = ["std"] }
rand_core_v6 = { package = "rand_core", version = "0.6.4", features = ["std"] }
[workspace.package]
version = "0.3.9"
version = "0.3.10"
edition = "2021"

[workspace.features]
Expand Down
6 changes: 2 additions & 4 deletions crates/orchestrator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use crate::status_update::NodeStatusUpdater;
use crate::store::core::RedisStore;
use crate::store::core::StoreContext;
use crate::utils::loop_heartbeats::LoopHeartbeats;
use alloy::primitives::U256;
use anyhow::Result;
use clap::Parser;
use clap::ValueEnum;
Expand All @@ -38,7 +37,6 @@ use plugins::SchedulerPlugin;
use plugins::StatusUpdatePlugin;
use shared::utils::google_cloud::GcsStorageProvider;
use shared::web3::contracts::core::builder::ContractBuilder;
use shared::web3::contracts::structs::compute_pool::PoolStatus;
use shared::web3::wallet::Wallet;
use std::sync::Arc;
use tokio::task::JoinSet;
Expand Down Expand Up @@ -186,7 +184,7 @@ async fn main() -> Result<()> {
.build()
.unwrap();

match contracts
/* match contracts
.compute_pool
.get_pool_info(U256::from(compute_pool_id))
.await
Expand All @@ -200,7 +198,7 @@ async fn main() -> Result<()> {
error!("Failed to get pool info: {e}");
return Ok(());
}
};
}; */
let group_store_context = store_context.clone();
let mut scheduler_plugins: Vec<Box<dyn SchedulerPlugin>> = Vec::new();
let mut status_update_plugins: Vec<Box<dyn StatusUpdatePlugin>> = vec![];
Expand Down
27 changes: 21 additions & 6 deletions crates/shared/src/web3/contracts/helpers/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use alloy::{
};
use anyhow::Result;
use log::{debug, info, warn};
use tokio::time::{timeout, Duration};
use tokio::time::Duration;

use crate::web3::wallet::WalletProvider;

Expand All @@ -30,13 +30,23 @@ where
N: Network,
D: CallDecoder + Clone,
{
const PENDING_TRANSACTION_TIMEOUT: Duration = Duration::from_secs(60);

let mut tries = 0;
let retry_delay = retry_delay.unwrap_or(2);
let mut tx_hash = None;

while tries < max_tries {
if tries > 0 {
tokio::time::sleep(Duration::from_secs(retry_delay)).await;

if let Some(tx_hash) = tx_hash {
let receipt = provider.get_transaction_receipt(tx_hash).await?;
if receipt.is_some() {
return Ok(tx_hash);
}
}

// On retry, always fetch fresh fee estimates from the provider.
let priority_fee_res = provider.get_max_priority_fee_per_gas().await;
let gas_price_res = provider.get_gas_price().await;
Expand All @@ -54,7 +64,7 @@ where
call = call
.clone()
.max_fee_per_gas(new_gas_price)
.max_priority_fee_per_gas(new_priority_fee);
.max_priority_fee_per_gas(new_priority_fee)
} else {
warn!("Could not get new gas fees, retrying with old settings.");
}
Expand All @@ -63,10 +73,15 @@ where
match call.clone().send().await {
Ok(result) => {
debug!("Transaction sent, waiting for confirmation...");
match timeout(Duration::from_secs(30), result.watch()).await {
Ok(Ok(hash)) => return Ok(hash),
Ok(Err(err)) => warn!("Transaction watch failed: {err:?}"),
Err(_) => warn!("Watch timed out, retrying transaction..."),
tx_hash = Some(*result.tx_hash());

match result
.with_timeout(Some(PENDING_TRANSACTION_TIMEOUT))
.watch()
.await
{
Ok(hash) => return Ok(hash),
Err(err) => warn!("Transaction watch failed: {err:?}"),
}
}
Err(err) => {
Expand Down
Loading