Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Prevents built-ins from being pruned.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed May 18, 2023
1 parent 329e473 commit 116b769
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
AccountSharedData::new(0, 0, &loader_id),
));
let interpreted = matches.value_of("mode").unwrap() != "jit";
with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts,);
with_mock_invoke_context!(invoke_context, transaction_context, transaction_accounts);

// Adding `DELAY_VISIBILITY_SLOT_OFFSET` to slots to accommodate for delay visibility of the program
let mut loaded_programs =
Expand All @@ -548,7 +548,7 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
debug!("Loaded program {}", key);
loaded_programs.replenish(key, program);
}
invoke_context.programs_loaded_for_tx_batch = &mut loaded_programs;
invoke_context.programs_loaded_for_tx_batch = &loaded_programs;

invoke_context
.transaction_context
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ pub mod tests {
matches::assert_matches,
rand::{thread_rng, Rng},
solana_entry::entry::{create_ticks, next_entry, next_entry_mut},
solana_program_runtime::{declare_process_instruction, loaded_programs::LoadedProgram},
solana_program_runtime::declare_process_instruction,
solana_runtime::{
genesis_utils::{
self, create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs,
Expand Down
4 changes: 3 additions & 1 deletion program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ impl LoadedPrograms {
.rev()
.filter(|entry| {
let relation = fork_graph.relationship(entry.deployment_slot, new_root);
if entry.deployment_slot >= new_root {
if matches!(entry.program, LoadedProgramType::Builtin(_)) {
true
} else if entry.deployment_slot >= new_root {
matches!(relation, BlockRelation::Equal | BlockRelation::Descendant)
} else if !first_ancestor_found
&& (matches!(relation, BlockRelation::Ancestor)
Expand Down
2 changes: 1 addition & 1 deletion runtime/benches/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate test;

use {
log::*,
solana_program_runtime::{declare_process_instruction, loaded_programs::LoadedProgram},
solana_program_runtime::declare_process_instruction,
solana_runtime::{
bank::{test_utils::goto_end_of_slot, *},
bank_client::BankClient,
Expand Down
11 changes: 10 additions & 1 deletion runtime/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ impl std::fmt::Debug for BuiltinPrototype {
impl solana_frozen_abi::abi_example::AbiExample for BuiltinPrototype {
fn example() -> Self {
// BuiltinPrototype isn't serializable by definition.
Self::default()
solana_program_runtime::declare_process_instruction!(entrypoint, 0, |_invoke_context| {
// Do nothing
Ok(())
});
Self {
feature_id: None,
program_id: Pubkey::default(),
name: "",
entrypoint,
}
}
}

Expand Down

0 comments on commit 116b769

Please sign in to comment.