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:
@ -249,9 +249,9 @@ pub enum InstructionError {
|
||||
#[error("Provided owner is not allowed")]
|
||||
IllegalOwner,
|
||||
|
||||
/// Accounts data budget exceeded
|
||||
#[error("Requested account data allocation exceeded the accounts data budget")]
|
||||
AccountsDataBudgetExceeded,
|
||||
/// Account data allocation exceeded the maximum accounts data size limit
|
||||
#[error("Account data allocation exceeded the maximum accounts data size limit")]
|
||||
MaxAccountsDataSizeExceeded,
|
||||
|
||||
/// Active vote account close
|
||||
#[error("Cannot close vote account unless it stopped voting at least one full epoch ago")]
|
||||
|
@ -49,8 +49,8 @@ pub enum ProgramError {
|
||||
UnsupportedSysvar,
|
||||
#[error("Provided owner is not allowed")]
|
||||
IllegalOwner,
|
||||
#[error("Requested account data allocation exceeded the accounts data budget")]
|
||||
AccountsDataBudgetExceeded,
|
||||
#[error("Account data allocation exceeded the maximum accounts data size limit")]
|
||||
MaxAccountsDataSizeExceeded,
|
||||
#[error("Cannot close vote account unless it stopped voting at least one full epoch ago")]
|
||||
ActiveVoteAccountClose,
|
||||
}
|
||||
@ -91,7 +91,7 @@ impl PrintProgramError for ProgramError {
|
||||
Self::AccountNotRentExempt => msg!("Error: AccountNotRentExempt"),
|
||||
Self::UnsupportedSysvar => msg!("Error: UnsupportedSysvar"),
|
||||
Self::IllegalOwner => msg!("Error: IllegalOwner"),
|
||||
Self::AccountsDataBudgetExceeded => msg!("Error: AccountsDataBudgetExceeded"),
|
||||
Self::MaxAccountsDataSizeExceeded => msg!("Error: MaxAccountsDataSizeExceeded"),
|
||||
Self::ActiveVoteAccountClose => msg!("Error: ActiveVoteAccountClose"),
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ pub const BORSH_IO_ERROR: u64 = to_builtin!(15);
|
||||
pub const ACCOUNT_NOT_RENT_EXEMPT: u64 = to_builtin!(16);
|
||||
pub const UNSUPPORTED_SYSVAR: u64 = to_builtin!(17);
|
||||
pub const ILLEGAL_OWNER: u64 = to_builtin!(18);
|
||||
pub const ACCOUNTS_DATA_BUDGET_EXCEEDED: u64 = to_builtin!(19);
|
||||
pub const MAX_ACCOUNTS_DATA_SIZE_EXCEEDED: u64 = to_builtin!(19);
|
||||
pub const ACTIVE_VOTE_ACCOUNT_CLOSE: u64 = to_builtin!(20);
|
||||
// Warning: Any new program errors added here must also be:
|
||||
// - Added to the below conversions
|
||||
@ -151,7 +151,7 @@ impl From<ProgramError> for u64 {
|
||||
ProgramError::AccountNotRentExempt => ACCOUNT_NOT_RENT_EXEMPT,
|
||||
ProgramError::UnsupportedSysvar => UNSUPPORTED_SYSVAR,
|
||||
ProgramError::IllegalOwner => ILLEGAL_OWNER,
|
||||
ProgramError::AccountsDataBudgetExceeded => ACCOUNTS_DATA_BUDGET_EXCEEDED,
|
||||
ProgramError::MaxAccountsDataSizeExceeded => MAX_ACCOUNTS_DATA_SIZE_EXCEEDED,
|
||||
ProgramError::ActiveVoteAccountClose => ACTIVE_VOTE_ACCOUNT_CLOSE,
|
||||
ProgramError::Custom(error) => {
|
||||
if error == 0 {
|
||||
@ -185,7 +185,7 @@ impl From<u64> for ProgramError {
|
||||
ACCOUNT_NOT_RENT_EXEMPT => Self::AccountNotRentExempt,
|
||||
UNSUPPORTED_SYSVAR => Self::UnsupportedSysvar,
|
||||
ILLEGAL_OWNER => Self::IllegalOwner,
|
||||
ACCOUNTS_DATA_BUDGET_EXCEEDED => Self::AccountsDataBudgetExceeded,
|
||||
MAX_ACCOUNTS_DATA_SIZE_EXCEEDED => Self::MaxAccountsDataSizeExceeded,
|
||||
ACTIVE_VOTE_ACCOUNT_CLOSE => Self::ActiveVoteAccountClose,
|
||||
_ => Self::Custom(error as u32),
|
||||
}
|
||||
@ -215,7 +215,7 @@ impl TryFrom<InstructionError> for ProgramError {
|
||||
Self::Error::AccountNotRentExempt => Ok(Self::AccountNotRentExempt),
|
||||
Self::Error::UnsupportedSysvar => Ok(Self::UnsupportedSysvar),
|
||||
Self::Error::IllegalOwner => Ok(Self::IllegalOwner),
|
||||
Self::Error::AccountsDataBudgetExceeded => Ok(Self::AccountsDataBudgetExceeded),
|
||||
Self::Error::MaxAccountsDataSizeExceeded => Ok(Self::MaxAccountsDataSizeExceeded),
|
||||
Self::Error::ActiveVoteAccountClose => Ok(Self::ActiveVoteAccountClose),
|
||||
_ => Err(error),
|
||||
}
|
||||
@ -247,7 +247,7 @@ where
|
||||
ACCOUNT_NOT_RENT_EXEMPT => Self::AccountNotRentExempt,
|
||||
UNSUPPORTED_SYSVAR => Self::UnsupportedSysvar,
|
||||
ILLEGAL_OWNER => Self::IllegalOwner,
|
||||
ACCOUNTS_DATA_BUDGET_EXCEEDED => Self::AccountsDataBudgetExceeded,
|
||||
MAX_ACCOUNTS_DATA_SIZE_EXCEEDED => Self::MaxAccountsDataSizeExceeded,
|
||||
ACTIVE_VOTE_ACCOUNT_CLOSE => Self::ActiveVoteAccountClose,
|
||||
_ => {
|
||||
// A valid custom error has no bits set in the upper 32
|
||||
|
Reference in New Issue
Block a user