From 2d84c1dbba26dd25a66a84dd93b7aefe03c73b61 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Mon, 9 Oct 2023 13:41:35 -0700 Subject: [PATCH] Fix deployment of program-v4 in freshly started test validator (#33583) --- programs/loader-v4/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/programs/loader-v4/src/lib.rs b/programs/loader-v4/src/lib.rs index 4645b33c26a6e0..6f15096ecc6389 100644 --- a/programs/loader-v4/src/lib.rs +++ b/programs/loader-v4/src/lib.rs @@ -366,7 +366,11 @@ pub fn process_instruction_deploy( authority_address, )?; let current_slot = invoke_context.get_sysvar_cache().get_clock()?.slot; - if state.slot.saturating_add(DEPLOYMENT_COOLDOWN_IN_SLOTS) > current_slot { + + // Slot = 0 indicates that the program hasn't been deployed yet. So no need to check for the cooldown slots. + // (Without this check, the program deployment is failing in freshly started test validators. That's + // because at startup current_slot is 0, which is < DEPLOYMENT_COOLDOWN_IN_SLOTS). + if state.slot != 0 && state.slot.saturating_add(DEPLOYMENT_COOLDOWN_IN_SLOTS) > current_slot { ic_logger_msg!( log_collector, "Program was deployed recently, cooldown still in effect"