Move load_accounts to runtime (#34017)

* Move load_accounts to runtime

---------

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
This commit is contained in:
Lucas Steuernagel 2023-11-16 18:45:58 -03:00 committed by GitHub
parent e589c07fef
commit 2c71d21fad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1875 additions and 1813 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,6 @@ extern crate lazy_static;
pub mod account_info;
pub mod account_overrides;
pub mod account_rent_state;
pub mod account_storage;
pub mod accounts;
pub mod accounts_cache;

View File

@ -10,7 +10,7 @@ use {
};
#[derive(Debug, PartialEq, Eq)]
pub enum RentState {
pub(crate) enum RentState {
/// account.lamports == 0
Uninitialized,
/// 0 < account.lamports < rent-exempt-minimum
@ -58,7 +58,7 @@ impl RentState {
}
}
pub(crate) fn submit_rent_state_metrics(pre_rent_state: &RentState, post_rent_state: &RentState) {
pub(super) fn submit_rent_state_metrics(pre_rent_state: &RentState, post_rent_state: &RentState) {
match (pre_rent_state, post_rent_state) {
(&RentState::Uninitialized, &RentState::RentPaying { .. }) => {
inc_new_counter_info!("rent_paying_err-new_account", 1);
@ -73,7 +73,7 @@ pub(crate) fn submit_rent_state_metrics(pre_rent_state: &RentState, post_rent_st
}
}
pub fn check_rent_state(
pub(crate) fn check_rent_state(
pre_rent_state: Option<&RentState>,
post_rent_state: Option<&RentState>,
transaction_context: &TransactionContext,
@ -97,7 +97,7 @@ pub fn check_rent_state(
Ok(())
}
pub(crate) fn check_rent_state_with_account(
pub(super) fn check_rent_state_with_account(
pre_rent_state: &RentState,
post_rent_state: &RentState,
address: &Pubkey,

1849
runtime/src/accounts/mod.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -278,6 +278,7 @@ pub struct BankRc {
pub(crate) bank_id_generator: Arc<AtomicU64>,
}
use crate::accounts::load_accounts;
#[cfg(RUSTC_WITH_SPECIALIZATION)]
use solana_frozen_abi::abi_example::AbiExample;
@ -5243,7 +5244,8 @@ impl Bank {
));
let mut load_time = Measure::start("accounts_load");
let mut loaded_transactions = self.rc.accounts.load_accounts(
let mut loaded_transactions = load_accounts(
&self.rc.accounts.accounts_db,
&self.ancestors,
sanitized_txs,
check_results,

View File

@ -1,7 +1,8 @@
use {
super::Bank,
crate::accounts::account_rent_state::RentState,
log::{debug, warn},
solana_accounts_db::{account_rent_state::RentState, stake_rewards::RewardInfo},
solana_accounts_db::stake_rewards::RewardInfo,
solana_sdk::{
account::{ReadableAccount, WritableAccount},
pubkey::Pubkey,

View File

@ -10872,7 +10872,8 @@ fn test_rent_state_list_len() {
let num_accounts = tx.message().account_keys.len();
let sanitized_tx = SanitizedTransaction::try_from_legacy_transaction(tx).unwrap();
let mut error_counters = TransactionErrorMetrics::default();
let loaded_txs = bank.rc.accounts.load_accounts(
let loaded_txs = load_accounts(
&bank.accounts().accounts_db,
&bank.ancestors,
&[sanitized_tx.clone()],
vec![(Ok(()), None)],

View File

@ -1,6 +1,8 @@
use {
crate::bank::Bank,
solana_accounts_db::account_rent_state::{check_rent_state, RentState},
crate::{
accounts::account_rent_state::{check_rent_state, RentState},
bank::Bank,
},
solana_sdk::{
account::ReadableAccount,
message::SanitizedMessage,

View File

@ -4,6 +4,7 @@
#[macro_use]
extern crate lazy_static;
pub mod accounts;
pub mod accounts_background_service;
pub mod bank;
pub mod bank_client;