-
Notifications
You must be signed in to change notification settings - Fork 188
feat: nv28 base migration #6921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+109
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Copyright 2019-2026 ChainSafe Systems | ||
| // SPDX-License-Identifier: Apache-2.0, MIT | ||
| // | ||
| //! This module contains the migration logic for the `NV28` upgrade. | ||
|
|
||
| use std::sync::Arc; | ||
|
|
||
| use crate::networks::{ChainConfig, Height}; | ||
| use crate::shim::{ | ||
| address::Address, | ||
| clock::ChainEpoch, | ||
| machine::BuiltinActorManifest, | ||
| state_tree::{StateTree, StateTreeVersion}, | ||
| }; | ||
| use crate::utils::db::CborStoreExt as _; | ||
| use anyhow::Context as _; | ||
| use cid::Cid; | ||
|
|
||
| use fvm_ipld_blockstore::Blockstore; | ||
|
|
||
| use super::{SystemStateOld, system, verifier::Verifier}; | ||
| use crate::state_migration::common::{StateMigration, migrators::nil_migrator}; | ||
|
|
||
| impl<BS: Blockstore> StateMigration<BS> { | ||
| pub fn add_nv28_migrations( | ||
| &mut self, | ||
| store: &Arc<BS>, | ||
| state: &Cid, | ||
| new_manifest: &BuiltinActorManifest, | ||
| ) -> anyhow::Result<()> { | ||
| let state_tree = StateTree::new_from_root(store.clone(), state)?; | ||
| let system_actor = state_tree.get_required_actor(&Address::SYSTEM_ACTOR)?; | ||
| let system_actor_state = store.get_cbor_required::<SystemStateOld>(&system_actor.state)?; | ||
|
|
||
| let current_manifest_data = system_actor_state.builtin_actors; | ||
|
|
||
| let current_manifest = | ||
| BuiltinActorManifest::load_v1_actor_list(store, ¤t_manifest_data)?; | ||
|
|
||
| for (name, code) in current_manifest.builtin_actors() { | ||
| let new_code = new_manifest.get(name)?; | ||
| self.add_migrator(code, nil_migrator(new_code)) | ||
|
LesnyRumcajs marked this conversation as resolved.
|
||
| } | ||
|
|
||
| self.add_migrator( | ||
| current_manifest.get_system(), | ||
| system::system_migrator(new_manifest), | ||
| ); | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| /// Runs the migration for `NV28`. Returns the new state root. | ||
| pub fn run_migration<DB>( | ||
| chain_config: &ChainConfig, | ||
| blockstore: &Arc<DB>, | ||
| state: &Cid, | ||
| epoch: ChainEpoch, | ||
| ) -> anyhow::Result<Cid> | ||
| where | ||
| DB: Blockstore + Send + Sync, | ||
| { | ||
| let new_manifest_cid = chain_config | ||
| .height_infos | ||
| .get(&Height::Xxx) | ||
| .context("no height info for network version NV28")? | ||
| .bundle | ||
| .as_ref() | ||
| .context("no bundle for network version NV28")?; | ||
|
|
||
| blockstore.get(new_manifest_cid)?.context(format!( | ||
| "manifest for network version NV28 not found in blockstore: {new_manifest_cid}" | ||
| ))?; | ||
|
|
||
| // Add migration specification verification | ||
| let verifier = Arc::new(Verifier::default()); | ||
|
|
||
| let new_manifest = BuiltinActorManifest::load_manifest(blockstore, new_manifest_cid)?; | ||
| let mut migration = StateMigration::<DB>::new(Some(verifier)); | ||
| migration.add_nv28_migrations(blockstore, state, &new_manifest)?; | ||
|
|
||
| let actors_in = StateTree::new_from_root(blockstore.clone(), state)?; | ||
| let actors_out = StateTree::new(blockstore.clone(), StateTreeVersion::V5)?; | ||
| let new_state = migration.migrate_state_tree(blockstore, epoch, actors_in, actors_out)?; | ||
|
|
||
| Ok(new_state) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright 2019-2026 ChainSafe Systems | ||
| // SPDX-License-Identifier: Apache-2.0, MIT | ||
|
|
||
| //! This module contains the migration logic for the `NV28` upgrade. | ||
| mod migration; | ||
|
|
||
| /// Run migration for `NV28`. This should be the only exported method in this | ||
| /// module. | ||
| #[allow(unused)] | ||
| pub use migration::run_migration; | ||
|
|
||
| use crate::{define_system_states, impl_system, impl_verifier}; | ||
|
|
||
| define_system_states!( | ||
| fil_actor_system_state::v17::State, | ||
| fil_actor_system_state::v18::State | ||
| ); | ||
|
|
||
| impl_system!(); | ||
| impl_verifier!(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.