Switch programs activation to whole-set based gating (#11750)
* Implement Debug for MessageProcessor * Switch from delta-based gating to whole-set gating * Remove dbg! * Fix clippy * Clippy * Add test * add loader to stable operating mode at proper epoch * refresh_programs_and_inflation after ancestor setup * Callback via snapshot; avoid account re-add; Debug * Fix test * Fix test and fix the past history * Make callback management stricter and cleaner * Fix test * Test overwrite and frozen for native programs * Test epoch callback with genesis-programs * Add assertions for parent bank * Add tests and some minor cleaning * Remove unsteady assertion... * Fix test... * Fix DOS * Skip ensuring account by dual (whole/delta) gating * Fix frozen abi implementation... * Move compute budget constatnt init back into bank Co-authored-by: Ryo Onodera <ryoqun@gmail.com>
This commit is contained in:
@ -7,7 +7,8 @@ use solana_sdk::{
|
||||
account::{create_keyed_readonly_accounts, Account, KeyedAccount},
|
||||
clock::Epoch,
|
||||
entrypoint_native::{
|
||||
ComputeMeter, InvokeContext, Logger, ProcessInstruction, ProcessInstructionWithContext,
|
||||
ComputeMeter, ErasedProcessInstruction, ErasedProcessInstructionWithContext, InvokeContext,
|
||||
Logger, ProcessInstruction, ProcessInstructionWithContext,
|
||||
},
|
||||
instruction::{CompiledInstruction, InstructionError},
|
||||
message::Message,
|
||||
@ -293,6 +294,44 @@ pub struct MessageProcessor {
|
||||
#[serde(skip)]
|
||||
compute_budget: u64,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for MessageProcessor {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
#[derive(Debug)]
|
||||
struct MessageProcessor<'a> {
|
||||
programs: Vec<String>,
|
||||
loaders: Vec<String>,
|
||||
native_loader: &'a NativeLoader,
|
||||
is_cross_program_supported: bool,
|
||||
}
|
||||
// rustc doesn't compile due to bug without this work around
|
||||
// https://github.com/rust-lang/rust/issues/50280
|
||||
// https://users.rust-lang.org/t/display-function-pointer/17073/2
|
||||
let processor = MessageProcessor {
|
||||
programs: self
|
||||
.programs
|
||||
.iter()
|
||||
.map(|(pubkey, instruction)| {
|
||||
let erased_instruction: ErasedProcessInstruction = *instruction;
|
||||
format!("{}: {:p}", pubkey, erased_instruction)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
loaders: self
|
||||
.loaders
|
||||
.iter()
|
||||
.map(|(pubkey, instruction)| {
|
||||
let erased_instruction: ErasedProcessInstructionWithContext = *instruction;
|
||||
format!("{}: {:p}", pubkey, erased_instruction)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
native_loader: &self.native_loader,
|
||||
is_cross_program_supported: self.is_cross_program_supported,
|
||||
};
|
||||
|
||||
write!(f, "{:?}", processor)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MessageProcessor {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
@ -360,6 +399,11 @@ impl MessageProcessor {
|
||||
self.compute_budget = compute_budget;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn get_cross_program_support(&mut self) -> bool {
|
||||
self.is_cross_program_supported
|
||||
}
|
||||
|
||||
/// Create the KeyedAccounts that will be passed to the program
|
||||
fn create_keyed_accounts<'a>(
|
||||
message: &'a Message,
|
||||
@ -648,6 +692,16 @@ impl MessageProcessor {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// only used for testing
|
||||
pub fn builtin_loader_ids(&self) -> Vec<Pubkey> {
|
||||
self.loaders.iter().map(|a| a.0).collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
// only used for testing
|
||||
pub fn builtin_program_ids(&self) -> Vec<Pubkey> {
|
||||
self.programs.iter().map(|a| a.0).collect::<Vec<_>>()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user