Detect legacy programs upfront
This commit is contained in:
18
src/bank.rs
18
src/bank.rs
@ -790,6 +790,13 @@ impl Bank {
|
|||||||
Ok(accounts)
|
Ok(accounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_legacy_program(program_id: &Pubkey) -> bool {
|
||||||
|
system_program::check_id(program_id)
|
||||||
|
|| budget_program::check_id(program_id)
|
||||||
|
|| storage_program::check_id(program_id)
|
||||||
|
|| vote_program::check_id(program_id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Process an instruction
|
/// Process an instruction
|
||||||
/// This method calls the instruction's program entry pont method
|
/// This method calls the instruction's program entry pont method
|
||||||
fn process_instruction(
|
fn process_instruction(
|
||||||
@ -802,18 +809,19 @@ impl Bank {
|
|||||||
|
|
||||||
// Call the contract method
|
// Call the contract method
|
||||||
// It's up to the contract to implement its own rules on moving funds
|
// It's up to the contract to implement its own rules on moving funds
|
||||||
if system_program::check_id(&program_id) {
|
if Self::is_legacy_program(&program_id) {
|
||||||
|
let res = if system_program::check_id(&program_id) {
|
||||||
system_program::process(&tx, instruction_index, program_accounts)
|
system_program::process(&tx, instruction_index, program_accounts)
|
||||||
.map_err(|err| BankError::ProgramError(instruction_index as u8, err))?;
|
|
||||||
} else if budget_program::check_id(&program_id) {
|
} else if budget_program::check_id(&program_id) {
|
||||||
budget_program::process(&tx, instruction_index, program_accounts)
|
budget_program::process(&tx, instruction_index, program_accounts)
|
||||||
.map_err(|err| BankError::ProgramError(instruction_index as u8, err))?;
|
|
||||||
} else if storage_program::check_id(&program_id) {
|
} else if storage_program::check_id(&program_id) {
|
||||||
storage_program::process(&tx, instruction_index, program_accounts)
|
storage_program::process(&tx, instruction_index, program_accounts)
|
||||||
.map_err(|err| BankError::ProgramError(instruction_index as u8, err))?;
|
|
||||||
} else if vote_program::check_id(&program_id) {
|
} else if vote_program::check_id(&program_id) {
|
||||||
vote_program::process(&tx, instruction_index, program_accounts)
|
vote_program::process(&tx, instruction_index, program_accounts)
|
||||||
.map_err(|err| BankError::ProgramError(instruction_index as u8, err))?;
|
} else {
|
||||||
|
unreachable!();
|
||||||
|
};
|
||||||
|
res.map_err(|err| BankError::ProgramError(instruction_index as u8, err))?;
|
||||||
} else {
|
} else {
|
||||||
let mut accounts = self.load_executable_accounts(tx.program_ids[instruction_index])?;
|
let mut accounts = self.load_executable_accounts(tx.program_ids[instruction_index])?;
|
||||||
let mut keyed_accounts = create_keyed_accounts(&mut accounts);
|
let mut keyed_accounts = create_keyed_accounts(&mut accounts);
|
||||||
|
Reference in New Issue
Block a user