set rent epoch to max on new account creation (#29528)
* set rent epoch to max on new account creation * add comment
This commit is contained in:
parent
2a0a185846
commit
2f0d849c84
|
@ -194,7 +194,7 @@ fn test_account_subscription() {
|
|||
"lamports": 100,
|
||||
"data": "",
|
||||
"executable": false,
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": 0,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5841,7 +5841,7 @@ pub mod tests {
|
|||
"executable": false,
|
||||
"owner": "11111111111111111111111111111111",
|
||||
"lamports": rent_exempt_amount,
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": 0,
|
||||
}
|
||||
],
|
||||
|
|
|
@ -933,7 +933,7 @@ mod tests {
|
|||
"lamports": balance,
|
||||
"data": [base64::encode(expected_data), encoding],
|
||||
"executable": false,
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": expected_data.len(),
|
||||
},
|
||||
},
|
||||
|
@ -1059,7 +1059,7 @@ mod tests {
|
|||
"lamports": 100,
|
||||
"data": expected_data,
|
||||
"executable": false,
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": account.data().len(),
|
||||
},
|
||||
},
|
||||
|
@ -1239,7 +1239,7 @@ mod tests {
|
|||
"lamports": 100,
|
||||
"data": "",
|
||||
"executable": false,
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": 0,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1272,7 +1272,10 @@ pub(crate) mod tests {
|
|||
space: usize,
|
||||
}
|
||||
|
||||
fn make_account_result(account_result: AccountResult) -> serde_json::Value {
|
||||
fn make_account_result(
|
||||
non_default_account: bool,
|
||||
account_result: AccountResult,
|
||||
) -> serde_json::Value {
|
||||
json!({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "accountNotification",
|
||||
|
@ -1284,7 +1287,7 @@ pub(crate) mod tests {
|
|||
"executable": false,
|
||||
"lamports": account_result.lamports,
|
||||
"owner": "11111111111111111111111111111111",
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": if non_default_account {u64::MAX} else {0},
|
||||
"space": account_result.space,
|
||||
},
|
||||
},
|
||||
|
@ -1329,12 +1332,15 @@ pub(crate) mod tests {
|
|||
0,
|
||||
&system_program::id(),
|
||||
);
|
||||
let expected0 = make_account_result(AccountResult {
|
||||
lamports: 1,
|
||||
subscription: 0,
|
||||
space: 0,
|
||||
data: "",
|
||||
});
|
||||
let expected0 = make_account_result(
|
||||
true,
|
||||
AccountResult {
|
||||
lamports: 1,
|
||||
subscription: 0,
|
||||
space: 0,
|
||||
data: "",
|
||||
},
|
||||
);
|
||||
|
||||
let tx1 = {
|
||||
let instruction =
|
||||
|
@ -1342,12 +1348,15 @@ pub(crate) mod tests {
|
|||
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
||||
Transaction::new(&[&alice, &mint_keypair], message, blockhash)
|
||||
};
|
||||
let expected1 = make_account_result(AccountResult {
|
||||
lamports: 0,
|
||||
subscription: 1,
|
||||
space: 0,
|
||||
data: "",
|
||||
});
|
||||
let expected1 = make_account_result(
|
||||
false,
|
||||
AccountResult {
|
||||
lamports: 0,
|
||||
subscription: 1,
|
||||
space: 0,
|
||||
data: "",
|
||||
},
|
||||
);
|
||||
|
||||
let tx2 = system_transaction::create_account(
|
||||
&mint_keypair,
|
||||
|
@ -1357,12 +1366,15 @@ pub(crate) mod tests {
|
|||
1024,
|
||||
&system_program::id(),
|
||||
);
|
||||
let expected2 = make_account_result(AccountResult {
|
||||
lamports: 1,
|
||||
subscription: 2,
|
||||
space: 1024,
|
||||
data: "error: data too large for bs58 encoding",
|
||||
});
|
||||
let expected2 = make_account_result(
|
||||
true,
|
||||
AccountResult {
|
||||
lamports: 1,
|
||||
subscription: 2,
|
||||
space: 1024,
|
||||
data: "error: data too large for bs58 encoding",
|
||||
},
|
||||
);
|
||||
|
||||
let subscribe_cases = vec![
|
||||
(alice.pubkey(), tx0, expected0),
|
||||
|
@ -1860,7 +1872,7 @@ pub(crate) mod tests {
|
|||
"executable": false,
|
||||
"lamports": 1,
|
||||
"owner": "Stake11111111111111111111111111111111111111",
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": 16,
|
||||
},
|
||||
"pubkey": alice.pubkey().to_string(),
|
||||
|
@ -2027,7 +2039,7 @@ pub(crate) mod tests {
|
|||
"executable": false,
|
||||
"lamports": lamports,
|
||||
"owner": "Stake11111111111111111111111111111111111111",
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": 16,
|
||||
},
|
||||
"pubkey": pubkey,
|
||||
|
@ -2308,7 +2320,7 @@ pub(crate) mod tests {
|
|||
"executable": false,
|
||||
"lamports": lamports,
|
||||
"owner": "Stake11111111111111111111111111111111111111",
|
||||
"rentEpoch": 0,
|
||||
"rentEpoch": u64::MAX,
|
||||
"space": 16,
|
||||
},
|
||||
"pubkey": pubkey,
|
||||
|
|
|
@ -319,7 +319,16 @@ impl Accounts {
|
|||
(account, 0)
|
||||
}
|
||||
})
|
||||
.unwrap_or_default()
|
||||
.unwrap_or_else(|| {
|
||||
let mut default_account = AccountSharedData::default();
|
||||
if set_exempt_rent_epoch_max {
|
||||
// All new accounts must be rent-exempt (enforced in Bank::execute_loaded_transaction).
|
||||
// Currently, rent collection sets rent_epoch to u64::MAX, but initializing the account
|
||||
// with this field already set would allow us to skip rent collection for these accounts.
|
||||
default_account.set_rent_epoch(u64::MAX);
|
||||
}
|
||||
(default_account, 0)
|
||||
})
|
||||
};
|
||||
|
||||
if !validated_fee_payer {
|
||||
|
|
Loading…
Reference in New Issue