diff --git a/src/networks/butterflynet/mod.rs b/src/networks/butterflynet/mod.rs index dc6e3b401d83..f3b3a28e495b 100644 --- a/src/networks/butterflynet/mod.rs +++ b/src/networks/butterflynet/mod.rs @@ -108,6 +108,8 @@ pub static HEIGHT_INFOS: LazyLock> = LazyLock::new(| make_height!(TukTuk, -27, get_bundle_cid("v15.0.0-rc1")), make_height!(Teep, 100, get_bundle_cid("v16.0.1")), make_height!(Tock, 100 + 2 * EPOCHS_IN_DAY), + // TODO(forest): https://github.com/ChainSafe/forest/issues/6022 + make_height!(GoldenWeek, i64::MAX, get_bundle_cid("v16.0.1")), ]) }); diff --git a/src/networks/calibnet/mod.rs b/src/networks/calibnet/mod.rs index 382ea97668dc..1f246fcfaaf2 100644 --- a/src/networks/calibnet/mod.rs +++ b/src/networks/calibnet/mod.rs @@ -93,6 +93,8 @@ pub static HEIGHT_INFOS: LazyLock> = LazyLock::new(| make_height!(Tock, 2_523_454 + 7 * EPOCHS_IN_DAY), // Mon 7 Apr 23:00:00 UTC 2025 make_height!(TockFix, 2_558_014, get_bundle_cid("v16.0.1")), + // TODO(forest): https://github.com/ChainSafe/forest/issues/5988 + make_height!(GoldenWeek, i64::MAX, get_bundle_cid("v16.0.1")), ]) }); diff --git a/src/networks/devnet/mod.rs b/src/networks/devnet/mod.rs index 789de682b47f..2846fdf8eb08 100644 --- a/src/networks/devnet/mod.rs +++ b/src/networks/devnet/mod.rs @@ -164,6 +164,12 @@ pub static HEIGHT_INFOS: LazyLock> = LazyLock::new(| get_upgrade_height_from_env("FOREST_TOCK_FIX_HEIGHT").unwrap_or(9999999999), get_bundle_cid("v16.0.1") ), + // TODO(forest): https://github.com/ChainSafe/forest/issues/5987 + make_height!( + GoldenWeek, + get_upgrade_height_from_env("FOREST_GOLDEN_WEEK_HEIGHT").unwrap_or(9999999999), + get_bundle_cid("v16.0.1") + ), ]) }); diff --git a/src/networks/mainnet/mod.rs b/src/networks/mainnet/mod.rs index 4772bdef237d..8863402b284e 100644 --- a/src/networks/mainnet/mod.rs +++ b/src/networks/mainnet/mod.rs @@ -90,6 +90,8 @@ pub static HEIGHT_INFOS: LazyLock> = LazyLock::new(| // This epoch, 90 days after Teep is the completion of FIP-0100 where actors will start applying // the new daily fee to pre-Teep sectors being extended. make_height!(Tock, 4_878_840 + EPOCHS_IN_DAY * 90), + // TODO(forest): https://github.com/ChainSafe/forest/issues/5989 + make_height!(GoldenWeek, i64::MAX, get_bundle_cid("v16.0.1")), ]) }); diff --git a/src/networks/mod.rs b/src/networks/mod.rs index d450a81f7f49..d067c8157372 100644 --- a/src/networks/mod.rs +++ b/src/networks/mod.rs @@ -171,6 +171,7 @@ pub enum Height { Teep, Tock, TockFix, + GoldenWeek, } impl Default for Height { @@ -216,6 +217,7 @@ impl From for NetworkVersion { Height::Teep => NetworkVersion::V25, Height::Tock => NetworkVersion::V26, Height::TockFix => NetworkVersion::V26, + Height::GoldenWeek => NetworkVersion::V27, } } } @@ -581,7 +583,7 @@ mod tests { fn heights_are_present(height_infos: &HashMap) { /// These are required heights that need to be defined for all networks, for, e.g., conformance /// with `Filecoin.StateGetNetworkParams` RPC method. - const REQUIRED_HEIGHTS: [Height; 29] = [ + const REQUIRED_HEIGHTS: [Height; 30] = [ Height::Breeze, Height::Smoke, Height::Ignition, @@ -611,6 +613,7 @@ mod tests { Height::Waffle, Height::TukTuk, Height::Teep, + Height::GoldenWeek, ]; for height in &REQUIRED_HEIGHTS { diff --git a/src/rpc/methods/state.rs b/src/rpc/methods/state.rs index f4faf38d5288..7a848503fa61 100644 --- a/src/rpc/methods/state.rs +++ b/src/rpc/methods/state.rs @@ -2959,6 +2959,7 @@ pub struct ForkUpgradeParams { upgrade_tuktuk_height: ChainEpoch, upgrade_teep_height: ChainEpoch, upgrade_tock_height: ChainEpoch, + //upgrade_golden_week_height: ChainEpoch, } impl TryFrom<&ChainConfig> for ForkUpgradeParams { @@ -3006,6 +3007,7 @@ impl TryFrom<&ChainConfig> for ForkUpgradeParams { upgrade_tuktuk_height: get_height(TukTuk)?, upgrade_teep_height: get_height(Teep)?, upgrade_tock_height: get_height(Tock)?, + //upgrade_golden_week_height: get_height(GoldenWeek)?, }) } } diff --git a/src/shim/version.rs b/src/shim/version.rs index 4d9c343f09fc..8b327774b0d1 100644 --- a/src/shim/version.rs +++ b/src/shim/version.rs @@ -66,6 +66,7 @@ impl NetworkVersion { pub const V24: Self = Self(NetworkVersion_latest::new(24)); pub const V25: Self = Self(NetworkVersion_latest::new(25)); pub const V26: Self = Self(NetworkVersion_latest::new(26)); + pub const V27: Self = Self(NetworkVersion_latest::new(27)); } impl Deref for NetworkVersion { diff --git a/src/state_migration/mod.rs b/src/state_migration/mod.rs index 10f9d43e3656..14142a7a242a 100644 --- a/src/state_migration/mod.rs +++ b/src/state_migration/mod.rs @@ -27,6 +27,7 @@ mod nv23; mod nv24; mod nv25; mod nv26fix; +mod nv27; mod type_migrations; type RunMigration = fn(&ChainConfig, &Arc, &Cid, ChainEpoch) -> anyhow::Result; @@ -46,6 +47,8 @@ where (Height::Waffle, nv23::run_migration::), (Height::TukTuk, nv24::run_migration::), (Height::Teep, nv25::run_migration::), + // TODO(forest): https://github.com/ChainSafe/forest/issues/5989 + // (Height::GoldenWeek, nv27::run_migration::), ] } NetworkChain::Calibnet => { @@ -62,10 +65,14 @@ where (Height::TukTuk, nv24::run_migration::), (Height::Teep, nv25::run_migration::), (Height::TockFix, nv26fix::run_migration::), + // TODO(forest): https://github.com/ChainSafe/forest/issues/5988 + // (Height::GoldenWeek, nv27::run_migration::), ] } NetworkChain::Butterflynet => { vec![(Height::Teep, nv25::run_migration::)] + // TODO(forest): https://github.com/ChainSafe/forest/issues/6022 + // (Height::GoldenWeek, nv27::run_migration::), } NetworkChain::Devnet(_) => { vec![ @@ -78,6 +85,8 @@ where (Height::TukTuk, nv24::run_migration::), (Height::Teep, nv25::run_migration::), (Height::TockFix, nv26fix::run_migration::), + // TODO(forest): https://github.com/ChainSafe/forest/issues/5987 + // (Height::GoldenWeek, nv27::run_migration::), ] } } diff --git a/src/state_migration/nv27/migration.rs b/src/state_migration/nv27/migration.rs new file mode 100644 index 000000000000..02ba7c12fbde --- /dev/null +++ b/src/state_migration/nv27/migration.rs @@ -0,0 +1,89 @@ +// Copyright 2019-2025 ChainSafe Systems +// SPDX-License-Identifier: Apache-2.0, MIT +// +//! This module contains the migration logic for the `NV27` 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 StateMigration { + pub fn add_nv27_migrations( + &mut self, + store: &Arc, + 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::(&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)) + } + + self.add_migrator( + current_manifest.get_system(), + system::system_migrator(new_manifest), + ); + + Ok(()) + } +} + +/// Runs the migration for `NV27`. Returns the new state root. +#[allow(dead_code)] +pub fn run_migration( + chain_config: &ChainConfig, + blockstore: &Arc, + state: &Cid, + epoch: ChainEpoch, +) -> anyhow::Result +where + DB: Blockstore + Send + Sync, +{ + let new_manifest_cid = chain_config + .height_infos + .get(&Height::GoldenWeek) + .context("no height info for network version NV27")? + .bundle + .as_ref() + .context("no bundle for network version NV27")?; + + blockstore.get(new_manifest_cid)?.context(format!( + "manifest for network version NV27 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::::new(Some(verifier)); + migration.add_nv27_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) +} diff --git a/src/state_migration/nv27/mod.rs b/src/state_migration/nv27/mod.rs new file mode 100644 index 000000000000..8609caaa72c7 --- /dev/null +++ b/src/state_migration/nv27/mod.rs @@ -0,0 +1,21 @@ +// Copyright 2019-2025 ChainSafe Systems +// SPDX-License-Identifier: Apache-2.0, MIT + +//! This module contains the migration logic for the `NV27` upgrade. +mod migration; + +/// Run migration for `NV27`. This should be the only exported method in this +/// module. +#[allow(unused_imports)] +pub use migration::run_migration; + +use crate::{define_system_states, impl_system, impl_verifier}; + +define_system_states!( + fil_actor_system_state::v16::State, + // TODO(forest): https://github.com/ChainSafe/forest/issues/5985 + fil_actor_system_state::v16::State +); + +impl_system!(); +impl_verifier!(); diff --git a/src/utils/misc/logo.rs b/src/utils/misc/logo.rs index 52e6c57e9b3b..f04417c6034c 100644 --- a/src/utils/misc/logo.rs +++ b/src/utils/misc/logo.rs @@ -31,6 +31,7 @@ pub fn reveal_upgrade_logo(network_version: NetworkVersion) { NetworkVersion::V23 => reveal_waffle_upgrade(), NetworkVersion::V24 => reveal_tuktuk_upgrade(), NetworkVersion::V25 => reveal_teep_upgrade(), + NetworkVersion::V27 => reveal_golden_week_upgrade(), _ => reveal_three_trees(), } } @@ -229,3 +230,8 @@ fn reveal_butterfly_logo() { "### ); } + +/// Reveals the `Golden Week` upgrade logo. Placeholder for now. +fn reveal_golden_week_upgrade() { + unimplemented!() +}