remove manifest from upgrade schedule, get it inside the migration instead
This commit is contained in:
parent
0ac8708396
commit
3b1964c507
@ -46,194 +46,132 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LegacyMigrationFunc = func(
|
|
||||||
ctx context.Context,
|
|
||||||
sm *stmgr.StateManager, cache stmgr.MigrationCache,
|
|
||||||
cb stmgr.ExecMonitor,
|
|
||||||
oldState cid.Cid,
|
|
||||||
height abi.ChainEpoch, ts *types.TipSet,
|
|
||||||
) (newState cid.Cid, err error)
|
|
||||||
|
|
||||||
type LegacyPreMigrationFunc = func(
|
|
||||||
ctx context.Context,
|
|
||||||
sm *stmgr.StateManager, cache stmgr.MigrationCache,
|
|
||||||
oldState cid.Cid,
|
|
||||||
height abi.ChainEpoch, ts *types.TipSet,
|
|
||||||
) error
|
|
||||||
|
|
||||||
func LegacyMigration(f LegacyMigrationFunc) stmgr.MigrationFunc {
|
|
||||||
return func(
|
|
||||||
ctx context.Context,
|
|
||||||
sm *stmgr.StateManager, cache stmgr.MigrationCache,
|
|
||||||
cb stmgr.ExecMonitor,
|
|
||||||
manifest cid.Cid,
|
|
||||||
oldState cid.Cid,
|
|
||||||
height abi.ChainEpoch, ts *types.TipSet,
|
|
||||||
) (newState cid.Cid, err error) {
|
|
||||||
return f(ctx, sm, cache, cb, oldState, height, ts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func LegacyPreMigration(f LegacyPreMigrationFunc) stmgr.PreMigrationFunc {
|
|
||||||
return func(
|
|
||||||
ctx context.Context,
|
|
||||||
sm *stmgr.StateManager, cache stmgr.MigrationCache,
|
|
||||||
manifest cid.Cid,
|
|
||||||
oldState cid.Cid,
|
|
||||||
height abi.ChainEpoch, ts *types.TipSet,
|
|
||||||
) error {
|
|
||||||
return f(ctx, sm, cache, oldState, height, ts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
|
func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
|
||||||
var us stmgr.UpgradeSchedule
|
var us stmgr.UpgradeSchedule
|
||||||
|
|
||||||
v8ManifestCid, ok := actors.GetManifest(actors.Version8)
|
|
||||||
if !ok {
|
|
||||||
v8ManifestCid = cid.Undef
|
|
||||||
}
|
|
||||||
|
|
||||||
updates := []stmgr.Upgrade{{
|
updates := []stmgr.Upgrade{{
|
||||||
Height: build.UpgradeBreezeHeight,
|
Height: build.UpgradeBreezeHeight,
|
||||||
Network: network.Version1,
|
Network: network.Version1,
|
||||||
Migration: LegacyMigration(UpgradeFaucetBurnRecovery),
|
Migration: UpgradeFaucetBurnRecovery,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeSmokeHeight,
|
Height: build.UpgradeSmokeHeight,
|
||||||
Network: network.Version2,
|
Network: network.Version2,
|
||||||
Migration: nil,
|
Migration: nil,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeIgnitionHeight,
|
Height: build.UpgradeIgnitionHeight,
|
||||||
Network: network.Version3,
|
Network: network.Version3,
|
||||||
Migration: LegacyMigration(UpgradeIgnition),
|
Migration: UpgradeIgnition,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeRefuelHeight,
|
Height: build.UpgradeRefuelHeight,
|
||||||
Network: network.Version3,
|
Network: network.Version3,
|
||||||
Migration: LegacyMigration(UpgradeRefuel),
|
Migration: UpgradeRefuel,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeAssemblyHeight,
|
Height: build.UpgradeAssemblyHeight,
|
||||||
Network: network.Version4,
|
Network: network.Version4,
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
Migration: LegacyMigration(UpgradeActorsV2),
|
Migration: UpgradeActorsV2,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeTapeHeight,
|
Height: build.UpgradeTapeHeight,
|
||||||
Network: network.Version5,
|
Network: network.Version5,
|
||||||
Migration: nil,
|
Migration: nil,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeLiftoffHeight,
|
Height: build.UpgradeLiftoffHeight,
|
||||||
Network: network.Version5,
|
Network: network.Version5,
|
||||||
Migration: LegacyMigration(UpgradeLiftoff),
|
Migration: UpgradeLiftoff,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeKumquatHeight,
|
Height: build.UpgradeKumquatHeight,
|
||||||
Network: network.Version6,
|
Network: network.Version6,
|
||||||
Migration: nil,
|
Migration: nil,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeCalicoHeight,
|
Height: build.UpgradeCalicoHeight,
|
||||||
Network: network.Version7,
|
Network: network.Version7,
|
||||||
Migration: LegacyMigration(UpgradeCalico),
|
Migration: UpgradeCalico,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradePersianHeight,
|
Height: build.UpgradePersianHeight,
|
||||||
Network: network.Version8,
|
Network: network.Version8,
|
||||||
Migration: nil,
|
Migration: nil,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeOrangeHeight,
|
Height: build.UpgradeOrangeHeight,
|
||||||
Network: network.Version9,
|
Network: network.Version9,
|
||||||
Migration: nil,
|
Migration: nil,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeTrustHeight,
|
Height: build.UpgradeTrustHeight,
|
||||||
Network: network.Version10,
|
Network: network.Version10,
|
||||||
Migration: LegacyMigration(UpgradeActorsV3),
|
Migration: UpgradeActorsV3,
|
||||||
PreMigrations: []stmgr.PreMigration{{
|
PreMigrations: []stmgr.PreMigration{{
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV3),
|
PreMigration: PreUpgradeActorsV3,
|
||||||
StartWithin: 120,
|
StartWithin: 120,
|
||||||
DontStartWithin: 60,
|
DontStartWithin: 60,
|
||||||
StopWithin: 35,
|
StopWithin: 35,
|
||||||
}, {
|
}, {
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV3),
|
PreMigration: PreUpgradeActorsV3,
|
||||||
StartWithin: 30,
|
StartWithin: 30,
|
||||||
DontStartWithin: 15,
|
DontStartWithin: 15,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
}},
|
}},
|
||||||
Manifest: cid.Undef,
|
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeNorwegianHeight,
|
Height: build.UpgradeNorwegianHeight,
|
||||||
Network: network.Version11,
|
Network: network.Version11,
|
||||||
Migration: nil,
|
Migration: nil,
|
||||||
Manifest: cid.Undef,
|
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeTurboHeight,
|
Height: build.UpgradeTurboHeight,
|
||||||
Network: network.Version12,
|
Network: network.Version12,
|
||||||
Migration: LegacyMigration(UpgradeActorsV4),
|
Migration: UpgradeActorsV4,
|
||||||
PreMigrations: []stmgr.PreMigration{{
|
PreMigrations: []stmgr.PreMigration{{
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV4),
|
PreMigration: PreUpgradeActorsV4,
|
||||||
StartWithin: 120,
|
StartWithin: 120,
|
||||||
DontStartWithin: 60,
|
DontStartWithin: 60,
|
||||||
StopWithin: 35,
|
StopWithin: 35,
|
||||||
}, {
|
}, {
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV4),
|
PreMigration: PreUpgradeActorsV4,
|
||||||
StartWithin: 30,
|
StartWithin: 30,
|
||||||
DontStartWithin: 15,
|
DontStartWithin: 15,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
}},
|
}},
|
||||||
Manifest: cid.Undef,
|
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeHyperdriveHeight,
|
Height: build.UpgradeHyperdriveHeight,
|
||||||
Network: network.Version13,
|
Network: network.Version13,
|
||||||
Migration: LegacyMigration(UpgradeActorsV5),
|
Migration: UpgradeActorsV5,
|
||||||
PreMigrations: []stmgr.PreMigration{{
|
PreMigrations: []stmgr.PreMigration{{
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV5),
|
PreMigration: PreUpgradeActorsV5,
|
||||||
StartWithin: 120,
|
StartWithin: 120,
|
||||||
DontStartWithin: 60,
|
DontStartWithin: 60,
|
||||||
StopWithin: 35,
|
StopWithin: 35,
|
||||||
}, {
|
}, {
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV5),
|
PreMigration: PreUpgradeActorsV5,
|
||||||
StartWithin: 30,
|
StartWithin: 30,
|
||||||
DontStartWithin: 15,
|
DontStartWithin: 15,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
}},
|
}},
|
||||||
Manifest: cid.Undef,
|
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeChocolateHeight,
|
Height: build.UpgradeChocolateHeight,
|
||||||
Network: network.Version14,
|
Network: network.Version14,
|
||||||
Migration: LegacyMigration(UpgradeActorsV6),
|
Migration: UpgradeActorsV6,
|
||||||
PreMigrations: []stmgr.PreMigration{{
|
PreMigrations: []stmgr.PreMigration{{
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV6),
|
PreMigration: PreUpgradeActorsV6,
|
||||||
StartWithin: 120,
|
StartWithin: 120,
|
||||||
DontStartWithin: 60,
|
DontStartWithin: 60,
|
||||||
StopWithin: 35,
|
StopWithin: 35,
|
||||||
}, {
|
}, {
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV6),
|
PreMigration: PreUpgradeActorsV6,
|
||||||
StartWithin: 30,
|
StartWithin: 30,
|
||||||
DontStartWithin: 15,
|
DontStartWithin: 15,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
}},
|
}},
|
||||||
Manifest: cid.Undef,
|
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeOhSnapHeight,
|
Height: build.UpgradeOhSnapHeight,
|
||||||
Network: network.Version15,
|
Network: network.Version15,
|
||||||
Migration: LegacyMigration(UpgradeActorsV7),
|
Migration: UpgradeActorsV7,
|
||||||
PreMigrations: []stmgr.PreMigration{{
|
PreMigrations: []stmgr.PreMigration{{
|
||||||
PreMigration: LegacyPreMigration(PreUpgradeActorsV7),
|
PreMigration: PreUpgradeActorsV7,
|
||||||
StartWithin: 180,
|
StartWithin: 180,
|
||||||
DontStartWithin: 60,
|
DontStartWithin: 60,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
}},
|
}},
|
||||||
Manifest: cid.Undef,
|
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
}, {
|
}, {
|
||||||
Height: build.UpgradeFVM1Height,
|
Height: build.UpgradeFVM1Height,
|
||||||
@ -245,7 +183,6 @@ func DefaultUpgradeSchedule() stmgr.UpgradeSchedule {
|
|||||||
DontStartWithin: 60,
|
DontStartWithin: 60,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
}},
|
}},
|
||||||
Manifest: v8ManifestCid,
|
|
||||||
Expensive: true,
|
Expensive: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1381,7 +1318,7 @@ func upgradeActorsV7Common(
|
|||||||
return newRoot, nil
|
return newRoot, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor, manifest cid.Cid, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
func UpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
||||||
// Use all the CPUs except 3.
|
// Use all the CPUs except 3.
|
||||||
workerCount := runtime.NumCPU() - 3
|
workerCount := runtime.NumCPU() - 3
|
||||||
if workerCount <= 0 {
|
if workerCount <= 0 {
|
||||||
@ -1395,7 +1332,7 @@ func UpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.Mi
|
|||||||
ProgressLogPeriod: 10 * time.Second,
|
ProgressLogPeriod: 10 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
newRoot, err := upgradeActorsV8Common(ctx, sm, cache, manifest, root, epoch, ts, config)
|
newRoot, err := upgradeActorsV8Common(ctx, sm, cache, root, epoch, ts, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("migrating actors v6 state: %w", err)
|
return cid.Undef, xerrors.Errorf("migrating actors v6 state: %w", err)
|
||||||
}
|
}
|
||||||
@ -1403,7 +1340,7 @@ func UpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.Mi
|
|||||||
return newRoot, nil
|
return newRoot, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PreUpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, manifest cid.Cid, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error {
|
func PreUpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error {
|
||||||
// Use half the CPUs for pre-migration, but leave at least 3.
|
// Use half the CPUs for pre-migration, but leave at least 3.
|
||||||
workerCount := runtime.NumCPU()
|
workerCount := runtime.NumCPU()
|
||||||
if workerCount <= 4 {
|
if workerCount <= 4 {
|
||||||
@ -1420,13 +1357,12 @@ func PreUpgradeActorsV8(ctx context.Context, sm *stmgr.StateManager, cache stmgr
|
|||||||
config := nv16.Config{MaxWorkers: uint(workerCount),
|
config := nv16.Config{MaxWorkers: uint(workerCount),
|
||||||
ProgressLogPeriod: time.Minute * 5}
|
ProgressLogPeriod: time.Minute * 5}
|
||||||
|
|
||||||
_, err = upgradeActorsV8Common(ctx, sm, cache, manifest, lbRoot, epoch, lbts, config)
|
_, err = upgradeActorsV8Common(ctx, sm, cache, lbRoot, epoch, lbts, config)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgradeActorsV8Common(
|
func upgradeActorsV8Common(
|
||||||
ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache,
|
ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache,
|
||||||
manifest cid.Cid,
|
|
||||||
root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet,
|
root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet,
|
||||||
config nv16.Config,
|
config nv16.Config,
|
||||||
) (cid.Cid, error) {
|
) (cid.Cid, error) {
|
||||||
@ -1446,6 +1382,11 @@ func upgradeActorsV8Common(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manifest, ok := actors.GetManifest(actors.Version8)
|
||||||
|
if !ok {
|
||||||
|
return cid.Undef, xerrors.Errorf("no manifest CID for v8 upgrade")
|
||||||
|
}
|
||||||
|
|
||||||
// Perform the migration
|
// Perform the migration
|
||||||
newHamtRoot, err := nv16.MigrateStateTree(ctx, store, manifest, stateRoot.Actors, epoch, config, migrationLogger{}, cache)
|
newHamtRoot, err := nv16.MigrateStateTree(ctx, store, manifest, stateRoot.Actors, epoch, config, migrationLogger{}, cache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -48,7 +48,6 @@ type MigrationFunc func(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
sm *StateManager, cache MigrationCache,
|
sm *StateManager, cache MigrationCache,
|
||||||
cb ExecMonitor,
|
cb ExecMonitor,
|
||||||
manifest cid.Cid,
|
|
||||||
oldState cid.Cid,
|
oldState cid.Cid,
|
||||||
height abi.ChainEpoch, ts *types.TipSet,
|
height abi.ChainEpoch, ts *types.TipSet,
|
||||||
) (newState cid.Cid, err error)
|
) (newState cid.Cid, err error)
|
||||||
@ -58,7 +57,6 @@ type MigrationFunc func(
|
|||||||
type PreMigrationFunc func(
|
type PreMigrationFunc func(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
sm *StateManager, cache MigrationCache,
|
sm *StateManager, cache MigrationCache,
|
||||||
manifest cid.Cid,
|
|
||||||
oldState cid.Cid,
|
oldState cid.Cid,
|
||||||
height abi.ChainEpoch, ts *types.TipSet,
|
height abi.ChainEpoch, ts *types.TipSet,
|
||||||
) error
|
) error
|
||||||
@ -95,10 +93,6 @@ type Upgrade struct {
|
|||||||
// These functions should fill the given cache with information that can speed up the
|
// These functions should fill the given cache with information that can speed up the
|
||||||
// eventual full migration at the upgrade epoch.
|
// eventual full migration at the upgrade epoch.
|
||||||
PreMigrations []PreMigration
|
PreMigrations []PreMigration
|
||||||
|
|
||||||
// Manifest is the migration manifest CID, starting with nv16; for older migrations it is
|
|
||||||
// undefined
|
|
||||||
Manifest cid.Cid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpgradeSchedule []Upgrade
|
type UpgradeSchedule []Upgrade
|
||||||
@ -182,7 +176,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
|
// Yes, we clone the cache, even for the final upgrade epoch. Why? Reverts. We may
|
||||||
// have to migrate multiple times.
|
// have to migrate multiple times.
|
||||||
tmpCache := u.cache.Clone()
|
tmpCache := u.cache.Clone()
|
||||||
retCid, err = u.upgrade(ctx, sm, tmpCache, cb, u.manifest, root, height, ts)
|
retCid, err = u.upgrade(ctx, sm, tmpCache, cb, root, height, ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorw("FAILED migration", "height", height, "from", root, "error", err)
|
log.Errorw("FAILED migration", "height", height, "from", root, "error", err)
|
||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
@ -219,7 +213,7 @@ func (sm *StateManager) hasExpensiveFork(height abi.ChainEpoch) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPreMigration(ctx context.Context, sm *StateManager, manifest cid.Cid, fn PreMigrationFunc, cache *nv16.MemMigrationCache, ts *types.TipSet) {
|
func runPreMigration(ctx context.Context, sm *StateManager, fn PreMigrationFunc, cache *nv16.MemMigrationCache, ts *types.TipSet) {
|
||||||
height := ts.Height()
|
height := ts.Height()
|
||||||
parent := ts.ParentState()
|
parent := ts.ParentState()
|
||||||
|
|
||||||
@ -231,7 +225,7 @@ func runPreMigration(ctx context.Context, sm *StateManager, manifest cid.Cid, fn
|
|||||||
// migration to use the cache may assume that
|
// migration to use the cache may assume that
|
||||||
// certain blocks exist, even if they don't.
|
// certain blocks exist, even if they don't.
|
||||||
tmpCache := cache.Clone()
|
tmpCache := cache.Clone()
|
||||||
err := fn(ctx, sm, tmpCache, manifest, parent, height, ts)
|
err := fn(ctx, sm, tmpCache, parent, height, ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorw("FAILED pre-migration", "error", err)
|
log.Errorw("FAILED pre-migration", "error", err)
|
||||||
return
|
return
|
||||||
@ -272,7 +266,6 @@ func (sm *StateManager) preMigrationWorker(ctx context.Context) {
|
|||||||
notAfterEpoch = stopEpoch - 1
|
notAfterEpoch = stopEpoch - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest := migration.manifest
|
|
||||||
// Add an op to start a pre-migration.
|
// Add an op to start a pre-migration.
|
||||||
schedule = append(schedule, op{
|
schedule = append(schedule, op{
|
||||||
after: afterEpoch,
|
after: afterEpoch,
|
||||||
@ -283,7 +276,7 @@ func (sm *StateManager) preMigrationWorker(ctx context.Context) {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
runPreMigration(preCtx, sm, manifest, migrationFunc, cache, ts)
|
runPreMigration(preCtx, sm, migrationFunc, cache, ts)
|
||||||
}()
|
}()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -130,7 +130,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
|||||||
Network: network.Version1,
|
Network: network.Version1,
|
||||||
Height: testForkHeight,
|
Height: testForkHeight,
|
||||||
Migration: func(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecMonitor,
|
Migration: func(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecMonitor,
|
||||||
_ cid.Cid, root cid.Cid, height abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
root cid.Cid, height abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
||||||
cst := ipldcbor.NewCborStore(sm.ChainStore().StateBlockstore())
|
cst := ipldcbor.NewCborStore(sm.ChainStore().StateBlockstore())
|
||||||
|
|
||||||
st, err := sm.StateTree(root)
|
st, err := sm.StateTree(root)
|
||||||
@ -276,7 +276,7 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) {
|
|||||||
Expensive: true,
|
Expensive: true,
|
||||||
Height: testForkHeight,
|
Height: testForkHeight,
|
||||||
Migration: func(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecMonitor,
|
Migration: func(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecMonitor,
|
||||||
_ cid.Cid, root cid.Cid, height abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
root cid.Cid, height abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
||||||
migrationCount++
|
migrationCount++
|
||||||
return root, nil
|
return root, nil
|
||||||
}}}, cg.BeaconSchedule())
|
}}}, cg.BeaconSchedule())
|
||||||
@ -412,7 +412,7 @@ func TestForkPreMigration(t *testing.T) {
|
|||||||
Network: network.Version1,
|
Network: network.Version1,
|
||||||
Height: testForkHeight,
|
Height: testForkHeight,
|
||||||
Migration: func(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecMonitor,
|
Migration: func(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecMonitor,
|
||||||
_ cid.Cid, root cid.Cid, height abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
root cid.Cid, height abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
||||||
|
|
||||||
// Make sure the test that should be canceled, is canceled.
|
// Make sure the test that should be canceled, is canceled.
|
||||||
select {
|
select {
|
||||||
@ -431,7 +431,7 @@ func TestForkPreMigration(t *testing.T) {
|
|||||||
PreMigrations: []PreMigration{{
|
PreMigrations: []PreMigration{{
|
||||||
StartWithin: 20,
|
StartWithin: 20,
|
||||||
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
||||||
_ cid.Cid, _ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
_ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
||||||
wait20.Done()
|
wait20.Done()
|
||||||
wait20.Wait()
|
wait20.Wait()
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ func TestForkPreMigration(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
StartWithin: 20,
|
StartWithin: 20,
|
||||||
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
||||||
_ cid.Cid, _ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
_ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
||||||
wait20.Done()
|
wait20.Done()
|
||||||
wait20.Wait()
|
wait20.Wait()
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ func TestForkPreMigration(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
StartWithin: 20,
|
StartWithin: 20,
|
||||||
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
||||||
_ cid.Cid, _ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
_ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
||||||
wait20.Done()
|
wait20.Done()
|
||||||
wait20.Wait()
|
wait20.Wait()
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ func TestForkPreMigration(t *testing.T) {
|
|||||||
StartWithin: 15,
|
StartWithin: 15,
|
||||||
StopWithin: 5,
|
StopWithin: 5,
|
||||||
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
||||||
_ cid.Cid, _ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
_ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
||||||
|
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
close(wasCanceled)
|
close(wasCanceled)
|
||||||
@ -487,7 +487,7 @@ func TestForkPreMigration(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
StartWithin: 10,
|
StartWithin: 10,
|
||||||
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
PreMigration: func(ctx context.Context, _ *StateManager, cache MigrationCache,
|
||||||
_ cid.Cid, _ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
_ cid.Cid, _ abi.ChainEpoch, _ *types.TipSet) error {
|
||||||
|
|
||||||
checkCache(t, cache)
|
checkCache(t, cache)
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ func NewStateManager(cs *store.ChainStore, exec Executor, sys vm.SyscallBuilder,
|
|||||||
upgrade: upgrade.Migration,
|
upgrade: upgrade.Migration,
|
||||||
preMigrations: upgrade.PreMigrations,
|
preMigrations: upgrade.PreMigrations,
|
||||||
cache: nv16.NewMemMigrationCache(),
|
cache: nv16.NewMemMigrationCache(),
|
||||||
manifest: upgrade.Manifest,
|
|
||||||
}
|
}
|
||||||
stateMigrations[upgrade.Height] = migration
|
stateMigrations[upgrade.Height] = migration
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user