Log more info on runtime account verification errors (#17861)
This commit is contained in:
@ -10,7 +10,7 @@ use solana_sdk::{
|
|||||||
account_utils::StateMut,
|
account_utils::StateMut,
|
||||||
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
|
||||||
feature_set::{demote_sysvar_write_locks, instructions_sysvar_enabled, FeatureSet},
|
feature_set::{demote_sysvar_write_locks, instructions_sysvar_enabled, FeatureSet},
|
||||||
ic_msg,
|
ic_logger_msg, ic_msg,
|
||||||
instruction::{CompiledInstruction, Instruction, InstructionError},
|
instruction::{CompiledInstruction, Instruction, InstructionError},
|
||||||
keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount},
|
keyed_account::{create_keyed_accounts_unified, keyed_account_at_index, KeyedAccount},
|
||||||
message::Message,
|
message::Message,
|
||||||
@ -403,6 +403,7 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
|
|||||||
.invoke_stack
|
.invoke_stack
|
||||||
.last()
|
.last()
|
||||||
.ok_or(InstructionError::CallDepth)?;
|
.ok_or(InstructionError::CallDepth)?;
|
||||||
|
let logger = self.get_logger();
|
||||||
MessageProcessor::verify_and_update(
|
MessageProcessor::verify_and_update(
|
||||||
message,
|
message,
|
||||||
instruction,
|
instruction,
|
||||||
@ -413,6 +414,7 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
|
|||||||
caller_write_privileges,
|
caller_write_privileges,
|
||||||
&mut self.timings,
|
&mut self.timings,
|
||||||
self.feature_set.is_active(&demote_sysvar_write_locks::id()),
|
self.feature_set.is_active(&demote_sysvar_write_locks::id()),
|
||||||
|
logger,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn get_caller(&self) -> Result<&Pubkey, InstructionError> {
|
fn get_caller(&self) -> Result<&Pubkey, InstructionError> {
|
||||||
@ -1015,6 +1017,7 @@ impl MessageProcessor {
|
|||||||
rent: &Rent,
|
rent: &Rent,
|
||||||
timings: &mut ExecuteDetailsTimings,
|
timings: &mut ExecuteDetailsTimings,
|
||||||
demote_sysvar_write_locks: bool,
|
demote_sysvar_write_locks: bool,
|
||||||
|
logger: Rc<RefCell<dyn Logger>>,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
// Verify all executable accounts have zero outstanding refs
|
// Verify all executable accounts have zero outstanding refs
|
||||||
Self::verify_account_references(executable_accounts)?;
|
Self::verify_account_references(executable_accounts)?;
|
||||||
@ -1031,14 +1034,24 @@ impl MessageProcessor {
|
|||||||
.map_err(|_| InstructionError::AccountBorrowOutstanding)?;
|
.map_err(|_| InstructionError::AccountBorrowOutstanding)?;
|
||||||
}
|
}
|
||||||
let account = accounts[account_index].borrow();
|
let account = accounts[account_index].borrow();
|
||||||
pre_accounts[unique_index].verify(
|
pre_accounts[unique_index]
|
||||||
|
.verify(
|
||||||
&program_id,
|
&program_id,
|
||||||
message.is_writable(account_index, demote_sysvar_write_locks),
|
message.is_writable(account_index, demote_sysvar_write_locks),
|
||||||
rent,
|
rent,
|
||||||
&account,
|
&account,
|
||||||
timings,
|
timings,
|
||||||
true,
|
true,
|
||||||
)?;
|
)
|
||||||
|
.map_err(|err| {
|
||||||
|
ic_logger_msg!(
|
||||||
|
logger,
|
||||||
|
"failed to verify account {}: {}",
|
||||||
|
pre_accounts[unique_index].key,
|
||||||
|
err
|
||||||
|
);
|
||||||
|
err
|
||||||
|
})?;
|
||||||
pre_sum += u128::from(pre_accounts[unique_index].lamports());
|
pre_sum += u128::from(pre_accounts[unique_index].lamports());
|
||||||
post_sum += u128::from(account.lamports());
|
post_sum += u128::from(account.lamports());
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -1054,6 +1067,7 @@ impl MessageProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Verify the results of a cross-program instruction
|
/// Verify the results of a cross-program instruction
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn verify_and_update(
|
fn verify_and_update(
|
||||||
message: &Message,
|
message: &Message,
|
||||||
instruction: &CompiledInstruction,
|
instruction: &CompiledInstruction,
|
||||||
@ -1064,6 +1078,7 @@ impl MessageProcessor {
|
|||||||
caller_write_privileges: Option<&[bool]>,
|
caller_write_privileges: Option<&[bool]>,
|
||||||
timings: &mut ExecuteDetailsTimings,
|
timings: &mut ExecuteDetailsTimings,
|
||||||
demote_sysvar_write_locks: bool,
|
demote_sysvar_write_locks: bool,
|
||||||
|
logger: Rc<RefCell<dyn Logger>>,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
// Verify the per-account instruction results
|
// Verify the per-account instruction results
|
||||||
let (mut pre_sum, mut post_sum) = (0_u128, 0_u128);
|
let (mut pre_sum, mut post_sum) = (0_u128, 0_u128);
|
||||||
@ -1086,14 +1101,12 @@ impl MessageProcessor {
|
|||||||
.map_err(|_| InstructionError::AccountBorrowOutstanding)?;
|
.map_err(|_| InstructionError::AccountBorrowOutstanding)?;
|
||||||
}
|
}
|
||||||
let account = account.borrow();
|
let account = account.borrow();
|
||||||
pre_account.verify(
|
pre_account
|
||||||
&program_id,
|
.verify(&program_id, is_writable, &rent, &account, timings, false)
|
||||||
is_writable,
|
.map_err(|err| {
|
||||||
&rent,
|
ic_logger_msg!(logger, "failed to verify account {}: {}", key, err);
|
||||||
&account,
|
err
|
||||||
timings,
|
})?;
|
||||||
false,
|
|
||||||
)?;
|
|
||||||
pre_sum += u128::from(pre_account.lamports());
|
pre_sum += u128::from(pre_account.lamports());
|
||||||
post_sum += u128::from(account.lamports());
|
post_sum += u128::from(account.lamports());
|
||||||
if is_writable && !account.executable() {
|
if is_writable && !account.executable() {
|
||||||
@ -1182,6 +1195,7 @@ impl MessageProcessor {
|
|||||||
&rent_collector.rent,
|
&rent_collector.rent,
|
||||||
timings,
|
timings,
|
||||||
demote_sysvar_write_locks,
|
demote_sysvar_write_locks,
|
||||||
|
invoke_context.get_logger(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
timings.accumulate(&invoke_context.timings);
|
timings.accumulate(&invoke_context.timings);
|
||||||
|
Reference in New Issue
Block a user