diff --git a/src/interpreter/fvm4.rs b/src/interpreter/fvm4.rs index d164f7539847..b936b0a1d460 100644 --- a/src/interpreter/fvm4.rs +++ b/src/interpreter/fvm4.rs @@ -10,7 +10,7 @@ use crate::chain::{ ChainStore, }; use crate::interpreter::errors::Error; -use crate::networks::ChainConfig; +use crate::networks::{ChainConfig, Height, NetworkChain}; use crate::shim::{ address::Address, gas::price_list_by_network_version, state_tree::StateTree, version::NetworkVersion, @@ -181,6 +181,7 @@ impl Consensus for ForestExterns { h2 ); }; + let bh_1 = from_slice_with_fallback::(h1)?; let bh_2 = from_slice_with_fallback::(h2)?; @@ -188,6 +189,28 @@ impl Consensus for ForestExterns { bail!("no consensus fault: submitted blocks are the same"); } + // This is a workaround for the broken calibnet chain. See: + // https://github.com/filecoin-project/lotus/pull/11399 + // Basically we relax the consensus fault checks around the WatermelonFix epoch. + if self.chain_config.network == NetworkChain::Calibnet { + let watermelonfix_height = self + .chain_config + .height_infos + .get(Height::WatermelonFix as usize) + .context("Missing WatermelonFix for calibnet")? + .epoch; + + let finality = self.chain_config.policy.chain_finality; + + let is_near_upgrade = |epoch| { + epoch > watermelonfix_height - finality && epoch < watermelonfix_height + finality + }; + + if is_near_upgrade(bh_1.epoch()) || is_near_upgrade(bh_2.epoch()) { + return Ok((None, total_gas)); + } + } + // (1) check conditions necessary to any consensus fault if bh_1.miner_address() != bh_2.miner_address() { diff --git a/src/state_migration/common/macros/system.rs b/src/state_migration/common/macros/system.rs index e32181bec98c..04147e323295 100644 --- a/src/state_migration/common/macros/system.rs +++ b/src/state_migration/common/macros/system.rs @@ -25,8 +25,6 @@ macro_rules! impl_system { use $crate::state_migration::common::*; use $crate::utils::db::CborStoreExt; - #[allow(dead_code)] // There are cases where it's not needed in a migration. - // See `nv21fix` migration. pub(super) fn system_migrator( new_manifest: &BuiltinActorManifest, ) -> Arc + Send + Sync> { diff --git a/src/state_migration/nv21fix/migration.rs b/src/state_migration/nv21fix/migration.rs index 041f9efddf89..80a010f2efb8 100644 --- a/src/state_migration/nv21fix/migration.rs +++ b/src/state_migration/nv21fix/migration.rs @@ -16,7 +16,7 @@ use cid::Cid; use fvm_ipld_blockstore::Blockstore; use fvm_ipld_encoding::CborStore; -use super::{verifier::Verifier, SystemStateOld}; +use super::{system, verifier::Verifier, SystemStateOld}; use crate::state_migration::common::{migrators::nil_migrator, StateMigration}; impl StateMigration { @@ -45,6 +45,11 @@ impl StateMigration { self.add_migrator(code, nil_migrator(new_code)) } + self.add_migrator( + current_manifest.get_system(), + system::system_migrator(new_manifest), + ); + Ok(()) } } @@ -90,7 +95,7 @@ impl PostMigrationCheck for PostMigrationVerifier { ); } - if actor_in.state != actor_out.state { + if actor_in.state != actor_out.state && actor_in.code != current_manifest.get_system() { bail!( "actor {address} state mismatch: pre-migration: {}, post-migration: {}", actor_in.state,