Skip to content
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

Fix the watermelon fix #3694

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 24 additions & 1 deletion src/interpreter/fvm4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -181,13 +181,36 @@ impl<DB: Blockstore + Send + Sync + 'static> Consensus for ForestExterns<DB> {
h2
);
};

let bh_1 = from_slice_with_fallback::<BlockHeader>(h1)?;
let bh_2 = from_slice_with_fallback::<BlockHeader>(h2)?;

if bh_1.cid() == bh_2.cid() {
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() {
Expand Down
2 changes: 0 additions & 2 deletions src/state_migration/common/macros/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BS: Blockstore>(
new_manifest: &BuiltinActorManifest,
) -> Arc<dyn ActorMigration<BS> + Send + Sync> {
Expand Down
9 changes: 7 additions & 2 deletions src/state_migration/nv21fix/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BS: Blockstore> StateMigration<BS> {
Expand Down Expand Up @@ -45,6 +45,11 @@ impl<BS: Blockstore> StateMigration<BS> {
self.add_migrator(code, nil_migrator(new_code))
}

self.add_migrator(
current_manifest.get_system(),
system::system_migrator(new_manifest),
);

Ok(())
}
}
Expand Down Expand Up @@ -90,7 +95,7 @@ impl<BS: Blockstore> PostMigrationCheck<BS> 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,
Expand Down
Loading