Pass the correct program_id to programs (#8630)
This commit is contained in:
@ -4884,10 +4884,13 @@ mod tests {
|
||||
let mut bank = Bank::new(&genesis_config);
|
||||
|
||||
fn mock_vote_processor(
|
||||
_pubkey: &Pubkey,
|
||||
_ka: &[KeyedAccount],
|
||||
_data: &[u8],
|
||||
program_id: &Pubkey,
|
||||
_keyed_accounts: &[KeyedAccount],
|
||||
_instruction_data: &[u8],
|
||||
) -> std::result::Result<(), InstructionError> {
|
||||
if !solana_vote_program::check_id(program_id) {
|
||||
return Err(InstructionError::IncorrectProgramId);
|
||||
}
|
||||
Err(InstructionError::CustomError(42))
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ use solana_sdk::{
|
||||
entrypoint_native,
|
||||
instruction::{CompiledInstruction, InstructionError},
|
||||
message::Message,
|
||||
native_loader::id as native_loader_id,
|
||||
pubkey::Pubkey,
|
||||
system_program,
|
||||
transaction::TransactionError,
|
||||
@ -172,7 +173,6 @@ impl MessageProcessor {
|
||||
executable_accounts: &[(Pubkey, RefCell<Account>)],
|
||||
program_accounts: &[Rc<RefCell<Account>>],
|
||||
) -> Result<(), InstructionError> {
|
||||
let program_id = instruction.program_id(&message.account_keys);
|
||||
let mut keyed_accounts = create_keyed_readonly_accounts(executable_accounts);
|
||||
let mut keyed_accounts2: Vec<_> = instruction
|
||||
.accounts
|
||||
@ -202,12 +202,16 @@ impl MessageProcessor {
|
||||
let root_program_id = keyed_accounts[0].unsigned_key();
|
||||
for (id, process_instruction) in &self.instruction_processors {
|
||||
if id == root_program_id {
|
||||
return process_instruction(&program_id, &keyed_accounts[1..], &instruction.data);
|
||||
return process_instruction(
|
||||
&root_program_id,
|
||||
&keyed_accounts[1..],
|
||||
&instruction.data,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
native_loader::invoke_entrypoint(
|
||||
&program_id,
|
||||
&native_loader_id(),
|
||||
&keyed_accounts,
|
||||
&instruction.data,
|
||||
&self.symbol_cache,
|
||||
|
@ -83,7 +83,7 @@ fn library_open(path: &PathBuf) -> std::io::Result<Library> {
|
||||
}
|
||||
|
||||
pub fn invoke_entrypoint(
|
||||
program_id: &Pubkey,
|
||||
_program_id: &Pubkey,
|
||||
keyed_accounts: &[KeyedAccount],
|
||||
instruction_data: &[u8],
|
||||
symbol_cache: &SymbolCache,
|
||||
@ -94,7 +94,7 @@ pub fn invoke_entrypoint(
|
||||
let name_vec = &program.try_account_ref()?.data;
|
||||
if let Some(entrypoint) = symbol_cache.read().unwrap().get(name_vec) {
|
||||
unsafe {
|
||||
return entrypoint(program_id, params, instruction_data);
|
||||
return entrypoint(names[0].unsigned_key(), params, instruction_data);
|
||||
}
|
||||
}
|
||||
let name = match str::from_utf8(name_vec) {
|
||||
@ -120,7 +120,7 @@ pub fn invoke_entrypoint(
|
||||
return Err(NativeLoaderError::EntrypointNotFound.into());
|
||||
}
|
||||
};
|
||||
let ret = entrypoint(program_id, params, instruction_data);
|
||||
let ret = entrypoint(names[0].unsigned_key(), params, instruction_data);
|
||||
symbol_cache
|
||||
.write()
|
||||
.unwrap()
|
||||
|
Reference in New Issue
Block a user