Fix deployment of program-v4 in freshly started test validator (#33583)

This commit is contained in:
Pankaj Garg 2023-10-09 13:41:35 -07:00 committed by GitHub
parent fc73813db2
commit 2d84c1dbba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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"