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

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

(cherry picked from commit 3c6840050c)

# Conflicts:
#	runtime/src/bank.rs

* fix conflicts

Co-authored-by: Brooks Prumo <brooks@solana.com>
This commit is contained in:
mergify[bot]
2022-03-10 18:59:46 +00:00
committed by GitHub
parent 49952e05cf
commit e0f5fb887b
9 changed files with 60 additions and 26 deletions

View File

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

View File

@ -1918,7 +1918,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);
}