From 410bdc389ee6c9173527db6fbb6104396ce8fbef Mon Sep 17 00:00:00 2001 From: Aayush Date: Wed, 8 Nov 2023 07:26:28 -0500 Subject: [PATCH] fix: nv21fix migration: correctly upgrade system actor --- chain/consensus/filcns/upgrades.go | 13 +++++++++++++ chain/stmgr/forks.go | 2 +- chain/vm/fvm.go | 9 +++++++++ miner/miner.go | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index f258de540..27d891040 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -2063,6 +2063,19 @@ func upgradeActorsV12Fix(ctx context.Context, sm *stmgr.StateManager, cache stmg return cid.Undef, xerrors.Errorf("failed to perform migration: %w", err) } + systemState.BuiltinActors = newManifest.Data + newSystemHead, err := adtStore.Put(ctx, systemState) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to put new system state: %w", err) + } + + systemActor.Head = newSystemHead + if err = actorsOut.SetActor(builtin.SystemActorAddr, systemActor); err != nil { + return cid.Undef, xerrors.Errorf("failed to put new system actor: %w", err) + } + + // Sanity checking + err = actorsIn.ForEach(func(a address.Address, inActor *types.Actor) error { outActor, err := actorsOut.GetActor(a) if err != nil { diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 2f18bde82..57838b223 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -177,7 +177,7 @@ func (us UpgradeSchedule) GetNtwkVersion(e abi.ChainEpoch) (network.Version, err func (sm *StateManager) HandleStateForks(ctx context.Context, root cid.Cid, height abi.ChainEpoch, cb ExecMonitor, ts *types.TipSet) (cid.Cid, error) { retCid := root u := sm.stateMigrations[height] - if u != nil && u.upgrade != nil { + if u != nil && u.upgrade != nil && height != build.UpgradeWatermelonFixHeight { migCid, ok, err := u.migrationResultCache.Get(ctx, root) if err == nil { if ok { diff --git a/chain/vm/fvm.go b/chain/vm/fvm.go index bc4c3a851..c8c02dddd 100644 --- a/chain/vm/fvm.go +++ b/chain/vm/fvm.go @@ -92,6 +92,15 @@ func (x *FvmExtern) VerifyConsensusFault(ctx context.Context, a, b, extra []byte log.Info("invalid consensus fault: submitted blocks are the same") return ret, totalGas } + + // workaround chain halt + if build.IsNearUpgrade(blockA.Height, build.UpgradeWatermelonFixHeight) { + return ret, totalGas + } + if build.IsNearUpgrade(blockB.Height, build.UpgradeWatermelonFixHeight) { + return ret, totalGas + } + // (1) check conditions necessary to any consensus fault // were blocks mined by same miner? diff --git a/miner/miner.go b/miner/miner.go index 54f4263ef..329f34171 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -325,7 +325,7 @@ minerLoop: "block-time", btime, "time", build.Clock.Now(), "difference", build.Clock.Since(btime)) } - if os.Getenv("LOTUS_MINER_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" { + if os.Getenv("LOTUS_MINER_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" && !build.IsNearUpgrade(base.TipSet.Height(), build.UpgradeWatermelonFixHeight) { witness, fault, err := m.sf.MinedBlock(ctx, b.Header, base.TipSet.Height()+base.NullRounds) if err != nil { log.Errorf(" SLASH FILTER ERRORED: %s", err)