From 7b8158b1af99164e93cd24762170110d9e06c915 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Sat, 7 Nov 2020 23:05:52 -0500 Subject: [PATCH] Update to actors v2.3.0 --- build/params_2k.go | 1 + build/params_mainnet.go | 3 ++ build/params_testground.go | 1 + chain/actors/policy/policy.go | 14 +++++---- chain/actors/policy/policy_test.go | 8 +++--- chain/stmgr/forks.go | 46 ++++++++++++++++++++++++++++-- go.mod | 6 ++-- go.sum | 10 ++++--- 8 files changed, 71 insertions(+), 18 deletions(-) diff --git a/build/params_2k.go b/build/params_2k.go index 6d1f3d46c..0f6a1b4aa 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -23,6 +23,7 @@ var UpgradeActorsV2Height = abi.ChainEpoch(10) var UpgradeLiftoffHeight = abi.ChainEpoch(-5) const UpgradeKumquatHeight = 15 +const UpgradeCalicoHeight = 20 var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, diff --git a/build/params_mainnet.go b/build/params_mainnet.go index 94deedfec..4dec54e7d 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -39,6 +39,9 @@ const UpgradeLiftoffHeight = 148888 const UpgradeKumquatHeight = 170000 +// TODO: Height?? +const UpgradeCalicoHeight = 999999 + func init() { policy.SetConsensusMinerMinPower(abi.NewStoragePower(10 << 40)) policy.SetSupportedProofTypes( diff --git a/build/params_testground.go b/build/params_testground.go index d9893a5f5..23a3e9da9 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -88,6 +88,7 @@ var ( UpgradeActorsV2Height abi.ChainEpoch = 10 UpgradeLiftoffHeight abi.ChainEpoch = -5 UpgradeKumquatHeight abi.ChainEpoch = -6 + UpgradeCalicoHeight abi.ChainEpoch = -7 DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index c1a971db5..492be79e9 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -32,7 +32,9 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) { } // Set for all miner versions. miner0.SupportedProofTypes = newTypes - miner2.SupportedProofTypes = newTypes + miner2.PreCommitSealProofTypesV0 = newTypes + miner2.PreCommitSealProofTypesV7 = newTypes + miner2.PreCommitSealProofTypesV8 = newTypes } // AddSupportedProofTypes sets supported proof types, across all actor versions. @@ -41,7 +43,9 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) { for _, t := range types { // Set for all miner versions. miner0.SupportedProofTypes[t] = struct{}{} - miner2.SupportedProofTypes[t] = struct{}{} + miner2.PreCommitSealProofTypesV0[t] = struct{}{} + miner2.PreCommitSealProofTypesV7[t] = struct{}{} + miner2.PreCommitSealProofTypesV8[t] = struct{}{} } } @@ -133,9 +137,9 @@ func GetMaxPoStPartitions(p abi.RegisteredPoStProof) (int, error) { } func GetDefaultSectorSize() abi.SectorSize { - // supported proof types are the same across versions. - szs := make([]abi.SectorSize, 0, len(miner2.SupportedProofTypes)) - for spt := range miner2.SupportedProofTypes { + // supported sector sizes are the same across versions. + szs := make([]abi.SectorSize, 0, len(miner2.PreCommitSealProofTypesV8)) + for spt := range miner2.PreCommitSealProofTypesV8 { ss, err := spt.SectorSize() if err != nil { panic(err) diff --git a/chain/actors/policy/policy_test.go b/chain/actors/policy/policy_test.go index af600cc75..24e47aaa0 100644 --- a/chain/actors/policy/policy_test.go +++ b/chain/actors/policy/policy_test.go @@ -44,7 +44,7 @@ func TestSupportedProofTypes(t *testing.T) { // Tests assumptions about policies being the same between actor versions. func TestAssumptions(t *testing.T) { - require.EqualValues(t, miner0.SupportedProofTypes, miner2.SupportedProofTypes) + require.EqualValues(t, miner0.SupportedProofTypes, miner2.PreCommitSealProofTypesV0) require.Equal(t, miner0.PreCommitChallengeDelay, miner2.PreCommitChallengeDelay) require.Equal(t, miner0.MaxSectorExpirationExtension, miner2.MaxSectorExpirationExtension) require.Equal(t, miner0.ChainFinality, miner2.ChainFinality) @@ -57,10 +57,10 @@ func TestAssumptions(t *testing.T) { } func TestPartitionSizes(t *testing.T) { - for p := range abi.PoStSealProofTypes { - sizeNew, err := builtin2.PoStProofWindowPoStPartitionSectors(p) + for _, p := range abi.SealProofInfos { + sizeNew, err := builtin2.PoStProofWindowPoStPartitionSectors(p.WindowPoStProof) require.NoError(t, err) - sizeOld, err := builtin0.PoStProofWindowPoStPartitionSectors(p) + sizeOld, err := builtin0.PoStProofWindowPoStPartitionSectors(p.WindowPoStProof) if err != nil { // new proof type. continue diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index e089a1084..15b0b369a 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -6,6 +6,10 @@ import ( "encoding/binary" "math" + "github.com/filecoin-project/specs-actors/v2/actors/migration/nv7" + + "github.com/filecoin-project/specs-actors/v2/actors/migration/nv4" + "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/go-address" @@ -23,7 +27,6 @@ import ( adt0 "github.com/filecoin-project/specs-actors/actors/util/adt" "github.com/filecoin-project/specs-actors/actors/migration/nv3" - m2 "github.com/filecoin-project/specs-actors/v2/actors/migration" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/adt" @@ -90,6 +93,10 @@ func DefaultUpgradeSchedule() UpgradeSchedule { Height: build.UpgradeKumquatHeight, Network: network.Version6, Migration: nil, + }, { + Height: build.UpgradeCalicoHeight, + Network: network.Version7, + Migration: UpgradeCalico, }} if build.UpgradeActorsV2Height == math.MaxInt64 { // disable actors upgrade @@ -601,7 +608,7 @@ func UpgradeActorsV2(ctx context.Context, sm *StateManager, cb ExecCallback, roo return cid.Undef, xerrors.Errorf("failed to create new state info for actors v2: %w", err) } - newHamtRoot, err := m2.MigrateStateTree(ctx, store, root, epoch, m2.DefaultConfig()) + newHamtRoot, err := nv4.MigrateStateTree(ctx, store, root, epoch, nv4.DefaultConfig()) if err != nil { return cid.Undef, xerrors.Errorf("upgrading to actors v2: %w", err) } @@ -652,6 +659,41 @@ func UpgradeLiftoff(ctx context.Context, sm *StateManager, cb ExecCallback, root return tree.Flush(ctx) } +func UpgradeCalico(ctx context.Context, sm *StateManager, cb ExecCallback, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) { + store := sm.cs.Store(ctx) + info, err := store.Put(ctx, new(types.StateInfo0)) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to create new state info for actors v2: %w", err) + } + + newHamtRoot, err := nv7.MigrateStateTree(ctx, store, root, epoch, nv7.DefaultConfig()) + if err != nil { + return cid.Undef, xerrors.Errorf("running nv7 migration: %w", err) + } + + newRoot, err := store.Put(ctx, &types.StateRoot{ + Version: types.StateTreeVersion1, + Actors: newHamtRoot, + Info: info, + }) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err) + } + + // perform some basic sanity checks to make sure everything still works. + if newSm, err := state.LoadStateTree(store, newRoot); err != nil { + return cid.Undef, xerrors.Errorf("state tree sanity load failed: %w", err) + } else if newRoot2, err := newSm.Flush(ctx); err != nil { + return cid.Undef, xerrors.Errorf("state tree sanity flush failed: %w", err) + } else if newRoot2 != newRoot { + return cid.Undef, xerrors.Errorf("state-root mismatch: %s != %s", newRoot, newRoot2) + } else if _, err := newSm.GetActor(builtin0.InitActorAddr); err != nil { + return cid.Undef, xerrors.Errorf("failed to load init actor after upgrade: %w", err) + } + + return newRoot, nil +} + func setNetworkName(ctx context.Context, store adt.Store, tree *state.StateTree, name string) error { ia, err := tree.GetActor(builtin0.InitActorAddr) if err != nil { diff --git a/go.mod b/go.mod index ccd44f20c..0ee9a7bbb 100644 --- a/go.mod +++ b/go.mod @@ -35,12 +35,12 @@ require ( github.com/filecoin-project/go-multistore v0.0.3 github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20 github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261 - github.com/filecoin-project/go-state-types v0.0.0-20201013222834-41ea465f274f + github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b - github.com/filecoin-project/specs-actors v0.9.12 - github.com/filecoin-project/specs-actors/v2 v2.2.0 + github.com/filecoin-project/specs-actors v0.9.13 + github.com/filecoin-project/specs-actors/v2 v2.3.0 github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796 github.com/filecoin-project/test-vectors/schema v0.0.5 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index cf62a2a72..f2023fbf8 100644 --- a/go.sum +++ b/go.sum @@ -275,8 +275,8 @@ github.com/filecoin-project/go-state-types v0.0.0-20200903145444-247639ffa6ad/go github.com/filecoin-project/go-state-types v0.0.0-20200904021452-1883f36ca2f4/go.mod h1:IQ0MBPnonv35CJHtWSN3YY1Hz2gkPru1Q9qoaYLxx9I= github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab h1:cEDC5Ei8UuT99hPWhCjA72SM9AuRtnpvdSTIYbnzN8I= github.com/filecoin-project/go-state-types v0.0.0-20200928172055-2df22083d8ab/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= -github.com/filecoin-project/go-state-types v0.0.0-20201013222834-41ea465f274f h1:TZDTu4MtBKSFLXWGKLy+cvC3nHfMFIrVgWLAz/+GgZQ= -github.com/filecoin-project/go-state-types v0.0.0-20201013222834-41ea465f274f/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= +github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc h1:+hbMY4Pcx2oizrfH08VWXwrj5mU8aJT6g0UNxGHFCGU= +github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe h1:dF8u+LEWeIcTcfUcCf3WFVlc81Fr2JKg8zPzIbBDKDw= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIiWBRilQjQ+5IiwdQ= @@ -286,9 +286,11 @@ github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/ github.com/filecoin-project/specs-actors v0.9.4/go.mod h1:BStZQzx5x7TmCkLv0Bpa07U6cPKol6fd3w9KjMPZ6Z4= github.com/filecoin-project/specs-actors v0.9.12 h1:iIvk58tuMtmloFNHhAOQHG+4Gci6Lui0n7DYQGi3cJk= github.com/filecoin-project/specs-actors v0.9.12/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= +github.com/filecoin-project/specs-actors v0.9.13 h1:rUEOQouefi9fuVY/2HOroROJlZbOzWYXXeIh41KF2M4= +github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= github.com/filecoin-project/specs-actors/v2 v2.0.1/go.mod h1:v2NZVYinNIKA9acEMBm5wWXxqv5+frFEbekBFemYghY= -github.com/filecoin-project/specs-actors/v2 v2.2.0 h1:IyCICb0NHYeD0sdSqjVGwWydn/7r7xXuxdpvGAcRCGY= -github.com/filecoin-project/specs-actors/v2 v2.2.0/go.mod h1:rlv5Mx9wUhV8Qsz+vUezZNm+zL4tK08O0HreKKPB2Wc= +github.com/filecoin-project/specs-actors/v2 v2.3.0 h1:V7lHeF2ylfFi84F4y80u5FE4BpPHYGvB71kLrhXkJto= +github.com/filecoin-project/specs-actors/v2 v2.3.0/go.mod h1:UuJQLoTx/HPvvWeqlIFmC/ywlOLHNe8SNQ3OunFbu2Y= github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796 h1:dJsTPWpG2pcTeojO2pyn0c6l+x/3MZYCBgo/9d11JEk= github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796/go.mod h1:nJRRM7Aa9XVvygr3W9k6xGF46RWzr2zxF/iGoAIfA/g= github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg=