Cleanup - Removes `LoadedProgram::maybe_expiration_slot` (#35023)
Removes LoadedProgram::maybe_expiration_slot.
This commit is contained in:
parent
46b9586630
commit
070a5a36b8
|
@ -137,8 +137,6 @@ pub struct LoadedProgram {
|
||||||
pub deployment_slot: Slot,
|
pub deployment_slot: Slot,
|
||||||
/// Slot in which this entry will become active (can be in the future)
|
/// Slot in which this entry will become active (can be in the future)
|
||||||
pub effective_slot: Slot,
|
pub effective_slot: Slot,
|
||||||
/// Optional expiration slot for this entry, after which it is treated as non-existent
|
|
||||||
pub maybe_expiration_slot: Option<Slot>,
|
|
||||||
/// How often this entry was used by a transaction
|
/// How often this entry was used by a transaction
|
||||||
pub tx_usage_counter: AtomicU64,
|
pub tx_usage_counter: AtomicU64,
|
||||||
/// How often this entry was used by an instruction
|
/// How often this entry was used by an instruction
|
||||||
|
@ -282,7 +280,6 @@ impl LoadedProgram {
|
||||||
program_runtime_environment: ProgramRuntimeEnvironment,
|
program_runtime_environment: ProgramRuntimeEnvironment,
|
||||||
deployment_slot: Slot,
|
deployment_slot: Slot,
|
||||||
effective_slot: Slot,
|
effective_slot: Slot,
|
||||||
maybe_expiration_slot: Option<Slot>,
|
|
||||||
elf_bytes: &[u8],
|
elf_bytes: &[u8],
|
||||||
account_size: usize,
|
account_size: usize,
|
||||||
metrics: &mut LoadProgramMetrics,
|
metrics: &mut LoadProgramMetrics,
|
||||||
|
@ -292,7 +289,6 @@ impl LoadedProgram {
|
||||||
program_runtime_environment,
|
program_runtime_environment,
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
maybe_expiration_slot,
|
|
||||||
elf_bytes,
|
elf_bytes,
|
||||||
account_size,
|
account_size,
|
||||||
metrics,
|
metrics,
|
||||||
|
@ -313,7 +309,6 @@ impl LoadedProgram {
|
||||||
program_runtime_environment: Arc<BuiltinProgram<InvokeContext<'static>>>,
|
program_runtime_environment: Arc<BuiltinProgram<InvokeContext<'static>>>,
|
||||||
deployment_slot: Slot,
|
deployment_slot: Slot,
|
||||||
effective_slot: Slot,
|
effective_slot: Slot,
|
||||||
maybe_expiration_slot: Option<Slot>,
|
|
||||||
elf_bytes: &[u8],
|
elf_bytes: &[u8],
|
||||||
account_size: usize,
|
account_size: usize,
|
||||||
metrics: &mut LoadProgramMetrics,
|
metrics: &mut LoadProgramMetrics,
|
||||||
|
@ -323,7 +318,6 @@ impl LoadedProgram {
|
||||||
program_runtime_environment,
|
program_runtime_environment,
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
maybe_expiration_slot,
|
|
||||||
elf_bytes,
|
elf_bytes,
|
||||||
account_size,
|
account_size,
|
||||||
metrics,
|
metrics,
|
||||||
|
@ -336,7 +330,6 @@ impl LoadedProgram {
|
||||||
program_runtime_environment: Arc<BuiltinProgram<InvokeContext<'static>>>,
|
program_runtime_environment: Arc<BuiltinProgram<InvokeContext<'static>>>,
|
||||||
deployment_slot: Slot,
|
deployment_slot: Slot,
|
||||||
effective_slot: Slot,
|
effective_slot: Slot,
|
||||||
maybe_expiration_slot: Option<Slot>,
|
|
||||||
elf_bytes: &[u8],
|
elf_bytes: &[u8],
|
||||||
account_size: usize,
|
account_size: usize,
|
||||||
metrics: &mut LoadProgramMetrics,
|
metrics: &mut LoadProgramMetrics,
|
||||||
|
@ -381,7 +374,6 @@ impl LoadedProgram {
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
account_size,
|
account_size,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
maybe_expiration_slot,
|
|
||||||
tx_usage_counter: AtomicU64::new(0),
|
tx_usage_counter: AtomicU64::new(0),
|
||||||
program,
|
program,
|
||||||
ix_usage_counter: AtomicU64::new(0),
|
ix_usage_counter: AtomicU64::new(0),
|
||||||
|
@ -395,7 +387,6 @@ impl LoadedProgram {
|
||||||
account_size: self.account_size,
|
account_size: self.account_size,
|
||||||
deployment_slot: self.deployment_slot,
|
deployment_slot: self.deployment_slot,
|
||||||
effective_slot: self.effective_slot,
|
effective_slot: self.effective_slot,
|
||||||
maybe_expiration_slot: self.maybe_expiration_slot,
|
|
||||||
tx_usage_counter: AtomicU64::new(self.tx_usage_counter.load(Ordering::Relaxed)),
|
tx_usage_counter: AtomicU64::new(self.tx_usage_counter.load(Ordering::Relaxed)),
|
||||||
ix_usage_counter: AtomicU64::new(self.ix_usage_counter.load(Ordering::Relaxed)),
|
ix_usage_counter: AtomicU64::new(self.ix_usage_counter.load(Ordering::Relaxed)),
|
||||||
latest_access_slot: AtomicU64::new(self.latest_access_slot.load(Ordering::Relaxed)),
|
latest_access_slot: AtomicU64::new(self.latest_access_slot.load(Ordering::Relaxed)),
|
||||||
|
@ -416,7 +407,6 @@ impl LoadedProgram {
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
account_size,
|
account_size,
|
||||||
effective_slot: deployment_slot,
|
effective_slot: deployment_slot,
|
||||||
maybe_expiration_slot: None,
|
|
||||||
tx_usage_counter: AtomicU64::new(0),
|
tx_usage_counter: AtomicU64::new(0),
|
||||||
program: LoadedProgramType::Builtin(BuiltinProgram::new_builtin(function_registry)),
|
program: LoadedProgramType::Builtin(BuiltinProgram::new_builtin(function_registry)),
|
||||||
ix_usage_counter: AtomicU64::new(0),
|
ix_usage_counter: AtomicU64::new(0),
|
||||||
|
@ -425,14 +415,11 @@ impl LoadedProgram {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_tombstone(slot: Slot, reason: LoadedProgramType) -> Self {
|
pub fn new_tombstone(slot: Slot, reason: LoadedProgramType) -> Self {
|
||||||
let maybe_expiration_slot = matches!(reason, LoadedProgramType::DelayVisibility)
|
|
||||||
.then_some(slot.saturating_add(DELAY_VISIBILITY_SLOT_OFFSET));
|
|
||||||
let tombstone = Self {
|
let tombstone = Self {
|
||||||
program: reason,
|
program: reason,
|
||||||
account_size: 0,
|
account_size: 0,
|
||||||
deployment_slot: slot,
|
deployment_slot: slot,
|
||||||
effective_slot: slot,
|
effective_slot: slot,
|
||||||
maybe_expiration_slot,
|
|
||||||
tx_usage_counter: AtomicU64::default(),
|
tx_usage_counter: AtomicU64::default(),
|
||||||
ix_usage_counter: AtomicU64::default(),
|
ix_usage_counter: AtomicU64::default(),
|
||||||
latest_access_slot: AtomicU64::new(0),
|
latest_access_slot: AtomicU64::new(0),
|
||||||
|
@ -835,12 +822,6 @@ impl<FG: ForkGraph> LoadedPrograms<FG> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(|entry| {
|
.filter(|entry| {
|
||||||
// Remove expired
|
|
||||||
if let Some(expiration) = entry.maybe_expiration_slot {
|
|
||||||
if expiration <= new_root_slot {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Remove outdated environment of previous feature set
|
// Remove outdated environment of previous feature set
|
||||||
if recompilation_phase_ends
|
if recompilation_phase_ends
|
||||||
&& !Self::matches_environment(entry, &self.environments)
|
&& !Self::matches_environment(entry, &self.environments)
|
||||||
|
@ -885,25 +866,6 @@ impl<FG: ForkGraph> LoadedPrograms<FG> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_entry_usable(
|
|
||||||
entry: &Arc<LoadedProgram>,
|
|
||||||
current_slot: Slot,
|
|
||||||
match_criteria: &LoadedProgramMatchCriteria,
|
|
||||||
) -> bool {
|
|
||||||
if entry
|
|
||||||
.maybe_expiration_slot
|
|
||||||
.map(|expiration_slot| expiration_slot <= current_slot)
|
|
||||||
.unwrap_or(false)
|
|
||||||
{
|
|
||||||
// Found an entry that's already expired. Any further entries in the list
|
|
||||||
// are older than the current one. So treat the program as missing in the
|
|
||||||
// cache and return early.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Self::matches_loaded_program_criteria(entry, match_criteria)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts a subset of the programs relevant to a transaction batch
|
/// Extracts a subset of the programs relevant to a transaction batch
|
||||||
/// and returns which program accounts the accounts DB needs to load.
|
/// and returns which program accounts the accounts DB needs to load.
|
||||||
pub fn extract(
|
pub fn extract(
|
||||||
|
@ -933,14 +895,9 @@ impl<FG: ForkGraph> LoadedPrograms<FG> {
|
||||||
entry,
|
entry,
|
||||||
&loaded_programs_for_tx_batch.environments,
|
&loaded_programs_for_tx_batch.environments,
|
||||||
) {
|
) {
|
||||||
if !Self::is_entry_usable(
|
if !Self::matches_loaded_program_criteria(entry, match_criteria) {
|
||||||
entry,
|
|
||||||
loaded_programs_for_tx_batch.slot,
|
|
||||||
match_criteria,
|
|
||||||
) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let LoadedProgramType::Unloaded(_environment) = &entry.program {
|
if let LoadedProgramType::Unloaded(_environment) = &entry.program {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1246,27 +1203,12 @@ mod tests {
|
||||||
deployment_slot: Slot,
|
deployment_slot: Slot,
|
||||||
effective_slot: Slot,
|
effective_slot: Slot,
|
||||||
usage_counter: AtomicU64,
|
usage_counter: AtomicU64,
|
||||||
) -> Arc<LoadedProgram> {
|
|
||||||
new_test_loaded_program_with_usage_and_expiry(
|
|
||||||
deployment_slot,
|
|
||||||
effective_slot,
|
|
||||||
usage_counter,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_test_loaded_program_with_usage_and_expiry(
|
|
||||||
deployment_slot: Slot,
|
|
||||||
effective_slot: Slot,
|
|
||||||
usage_counter: AtomicU64,
|
|
||||||
expiry: Option<Slot>,
|
|
||||||
) -> Arc<LoadedProgram> {
|
) -> Arc<LoadedProgram> {
|
||||||
Arc::new(LoadedProgram {
|
Arc::new(LoadedProgram {
|
||||||
program: LoadedProgramType::TestLoaded(MOCK_ENVIRONMENT.get().unwrap().clone()),
|
program: LoadedProgramType::TestLoaded(MOCK_ENVIRONMENT.get().unwrap().clone()),
|
||||||
account_size: 0,
|
account_size: 0,
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
maybe_expiration_slot: expiry,
|
|
||||||
tx_usage_counter: usage_counter,
|
tx_usage_counter: usage_counter,
|
||||||
ix_usage_counter: AtomicU64::default(),
|
ix_usage_counter: AtomicU64::default(),
|
||||||
latest_access_slot: AtomicU64::new(deployment_slot),
|
latest_access_slot: AtomicU64::new(deployment_slot),
|
||||||
|
@ -1279,7 +1221,6 @@ mod tests {
|
||||||
account_size: 0,
|
account_size: 0,
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
maybe_expiration_slot: None,
|
|
||||||
tx_usage_counter: AtomicU64::default(),
|
tx_usage_counter: AtomicU64::default(),
|
||||||
ix_usage_counter: AtomicU64::default(),
|
ix_usage_counter: AtomicU64::default(),
|
||||||
latest_access_slot: AtomicU64::default(),
|
latest_access_slot: AtomicU64::default(),
|
||||||
|
@ -1308,7 +1249,6 @@ mod tests {
|
||||||
account_size: 0,
|
account_size: 0,
|
||||||
deployment_slot: slot,
|
deployment_slot: slot,
|
||||||
effective_slot: slot.saturating_add(1),
|
effective_slot: slot.saturating_add(1),
|
||||||
maybe_expiration_slot: None,
|
|
||||||
tx_usage_counter: AtomicU64::default(),
|
tx_usage_counter: AtomicU64::default(),
|
||||||
ix_usage_counter: AtomicU64::default(),
|
ix_usage_counter: AtomicU64::default(),
|
||||||
latest_access_slot: AtomicU64::default(),
|
latest_access_slot: AtomicU64::default(),
|
||||||
|
@ -1905,7 +1845,6 @@ mod tests {
|
||||||
account_size: 0,
|
account_size: 0,
|
||||||
deployment_slot: 20,
|
deployment_slot: 20,
|
||||||
effective_slot: 20,
|
effective_slot: 20,
|
||||||
maybe_expiration_slot: None,
|
|
||||||
tx_usage_counter: AtomicU64::default(),
|
tx_usage_counter: AtomicU64::default(),
|
||||||
ix_usage_counter: AtomicU64::default(),
|
ix_usage_counter: AtomicU64::default(),
|
||||||
latest_access_slot: AtomicU64::default(),
|
latest_access_slot: AtomicU64::default(),
|
||||||
|
@ -2192,58 +2131,6 @@ mod tests {
|
||||||
|
|
||||||
assert!(match_missing(&missing, &program3, false));
|
assert!(match_missing(&missing, &program3, false));
|
||||||
|
|
||||||
// The following is a special case, where there's an expiration slot
|
|
||||||
let test_program = Arc::new(LoadedProgram {
|
|
||||||
program: LoadedProgramType::DelayVisibility,
|
|
||||||
account_size: 0,
|
|
||||||
deployment_slot: 19,
|
|
||||||
effective_slot: 19,
|
|
||||||
maybe_expiration_slot: Some(21),
|
|
||||||
tx_usage_counter: AtomicU64::default(),
|
|
||||||
ix_usage_counter: AtomicU64::default(),
|
|
||||||
latest_access_slot: AtomicU64::default(),
|
|
||||||
});
|
|
||||||
assert!(!cache.replenish(program4, test_program).0);
|
|
||||||
|
|
||||||
// Testing fork 0 - 5 - 11 - 15 - 16 - 19 - 21 - 23 with current slot at 19
|
|
||||||
let mut missing = vec![
|
|
||||||
(program1, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program2, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program3, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program4, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
];
|
|
||||||
let mut extracted = LoadedProgramsForTxBatch::new(19, cache.environments.clone());
|
|
||||||
cache.extract(&mut missing, &mut extracted, true);
|
|
||||||
|
|
||||||
assert!(match_slot(&extracted, &program1, 0, 19));
|
|
||||||
assert!(match_slot(&extracted, &program2, 11, 19));
|
|
||||||
// Program4 deployed at slot 19 should not be expired yet
|
|
||||||
assert!(match_slot(&extracted, &program4, 19, 19));
|
|
||||||
|
|
||||||
assert!(match_missing(&missing, &program3, false));
|
|
||||||
|
|
||||||
// Testing fork 0 - 5 - 11 - 15 - 16 - 19 - 21 - 23 with current slot at 21
|
|
||||||
// This would cause program4 deployed at slot 19 to be expired.
|
|
||||||
let mut missing = vec![
|
|
||||||
(program1, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program2, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program3, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program4, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
];
|
|
||||||
let mut extracted = LoadedProgramsForTxBatch::new(21, cache.environments.clone());
|
|
||||||
cache.extract(&mut missing, &mut extracted, true);
|
|
||||||
|
|
||||||
assert!(match_slot(&extracted, &program1, 0, 21));
|
|
||||||
assert!(match_slot(&extracted, &program2, 11, 21));
|
|
||||||
|
|
||||||
assert!(match_missing(&missing, &program3, false));
|
|
||||||
assert!(match_missing(&missing, &program4, false));
|
|
||||||
|
|
||||||
// Remove the expired entry to let the rest of the test continue
|
|
||||||
if let Some(second_level) = cache.entries.get_mut(&program4) {
|
|
||||||
second_level.slot_versions.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
cache.prune(5, 0);
|
cache.prune(5, 0);
|
||||||
|
|
||||||
// Fork graph after pruning
|
// Fork graph after pruning
|
||||||
|
@ -2499,117 +2386,6 @@ mod tests {
|
||||||
assert!(match_missing(&missing, &program3, true));
|
assert!(match_missing(&missing, &program3, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_prune_expired() {
|
|
||||||
let mut cache = new_mock_cache::<TestForkGraphSpecific>();
|
|
||||||
|
|
||||||
// Fork graph created for the test
|
|
||||||
// 0
|
|
||||||
// / \
|
|
||||||
// 10 5
|
|
||||||
// | |
|
|
||||||
// 20 11
|
|
||||||
// | | \
|
|
||||||
// 22 15 25
|
|
||||||
// | |
|
|
||||||
// 16 27
|
|
||||||
// |
|
|
||||||
// 19
|
|
||||||
// |
|
|
||||||
// 23
|
|
||||||
|
|
||||||
let mut fork_graph = TestForkGraphSpecific::default();
|
|
||||||
fork_graph.insert_fork(&[0, 10, 20, 22]);
|
|
||||||
fork_graph.insert_fork(&[0, 5, 11, 12, 15, 16, 18, 19, 21, 23]);
|
|
||||||
fork_graph.insert_fork(&[0, 5, 11, 25, 27]);
|
|
||||||
let fork_graph = Arc::new(RwLock::new(fork_graph));
|
|
||||||
cache.set_fork_graph(fork_graph);
|
|
||||||
|
|
||||||
let program1 = Pubkey::new_unique();
|
|
||||||
assert!(!cache.replenish(program1, new_test_loaded_program(10, 11)).0);
|
|
||||||
assert!(!cache.replenish(program1, new_test_loaded_program(20, 21)).0);
|
|
||||||
|
|
||||||
let program2 = Pubkey::new_unique();
|
|
||||||
assert!(!cache.replenish(program2, new_test_loaded_program(5, 6)).0);
|
|
||||||
assert!(!cache.replenish(program2, new_test_loaded_program(11, 12)).0);
|
|
||||||
|
|
||||||
let program3 = Pubkey::new_unique();
|
|
||||||
assert!(!cache.replenish(program3, new_test_loaded_program(25, 26)).0);
|
|
||||||
|
|
||||||
// The following is a special case, where there's an expiration slot
|
|
||||||
let test_program = Arc::new(LoadedProgram {
|
|
||||||
program: LoadedProgramType::DelayVisibility,
|
|
||||||
account_size: 0,
|
|
||||||
deployment_slot: 11,
|
|
||||||
effective_slot: 11,
|
|
||||||
maybe_expiration_slot: Some(15),
|
|
||||||
tx_usage_counter: AtomicU64::default(),
|
|
||||||
ix_usage_counter: AtomicU64::default(),
|
|
||||||
latest_access_slot: AtomicU64::default(),
|
|
||||||
});
|
|
||||||
assert!(!cache.replenish(program1, test_program).0);
|
|
||||||
|
|
||||||
// Testing fork 0 - 5 - 11 - 15 - 16 - 19 - 21 - 23 with current slot at 19
|
|
||||||
let mut missing = vec![
|
|
||||||
(program1, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program2, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program3, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
];
|
|
||||||
let mut extracted = LoadedProgramsForTxBatch::new(12, cache.environments.clone());
|
|
||||||
cache.extract(&mut missing, &mut extracted, true);
|
|
||||||
|
|
||||||
// Program1 deployed at slot 11 should not be expired yet
|
|
||||||
assert!(match_slot(&extracted, &program1, 11, 12));
|
|
||||||
assert!(match_slot(&extracted, &program2, 11, 12));
|
|
||||||
|
|
||||||
assert!(match_missing(&missing, &program3, false));
|
|
||||||
|
|
||||||
// Testing fork 0 - 5 - 11 - 12 - 15 - 16 - 19 - 21 - 23 with current slot at 15
|
|
||||||
// This would cause program4 deployed at slot 15 to be expired.
|
|
||||||
let mut missing = vec![
|
|
||||||
(program1, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program2, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
(program3, (LoadedProgramMatchCriteria::NoCriteria, 1)),
|
|
||||||
];
|
|
||||||
let mut extracted = LoadedProgramsForTxBatch::new(15, cache.environments.clone());
|
|
||||||
cache.extract(&mut missing, &mut extracted, true);
|
|
||||||
|
|
||||||
assert!(match_slot(&extracted, &program2, 11, 15));
|
|
||||||
|
|
||||||
assert!(match_missing(&missing, &program1, false));
|
|
||||||
assert!(match_missing(&missing, &program3, false));
|
|
||||||
|
|
||||||
// Test that the program still exists in the cache, even though it is expired.
|
|
||||||
assert_eq!(
|
|
||||||
cache
|
|
||||||
.entries
|
|
||||||
.get(&program1)
|
|
||||||
.expect("Didn't find program1")
|
|
||||||
.slot_versions
|
|
||||||
.len(),
|
|
||||||
3
|
|
||||||
);
|
|
||||||
|
|
||||||
// New root 5 should not evict the expired entry for program1
|
|
||||||
cache.prune(5, 0);
|
|
||||||
assert_eq!(
|
|
||||||
cache
|
|
||||||
.entries
|
|
||||||
.get(&program1)
|
|
||||||
.expect("Didn't find program1")
|
|
||||||
.slot_versions
|
|
||||||
.len(),
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
// Unlock the cooperative loading lock so that the subsequent prune can do its job
|
|
||||||
cache.finish_cooperative_loading_task(15, program1, new_test_loaded_program(0, 1));
|
|
||||||
|
|
||||||
// New root 15 should evict the expired entry for program1
|
|
||||||
cache.prune(15, 0);
|
|
||||||
assert!(cache.entries.get(&program1).is_none());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fork_prune_find_first_ancestor() {
|
fn test_fork_prune_find_first_ancestor() {
|
||||||
let mut cache = new_mock_cache::<TestForkGraphSpecific>();
|
let mut cache = new_mock_cache::<TestForkGraphSpecific>();
|
||||||
|
@ -2741,109 +2517,96 @@ mod tests {
|
||||||
new_mock_cache::<TestForkGraph>();
|
new_mock_cache::<TestForkGraph>();
|
||||||
let tombstone = Arc::new(LoadedProgram::new_tombstone(0, LoadedProgramType::Closed));
|
let tombstone = Arc::new(LoadedProgram::new_tombstone(0, LoadedProgramType::Closed));
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&tombstone,
|
LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
0,
|
&tombstone,
|
||||||
&LoadedProgramMatchCriteria::NoCriteria
|
&LoadedProgramMatchCriteria::NoCriteria
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&tombstone,
|
LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&tombstone,
|
||||||
&LoadedProgramMatchCriteria::Tombstone
|
&LoadedProgramMatchCriteria::Tombstone
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&tombstone,
|
LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&tombstone,
|
||||||
&LoadedProgramMatchCriteria::NoCriteria
|
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(0)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&tombstone,
|
!LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&tombstone,
|
||||||
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(0)
|
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(1)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
assert!(!LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
|
||||||
&tombstone,
|
|
||||||
1,
|
|
||||||
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(1)
|
|
||||||
));
|
|
||||||
|
|
||||||
let program = new_test_loaded_program(0, 1);
|
let program = new_test_loaded_program(0, 1);
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
0,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::NoCriteria
|
&LoadedProgramMatchCriteria::NoCriteria
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(!LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
!LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::Tombstone
|
&LoadedProgramMatchCriteria::Tombstone
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::NoCriteria
|
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(0)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
!LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(0)
|
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(1)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(!LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
let program = Arc::new(new_test_loaded_program_with_usage(
|
||||||
&program,
|
|
||||||
1,
|
|
||||||
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(1)
|
|
||||||
));
|
|
||||||
|
|
||||||
let program = Arc::new(new_test_loaded_program_with_usage_and_expiry(
|
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
AtomicU64::default(),
|
AtomicU64::default(),
|
||||||
Some(2),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
0,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::NoCriteria
|
&LoadedProgramMatchCriteria::NoCriteria
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
!LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::NoCriteria
|
&LoadedProgramMatchCriteria::Tombstone
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(!LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
1,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::Tombstone
|
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(0)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
assert!(!LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
assert!(
|
||||||
&program,
|
!LoadedPrograms::<TestForkGraph>::matches_loaded_program_criteria(
|
||||||
2,
|
&program,
|
||||||
&LoadedProgramMatchCriteria::NoCriteria
|
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(1)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
assert!(LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
|
||||||
&program,
|
|
||||||
1,
|
|
||||||
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(0)
|
|
||||||
));
|
|
||||||
|
|
||||||
assert!(!LoadedPrograms::<TestForkGraph>::is_entry_usable(
|
|
||||||
&program,
|
|
||||||
1,
|
|
||||||
&LoadedProgramMatchCriteria::DeployedOnOrAfterSlot(1)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,6 @@ pub fn load_program_from_bytes(
|
||||||
program_runtime_environment,
|
program_runtime_environment,
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
None,
|
|
||||||
programdata,
|
programdata,
|
||||||
account_size,
|
account_size,
|
||||||
load_program_metrics,
|
load_program_metrics,
|
||||||
|
@ -93,7 +92,6 @@ pub fn load_program_from_bytes(
|
||||||
program_runtime_environment,
|
program_runtime_environment,
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
None,
|
|
||||||
programdata,
|
programdata,
|
||||||
account_size,
|
account_size,
|
||||||
load_program_metrics,
|
load_program_metrics,
|
||||||
|
@ -4004,7 +4002,6 @@ mod tests {
|
||||||
account_size: 0,
|
account_size: 0,
|
||||||
deployment_slot: 0,
|
deployment_slot: 0,
|
||||||
effective_slot: 0,
|
effective_slot: 0,
|
||||||
maybe_expiration_slot: None,
|
|
||||||
tx_usage_counter: AtomicU64::new(100),
|
tx_usage_counter: AtomicU64::new(100),
|
||||||
ix_usage_counter: AtomicU64::new(100),
|
ix_usage_counter: AtomicU64::new(100),
|
||||||
latest_access_slot: AtomicU64::new(0),
|
latest_access_slot: AtomicU64::new(0),
|
||||||
|
@ -4045,7 +4042,6 @@ mod tests {
|
||||||
account_size: 0,
|
account_size: 0,
|
||||||
deployment_slot: 0,
|
deployment_slot: 0,
|
||||||
effective_slot: 0,
|
effective_slot: 0,
|
||||||
maybe_expiration_slot: None,
|
|
||||||
tx_usage_counter: AtomicU64::new(100),
|
tx_usage_counter: AtomicU64::new(100),
|
||||||
ix_usage_counter: AtomicU64::new(100),
|
ix_usage_counter: AtomicU64::new(100),
|
||||||
latest_access_slot: AtomicU64::new(0),
|
latest_access_slot: AtomicU64::new(0),
|
||||||
|
|
|
@ -419,7 +419,6 @@ pub fn process_instruction_deploy(
|
||||||
.clone(),
|
.clone(),
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
effective_slot,
|
effective_slot,
|
||||||
None,
|
|
||||||
programdata,
|
programdata,
|
||||||
buffer.get_data().len(),
|
buffer.get_data().len(),
|
||||||
&mut load_program_metrics,
|
&mut load_program_metrics,
|
||||||
|
@ -660,7 +659,6 @@ mod tests {
|
||||||
.clone(),
|
.clone(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
None,
|
|
||||||
programdata,
|
programdata,
|
||||||
account.data().len(),
|
account.data().len(),
|
||||||
&mut load_program_metrics,
|
&mut load_program_metrics,
|
||||||
|
|
|
@ -774,7 +774,6 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
||||||
program_runtime_environment.clone(),
|
program_runtime_environment.clone(),
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
deployment_slot.saturating_add(DELAY_VISIBILITY_SLOT_OFFSET),
|
deployment_slot.saturating_add(DELAY_VISIBILITY_SLOT_OFFSET),
|
||||||
None,
|
|
||||||
programdata,
|
programdata,
|
||||||
account_size,
|
account_size,
|
||||||
load_program_metrics,
|
load_program_metrics,
|
||||||
|
@ -786,7 +785,6 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
|
||||||
program_runtime_environment.clone(),
|
program_runtime_environment.clone(),
|
||||||
deployment_slot,
|
deployment_slot,
|
||||||
deployment_slot.saturating_add(DELAY_VISIBILITY_SLOT_OFFSET),
|
deployment_slot.saturating_add(DELAY_VISIBILITY_SLOT_OFFSET),
|
||||||
None,
|
|
||||||
programdata,
|
programdata,
|
||||||
account_size,
|
account_size,
|
||||||
load_program_metrics,
|
load_program_metrics,
|
||||||
|
|
Loading…
Reference in New Issue