Skip to content

Commit

Permalink
Merge pull request #11407 from filecoin-project/asr/calibnet-master
Browse files Browse the repository at this point in the history
chore: forward-port calibnet hotfix to master
  • Loading branch information
arajasek authored Nov 10, 2023
2 parents fbafe1c + 5b5dd52 commit 7344dd5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
15 changes: 14 additions & 1 deletion chain/consensus/filcns/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -2081,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)
}

Expand Down
21 changes: 12 additions & 9 deletions chain/stmgr/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,26 @@ func (sm *StateManager) HandleStateForks(ctx context.Context, root cid.Cid, heig
retCid := root
u := sm.stateMigrations[height]
if u != nil && u.upgrade != nil {
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 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()
log.Warnw("STARTING migration", "height", height, "from", root)
// 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)
Expand Down
9 changes: 9 additions & 0 deletions chain/vm/fvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion node/impl/full/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7344dd5

Please sign in to comment.