forest/state_migration/nv23/
mining_reserve.rs1use crate::shim::address::Address;
8use crate::shim::state_tree::ActorState;
9use crate::state_migration::common::PostMigrator;
10use crate::utils::db::CborStoreExt as _;
11use cid::Cid;
12use fvm_ipld_blockstore::Blockstore;
13
14pub struct MiningReservePostMigrator {
15 pub new_account_code_cid: Cid,
16 pub new_multisig_code_cid: Cid,
17}
18
19impl<BS: Blockstore> PostMigrator<BS> for MiningReservePostMigrator {
20 fn post_migrate_state(
21 &self,
22 store: &BS,
23 actors_out: &mut crate::shim::state_tree::StateTree<BS>,
24 ) -> anyhow::Result<()> {
25 let f090_old_actor = actors_out.get_required_actor(&Address::RESERVE_ACTOR)?;
26 if f090_old_actor.code != self.new_multisig_code_cid {
28 return Ok(());
29 }
30 let f090_new_state = fil_actor_account_state::v14::State {
31 address: Address::RESERVE_ACTOR.into(),
32 };
33 let f090_new_state = store.put_cbor_default(&f090_new_state)?;
34
35 actors_out.set_actor(
36 &Address::RESERVE_ACTOR,
37 ActorState::new(
38 self.new_account_code_cid,
39 f090_new_state,
40 f090_old_actor.balance.clone().into(),
41 f090_old_actor.sequence,
42 None,
43 ),
44 )?;
45
46 Ok(())
47 }
48}