Skip to content

Commit 29b71a4

Browse files
committed
runtime: drop unused exit()
1 parent 7de3759 commit 29b71a4

File tree

4 files changed

+3
-81
lines changed

4 files changed

+3
-81
lines changed

runtime/src/runtime/fvm.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,6 @@ where
371371
.context_code(ExitCode::USR_ASSERTION_FAILED, "failed to emit event")
372372
}
373373

374-
fn exit(&self, code: u32, data: Option<IpldBlock>, msg: Option<&str>) -> ! {
375-
fvm::vm::exit(code, data, msg)
376-
}
377-
378374
fn read_only(&self) -> bool {
379375
fvm::vm::read_only()
380376
}

runtime/src/runtime/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,6 @@ pub trait Runtime: Primitives + Verifier + RuntimePolicy {
251251
/// Emits an event denoting that something externally noteworthy has ocurred.
252252
fn emit_event(&self, event: &ActorEvent) -> Result<(), ActorError>;
253253

254-
/// Exit the current computation with an error code and optionally data and a debugging
255-
/// message.
256-
fn exit(&self, code: u32, data: Option<IpldBlock>, msg: Option<&str>) -> !;
257-
258254
/// Returns true if the call is read_only.
259255
/// All state updates, including actor creation and balance transfers, are rejected in read_only calls.
260256
fn read_only(&self) -> bool;

runtime/src/test_utils.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ pub fn init_logging() -> Result<(), log::SetLoggerError> {
134134
pretty_env_logger::try_init()
135135
}
136136

137-
pub struct ActorExit {
138-
code: u32,
139-
data: Option<IpldBlock>,
140-
msg: Option<String>,
141-
}
142-
143137
pub struct MockRuntime<BS = MemoryBlockstore> {
144138
pub epoch: ChainEpoch,
145139
pub miner: Address,
@@ -187,9 +181,6 @@ pub struct MockRuntime<BS = MemoryBlockstore> {
187181
pub actor_balances: HashMap<ActorID, TokenAmount>,
188182
pub tipset_timestamp: u64,
189183
pub tipset_cids: Vec<Cid>,
190-
191-
// actor exits
192-
pub actor_exit: RefCell<Option<ActorExit>>,
193184
}
194185

195186
#[derive(Default)]
@@ -365,7 +356,6 @@ impl<BS> MockRuntime<BS> {
365356
actor_balances: Default::default(),
366357
tipset_timestamp: Default::default(),
367358
tipset_cids: Default::default(),
368-
actor_exit: Default::default(),
369359
}
370360
}
371361
}
@@ -563,26 +553,7 @@ impl<BS: Blockstore> MockRuntime<BS> {
563553
) -> Result<Option<IpldBlock>, ActorError> {
564554
self.in_call = true;
565555
let prev_state = self.state;
566-
let res: Result<Option<IpldBlock>, ActorError> =
567-
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
568-
A::invoke_method(self, method_num, params)
569-
}))
570-
.unwrap_or_else(|panic| {
571-
if self.actor_exit.borrow().is_some() {
572-
let exit = self.actor_exit.take().unwrap();
573-
if exit.code == 0 {
574-
Ok(exit.data)
575-
} else {
576-
Err(ActorError::unchecked_with_data(
577-
ExitCode::new(exit.code),
578-
exit.msg.unwrap_or_else(|| "actor exited".to_owned()),
579-
exit.data,
580-
))
581-
}
582-
} else {
583-
std::panic::resume_unwind(panic)
584-
}
585-
});
556+
let res = A::invoke_method(self, method_num, params);
586557

587558
if res.is_err() {
588559
self.state = prev_state;
@@ -1311,11 +1282,6 @@ impl<BS: Blockstore> Runtime for MockRuntime<BS> {
13111282
Ok(())
13121283
}
13131284

1314-
fn exit(&self, code: u32, data: Option<IpldBlock>, msg: Option<&str>) -> ! {
1315-
self.actor_exit.replace(Some(ActorExit { code, data, msg: msg.map(|s| s.to_owned()) }));
1316-
std::panic::panic_any("actor exit");
1317-
}
1318-
13191285
fn chain_id(&self) -> ChainID {
13201286
self.chain_id
13211287
}

test_vm/src/lib.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,8 @@ impl<'bs> VM<'bs> {
466466
read_only: false,
467467
policy: &Policy::default(),
468468
subinvocations: RefCell::new(vec![]),
469-
actor_exit: RefCell::new(None),
470469
};
471-
let res = new_ctx.invoke_actor();
470+
let res = new_ctx.invoke();
472471

473472
let invoc = new_ctx.gather_trace(res.clone());
474473
RefMut::map(self.invocations.borrow_mut(), |invocs| {
@@ -608,13 +607,6 @@ pub struct InvocationCtx<'invocation, 'bs> {
608607
read_only: bool,
609608
policy: &'invocation Policy,
610609
subinvocations: RefCell<Vec<InvocationTrace>>,
611-
actor_exit: RefCell<Option<ActorExit>>,
612-
}
613-
614-
struct ActorExit {
615-
code: u32,
616-
data: Option<IpldBlock>,
617-
msg: Option<String>,
618610
}
619611

620612
impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> {
@@ -676,7 +668,6 @@ impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> {
676668
read_only: false,
677669
policy: self.policy,
678670
subinvocations: RefCell::new(vec![]),
679-
actor_exit: RefCell::new(None),
680671
};
681672
if is_account {
682673
new_ctx.create_actor(*ACCOUNT_ACTOR_CODE_ID, target_id, None).unwrap();
@@ -714,27 +705,6 @@ impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> {
714705
self.resolve_target(&self.msg.to).unwrap().1
715706
}
716707

717-
fn invoke_actor(&mut self) -> Result<Option<IpldBlock>, ActorError> {
718-
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| self.invoke())).unwrap_or_else(
719-
|panic| {
720-
if self.actor_exit.borrow().is_some() {
721-
let exit = self.actor_exit.take().unwrap();
722-
if exit.code == 0 {
723-
Ok(exit.data)
724-
} else {
725-
Err(ActorError::unchecked_with_data(
726-
ExitCode::new(exit.code),
727-
exit.msg.unwrap_or_else(|| "actor exited".to_owned()),
728-
exit.data,
729-
))
730-
}
731-
} else {
732-
std::panic::resume_unwind(panic)
733-
}
734-
},
735-
)
736-
}
737-
738708
fn invoke(&mut self) -> Result<Option<IpldBlock>, ActorError> {
739709
let prior_root = self.v.checkpoint();
740710

@@ -1019,9 +989,8 @@ impl<'invocation, 'bs> Runtime for InvocationCtx<'invocation, 'bs> {
1019989
read_only: send_flags.read_only(),
1020990
policy: self.policy,
1021991
subinvocations: RefCell::new(vec![]),
1022-
actor_exit: RefCell::new(None),
1023992
};
1024-
let res = new_ctx.invoke_actor();
993+
let res = new_ctx.invoke();
1025994
let invoc = new_ctx.gather_trace(res.clone());
1026995
RefMut::map(self.subinvocations.borrow_mut(), |subinvocs| {
1027996
subinvocs.push(invoc);
@@ -1149,11 +1118,6 @@ impl<'invocation, 'bs> Runtime for InvocationCtx<'invocation, 'bs> {
11491118
Ok(())
11501119
}
11511120

1152-
fn exit(&self, code: u32, data: Option<IpldBlock>, msg: Option<&str>) -> ! {
1153-
self.actor_exit.replace(Some(ActorExit { code, data, msg: msg.map(|s| s.to_owned()) }));
1154-
std::panic::panic_any("actor exit");
1155-
}
1156-
11571121
fn read_only(&self) -> bool {
11581122
self.read_only
11591123
}

0 commit comments

Comments
 (0)