From 35c4150732866f0a218c2fd74b5d90a17799cd64 Mon Sep 17 00:00:00 2001 From: Nick Garfield Date: Mon, 31 Oct 2022 11:24:08 +0000 Subject: [PATCH] Error out early if sim exceeds rate-limit --- plugin/src/builders/thread_exec.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugin/src/builders/thread_exec.rs b/plugin/src/builders/thread_exec.rs index e11657949..955af5ae2 100644 --- a/plugin/src/builders/thread_exec.rs +++ b/plugin/src/builders/thread_exec.rs @@ -110,11 +110,19 @@ fn build_thread_exec_tx( if let Some(account) = ui_account.decode::() { if let Ok(sim_thread) = Thread::try_from(account.data) { if sim_thread.next_instruction.is_some() { - ixs.push(build_exec_ix( - sim_thread, - signatory_pubkey, - worker_id, - )); + if let Some(exec_context) = sim_thread.exec_context { + if exec_context.execs_since_slot.lt(&sim_thread.rate_limit) + { + ixs.push(build_exec_ix( + sim_thread, + signatory_pubkey, + worker_id, + )); + } else { + // Exit early if the thread has reached its rate limit. + break; + } + } } else { break; }