From 1b039b8ab17c8ecf31ccb714702386afcb0c7f50 Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 5 May 2022 19:51:58 +0300 Subject: [PATCH] install_actor is a primitive --- actors/runtime/src/runtime/fvm.rs | 8 ++++---- actors/runtime/src/runtime/mod.rs | 4 ++-- actors/runtime/src/test_utils.rs | 8 ++++---- test_vm/src/lib.rs | 4 ++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/actors/runtime/src/runtime/fvm.rs b/actors/runtime/src/runtime/fvm.rs index 2651c8361..3db06dcb6 100644 --- a/actors/runtime/src/runtime/fvm.rs +++ b/actors/runtime/src/runtime/fvm.rs @@ -380,6 +380,10 @@ where fvm::crypto::compute_unsealed_sector_cid(proof_type, pieces) .map_err(|e| anyhow!("failed to compute unsealed sector CID; exit code: {}", e)) } + + fn install_actor(&self, code_id: &Cid) -> Result<(), Error> { + fvm::actor::install_actor(code_id).map_err(|_| Error::msg("failed to install actor")) + } } #[cfg(not(feature = "fake-proofs"))] @@ -430,10 +434,6 @@ where Ok(false) | Err(_) => Err(Error::msg("invalid replica")), } } - - fn install_actor(&self, code_id: &Cid) -> Result<(), Error> { - fvm::actor::install_actor(code_id).map_err(|_| Error::msg("failed to install actor")) - } } #[cfg(feature = "fake-proofs")] diff --git a/actors/runtime/src/runtime/mod.rs b/actors/runtime/src/runtime/mod.rs index 7bcb9fa91..b167bd840 100644 --- a/actors/runtime/src/runtime/mod.rs +++ b/actors/runtime/src/runtime/mod.rs @@ -195,6 +195,8 @@ pub trait Primitives { signer: &Address, plaintext: &[u8], ) -> Result<(), anyhow::Error>; + + fn install_actor(&self, code_cid: &Cid) -> Result<(), anyhow::Error>; } /// filcrypto verification primitives provided by the runtime @@ -230,6 +232,4 @@ pub trait Verifier { ) -> Result<(), anyhow::Error>; fn verify_replica_update(&self, replica: &ReplicaUpdateInfo) -> Result<(), anyhow::Error>; - - fn install_actor(&self, code_cid: &Cid) -> Result<(), anyhow::Error>; } diff --git a/actors/runtime/src/test_utils.rs b/actors/runtime/src/test_utils.rs index bff65791e..f338a47a0 100644 --- a/actors/runtime/src/test_utils.rs +++ b/actors/runtime/src/test_utils.rs @@ -1053,6 +1053,10 @@ impl Primitives for MockRuntime { } Ok(exp.cid) } + + fn install_actor(&self, _code_cid: &Cid) -> anyhow::Result<(), anyhow::Error> { + Ok(()) + } } impl Verifier for MockRuntime { @@ -1181,10 +1185,6 @@ impl Verifier for MockRuntime { ); exp.result } - - fn install_actor(&self, _code_cid: &Cid) -> anyhow::Result<(), anyhow::Error> { - Ok(()) - } } impl RuntimePolicy for MockRuntime { diff --git a/test_vm/src/lib.rs b/test_vm/src/lib.rs index 689b09a18..d0141e185 100644 --- a/test_vm/src/lib.rs +++ b/test_vm/src/lib.rs @@ -767,6 +767,10 @@ impl Primitives for InvocationCtx<'_, '_> { ) -> Result { panic!("TODO implement me") } + + fn install_actor(&self, code_id: &Cid) -> Result<(), anyhow::Error> { + panic!("TODO implement me") + } } impl Verifier for InvocationCtx<'_, '_> {