Skip to content

Commit

Permalink
Move load_accounts to runtime (solana-labs#34017)
Browse files Browse the repository at this point in the history
* Move load_accounts to runtime

---------

Signed-off-by: Lucas Steuernagel <[email protected]>
  • Loading branch information
LucasSte authored Nov 16, 2023
1 parent e589c07 commit 2c71d21
Show file tree
Hide file tree
Showing 9 changed files with 1,884 additions and 1,822 deletions.
1,831 changes: 19 additions & 1,812 deletions accounts-db/src/accounts.rs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion accounts-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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,
Expand Down
1,849 changes: 1,849 additions & 0 deletions runtime/src/accounts/mod.rs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/bank/fee_distribution.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down
6 changes: 4 additions & 2 deletions runtime/src/bank/transaction_account_state_info.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 1 addition & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2c71d21

Please sign in to comment.