Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/networks/butterflynet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub static HEIGHT_INFOS: LazyLock<HashMap<Height, HeightInfo>> = 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")),
Comment thread
LesnyRumcajs marked this conversation as resolved.
])
});

Expand Down
2 changes: 2 additions & 0 deletions src/networks/calibnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ pub static HEIGHT_INFOS: LazyLock<HashMap<Height, HeightInfo>> = 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")),
])
});

Expand Down
6 changes: 6 additions & 0 deletions src/networks/devnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ pub static HEIGHT_INFOS: LazyLock<HashMap<Height, HeightInfo>> = 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")
),
])
});

Expand Down
2 changes: 2 additions & 0 deletions src/networks/mainnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ pub static HEIGHT_INFOS: LazyLock<HashMap<Height, HeightInfo>> = 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")),
])
});

Expand Down
5 changes: 4 additions & 1 deletion src/networks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ pub enum Height {
Teep,
Tock,
TockFix,
GoldenWeek,
}

impl Default for Height {
Expand Down Expand Up @@ -216,6 +217,7 @@ impl From<Height> for NetworkVersion {
Height::Teep => NetworkVersion::V25,
Height::Tock => NetworkVersion::V26,
Height::TockFix => NetworkVersion::V26,
Height::GoldenWeek => NetworkVersion::V27,
}
Comment thread
LesnyRumcajs marked this conversation as resolved.
}
}
Expand Down Expand Up @@ -581,7 +583,7 @@ mod tests {
fn heights_are_present(height_infos: &HashMap<Height, HeightInfo>) {
/// 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] = [
Comment thread
LesnyRumcajs marked this conversation as resolved.
Height::Breeze,
Height::Smoke,
Height::Ignition,
Expand Down Expand Up @@ -611,6 +613,7 @@ mod tests {
Height::Waffle,
Height::TukTuk,
Height::Teep,
Height::GoldenWeek,
];

for height in &REQUIRED_HEIGHTS {
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/methods/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)?,
})
Comment thread
LesnyRumcajs marked this conversation as resolved.
Outdated
}
}
Expand Down
1 change: 1 addition & 0 deletions src/shim/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/state_migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ mod nv23;
mod nv24;
mod nv25;
mod nv26fix;
mod nv27;
mod type_migrations;

type RunMigration<DB> = fn(&ChainConfig, &Arc<DB>, &Cid, ChainEpoch) -> anyhow::Result<Cid>;
Expand All @@ -46,6 +47,8 @@ where
(Height::Waffle, nv23::run_migration::<DB>),
(Height::TukTuk, nv24::run_migration::<DB>),
(Height::Teep, nv25::run_migration::<DB>),
// TODO(forest): https://github.com/ChainSafe/forest/issues/5989
// (Height::GoldenWeek, nv27::run_migration::<DB>),
]
}
NetworkChain::Calibnet => {
Expand All @@ -62,10 +65,14 @@ where
(Height::TukTuk, nv24::run_migration::<DB>),
(Height::Teep, nv25::run_migration::<DB>),
(Height::TockFix, nv26fix::run_migration::<DB>),
// TODO(forest): https://github.com/ChainSafe/forest/issues/5988
// (Height::GoldenWeek, nv27::run_migration::<DB>),
]
}
NetworkChain::Butterflynet => {
vec![(Height::Teep, nv25::run_migration::<DB>)]
// TODO(forest): https://github.com/ChainSafe/forest/issues/6022
// (Height::GoldenWeek, nv27::run_migration::<DB>),
}
NetworkChain::Devnet(_) => {
vec![
Expand All @@ -78,6 +85,8 @@ where
(Height::TukTuk, nv24::run_migration::<DB>),
(Height::Teep, nv25::run_migration::<DB>),
(Height::TockFix, nv26fix::run_migration::<DB>),
// TODO(forest): https://github.com/ChainSafe/forest/issues/5987
// (Height::GoldenWeek, nv27::run_migration::<DB>),
]
}
}
Expand Down
89 changes: 89 additions & 0 deletions src/state_migration/nv27/migration.rs
Original file line number Diff line number Diff line change
@@ -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<BS: Blockstore> StateMigration<BS> {
pub fn add_nv27_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, &current_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),
);
Comment thread
LesnyRumcajs marked this conversation as resolved.

Ok(())
}
}

/// Runs the migration for `NV27`. Returns the new state root.
#[allow(dead_code)]
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::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::<DB>::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)
}
21 changes: 21 additions & 0 deletions src/state_migration/nv27/mod.rs
Original file line number Diff line number Diff line change
@@ -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!();
6 changes: 6 additions & 0 deletions src/utils/misc/logo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down Expand Up @@ -229,3 +230,8 @@ fn reveal_butterfly_logo() {
"###
);
}

/// Reveals the `Golden Week` upgrade logo. Placeholder for now.
fn reveal_golden_week_upgrade() {
unimplemented!()
Comment thread
LesnyRumcajs marked this conversation as resolved.
}
Comment thread
LesnyRumcajs marked this conversation as resolved.
Loading