Skip to content

Commit

Permalink
transaction executors: simulate only first transaction in the list
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed Sep 11, 2023
1 parent 4cbe0ef commit a2d1bc8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libs/marinade-client-rs/src/transactions/transaction_executors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,16 @@ pub fn execute_transaction_builder(
}

if simulate {
// expecting the instructions are dependent one to each other
// the result of the first can be used in the next one, for that simulation is run only for the fist bunch
let mut number_of_transactions = 0_u32;
for mut prepared_transaction in transaction_builder.sequence_combined() {
number_of_transactions += 1;
if number_of_transactions > 1 {
// only the first bunch is simulated
// need to drain whole sequence to find the number of transaction bunches
continue;
}
let simulation_config_default = RpcSimulateTransactionConfig::default();
let simulation_commitment = if preflight_config.preflight_commitment.is_some() {
Some(CommitmentConfig {
Expand All @@ -233,6 +242,9 @@ pub fn execute_transaction_builder(
);
log_simulation(&simulation_result)?;
}
if number_of_transactions > 1 {
warn!("Simulation mode: only the first bunch of transactions was simulated, the rest was not simulated.");
}
} else {
for mut prepared_transaction in transaction_builder.sequence_combined() {
let execution_result = execute_prepared_transaction(
Expand Down

0 comments on commit a2d1bc8

Please sign in to comment.