From ae75aa1d0da9930e29633f9d85fa788982b4eb5d Mon Sep 17 00:00:00 2001 From: Aayush Date: Wed, 8 Nov 2023 09:10:31 -0500 Subject: [PATCH] skip migration cache correctly --- chain/consensus/filcns/upgrades.go | 4 ++-- chain/stmgr/forks.go | 23 +++++++++++++---------- node/impl/full/sync.go | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index 900f95e94..3fa3dd995 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -2064,7 +2064,7 @@ func upgradeActorsV12Fix(ctx context.Context, sm *stmgr.StateManager, cache stmg } systemState.BuiltinActors = newManifest.Data - newSystemHead, err := adtStore.Put(ctx, systemState) + newSystemHead, err := adtStore.Put(ctx, &systemState) if err != nil { return cid.Undef, xerrors.Errorf("failed to put new system state: %w", err) } @@ -2094,7 +2094,7 @@ func upgradeActorsV12Fix(ctx context.Context, sm *stmgr.StateManager, cache stmg return xerrors.Errorf("mismatched address for actor %s: %s != %s", a, inActor.Address, outActor.Address) } - if inActor.Head != outActor.Head { + if inActor.Head != outActor.Head && a != builtin.SystemActorAddr { return xerrors.Errorf("mismatched head for actor %s", a) } diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 16abaaf9a..8d1ac1dfb 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -177,17 +177,19 @@ 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 && height != build.UpgradeWatermelonFixHeight { - migCid, ok, err := u.migrationResultCache.Get(ctx, root) - if err == nil { - if ok { - log.Infow("CACHED migration", "height", height, "from", root, "to", migCid) - return migCid, nil + if u != nil && u.upgrade != nil { + if height != build.UpgradeWatermelonFixHeight { + migCid, ok, err := u.migrationResultCache.Get(ctx, root) + if err == nil { + if ok { + log.Infow("CACHED migration", "height", height, "from", root, "to", migCid) + return migCid, nil + } + } else if !errors.Is(err, datastore.ErrNotFound) { + log.Errorw("failed to lookup previous migration result", "err", err) + } else { + log.Debug("no cached migration found, migrating from scratch") } - } else if !errors.Is(err, datastore.ErrNotFound) { - log.Errorw("failed to lookup previous migration result", "err", err) - } else { - log.Debug("no cached migration found, migrating from scratch") } startTime := time.Now() @@ -195,6 +197,7 @@ func (sm *StateManager) HandleStateForks(ctx context.Context, root cid.Cid, heig // Yes, we clone the cache, even for the final upgrade epoch. Why? Reverts. We may // have to migrate multiple times. tmpCache := u.cache.Clone() + var err error retCid, err = u.upgrade(ctx, sm, tmpCache, cb, root, height, ts) if err != nil { log.Errorw("FAILED migration", "height", height, "from", root, "error", err) diff --git a/node/impl/full/sync.go b/node/impl/full/sync.go index 223f5c29e..4bf44363c 100644 --- a/node/impl/full/sync.go +++ b/node/impl/full/sync.go @@ -57,7 +57,7 @@ func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) erro return xerrors.Errorf("loading parent block: %w", err) } - if a.SlashFilter != nil && os.Getenv("LOTUS_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" { + if a.SlashFilter != nil && os.Getenv("LOTUS_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" && !build.IsNearUpgrade(blk.Header.Height, build.UpgradeWatermelonFixHeight) { witness, fault, err := a.SlashFilter.MinedBlock(ctx, blk.Header, parent.Height) if err != nil { log.Errorf(" SLASH FILTER ERRORED: %s", err)