Prevent rent-paying account creation (backport #22292) (#22428)

* Prevent rent-paying account creation (#22292)

* Fixup typo

* Add new feature

* Add new TransactionError

* Add framework for checking account state before and after transaction processing

* Fail transactions that leave new rent-paying accounts

* Only check rent-state of writable tx accounts

* Review comments: combine process_result success behavior; log and metrics before feature activation

* Fix tests that assume rent-exempt accounts are okay

* Remove test no longer relevant

* Remove native/sysvar special case

* Move metrics submission to report legacy->legacy rent paying transitions as well

(cherry picked from commit 637e366b18)

# Conflicts:
#	runtime/src/bank.rs
#	runtime/src/lib.rs

* Fix conflicts and rework for TransactionRefCells

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2022-01-11 23:17:03 +00:00
committed by GitHub
parent f0695ef6d9
commit 58dcc451a9
24 changed files with 821 additions and 179 deletions

View File

@ -283,6 +283,10 @@ pub mod max_tx_account_locks {
solana_sdk::declare_id!("CBkDroRDqm8HwHe6ak9cguPjUomrASEkfmxEaZ5CNNxz");
}
pub mod require_rent_exempt_accounts {
solana_sdk::declare_id!("BkFDxiJQWZXGTZaJQxH7wVEHkAmwCgSEVkrvswFfRJPD");
}
lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@ -348,6 +352,7 @@ lazy_static! {
(reject_all_elf_rw::id(), "reject all read-write data in program elfs"),
(cap_accounts_data_len::id(), "cap the accounts data len"),
(max_tx_account_locks::id(), "enforce max number of locked accounts per transaction"),
(require_rent_exempt_accounts::id(), "require all new transaction accounts with data to be rent-exempt"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()

View File

@ -125,6 +125,12 @@ pub enum TransactionError {
/// Address table lookup uses an invalid index
#[error("Transaction address table lookup uses an invalid index")]
InvalidAddressLookupTableIndex,
/// Transaction leaves an account with a lower balance than rent-exempt minimum
#[error(
"Transaction leaves an account with data with a lower balance than rent-exempt minimum"
)]
InvalidRentPayingAccount,
}
impl From<SanitizeError> for TransactionError {