diff --git a/runtime/src/runtime/fvm.rs b/runtime/src/runtime/fvm.rs index 40a9602ff..d4aa52bc6 100644 --- a/runtime/src/runtime/fvm.rs +++ b/runtime/src/runtime/fvm.rs @@ -371,10 +371,6 @@ where .context_code(ExitCode::USR_ASSERTION_FAILED, "failed to emit event") } - fn exit(&self, code: u32, data: Option, msg: Option<&str>) -> ! { - fvm::vm::exit(code, data, msg) - } - fn read_only(&self) -> bool { fvm::vm::read_only() } diff --git a/runtime/src/runtime/mod.rs b/runtime/src/runtime/mod.rs index 6648a52c2..5167c9187 100644 --- a/runtime/src/runtime/mod.rs +++ b/runtime/src/runtime/mod.rs @@ -251,10 +251,6 @@ pub trait Runtime: Primitives + Verifier + RuntimePolicy { /// Emits an event denoting that something externally noteworthy has ocurred. fn emit_event(&self, event: &ActorEvent) -> Result<(), ActorError>; - /// Exit the current computation with an error code and optionally data and a debugging - /// message. - fn exit(&self, code: u32, data: Option, msg: Option<&str>) -> !; - /// Returns true if the call is read_only. /// All state updates, including actor creation and balance transfers, are rejected in read_only calls. fn read_only(&self) -> bool; diff --git a/runtime/src/test_utils.rs b/runtime/src/test_utils.rs index 58d111a1a..2ee7a8fc3 100644 --- a/runtime/src/test_utils.rs +++ b/runtime/src/test_utils.rs @@ -134,12 +134,6 @@ pub fn init_logging() -> Result<(), log::SetLoggerError> { pretty_env_logger::try_init() } -pub struct ActorExit { - code: u32, - data: Option, - msg: Option, -} - pub struct MockRuntime { pub epoch: ChainEpoch, pub miner: Address, @@ -187,9 +181,6 @@ pub struct MockRuntime { pub actor_balances: HashMap, pub tipset_timestamp: u64, pub tipset_cids: Vec, - - // actor exits - pub actor_exit: RefCell>, } #[derive(Default)] @@ -365,7 +356,6 @@ impl MockRuntime { actor_balances: Default::default(), tipset_timestamp: Default::default(), tipset_cids: Default::default(), - actor_exit: Default::default(), } } } @@ -563,26 +553,7 @@ impl MockRuntime { ) -> Result, ActorError> { self.in_call = true; let prev_state = self.state; - let res: Result, ActorError> = - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - A::invoke_method(self, method_num, params) - })) - .unwrap_or_else(|panic| { - if self.actor_exit.borrow().is_some() { - let exit = self.actor_exit.take().unwrap(); - if exit.code == 0 { - Ok(exit.data) - } else { - Err(ActorError::unchecked_with_data( - ExitCode::new(exit.code), - exit.msg.unwrap_or_else(|| "actor exited".to_owned()), - exit.data, - )) - } - } else { - std::panic::resume_unwind(panic) - } - }); + let res = A::invoke_method(self, method_num, params); if res.is_err() { self.state = prev_state; @@ -1311,11 +1282,6 @@ impl Runtime for MockRuntime { Ok(()) } - fn exit(&self, code: u32, data: Option, msg: Option<&str>) -> ! { - self.actor_exit.replace(Some(ActorExit { code, data, msg: msg.map(|s| s.to_owned()) })); - std::panic::panic_any("actor exit"); - } - fn chain_id(&self) -> ChainID { self.chain_id } diff --git a/test_vm/src/lib.rs b/test_vm/src/lib.rs index 8a1f79bd5..c3045e4f0 100644 --- a/test_vm/src/lib.rs +++ b/test_vm/src/lib.rs @@ -466,9 +466,8 @@ impl<'bs> VM<'bs> { read_only: false, policy: &Policy::default(), subinvocations: RefCell::new(vec![]), - actor_exit: RefCell::new(None), }; - let res = new_ctx.invoke_actor(); + let res = new_ctx.invoke(); let invoc = new_ctx.gather_trace(res.clone()); RefMut::map(self.invocations.borrow_mut(), |invocs| { @@ -608,13 +607,6 @@ pub struct InvocationCtx<'invocation, 'bs> { read_only: bool, policy: &'invocation Policy, subinvocations: RefCell>, - actor_exit: RefCell>, -} - -struct ActorExit { - code: u32, - data: Option, - msg: Option, } impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> { @@ -676,7 +668,6 @@ impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> { read_only: false, policy: self.policy, subinvocations: RefCell::new(vec![]), - actor_exit: RefCell::new(None), }; if is_account { new_ctx.create_actor(*ACCOUNT_ACTOR_CODE_ID, target_id, None).unwrap(); @@ -714,27 +705,6 @@ impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> { self.resolve_target(&self.msg.to).unwrap().1 } - fn invoke_actor(&mut self) -> Result, ActorError> { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| self.invoke())).unwrap_or_else( - |panic| { - if self.actor_exit.borrow().is_some() { - let exit = self.actor_exit.take().unwrap(); - if exit.code == 0 { - Ok(exit.data) - } else { - Err(ActorError::unchecked_with_data( - ExitCode::new(exit.code), - exit.msg.unwrap_or_else(|| "actor exited".to_owned()), - exit.data, - )) - } - } else { - std::panic::resume_unwind(panic) - } - }, - ) - } - fn invoke(&mut self) -> Result, ActorError> { let prior_root = self.v.checkpoint(); @@ -1019,9 +989,8 @@ impl<'invocation, 'bs> Runtime for InvocationCtx<'invocation, 'bs> { read_only: send_flags.read_only(), policy: self.policy, subinvocations: RefCell::new(vec![]), - actor_exit: RefCell::new(None), }; - let res = new_ctx.invoke_actor(); + let res = new_ctx.invoke(); let invoc = new_ctx.gather_trace(res.clone()); RefMut::map(self.subinvocations.borrow_mut(), |subinvocs| { subinvocs.push(invoc); @@ -1149,11 +1118,6 @@ impl<'invocation, 'bs> Runtime for InvocationCtx<'invocation, 'bs> { Ok(()) } - fn exit(&self, code: u32, data: Option, msg: Option<&str>) -> ! { - self.actor_exit.replace(Some(ActorExit { code, data, msg: msg.map(|s| s.to_owned()) })); - std::panic::panic_any("actor exit"); - } - fn read_only(&self) -> bool { self.read_only }