From 25fe931bd3b1742f8dd9c67ca31e02bd7f351032 Mon Sep 17 00:00:00 2001 From: Nick Garfield Date: Wed, 31 May 2023 01:22:15 +0000 Subject: [PATCH 1/2] Make threads the transaction fee payer --- plugin/src/builders/thread_exec.rs | 6 +++--- programs/thread/src/instructions/thread_exec.rs | 9 +-------- rust-toolchain.toml | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/plugin/src/builders/thread_exec.rs b/plugin/src/builders/thread_exec.rs index e0ac02df7..597bdd8e4 100644 --- a/plugin/src/builders/thread_exec.rs +++ b/plugin/src/builders/thread_exec.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use anchor_lang::{InstructionData, ToAccountMetas}; -use clockwork_thread_program::state::{VersionedThread, Trigger}; use clockwork_network_program::state::Worker; +use clockwork_thread_program::state::{Trigger, VersionedThread}; use clockwork_utils::thread::PAYER_PUBKEY; use log::info; use solana_account_decoder::UiAccountEncoding; @@ -73,7 +73,7 @@ pub async fn build_thread_exec_tx( let mut successful_ixs: Vec = vec![]; let mut units_consumed: Option = None; loop { - let mut sim_tx = Transaction::new_with_payer(&ixs, Some(&signatory_pubkey)); + let mut sim_tx = Transaction::new_with_payer(&ixs, Some(&thread_pubkey)); sim_tx.sign(&[payer], blockhash); // Exit early if the transaction exceeds the size limit. @@ -199,7 +199,7 @@ pub async fn build_thread_exec_tx( } // Build and return the signed transaction. - let mut tx = Transaction::new_with_payer(&successful_ixs, Some(&signatory_pubkey)); + let mut tx = Transaction::new_with_payer(&successful_ixs, Some(&thread_pubkey)); tx.sign(&[payer], blockhash); info!( "slot: {:?} thread: {:?} sim_duration: {:?} instruction_count: {:?} compute_units: {:?} tx_sig: {:?}", diff --git a/programs/thread/src/instructions/thread_exec.rs b/programs/thread/src/instructions/thread_exec.rs index 8c1ee4db8..b674a4757 100644 --- a/programs/thread/src/instructions/thread_exec.rs +++ b/programs/thread/src/instructions/thread_exec.rs @@ -178,7 +178,6 @@ pub fn handler(ctx: Context) -> Result<()> { } // Update the exec context. - let should_reimburse_transaction = clock.slot > thread.exec_context.unwrap().last_exec_at; thread.exec_context = Some(ExecContext { exec_index, execs_since_slot: if clock.slot == thread.exec_context.unwrap().last_exec_at { @@ -197,13 +196,7 @@ pub fn handler(ctx: Context) -> Result<()> { // Reimbursement signatory for lamports paid during inner ix. let signatory_lamports_post = signatory.lamports(); - let mut signatory_reimbursement = - signatory_lamports_pre.saturating_sub(signatory_lamports_post); - if should_reimburse_transaction { - signatory_reimbursement = signatory_reimbursement - .checked_add(TRANSACTION_BASE_FEE_REIMBURSEMENT) - .unwrap(); - } + let signatory_reimbursement = signatory_lamports_pre.saturating_sub(signatory_lamports_post); if signatory_reimbursement.gt(&0) { **thread.to_account_info().try_borrow_mut_lamports()? = thread .to_account_info() diff --git a/rust-toolchain.toml b/rust-toolchain.toml index f54e3b8be..184939d3f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.60.0" +channel = "1.65.0" components = [ "rustfmt", "rust-analyzer" ] profile = "minimal" targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin"] From 7f2f1220bf4efc2a6ee2748fc65c832aa41b5562 Mon Sep 17 00:00:00 2001 From: Nick Garfield Date: Wed, 31 May 2023 13:38:40 +0000 Subject: [PATCH 2/2] Revert rust toolchain to 1.60.0 --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 184939d3f..f54e3b8be 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.65.0" +channel = "1.60.0" components = [ "rustfmt", "rust-analyzer" ] profile = "minimal" targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin"]