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,
|
"lamports": 100,
|
||||||
"data": "",
|
"data": "",
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": 0,
|
"space": 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -5841,7 +5841,7 @@ pub mod tests {
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"owner": "11111111111111111111111111111111",
|
"owner": "11111111111111111111111111111111",
|
||||||
"lamports": rent_exempt_amount,
|
"lamports": rent_exempt_amount,
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": 0,
|
"space": 0,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -933,7 +933,7 @@ mod tests {
|
||||||
"lamports": balance,
|
"lamports": balance,
|
||||||
"data": [base64::encode(expected_data), encoding],
|
"data": [base64::encode(expected_data), encoding],
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": expected_data.len(),
|
"space": expected_data.len(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1059,7 +1059,7 @@ mod tests {
|
||||||
"lamports": 100,
|
"lamports": 100,
|
||||||
"data": expected_data,
|
"data": expected_data,
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": account.data().len(),
|
"space": account.data().len(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1239,7 +1239,7 @@ mod tests {
|
||||||
"lamports": 100,
|
"lamports": 100,
|
||||||
"data": "",
|
"data": "",
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": 0,
|
"space": 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1272,7 +1272,10 @@ pub(crate) mod tests {
|
||||||
space: usize,
|
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!({
|
json!({
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "accountNotification",
|
"method": "accountNotification",
|
||||||
|
@ -1284,7 +1287,7 @@ pub(crate) mod tests {
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"lamports": account_result.lamports,
|
"lamports": account_result.lamports,
|
||||||
"owner": "11111111111111111111111111111111",
|
"owner": "11111111111111111111111111111111",
|
||||||
"rentEpoch": 0,
|
"rentEpoch": if non_default_account {u64::MAX} else {0},
|
||||||
"space": account_result.space,
|
"space": account_result.space,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1329,12 +1332,15 @@ pub(crate) mod tests {
|
||||||
0,
|
0,
|
||||||
&system_program::id(),
|
&system_program::id(),
|
||||||
);
|
);
|
||||||
let expected0 = make_account_result(AccountResult {
|
let expected0 = make_account_result(
|
||||||
lamports: 1,
|
true,
|
||||||
subscription: 0,
|
AccountResult {
|
||||||
space: 0,
|
lamports: 1,
|
||||||
data: "",
|
subscription: 0,
|
||||||
});
|
space: 0,
|
||||||
|
data: "",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let tx1 = {
|
let tx1 = {
|
||||||
let instruction =
|
let instruction =
|
||||||
|
@ -1342,12 +1348,15 @@ pub(crate) mod tests {
|
||||||
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
let message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
|
||||||
Transaction::new(&[&alice, &mint_keypair], message, blockhash)
|
Transaction::new(&[&alice, &mint_keypair], message, blockhash)
|
||||||
};
|
};
|
||||||
let expected1 = make_account_result(AccountResult {
|
let expected1 = make_account_result(
|
||||||
lamports: 0,
|
false,
|
||||||
subscription: 1,
|
AccountResult {
|
||||||
space: 0,
|
lamports: 0,
|
||||||
data: "",
|
subscription: 1,
|
||||||
});
|
space: 0,
|
||||||
|
data: "",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let tx2 = system_transaction::create_account(
|
let tx2 = system_transaction::create_account(
|
||||||
&mint_keypair,
|
&mint_keypair,
|
||||||
|
@ -1357,12 +1366,15 @@ pub(crate) mod tests {
|
||||||
1024,
|
1024,
|
||||||
&system_program::id(),
|
&system_program::id(),
|
||||||
);
|
);
|
||||||
let expected2 = make_account_result(AccountResult {
|
let expected2 = make_account_result(
|
||||||
lamports: 1,
|
true,
|
||||||
subscription: 2,
|
AccountResult {
|
||||||
space: 1024,
|
lamports: 1,
|
||||||
data: "error: data too large for bs58 encoding",
|
subscription: 2,
|
||||||
});
|
space: 1024,
|
||||||
|
data: "error: data too large for bs58 encoding",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let subscribe_cases = vec![
|
let subscribe_cases = vec![
|
||||||
(alice.pubkey(), tx0, expected0),
|
(alice.pubkey(), tx0, expected0),
|
||||||
|
@ -1860,7 +1872,7 @@ pub(crate) mod tests {
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"lamports": 1,
|
"lamports": 1,
|
||||||
"owner": "Stake11111111111111111111111111111111111111",
|
"owner": "Stake11111111111111111111111111111111111111",
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": 16,
|
"space": 16,
|
||||||
},
|
},
|
||||||
"pubkey": alice.pubkey().to_string(),
|
"pubkey": alice.pubkey().to_string(),
|
||||||
|
@ -2027,7 +2039,7 @@ pub(crate) mod tests {
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"lamports": lamports,
|
"lamports": lamports,
|
||||||
"owner": "Stake11111111111111111111111111111111111111",
|
"owner": "Stake11111111111111111111111111111111111111",
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": 16,
|
"space": 16,
|
||||||
},
|
},
|
||||||
"pubkey": pubkey,
|
"pubkey": pubkey,
|
||||||
|
@ -2308,7 +2320,7 @@ pub(crate) mod tests {
|
||||||
"executable": false,
|
"executable": false,
|
||||||
"lamports": lamports,
|
"lamports": lamports,
|
||||||
"owner": "Stake11111111111111111111111111111111111111",
|
"owner": "Stake11111111111111111111111111111111111111",
|
||||||
"rentEpoch": 0,
|
"rentEpoch": u64::MAX,
|
||||||
"space": 16,
|
"space": 16,
|
||||||
},
|
},
|
||||||
"pubkey": pubkey,
|
"pubkey": pubkey,
|
||||||
|
|
|
@ -319,7 +319,16 @@ impl Accounts {
|
||||||
(account, 0)
|
(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 {
|
if !validated_fee_payer {
|
||||||
|
|
Loading…
Reference in New Issue