Skip to content

Commit

Permalink
rename is_builtin_actor syscall to resolve_builtin_actor_type.
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk committed Mar 1, 2022
1 parent f76dcad commit dd314c6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions actors/init/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ where
BS: Blockstore,
RT: Runtime<BS>,
{
rt.is_builtin_actor(exec)
rt.resolve_builtin_actor_type(exec)
.map(|typ| match typ {
Type::Multisig | Type::PaymentChannel => true,
Type::Miner if rt.is_builtin_actor(caller) == Some(Type::Power) => true,
Type::Miner if rt.resolve_builtin_actor_type(caller) == Some(Type::Power) => true,
_ => false,
})
.unwrap_or(false)
Expand Down
4 changes: 2 additions & 2 deletions actors/market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl Actor {
actor_error!(ErrIllegalArgument, "no code ID for address {}", provider)
})?;

if rt.is_builtin_actor(&code_id) != Some(Type::Miner) {
if rt.resolve_builtin_actor_type(&code_id) != Some(Type::Miner) {
return Err(actor_error!(
ErrIllegalArgument,
"deal provider is not a storage miner actor"
Expand Down Expand Up @@ -1404,7 +1404,7 @@ where
.get_actor_code_cid(&nominal)
.ok_or_else(|| actor_error!(ErrIllegalArgument, "no code for address {}", nominal))?;

if rt.is_builtin_actor(&code_id) == Some(Type::Miner) {
if rt.resolve_builtin_actor_type(&code_id) == Some(Type::Miner) {
// Storage miner actor entry; implied funds recipient is the associated owner address.
let (owner_addr, worker_addr, _) = request_miner_control_addrs(rt, nominal)?;
return Ok((nominal, owner_addr, vec![owner_addr, worker_addr]));
Expand Down
4 changes: 2 additions & 2 deletions actors/miner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3730,7 +3730,7 @@ where
.ok_or_else(|| actor_error!(ErrIllegalArgument, "no code for address: {}", resolved))?;

let is_principal = rt
.is_builtin_actor(&owner_code)
.resolve_builtin_actor_type(&owner_code)
.map(is_principal)
.unwrap_or(false);

Expand Down Expand Up @@ -3759,7 +3759,7 @@ where
let worker_code = rt
.get_actor_code_cid(&resolved)
.ok_or_else(|| actor_error!(ErrIllegalArgument, "no code for address: {}", resolved))?;
if rt.is_builtin_actor(&worker_code) != Some(Type::Account) {
if rt.resolve_builtin_actor_type(&worker_code) != Some(Type::Account) {
return Err(actor_error!(
ErrIllegalArgument,
"worker actor type must be an account, was {}",
Expand Down
2 changes: 1 addition & 1 deletion actors/paych/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Actor {
.get_actor_code_cid(&resolved)
.ok_or_else(|| actor_error!(ErrIllegalArgument, "no code for address {}", resolved))?;

let typ = rt.is_builtin_actor(&code_cid);
let typ = rt.resolve_builtin_actor_type(&code_cid);

if typ != Some(Type::Account) {
Err(actor_error!(
Expand Down
6 changes: 3 additions & 3 deletions actors/runtime/src/runtime/fvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ where
.expect("failed to lookup caller code")
};

match self.is_builtin_actor(&caller_cid) {
match self.resolve_builtin_actor_type(&caller_cid) {
Some(typ) if types.into_iter().any(|t| *t == typ) => Ok(()),
_ => Err(actor_error!(SysErrForbidden;
"caller cid type {} not one of supported", caller_cid)
Expand All @@ -151,8 +151,8 @@ where
fvm::actor::get_actor_code_cid(addr)
}

fn is_builtin_actor(&self, code_id: &Cid) -> Option<Type> {
fvm::actor::is_builtin_actor(code_id)
fn resolve_builtin_actor_type(&self, code_id: &Cid) -> Option<Type> {
fvm::actor::resolve_builtin_actor_type(code_id)
}

fn get_code_cid_for_type(&self, typ: Type) -> Cid {
Expand Down
2 changes: 1 addition & 1 deletion actors/runtime/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub trait Runtime<BS: Blockstore>: Syscalls {
fn delete_actor(&mut self, beneficiary: &Address) -> Result<(), ActorError>;

/// Returns whether the specified CodeCID belongs to a built-in actor.
fn is_builtin_actor(&self, code_id: &Cid) -> Option<Type>;
fn resolve_builtin_actor_type(&self, code_id: &Cid) -> Option<Type>;

/// Returns the CodeCID for a built-in actor type. The kernel will abort
/// if the supplied type is invalid.
Expand Down
2 changes: 1 addition & 1 deletion actors/runtime/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ impl Runtime<MemoryBlockstore> for MockRuntime {
Ok(())
}

fn is_builtin_actor(&self, code_id: &Cid) -> Option<Type> {
fn resolve_builtin_actor_type(&self, code_id: &Cid) -> Option<Type> {
self.require_in_call();
(*ACTOR_TYPES).get(code_id).cloned()
}
Expand Down
2 changes: 1 addition & 1 deletion actors/runtime/src/util/chaos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl Actor {
let types: Vec<Type> = args
.types
.iter()
.map(|typ| rt.is_builtin_actor(typ).unwrap())
.map(|typ| rt.resolve_builtin_actor_type(typ).unwrap())
.collect();
rt.validate_immediate_caller_type(&types)?;
}
Expand Down

0 comments on commit dd314c6

Please sign in to comment.