forest/state_migration/nv25/
evm.rs1use crate::state_migration::common::{
8 ActorMigration, ActorMigrationInput, ActorMigrationOutput, TypeMigration, TypeMigrator,
9};
10use crate::utils::db::CborStoreExt as _;
11use cid::Cid;
12use fil_actor_evm_state::v15::State as EvmStateOld;
13use fil_actor_evm_state::v16::State as EvmStateNew;
14use fvm_ipld_blockstore::Blockstore;
15
16pub struct EvmMigrator {
17 pub new_code_cid: Cid,
18}
19
20impl<BS: Blockstore> ActorMigration<BS> for EvmMigrator {
21 fn migrate_state(
22 &self,
23 store: &BS,
24 input: ActorMigrationInput,
25 ) -> anyhow::Result<Option<ActorMigrationOutput>> {
26 let in_state: EvmStateOld = store.get_cbor_required(&input.head)?;
27 let out_state: EvmStateNew = TypeMigrator::migrate_type(in_state, store)?;
28 let new_head = store.put_cbor_default(&out_state)?;
29 Ok(Some(ActorMigrationOutput {
30 new_code_cid: self.new_code_cid,
31 new_head,
32 }))
33 }
34}