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

@ -19,6 +19,7 @@ use {
commitment_config::CommitmentConfig,
hash::Hash,
pubkey::Pubkey,
rent::Rent,
signature::{Keypair, Signer},
system_transaction,
transaction::Transaction,
@ -79,7 +80,12 @@ fn test_rpc_send_tx() {
.unwrap();
info!("blockhash: {:?}", blockhash);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
let tx = system_transaction::transfer(
&alice,
&bob_pubkey,
Rent::default().minimum_balance(0),
blockhash,
);
let serialized_encoded_tx = bs58::encode(serialize(&tx).unwrap()).into_string();
let req = json_req!("sendTransaction", json!([serialized_encoded_tx]));
@ -242,7 +248,7 @@ fn test_rpc_subscriptions() {
system_transaction::transfer(
&alice,
&solana_sdk::pubkey::new_rand(),
1,
Rent::default().minimum_balance(0),
recent_blockhash,
)
})
@ -380,7 +386,7 @@ fn test_rpc_subscriptions() {
let timeout = deadline.saturating_duration_since(Instant::now());
match account_receiver.recv_timeout(timeout) {
Ok(result) => {
assert_eq!(result.value.lamports, 1);
assert_eq!(result.value.lamports, Rent::default().minimum_balance(0));
account_notifications -= 1;
}
Err(_err) => {