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
This commit is contained in:
Tyera Eulberg
2022-01-11 11:32:25 -07:00
committed by GitHub
parent a49ef49f87
commit 637e366b18
24 changed files with 819 additions and 179 deletions

View File

@ -20,6 +20,7 @@ use {
commitment_config::CommitmentConfig,
hash::Hash,
pubkey::Pubkey,
rent::Rent,
signature::{Keypair, Signer},
system_transaction,
transaction::Transaction,
@ -80,7 +81,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]));
@ -243,7 +249,7 @@ fn test_rpc_subscriptions() {
system_transaction::transfer(
&alice,
&solana_sdk::pubkey::new_rand(),
1,
Rent::default().minimum_balance(0),
recent_blockhash,
)
})
@ -381,7 +387,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) => {