forest/state_migration/nv18/
eam.rs

1// Copyright 2019-2025 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use crate::shim::{
5    address::Address,
6    machine::{BuiltinActor, BuiltinActorManifest},
7    state_tree::{ActorState, StateTree},
8};
9use crate::utils::db::CborStoreExt as _;
10use fvm_ipld_blockstore::Blockstore;
11
12use crate::state_migration::common::PostMigrator;
13
14use super::SystemStateNew;
15
16pub struct EamPostMigrator;
17
18impl<BS: Blockstore> PostMigrator<BS> for EamPostMigrator {
19    /// Creates the Ethereum Account Manager actor in the state tree.
20    fn post_migrate_state(&self, store: &BS, actors_out: &mut StateTree<BS>) -> anyhow::Result<()> {
21        let sys_actor = actors_out.get_required_actor(&Address::SYSTEM_ACTOR)?;
22        let sys_state: SystemStateNew = store.get_cbor_required(&sys_actor.state)?;
23
24        let manifest = BuiltinActorManifest::load_v1_actor_list(store, &sys_state.builtin_actors)?;
25
26        let eam_actor = ActorState::new_empty(manifest.get(BuiltinActor::EAM)?, None);
27        actors_out.set_actor(&Address::ETHEREUM_ACCOUNT_MANAGER_ACTOR, eam_actor)?;
28        Ok(())
29    }
30}