Fix parent record locks usage in child banks (#4159)
* Introduce record locks on txs that will be recorded * Add tests for LockedAccountsResults * Fix broken bench * Exit process_entries on detecting conflicting locks within same entry
This commit is contained in:
@@ -10,6 +10,7 @@ use solana_sdk::genesis_block::GenesisBlock;
|
||||
use solana_sdk::timing::duration_as_ms;
|
||||
use solana_sdk::timing::MAX_RECENT_BLOCKHASHES;
|
||||
use solana_sdk::transaction::Result;
|
||||
use solana_sdk::transaction::Transaction;
|
||||
use std::result;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -21,7 +22,10 @@ fn first_err(results: &[Result<()>]) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn par_execute_entries(bank: &Bank, entries: &[(&Entry, LockedAccountsResults)]) -> Result<()> {
|
||||
fn par_execute_entries(
|
||||
bank: &Bank,
|
||||
entries: &[(&Entry, LockedAccountsResults<Transaction>)],
|
||||
) -> Result<()> {
|
||||
inc_new_counter_info!("bank-par_execute_entries-count", entries.len());
|
||||
let results: Vec<Result<()>> = entries
|
||||
.into_par_iter()
|
||||
@@ -77,7 +81,25 @@ pub fn process_entries(bank: &Bank, entries: &[Entry]) -> Result<()> {
|
||||
let lock_results = bank.lock_accounts(&entry.transactions);
|
||||
// if any of the locks error out
|
||||
// execute the current group
|
||||
if first_err(lock_results.locked_accounts_results()).is_err() {
|
||||
let first_lock_err = first_err(lock_results.locked_accounts_results());
|
||||
if first_lock_err.is_err() {
|
||||
if mt_group.is_empty() {
|
||||
// An entry has account lock conflicts with itself, which should not happen
|
||||
// if generated by properly functioning leaders
|
||||
solana_metrics::submit(
|
||||
solana_metrics::influxdb::Point::new("validator_process_entry_error")
|
||||
.add_field(
|
||||
"error",
|
||||
solana_metrics::influxdb::Value::String(format!(
|
||||
"Lock accounts error, entry conflicts with itself, txs: {:?}",
|
||||
entry.transactions
|
||||
)),
|
||||
)
|
||||
.to_owned(),
|
||||
);
|
||||
|
||||
first_lock_err?;
|
||||
}
|
||||
par_execute_entries(bank, &mt_group)?;
|
||||
// Drop all the locks on accounts by clearing the LockedAccountsFinalizer's in the
|
||||
// mt_group
|
||||
|
Reference in New Issue
Block a user