Skip to content

Commit

Permalink
correctly initialize account overrides (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
segfaultdoc authored and buffalu committed Mar 18, 2024
1 parent c49aa58 commit 0fba39c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ jsonrpc-derive = "18.0.0"
jsonrpc-http-server = "18.0.0"
jsonrpc-ipc-server = "18.0.0"
jsonrpc-pubsub = "18.0.0"
jsonrpc-server-utils = "18.0.0"
lazy_static = "1.4.0"
libc = "0.2.153"
libloading = "0.7.4"
Expand Down
22 changes: 19 additions & 3 deletions bundle/src/bundle_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use {
},
solana_svm::{
account_loader::TransactionLoadResult, account_overrides::AccountOverrides,
transaction_processor::ExecutionRecordingConfig,
transaction_results::TransactionExecutionResult,
},
solana_transaction_status::{token_balances::TransactionTokenBalances, PreBalanceInfo},
Expand Down Expand Up @@ -251,8 +252,20 @@ pub fn load_and_execute_bundle<'a>(
metrics: BundleExecutionMetrics::default(),
};
}

let mut binding = AccountOverrides::default();
let account_overrides = account_overrides.unwrap_or(&mut binding);
if is_simulation {
bundle
.transactions
.iter()
.map(|tx| tx.message().account_keys())
.for_each(|account_keys| {
account_overrides.upsert_account_overrides(
bank.get_account_overrides_for_simulation(&account_keys),
);
});
}

let mut chunk_start = 0;
let start_time = Instant::now();
Expand Down Expand Up @@ -341,12 +354,15 @@ pub fn load_and_execute_bundle<'a>(
.load_and_execute_transactions(
&batch,
max_age,
enable_cpi_recording,
enable_log_recording,
enable_return_data_recording,
ExecutionRecordingConfig {
enable_cpi_recording,
enable_log_recording,
enable_return_data_recording,
},
&mut metrics.execute_timings,
Some(account_overrides),
*log_messages_bytes_limit,
true
));
debug!(
"bundle id: {} loaded_transactions: {:?}",
Expand Down
1 change: 1 addition & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions runtime-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jsonrpc-core = { workspace = true }
jsonrpc-core-client = { workspace = true, features = ["ipc"] }
jsonrpc-derive = { workspace = true }
jsonrpc-ipc-server = { workspace = true }
jsonrpc-server-utils = { workspace = true }
libloading = { workspace = true }
log = { workspace = true }
solana-runtime = { workspace = true }
Expand Down
6 changes: 5 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4422,7 +4422,11 @@ impl Bank {
}
}

fn get_account_overrides_for_simulation(&self, account_keys: &AccountKeys) -> AccountOverrides {
// NOTE: Do not revert this back to private during rebases.
pub fn get_account_overrides_for_simulation(
&self,
account_keys: &AccountKeys,
) -> AccountOverrides {
let mut account_overrides = AccountOverrides::default();
let slot_history_id = sysvar::slot_history::id();
if account_keys.iter().any(|pubkey| *pubkey == slot_history_id) {
Expand Down
2 changes: 1 addition & 1 deletion validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use {
clap::{crate_name, value_t, value_t_or_exit, values_t, values_t_or_exit, ArgMatches},
console::style,
crossbeam_channel::unbounded,
jsonrpc_server_utils::tokio::runtime::Runtime,
log::*,
rand::{seq::SliceRandom, thread_rng},
solana_accounts_db::{
Expand Down Expand Up @@ -89,6 +88,7 @@ use {
sync::{atomic::AtomicBool, Arc, Mutex, RwLock},
time::{Duration, SystemTime},
},
tokio::runtime::Runtime,
};

#[cfg(not(target_env = "msvc"))]
Expand Down

0 comments on commit 0fba39c

Please sign in to comment.