Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Jan 30, 2023
1 parent 6e294f8 commit 076e7b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
4 changes: 2 additions & 2 deletions runtime/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,10 @@ impl<BS: Blockstore> MockRuntime<BS> {
method,
params,
value,
gas_limit: None,
send_flags: SendFlags::default(),
send_return,
exit_code,
send_flags: SendFlags::default(),
gas_limit: None,
send_error: None,
})
}
Expand Down
35 changes: 2 additions & 33 deletions test_vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,8 @@ impl<'bs> VM<'bs> {
caller_validated: 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| {
Expand Down Expand Up @@ -578,13 +577,6 @@ pub struct InvocationCtx<'invocation, 'bs> {
caller_validated: bool,
policy: &'invocation Policy,
subinvocations: RefCell<Vec<InvocationTrace>>,
actor_exit: RefCell<Option<ActorExit>>,
}

struct ActorExit {
code: u32,
data: Option<IpldBlock>,
msg: Option<String>,
}

impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> {
Expand Down Expand Up @@ -637,7 +629,6 @@ impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> {
caller_validated: 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();
Expand Down Expand Up @@ -675,27 +666,6 @@ impl<'invocation, 'bs> InvocationCtx<'invocation, 'bs> {
self.resolve_target(&self.msg.to).unwrap().1
}

fn invoke_actor(&mut self) -> Result<Option<IpldBlock>, 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<Option<IpldBlock>, ActorError> {
let prior_root = self.v.checkpoint();

Expand Down Expand Up @@ -907,9 +877,8 @@ impl<'invocation, 'bs> Runtime for InvocationCtx<'invocation, 'bs> {
caller_validated: false,
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);
Expand Down

0 comments on commit 076e7b6

Please sign in to comment.