forest/state_migration/common/macros/
system.rs1#[macro_export]
7macro_rules! define_system_states {
8 ($state_old:ty, $state_new:ty) => {
9 type SystemStateOld = $state_old;
10 type SystemStateNew = $state_new;
11 };
12}
13
14#[macro_export]
17macro_rules! impl_system {
18 () => {
19 pub(super) mod system {
20 use std::sync::Arc;
21
22 use cid::Cid;
23 use fvm_ipld_blockstore::Blockstore;
24 use $crate::shim::machine::BuiltinActorManifest;
25 use $crate::state_migration::common::*;
26 use $crate::utils::db::CborStoreExt;
27
28 pub(super) fn system_migrator<BS: Blockstore>(
29 new_manifest: &BuiltinActorManifest,
30 ) -> Arc<dyn ActorMigration<BS> + Send + Sync> {
31 Arc::new(SystemMigrator {
32 new_builtin_actors_cid: new_manifest.source_cid(),
33 new_code_cid: new_manifest.get_system(),
34 })
35 }
36
37 pub struct SystemMigrator {
38 new_builtin_actors_cid: Cid,
39 new_code_cid: Cid,
40 }
41
42 impl<BS: Blockstore> ActorMigration<BS> for SystemMigrator {
43 fn migrate_state(
44 &self,
45 store: &BS,
46 _input: ActorMigrationInput,
47 ) -> anyhow::Result<Option<ActorMigrationOutput>> {
48 let state = super::SystemStateNew {
49 builtin_actors: self.new_builtin_actors_cid,
50 };
51 let new_head = store.put_cbor_default(&state)?;
52
53 Ok(Some(ActorMigrationOutput {
54 new_code_cid: self.new_code_cid,
55 new_head,
56 }))
57 }
58 }
59 }
60 };
61}