diff --git a/crates/evm/src/assembler.rs b/crates/evm/src/assembler.rs index 702f2ac..595ce26 100644 --- a/crates/evm/src/assembler.rs +++ b/crates/evm/src/assembler.rs @@ -42,6 +42,13 @@ impl ArcBlockAssembler { } } +fn storage_read_result(result: Result) -> Result +where + E: core::error::Error + Send + Sync + 'static, +{ + result.map_err(BlockExecutionError::other) +} + impl BlockAssembler for ArcBlockAssembler where F: for<'a> BlockExecutorFactory< @@ -83,10 +90,11 @@ where // Read from state provider if the state is not changed. if value.is_none() { - value = input - .state_provider - .storage(SYSTEM_ACCOUNTING_ADDRESS, slot) - .unwrap_or(None) + value = storage_read_result( + input + .state_provider + .storage(SYSTEM_ACCOUNTING_ADDRESS, slot), + )?; } if let Some(value) = value { @@ -110,6 +118,19 @@ mod tests { use alloc::sync::Arc; use arc_execution_config::chainspec::LOCAL_DEV; + #[test] + fn storage_provider_error_is_propagated() { + let result: Result, std::io::Error> = + Err(std::io::Error::other("storage read failed")); + + let error = match storage_read_result(result) { + Ok(_) => panic!("storage error should be propagated"), + Err(error) => error, + }; + + assert!(error.to_string().contains("storage read failed")); + } + #[test] fn block_assembler_creation() { let chain_spec = LOCAL_DEV.clone();