Skip to content

Commit 53456cb

Browse files
Move internal error handling to runners
1 parent 6239ebf commit 53456cb

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

basic_bootloader/src/bootloader/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ruint::aliases::*;
66
use system_hooks::addresses_constants::BOOTLOADER_FORMAL_ADDRESS;
77
use zk_ee::execution_environment_type::ExecutionEnvironmentType;
88
use zk_ee::memory::slice_vec::SliceVec;
9+
use zk_ee::system::errors::InternalError;
910
use zk_ee::system::{EthereumLikeTypes, System, SystemTypes};
1011

1112
pub mod run_single_interaction;
@@ -169,7 +170,7 @@ impl<S: EthereumLikeTypes> BasicBootloader<S> {
169170
pub fn run_prepared<Config: BasicBootloaderExecutionConfig>(
170171
oracle: <S::IO as IOSubsystemExt>::IOOracle,
171172
result_keeper: &mut impl ResultKeeperExt,
172-
) -> <S::IO as IOSubsystemExt>::FinalData
173+
) -> Result<<S::IO as IOSubsystemExt>::FinalData, InternalError>
173174
where
174175
S::IO: IOSubsystemExt,
175176
S::Memory: MemorySubsystemExt,
@@ -241,7 +242,7 @@ impl<S: EthereumLikeTypes> BasicBootloader<S> {
241242
"Tx execution result: Internal error = {:?}\n",
242243
err,
243244
));
244-
panic!("Internal error during tx execution {:?}", err)
245+
return Err(err);
245246
}
246247
Err(TxError::Validation(err)) => {
247248
let _ = system.get_logger().write_fmt(format_args!(
@@ -374,6 +375,6 @@ impl<S: EthereumLikeTypes> BasicBootloader<S> {
374375
let r = system.finish(block_hash, l1_to_l2_tx_hash, upgrade_tx_hash, result_keeper);
375376
cycle_marker::end!("run_prepared");
376377
#[allow(clippy::let_and_return)]
377-
r
378+
Ok(r)
378379
}
379380
}

forward_system/src/run/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ pub fn run_batch_from_oracle_dump<
161161
///
162162
/// Simulate single transaction on top of given state.
163163
/// The validation step is skipped, fields that needed for validation can be empty(any).
164+
/// Note that, as the validation step is skipped, an internal error is returned
165+
/// if the sender does not have enough balance for the top-level call value transfer.
164166
///
165167
/// Needed for `eth_call` and `eth_estimateGas`.
166168
///
@@ -189,7 +191,7 @@ pub fn simulate_tx<S: ReadStorage, PS: PreimageSource>(
189191
CallSimulationBootloader::run_prepared::<BasicBootloaderCallSimulationConfig>(
190192
oracle,
191193
&mut result_keeper,
192-
);
194+
)?;
193195
let mut batch_output: BatchOutput = result_keeper.into();
194196
Ok(batch_output.tx_results.remove(0))
195197
}

forward_system/src/system/bootloader.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ pub fn run_forward<
1717
oracle: ForwardRunningOracle<T, PS, TS>,
1818
result_keeper: &mut impl ResultKeeperExt,
1919
) {
20-
let _oracle = ForwardBootloader::run_prepared::<Config>(oracle, result_keeper);
20+
if let Err(err) = ForwardBootloader::run_prepared::<Config>(oracle, result_keeper) {
21+
panic!("Forward run failed with: {:?}", err)
22+
};
2123
}

proof_running_system/src/system/bootloader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ pub fn run_proving_inner<
178178
// Load all transactions from oracle and apply them.
179179
let (mut oracle, public_input) = ProvingBootloader::<O, L>::run_prepared::<
180180
BasicBootloaderProvingExecutionConfig,
181-
>(oracle, &mut NopResultKeeper);
181+
>(oracle, &mut NopResultKeeper)
182+
.expect("Tried to prove a failing batch");
182183

183184
// disconnect oracle before returning
184185
// TODO: check this is the intended behaviour (ignoring the result)

0 commit comments

Comments
 (0)