From a005cf77207622637117d497d1f688c14cfb261b Mon Sep 17 00:00:00 2001 From: Mikers Date: Thu, 12 Dec 2024 17:11:37 -1000 Subject: [PATCH] remove error case from new --- actors/evm/src/interpreter/system.rs | 19 +++++++++---------- actors/evm/src/interpreter/test_util.rs | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/actors/evm/src/interpreter/system.rs b/actors/evm/src/interpreter/system.rs index a352eb88e..ec1c29e01 100644 --- a/actors/evm/src/interpreter/system.rs +++ b/actors/evm/src/interpreter/system.rs @@ -111,14 +111,14 @@ pub struct System<'r, RT: Runtime> { } impl<'r, RT: Runtime> System<'r, RT> { - pub(crate) fn new(rt: &'r RT, readonly: bool) -> Result + pub(crate) fn new(rt: &'r RT, readonly: bool) -> Self where RT::Blockstore: Clone, { let store = rt.store().clone(); let transient_store = rt.store().clone(); let current_transient_data_lifespan = get_current_transient_data_lifespan(rt); - Ok(Self { + Self { rt, slots: StateKamt::new_with_config(store, KAMT_CONFIG.clone()), transient_slots: StateKamt::new_with_config(transient_store, KAMT_CONFIG.clone()), @@ -129,7 +129,7 @@ impl<'r, RT: Runtime> System<'r, RT> { readonly, randomness: None, tombstone: None, - }) + } } /// Resurrect the contract. This will return a new empty contract if, and only if, the contract @@ -150,7 +150,7 @@ impl<'r, RT: Runtime> System<'r, RT> { return Err(actor_error!(forbidden, "can only resurrect a dead contract")); } - return Self::new(rt, read_only); + return Ok(Self::new(rt, read_only)); } /// Create the contract. This will return a new empty contract if, and only if, the contract @@ -164,7 +164,7 @@ impl<'r, RT: Runtime> System<'r, RT> { if state_root != EMPTY_ARR_CID { return Err(actor_error!(illegal_state, "can't create over an existing actor")); } - return Self::new(rt, read_only); + return Ok(Self::new(rt, read_only)); } /// Load the actor from state. @@ -183,7 +183,7 @@ impl<'r, RT: Runtime> System<'r, RT> { if crate::is_dead(rt, &state) { // If we're "dead", return an empty read-only contract. The code will be empty, so // nothing can happen anyways. - return Self::new(rt, true); + return Ok(Self::new(rt, true)); } let read_only = rt.read_only(); @@ -541,10 +541,9 @@ impl<'r, RT: Runtime> System<'r, RT> { } /// Returns the current transient data lifespan based on the execution environment. -fn get_current_transient_data_lifespan( - rt: &RT, -) -> TransientDataLifespan { +fn get_current_transient_data_lifespan(rt: &RT) -> TransientDataLifespan { TransientDataLifespan { origin: rt.message().origin().id().unwrap(), nonce: rt.message().nonce(), - }} + } +} diff --git a/actors/evm/src/interpreter/test_util.rs b/actors/evm/src/interpreter/test_util.rs index f17406925..3ec2a4750 100644 --- a/actors/evm/src/interpreter/test_util.rs +++ b/actors/evm/src/interpreter/test_util.rs @@ -33,7 +33,7 @@ macro_rules! evm_unit_test { let code = vec![$($crate::evm_instruction!($inst)),*]; - let mut system = System::new(&$rt, false).expect("Failed to initialize System"); + let mut system = System::new(&$rt, false); let bytecode = Bytecode::new(code); #[allow(unused_mut)] let mut $machine = Machine { @@ -64,7 +64,7 @@ macro_rules! evm_unit_test { let code = vec![$($crate::evm_instruction!($inst)),*]; - let mut system = System::new(&rt, false).expect("Failed to initialize System"); + let mut system = System::new(&rt, false); let bytecode = Bytecode::new(code); #[allow(unused_mut)] let mut $machine = Machine {