Skip to content

Commit fcc16a4

Browse files
authored
Merge pull request #65 from helium/bugfix/rpc-race
Fix RPC race condition on task fetching, retry RawSimulated failure add better cli options
1 parent 7975d94 commit fcc16a4

File tree

11 files changed

+311
-96
lines changed

11 files changed

+311
-96
lines changed

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ spl-associated-token-account = "6.0.0"
5757
spl-token = "4.0.0"
5858
itertools = "0.13"
5959
tokio-graceful-shutdown = "0.15"
60-
solana-transaction-utils = { version = "0.4.0", path = "./solana-transaction-utils" }
61-
tuktuk-sdk = { version = "0.3.5", path = "./tuktuk-sdk" }
60+
solana-transaction-utils = { version = "0.4.2", path = "./solana-transaction-utils" }
61+
tuktuk-sdk = { version = "0.3.6", path = "./tuktuk-sdk" }
6262
tuktuk-program = { version = "0.3.2", path = "./tuktuk-program" }
6363
solana-account-decoder = { version = "2.2.3" }
6464
solana-clock = { version = "2.2.1" }

solana-transaction-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "solana-transaction-utils"
3-
version = "0.4.0"
3+
version = "0.4.2"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

solana-transaction-utils/src/priority_fee.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,10 @@ pub async fn compute_budget_for_instructions<C: AsRef<RpcClient>>(
145145

146146
// Simulate the transaction to get the actual compute used
147147
let simulation_result = client.as_ref().simulate_transaction(&snub_tx).await?;
148-
if let Some(err) = simulation_result.value.err {
148+
if simulation_result.value.err.is_some() {
149149
info!(?simulation_result.value.logs, "simulation error");
150-
return Err(Error::SimulatedTransactionError(err));
151150
}
152-
let actual_compute_used = simulation_result.value.units_consumed.unwrap_or(200000);
151+
let actual_compute_used = simulation_result.value.units_consumed.unwrap_or(1000000);
153152

154153
let final_compute_budget = (actual_compute_used as f32 * compute_multiplier) as u32;
155154
Ok((
@@ -175,11 +174,11 @@ pub async fn auto_compute_price<C: AsRef<RpcClient>>(
175174
compute_price_instruction_for_accounts(client, &accounts).await?;
176175

177176
// Replace or insert compute price instruction
178-
if let Some(pos) = instructions
179-
.iter()
180-
.position(|ix| ix.program_id == solana_sdk::compute_budget::id())
181-
{
182-
updated_instructions[pos + 1] = compute_price_ix; // Replace existing
177+
if let Some(pos) = instructions.iter().position(|ix| {
178+
ix.program_id == solana_sdk::compute_budget::id()
179+
&& ix.data.first() == compute_price_ix.data.first()
180+
}) {
181+
updated_instructions[pos] = compute_price_ix; // Replace existing
183182
} else {
184183
updated_instructions.insert(1, compute_price_ix); // Insert after compute budget
185184
}
@@ -239,10 +238,10 @@ pub async fn auto_compute_limit_and_price<C: AsRef<RpcClient>>(
239238
.await?;
240239

241240
// Replace or insert compute budget instruction
242-
if let Some(pos) = updated_instructions
243-
.iter()
244-
.position(|ix| ix.program_id == solana_sdk::compute_budget::id())
245-
{
241+
if let Some(pos) = updated_instructions.iter().position(|ix| {
242+
ix.program_id == solana_sdk::compute_budget::id()
243+
&& ix.data.first() == compute_budget_ix.data.first()
244+
}) {
246245
updated_instructions[pos] = compute_budget_ix; // Replace existing
247246
} else {
248247
updated_instructions.insert(0, compute_budget_ix); // Insert at the beginning

solana-transaction-utils/src/queue.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ pub async fn create_transaction_queue<T: Send + Clone + 'static + Sync>(
121121
let mut updated_instructions = bundle.tx.instructions.clone();
122122
let compute_budget_ix = compute_budget_instruction(compute_units);
123123
// Replace or insert compute budget instruction
124-
if let Some(pos) = updated_instructions
125-
.iter()
126-
.position(|ix| ix.program_id == solana_sdk::compute_budget::id())
127-
{
124+
if let Some(pos) = updated_instructions.iter().position(|ix| {
125+
ix.program_id == solana_sdk::compute_budget::id()
126+
&& ix.data.first() == compute_budget_ix.data.first()
127+
}) {
128128
updated_instructions[pos] = compute_budget_ix; // Replace existing
129129
} else {
130130
updated_instructions.insert(0, compute_budget_ix); // Insert at the beginning

tuktuk-cli/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tuktuk-cli"
3-
version = "0.2.11"
3+
version = "0.2.12"
44
description = "A cli for tuktuk"
55
homepage.workspace = true
66
repository.workspace = true
@@ -38,3 +38,4 @@ spl-token = { workspace = true }
3838
solana-program = { workspace = true }
3939
itertools = { workspace = true }
4040
bs58 = "0.5.1"
41+
futures = { workspace = true }

0 commit comments

Comments
 (0)