From 64a1e7e32d4fac27feda2b7f5507bd3505d25157 Mon Sep 17 00:00:00 2001 From: Evan Batsell Date: Mon, 3 Jun 2024 14:24:15 -0400 Subject: [PATCH] Feature for mainnet compilation --- programs/steward/src/constants.rs | 3 +++ programs/steward/src/score.rs | 5 ++++- tests/tests/steward/test_integration.rs | 9 ++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/programs/steward/src/constants.rs b/programs/steward/src/constants.rs index 8cd71de1..8957cf82 100644 --- a/programs/steward/src/constants.rs +++ b/programs/steward/src/constants.rs @@ -11,4 +11,7 @@ pub const EPOCH_PROGRESS_MAX: f64 = 0.99; pub const NUM_EPOCHS_BETWEEN_SCORING_MAX: u64 = 100; // Cannot score validators in under 100 slots, to submit 1 instruction per validator pub const COMPUTE_SCORE_SLOT_RANGE_MIN: usize = 100; +#[cfg(feature = "mainnet-beta")] pub const VALIDATOR_HISTORY_FIRST_RELIABLE_EPOCH: usize = 520; +#[cfg(not(feature = "mainnet-beta"))] +pub const VALIDATOR_HISTORY_FIRST_RELIABLE_EPOCH: usize = 0; diff --git a/programs/steward/src/score.rs b/programs/steward/src/score.rs index 1eab873a..665ff0c2 100644 --- a/programs/steward/src/score.rs +++ b/programs/steward/src/score.rs @@ -147,7 +147,10 @@ pub fn validator_score( let historical_commission_max = validator .history - .commission_range(0 as u16, current_epoch as u16) // TODO SOLUTION FOR FIRST_RELIABLE_EPOCH + .commission_range( + VALIDATOR_HISTORY_FIRST_RELIABLE_EPOCH as u16, + current_epoch as u16, + ) .iter() .filter_map(|&i| i) .max() diff --git a/tests/tests/steward/test_integration.rs b/tests/tests/steward/test_integration.rs index cd536aec..ea3ded46 100644 --- a/tests/tests/steward/test_integration.rs +++ b/tests/tests/steward/test_integration.rs @@ -304,7 +304,8 @@ async fn test_compute_scores() { let tx = Transaction::new_signed_with_payer( &[ // Only high because we are averaging 512 epochs - ComputeBudgetInstruction::set_compute_unit_limit(1_400_000), + ComputeBudgetInstruction::set_compute_unit_limit(600_000), + ComputeBudgetInstruction::request_heap_frame(128 * 1024), compute_scores_ix.clone(), ], Some(&fixture.keypair.pubkey()), @@ -349,7 +350,8 @@ async fn test_compute_scores() { let tx = Transaction::new_signed_with_payer( &[ - ComputeBudgetInstruction::set_compute_unit_limit(1_400_000), + ComputeBudgetInstruction::set_compute_unit_limit(600_000), + ComputeBudgetInstruction::request_heap_frame(128 * 1024), compute_scores_ix.clone(), ], Some(&fixture.keypair.pubkey()), @@ -377,7 +379,8 @@ async fn test_compute_scores() { let blockhash = fixture.get_latest_blockhash().await; let tx = Transaction::new_signed_with_payer( &[ - ComputeBudgetInstruction::set_compute_unit_limit(1_400_000), + ComputeBudgetInstruction::set_compute_unit_limit(600_000), + ComputeBudgetInstruction::request_heap_frame(128 * 1024), compute_scores_ix.clone(), ], Some(&fixture.keypair.pubkey()),