Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIP-0085 migration test #12139

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions itests/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
Expand All @@ -17,6 +18,7 @@ import (
miner11 "github.com/filecoin-project/go-state-types/builtin/v11/miner"
power11 "github.com/filecoin-project/go-state-types/builtin/v11/power"
adt11 "github.com/filecoin-project/go-state-types/builtin/v11/util/adt"
account "github.com/filecoin-project/go-state-types/builtin/v14/account"
markettypes "github.com/filecoin-project/go-state-types/builtin/v9/market"
migration "github.com/filecoin-project/go-state-types/builtin/v9/migration/test"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"
Expand Down Expand Up @@ -828,3 +830,70 @@ func TestMigrationNV21(t *testing.T) {
//todo @zen Direct data onboarding tests

}

func TestMigrationNV23(t *testing.T) {
kit.QuietMiningLogs()
f090Addr, err := address.NewIDAddress(90)
require.NoError(t, err)
nv23epoch := abi.ChainEpoch(100)
testClient, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
kit.UpgradeSchedule(stmgr.Upgrade{
Network: network.Version22,
Height: -1,
}, stmgr.Upgrade{
Network: network.Version23,
Height: nv23epoch,
Migration: filcns.UpgradeActorsV14,
},
))

ens.InterconnectAll().BeginMining(10 * time.Millisecond)

clientApi := testClient.FullNode.(*impl.FullNodeAPI)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

testClient.WaitTillChain(ctx, kit.HeightAtLeast(nv23epoch+5))

bs := blockstore.NewAPIBlockstore(testClient)
ctxStore := gstStore.WrapBlockStore(ctx, bs)

preMigrationTs, err := clientApi.ChainGetTipSetByHeight(ctx, nv23epoch-1, types.EmptyTSK)
require.NoError(t, err)

root := preMigrationTs.Blocks()[0].ParentStateRoot
preStateTree, err := state.LoadStateTree(ctxStore, root)
require.NoError(t, err)
require.Equal(t, types.StateTreeVersion5, preStateTree.Version())

// Check f090 actor before migration
msigCodeNv22, ok := actors.GetActorCodeID(actorstypes.Version13, manifest.MultisigKey)
assert.True(t, ok)
f090ActorPre, err := preStateTree.GetActor(f090Addr)
require.NoError(t, err)
require.True(t, f090ActorPre.Code.Equals(msigCodeNv22))

// Get state after the migration
postMigrationTs, err := clientApi.ChainHead(ctx)
require.NoError(t, err)
postStateTree, err := state.LoadStateTree(ctxStore, postMigrationTs.Blocks()[0].ParentStateRoot)
require.NoError(t, err)

// Check the new system actor
systemAct, err := postStateTree.GetActor(builtin.SystemActorAddr)
require.NoError(t, err)
systemCode, ok := actors.GetActorCodeID(actorstypes.Version14, manifest.SystemKey)
require.True(t, ok)
require.Equal(t, systemCode, systemAct.Code)

// Check f090 actor after migration
f090ActorPost, err := postStateTree.GetActor(f090Addr)
require.NoError(t, err)
accountNV23, ok := actors.GetActorCodeID(actorstypes.Version14, manifest.AccountKey)
assert.True(t, ok)
require.True(t, f090ActorPost.Code.Equals(accountNV23))
f090StatePost, err := clientApi.StateReadState(ctx, f090Addr, types.EmptyTSK)
require.NoError(t, err)
state := f090StatePost.State.(*account.State)
require.Equal(t, state.Address, f090Addr)
}