diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 772a1a9a3..96873b675 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -21,6 +21,7 @@ import ( "github.com/filecoin-project/specs-actors/actors/migration/nv3" m2 "github.com/filecoin-project/specs-actors/v2/actors/migration" + states2 "github.com/filecoin-project/specs-actors/v2/actors/states" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" @@ -431,6 +432,19 @@ func UpgradeActorsV2(ctx context.Context, sm *StateManager, cb ExecCallback, roo return cid.Undef, xerrors.Errorf("upgrading to actors v2: %w", err) } + newStateTree, err := states2.LoadTree(store, newHamtRoot) + if err != nil { + return cid.Undef, xerrors.Errorf("failed to load new state tree: %w", err) + } + + // Check all state-tree invariants. + if msgs, err := states2.CheckStateInvariants(newStateTree, types.TotalFilecoinInt); err != nil { + return cid.Undef, xerrors.Errorf("failed to check new state tree: %w", err) + } else if !msgs.IsEmpty() { + // This error is going to be really nasty. + return cid.Undef, xerrors.Errorf("network upgrade failed: %v", msgs.Messages()) + } + newRoot, err := store.Put(ctx, &types.StateRoot{ // TODO: ActorUpgrade: should be state-tree specific, not just the actors version. Version: actors.Version2, @@ -441,7 +455,7 @@ func UpgradeActorsV2(ctx context.Context, sm *StateManager, cb ExecCallback, roo return cid.Undef, xerrors.Errorf("failed to persist new state root: %w", err) } - // perform some basic sanity checks. + // 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 { diff --git a/go.mod b/go.mod index 4908523fc..55f2fa308 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( 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-0.20200928180918-488a087c5add - github.com/filecoin-project/specs-actors/v2 v2.0.0-20200928175842-971c8d772684 + github.com/filecoin-project/specs-actors/v2 v2.0.0-20200929004132-ea2d270c9f47 github.com/filecoin-project/specs-storage v0.1.1-0.20200907031224-ed2e5cd13796 github.com/filecoin-project/test-vectors/schema v0.0.1 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index 042b0d855..3413d730a 100644 --- a/go.sum +++ b/go.sum @@ -263,8 +263,8 @@ github.com/filecoin-project/specs-actors v0.9.7/go.mod h1:wM2z+kwqYgXn5Z7scV1YHL github.com/filecoin-project/specs-actors v0.9.9/go.mod h1:czlvLQGEX0fjLLfdNHD7xLymy6L3n7aQzRWzsYGf+ys= github.com/filecoin-project/specs-actors v0.9.12-0.20200928180918-488a087c5add h1:iXQOxr8uSyZ/qnTlOZf7ALp0io+jwLxmuWsNAk/YdoQ= github.com/filecoin-project/specs-actors v0.9.12-0.20200928180918-488a087c5add/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao= -github.com/filecoin-project/specs-actors/v2 v2.0.0-20200928175842-971c8d772684 h1:sjWZqblOOf1RaohI9w2R2AVp5uifNdzsusy7oVi5ioU= -github.com/filecoin-project/specs-actors/v2 v2.0.0-20200928175842-971c8d772684/go.mod h1:/2Zra1BhLtpRywUhm++QP+3I5Ir+hBk/W24TpYjj43E= +github.com/filecoin-project/specs-actors/v2 v2.0.0-20200929004132-ea2d270c9f47 h1:bt/CdGbF1Rq5rDVaMV+XWfHBRCxN7IxZfw6lC1v6KQM= +github.com/filecoin-project/specs-actors/v2 v2.0.0-20200929004132-ea2d270c9f47/go.mod h1:/2Zra1BhLtpRywUhm++QP+3I5Ir+hBk/W24TpYjj43E= 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.1 h1:5fNF76nl4qolEvcIsjc0kUADlTMVHO73tW4kXXPnsus=