Ensure blocks do not exceed the max accounts data size during Replay Stage (#23422)

This commit is contained in:
Brooks Prumo
2022-03-10 10:24:31 -06:00
committed by GitHub
parent 58c0db9704
commit 3c6840050c
9 changed files with 56 additions and 24 deletions

View File

@ -80,7 +80,7 @@ impl AccountsDataMeter {
/// the remaining space, return an error and *do not* adjust accounts data space.
pub fn adjust_delta(&mut self, amount: i64) -> Result<(), InstructionError> {
if amount > self.remaining() as i64 {
return Err(InstructionError::AccountsDataBudgetExceeded);
return Err(InstructionError::MaxAccountsDataSizeExceeded);
}
self.adjust_delta_unchecked(amount);
Ok(())

View File

@ -1745,7 +1745,7 @@ mod tests {
assert!(result.is_err());
assert!(matches!(
result,
Err(solana_sdk::instruction::InstructionError::AccountsDataBudgetExceeded)
Err(solana_sdk::instruction::InstructionError::MaxAccountsDataSizeExceeded)
));
assert_eq!(invoke_context.accounts_data_meter.remaining(), 0);
}