diff --git a/fixtures/networks/integrationtestnet.go b/fixtures/networks/integrationtestnet.go index e976eba381..98b59fd10f 100644 --- a/fixtures/networks/integrationtestnet.go +++ b/fixtures/networks/integrationtestnet.go @@ -47,7 +47,8 @@ func IntegrationNet() *NetworkConf { UpgradeHyperdriveHeight: 892800, UpgradeChocolateHeight: 1231620, UpgradeOhSnapHeight: 1594680, - UpgradeSkyrHeight: 99999999999999, + UpgradeSkyrHeight: 1960320, + UpgradeV17Height: 99999999999999, }, DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1}, AddressNetwork: address.Testnet, diff --git a/fixtures/networks/net_2k.go b/fixtures/networks/net_2k.go index 3020e6951c..d50f42da38 100644 --- a/fixtures/networks/net_2k.go +++ b/fixtures/networks/net_2k.go @@ -27,26 +27,25 @@ func Net2k() *NetworkConf { MinVerifiedDealSize: 256, PreCommitChallengeDelay: abi.ChainEpoch(10), ForkUpgradeParam: &config.ForkUpgradeConfig{ - UpgradeBreezeHeight: -1, - UpgradeSmokeHeight: -2, - UpgradeIgnitionHeight: -3, - UpgradeRefuelHeight: -4, - UpgradeTapeHeight: -5, - UpgradeAssemblyHeight: -6, - UpgradeLiftoffHeight: -7, - UpgradeKumquatHeight: -8, - UpgradeCalicoHeight: -9, - UpgradePersianHeight: -10, - UpgradeOrangeHeight: -11, - UpgradeTrustHeight: -13, - UpgradeNorwegianHeight: -14, - UpgradeTurboHeight: -15, - UpgradeHyperdriveHeight: -16, - UpgradeChocolateHeight: -17, - UpgradeOhSnapHeight: -18, - BreezeGasTampingDuration: 0, - UpgradeClausHeight: -11, + UpgradeBreezeHeight: -1, + UpgradeSmokeHeight: -2, + UpgradeIgnitionHeight: -3, + UpgradeRefuelHeight: -4, + UpgradeTapeHeight: -5, + UpgradeAssemblyHeight: -6, + UpgradeLiftoffHeight: -7, + UpgradeKumquatHeight: -8, + UpgradeCalicoHeight: -9, + UpgradePersianHeight: -10, + UpgradeOrangeHeight: -11, + UpgradeClausHeight: -12, + UpgradeTrustHeight: -13, + UpgradeNorwegianHeight: -14, + UpgradeTurboHeight: -15, + UpgradeHyperdriveHeight: -16, + UpgradeChocolateHeight: -17, + UpgradeOhSnapHeight: -18, UpgradeSkyrHeight: -19, UpgradeV17Height: 99999999999999, }, diff --git a/pkg/migration/migrate.go b/pkg/migration/migrate.go index af7b098144..7260990e6b 100644 --- a/pkg/migration/migrate.go +++ b/pkg/migration/migrate.go @@ -31,6 +31,7 @@ var versionMap = []versionInfo{ {version: 6, upgrade: Version6Upgrade}, {version: 7, upgrade: Version7Upgrade}, {version: 8, upgrade: Version8Upgrade}, + {version: 9, upgrade: Version9Upgrade}, } // TryToMigrate used to migrate data(db,config,file,etc) in local repo @@ -121,7 +122,7 @@ func Version4Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 4) } -//Version5Upgrade +// Version5Upgrade func Version5Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 4); err != nil { @@ -159,7 +160,7 @@ func Version5Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 5) } -//Version6Upgrade +// Version6Upgrade func Version6Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 5); err != nil { @@ -197,7 +198,7 @@ func Version6Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 6) } -//Version7Upgrade +// Version7Upgrade func Version7Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 6); err != nil { @@ -259,7 +260,7 @@ func Version7Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 7) } -//Version8Upgrade +// Version8Upgrade func Version8Upgrade(repoPath string) (err error) { var fsrRepo repo.Repo if fsrRepo, err = repo.OpenFSRepo(repoPath, 7); err != nil { @@ -281,10 +282,10 @@ func Version8Upgrade(repoPath string) (err error) { cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 case types.NetworkInterop: cfg.NetworkParams.GenesisNetworkVersion = network.Version15 - cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 100 + cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 case types.NetworkButterfly: cfg.NetworkParams.GenesisNetworkVersion = network.Version15 - cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = 50 + cfg.NetworkParams.ForkUpgradeParam.UpgradeSkyrHeight = -19 default: return fsrRepo.Close() } @@ -299,3 +300,44 @@ func Version8Upgrade(repoPath string) (err error) { return repo.WriteVersion(repoPath, 8) } + +// Version9Upgrade +func Version9Upgrade(repoPath string) (err error) { + var fsrRepo repo.Repo + if fsrRepo, err = repo.OpenFSRepo(repoPath, 8); err != nil { + return + } + cfg := fsrRepo.Config() + switch cfg.NetworkParams.NetworkType { + case types.NetworkMainnet: + cfg.NetworkParams.GenesisNetworkVersion = network.Version0 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.Network2k: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkCalibnet: + cfg.NetworkParams.GenesisNetworkVersion = network.Version0 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkForce: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkInterop: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + case types.NetworkButterfly: + cfg.NetworkParams.GenesisNetworkVersion = network.Version16 + cfg.NetworkParams.ForkUpgradeParam.UpgradeV17Height = 99999999999999 + default: + return fsrRepo.Close() + } + + if err = fsrRepo.ReplaceConfig(cfg); err != nil { + return + } + + if err = fsrRepo.Close(); err != nil { + return + } + + return repo.WriteVersion(repoPath, 9) +} diff --git a/pkg/migration/migrate_test.go b/pkg/migration/migrate_test.go index 1dd430c8e0..c9192ad7d5 100644 --- a/pkg/migration/migrate_test.go +++ b/pkg/migration/migrate_test.go @@ -22,6 +22,7 @@ func TestMigration(t *testing.T) { types.NetworkButterfly: &networks.ButterflySnapNet().Network, types.NetworkCalibnet: &networks.Calibration().Network, types.NetworkMainnet: &networks.Mainnet().Network, + types.Integrationnet: &networks.IntegrationNet().Network, } for nt, paramsCfg := range cfgs { diff --git a/pkg/repo/fsrepo.go b/pkg/repo/fsrepo.go index 59a030477d..6cc54def94 100644 --- a/pkg/repo/fsrepo.go +++ b/pkg/repo/fsrepo.go @@ -26,7 +26,7 @@ import ( ) // Version is the version of repo schema that this code understands. -const LatestVersion uint = 8 +const LatestVersion uint = 9 const ( // apiFile is the filename containing the filecoin node's api address. @@ -247,9 +247,6 @@ func (r *FSRepo) loadFromDisk() error { return errors.Wrap(err, "failed to open paych datastore") } - /*if err := r.openMarketDataStore(); err != nil { - return errors.Wrap(err, "failed to open market datastore") - }*/ return nil } @@ -474,14 +471,6 @@ func (r *FSRepo) openPaychDataStore() error { return nil } -/*func (r *FSRepo) openMarketDataStore() error { - var err error - r.marketDs, err = badgerds.NewDatastore(filepath.Join(r.path, marketDatastoreProfix), badgerOptions()) - if err != nil { - return err - } - return nil -}*/ func (r *FSRepo) openWalletDatastore() error { // TODO: read wallet datastore info from config, use that to open it up ds, err := badgerds.NewDatastore(filepath.Join(r.path, walletDatastorePrefix), badgerOptions())