feat: shed: test the nv18 migration
This commit is contained in:
parent
00b6d06041
commit
fab7ea6ca1
@ -240,8 +240,8 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
|
|||||||
Migration: UpgradeActorsV10,
|
Migration: UpgradeActorsV10,
|
||||||
PreMigrations: []stmgr.PreMigration{{
|
PreMigrations: []stmgr.PreMigration{{
|
||||||
PreMigration: PreUpgradeActorsV10,
|
PreMigration: PreUpgradeActorsV10,
|
||||||
StartWithin: 180,
|
StartWithin: 60,
|
||||||
DontStartWithin: 60,
|
DontStartWithin: 10,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
}},
|
}},
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||||
"github.com/filecoin-project/go-state-types/builtin"
|
"github.com/filecoin-project/go-state-types/builtin"
|
||||||
|
v10 "github.com/filecoin-project/go-state-types/builtin/v10"
|
||||||
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
market8 "github.com/filecoin-project/go-state-types/builtin/v8/market"
|
||||||
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
|
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
|
||||||
v9 "github.com/filecoin-project/go-state-types/builtin/v9"
|
v9 "github.com/filecoin-project/go-state-types/builtin/v9"
|
||||||
@ -151,7 +152,7 @@ var migrationsCmd = &cli.Command{
|
|||||||
if !cctx.IsSet("skip-pre-migration") {
|
if !cctx.IsSet("skip-pre-migration") {
|
||||||
cache := mutil.NewMemMigrationCache()
|
cache := mutil.NewMemMigrationCache()
|
||||||
|
|
||||||
ts1, err := cs.GetTipsetByHeight(ctx, blk.Height-240, migrationTs, false)
|
ts1, err := cs.GetTipsetByHeight(ctx, blk.Height-60, migrationTs, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -163,21 +164,7 @@ var migrationsCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
preMigration1Time := time.Since(startTime)
|
preMigrationTime := time.Since(startTime)
|
||||||
|
|
||||||
ts2, err := cs.GetTipsetByHeight(ctx, blk.Height-15, migrationTs, false)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
startTime = time.Now()
|
|
||||||
|
|
||||||
err = preUpgradeActorsFunc(ctx, sm, cache, ts2.ParentState(), ts2.Height()-1, ts2)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
preMigration2Time := time.Since(startTime)
|
|
||||||
|
|
||||||
startTime = time.Now()
|
startTime = time.Now()
|
||||||
|
|
||||||
@ -192,8 +179,7 @@ var migrationsCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("got different results with and without the cache: %s, %s", newCid1,
|
return xerrors.Errorf("got different results with and without the cache: %s, %s", newCid1,
|
||||||
newCid2)
|
newCid2)
|
||||||
}
|
}
|
||||||
fmt.Println("completed premigration 1, took ", preMigration1Time)
|
fmt.Println("completed premigration, took ", preMigrationTime)
|
||||||
fmt.Println("completed premigration 2, took ", preMigration2Time)
|
|
||||||
fmt.Println("completed round actual (with cache), took ", cachedMigrationTime)
|
fmt.Println("completed round actual (with cache), took ", cachedMigrationTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +202,7 @@ func getMigrationFuncsForNetwork(nv network.Version) (UpgradeActorsFunc, PreUpgr
|
|||||||
case network.Version17:
|
case network.Version17:
|
||||||
return filcns.UpgradeActorsV9, filcns.PreUpgradeActorsV9, checkNv17Invariants, nil
|
return filcns.UpgradeActorsV9, filcns.PreUpgradeActorsV9, checkNv17Invariants, nil
|
||||||
case network.Version18:
|
case network.Version18:
|
||||||
return filcns.UpgradeActorsV10, filcns.PreUpgradeActorsV10, nil, nil
|
return filcns.UpgradeActorsV10, filcns.PreUpgradeActorsV10, checkNv18Invariants, nil
|
||||||
default:
|
default:
|
||||||
return nil, nil, nil, xerrors.Errorf("migration not implemented for nv%d", nv)
|
return nil, nil, nil, xerrors.Errorf("migration not implemented for nv%d", nv)
|
||||||
}
|
}
|
||||||
@ -226,6 +212,40 @@ type UpgradeActorsFunc = func(context.Context, *stmgr.StateManager, stmgr.Migrat
|
|||||||
type PreUpgradeActorsFunc = func(context.Context, *stmgr.StateManager, stmgr.MigrationCache, cid.Cid, abi.ChainEpoch, *types.TipSet) error
|
type PreUpgradeActorsFunc = func(context.Context, *stmgr.StateManager, stmgr.MigrationCache, cid.Cid, abi.ChainEpoch, *types.TipSet) error
|
||||||
type CheckInvariantsFunc = func(context.Context, cid.Cid, cid.Cid, blockstore.Blockstore, abi.ChainEpoch) error
|
type CheckInvariantsFunc = func(context.Context, cid.Cid, cid.Cid, blockstore.Blockstore, abi.ChainEpoch) error
|
||||||
|
|
||||||
|
func checkNv18Invariants(ctx context.Context, oldStateRootCid cid.Cid, newStateRootCid cid.Cid, bs blockstore.Blockstore, epoch abi.ChainEpoch) error {
|
||||||
|
actorStore := store.ActorStore(ctx, bs)
|
||||||
|
startTime := time.Now()
|
||||||
|
|
||||||
|
// Load the new state root.
|
||||||
|
var newStateRoot types.StateRoot
|
||||||
|
if err := actorStore.Get(ctx, newStateRootCid, &newStateRoot); err != nil {
|
||||||
|
return xerrors.Errorf("failed to decode state root: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
actorCodeCids, err := actors.GetActorCodeIDs(actorstypes.Version10)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
newActorTree, err := builtin.LoadTree(actorStore, newStateRoot.Actors)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
messages, err := v10.CheckStateInvariants(newActorTree, epoch, actorCodeCids)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("checking state invariants: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, message := range messages.Messages() {
|
||||||
|
fmt.Println("got the following error: ", message)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("completed invariant checks, took ", time.Since(startTime))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/// NV17 and earlier stuff
|
||||||
|
|
||||||
func checkNv17Invariants(ctx context.Context, v8StateRootCid cid.Cid, v9StateRootCid cid.Cid, bs blockstore.Blockstore, epoch abi.ChainEpoch) error {
|
func checkNv17Invariants(ctx context.Context, v8StateRootCid cid.Cid, v9StateRootCid cid.Cid, bs blockstore.Blockstore, epoch abi.ChainEpoch) error {
|
||||||
actorStore := store.ActorStore(ctx, bs)
|
actorStore := store.ActorStore(ctx, bs)
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
Loading…
Reference in New Issue
Block a user