Merge pull request #6372 from filecoin-project/fix/nv11-tests
Fix nv13 1.11 tests
This commit is contained in:
commit
2a787dd4a3
@ -63,7 +63,7 @@ func TestDeadlineToggling(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
n, sn := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(upgradeH)}, OneMiner)
|
||||
n, sn := b(t, []FullNodeOpts{FullNodeWithNetworkUpgradeAt(network.Version12, upgradeH)}, OneMiner)
|
||||
|
||||
client := n[0].FullNode.(*impl.FullNodeAPI)
|
||||
minerA := sn[0]
|
||||
|
@ -122,31 +122,46 @@ var OneFull = DefaultFullOpts(1)
|
||||
var TwoFull = DefaultFullOpts(2)
|
||||
|
||||
var FullNodeWithLatestActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts {
|
||||
if upgradeHeight == -1 {
|
||||
// Attention: Update this when introducing new actor versions or your tests will be sad
|
||||
upgradeHeight = 4
|
||||
// Attention: Update this when introducing new actor versions or your tests will be sad
|
||||
return FullNodeWithNetworkUpgradeAt(network.Version13, upgradeHeight)
|
||||
}
|
||||
|
||||
var FullNodeWithNetworkUpgradeAt = func(version network.Version, upgradeHeight abi.ChainEpoch) FullNodeOpts {
|
||||
fullSchedule := stmgr.UpgradeSchedule{{
|
||||
// prepare for upgrade.
|
||||
Network: network.Version9,
|
||||
Height: 1,
|
||||
Migration: stmgr.UpgradeActorsV2,
|
||||
}, {
|
||||
Network: network.Version10,
|
||||
Height: 2,
|
||||
Migration: stmgr.UpgradeActorsV3,
|
||||
}, {
|
||||
Network: network.Version12,
|
||||
Height: 3,
|
||||
Migration: stmgr.UpgradeActorsV4,
|
||||
}, {
|
||||
Network: network.Version13,
|
||||
Height: 4,
|
||||
Migration: stmgr.UpgradeActorsV5,
|
||||
}}
|
||||
|
||||
schedule := stmgr.UpgradeSchedule{}
|
||||
for _, upgrade := range fullSchedule {
|
||||
if upgrade.Network > version {
|
||||
break
|
||||
}
|
||||
|
||||
schedule = append(schedule, upgrade)
|
||||
}
|
||||
|
||||
if upgradeHeight > 0 {
|
||||
schedule[len(schedule)-1].Height = upgradeHeight
|
||||
}
|
||||
|
||||
return FullNodeOpts{
|
||||
Opts: func(nodes []TestNode) node.Option {
|
||||
return node.Override(new(stmgr.UpgradeSchedule), stmgr.UpgradeSchedule{{
|
||||
// prepare for upgrade.
|
||||
Network: network.Version9,
|
||||
Height: 1,
|
||||
Migration: stmgr.UpgradeActorsV2,
|
||||
}, {
|
||||
Network: network.Version10,
|
||||
Height: 2,
|
||||
Migration: stmgr.UpgradeActorsV3,
|
||||
}, {
|
||||
Network: network.Version12,
|
||||
Height: 3,
|
||||
Migration: stmgr.UpgradeActorsV4,
|
||||
}, {
|
||||
Network: network.Version13,
|
||||
Height: upgradeHeight,
|
||||
Migration: stmgr.UpgradeActorsV5,
|
||||
}})
|
||||
return node.Override(new(stmgr.UpgradeSchedule), schedule)
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -170,31 +185,6 @@ var FullNodeWithSDRAt = func(calico, persian abi.ChainEpoch) FullNodeOpts {
|
||||
}
|
||||
}
|
||||
|
||||
var FullNodeWithV4ActorsAt = func(upgradeHeight abi.ChainEpoch) FullNodeOpts {
|
||||
if upgradeHeight == -1 {
|
||||
upgradeHeight = 3
|
||||
}
|
||||
|
||||
return FullNodeOpts{
|
||||
Opts: func(nodes []TestNode) node.Option {
|
||||
return node.Override(new(stmgr.UpgradeSchedule), stmgr.UpgradeSchedule{{
|
||||
// prepare for upgrade.
|
||||
Network: network.Version9,
|
||||
Height: 1,
|
||||
Migration: stmgr.UpgradeActorsV2,
|
||||
}, {
|
||||
Network: network.Version10,
|
||||
Height: 2,
|
||||
Migration: stmgr.UpgradeActorsV3,
|
||||
}, {
|
||||
Network: network.Version12,
|
||||
Height: upgradeHeight,
|
||||
Migration: stmgr.UpgradeActorsV4,
|
||||
}})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var MineNext = miner.MineReq{
|
||||
InjectNulls: 0,
|
||||
Done: func(bool, abi.ChainEpoch, error) {},
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
@ -19,108 +21,120 @@ import (
|
||||
)
|
||||
|
||||
func AddVerifiedClient(t *testing.T, b APIBuilder) {
|
||||
test := func(nv network.Version, shouldWork bool) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
|
||||
nodes, miners := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(-1)}, OneMiner)
|
||||
api := nodes[0].FullNode.(*impl.FullNodeAPI)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
nodes, miners := b(t, []FullNodeOpts{FullNodeWithNetworkUpgradeAt(nv, -1)}, OneMiner)
|
||||
api := nodes[0].FullNode.(*impl.FullNodeAPI)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
//Get VRH
|
||||
vrh, err := api.StateVerifiedRegistryRootKey(ctx, types.TipSetKey{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
//Get VRH
|
||||
vrh, err := api.StateVerifiedRegistryRootKey(ctx, types.TipSetKey{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
//Add verifier
|
||||
verifier, err := api.WalletDefaultAddress(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
params, err := actors.SerializeParams(&verifreg4.AddVerifierParams{Address: verifier, Allowance: big.NewInt(100000000000)})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
msg := &types.Message{
|
||||
To: verifreg.Address,
|
||||
From: vrh,
|
||||
Method: verifreg.Methods.AddVerifier,
|
||||
Params: params,
|
||||
Value: big.Zero(),
|
||||
}
|
||||
|
||||
bm := NewBlockMiner(ctx, t, miners[0], 100*time.Millisecond)
|
||||
bm.MineBlocks()
|
||||
defer bm.Stop()
|
||||
|
||||
sm, err := api.MpoolPushMessage(ctx, msg, nil)
|
||||
if err != nil {
|
||||
t.Fatal("AddVerifier failed: ", err)
|
||||
}
|
||||
res, err := api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Receipt.ExitCode != 0 {
|
||||
t.Fatal("did not successfully send message")
|
||||
}
|
||||
|
||||
//Assign datacap to a client
|
||||
datacap := big.NewInt(10000)
|
||||
clientAddress, err := api.WalletNew(ctx, types.KTBLS)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
params, err = actors.SerializeParams(&verifreg4.AddVerifiedClientParams{Address: clientAddress, Allowance: datacap})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
msg = &types.Message{
|
||||
To: verifreg.Address,
|
||||
From: verifier,
|
||||
Method: verifreg.Methods.AddVerifiedClient,
|
||||
Params: params,
|
||||
Value: big.Zero(),
|
||||
}
|
||||
|
||||
sm, err = api.MpoolPushMessage(ctx, msg, nil)
|
||||
if err != nil {
|
||||
t.Fatal("AddVerifiedClient faield: ", err)
|
||||
}
|
||||
res, err = api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Receipt.ExitCode != 0 {
|
||||
t.Fatal("did not successfully send message")
|
||||
}
|
||||
|
||||
//check datacap balance
|
||||
dcap, err := api.StateVerifiedClientStatus(ctx, clientAddress, types.EmptyTSK)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !dcap.Equals(datacap) {
|
||||
t.Fatal("")
|
||||
}
|
||||
|
||||
//try to assign datacap to the same client should fail for actor v4 and below
|
||||
params, err = actors.SerializeParams(&verifreg4.AddVerifiedClientParams{Address: clientAddress, Allowance: datacap})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
msg = &types.Message{
|
||||
To: verifreg.Address,
|
||||
From: verifier,
|
||||
Method: verifreg.Methods.AddVerifiedClient,
|
||||
Params: params,
|
||||
Value: big.Zero(),
|
||||
}
|
||||
|
||||
_, err = api.MpoolPushMessage(ctx, msg, nil)
|
||||
if shouldWork && err != nil {
|
||||
t.Fatal("expected nil err", err)
|
||||
}
|
||||
|
||||
if !shouldWork && (err == nil || !strings.Contains(err.Error(), "verified client already exists")) {
|
||||
t.Fatal("Add datacap to an existing verified client should fail")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Add verifier
|
||||
verifier, err := api.WalletDefaultAddress(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
params, err := actors.SerializeParams(&verifreg4.AddVerifierParams{Address: verifier, Allowance: big.NewInt(100000000000)})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
msg := &types.Message{
|
||||
To: verifreg.Address,
|
||||
From: vrh,
|
||||
Method: verifreg.Methods.AddVerifier,
|
||||
Params: params,
|
||||
Value: big.Zero(),
|
||||
}
|
||||
|
||||
bm := NewBlockMiner(ctx, t, miners[0], 100*time.Millisecond)
|
||||
bm.MineBlocks()
|
||||
defer bm.Stop()
|
||||
|
||||
sm, err := api.MpoolPushMessage(ctx, msg, nil)
|
||||
if err != nil {
|
||||
t.Fatal("AddVerifier failed: ", err)
|
||||
}
|
||||
res, err := api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Receipt.ExitCode != 0 {
|
||||
t.Fatal("did not successfully send message")
|
||||
}
|
||||
|
||||
//Assign datacap to a client
|
||||
datacap := big.NewInt(10000)
|
||||
clientAddress, err := api.WalletNew(ctx, types.KTBLS)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
params, err = actors.SerializeParams(&verifreg4.AddVerifiedClientParams{Address: clientAddress, Allowance: datacap})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
msg = &types.Message{
|
||||
To: verifreg.Address,
|
||||
From: verifier,
|
||||
Method: verifreg.Methods.AddVerifiedClient,
|
||||
Params: params,
|
||||
Value: big.Zero(),
|
||||
}
|
||||
|
||||
sm, err = api.MpoolPushMessage(ctx, msg, nil)
|
||||
if err != nil {
|
||||
t.Fatal("AddVerifiedClient faield: ", err)
|
||||
}
|
||||
res, err = api.StateWaitMsg(ctx, sm.Cid(), 1, lapi.LookbackNoLimit, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.Receipt.ExitCode != 0 {
|
||||
t.Fatal("did not successfully send message")
|
||||
}
|
||||
|
||||
//check datacap balance
|
||||
dcap, err := api.StateVerifiedClientStatus(ctx, clientAddress, types.EmptyTSK)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !dcap.Equals(datacap) {
|
||||
t.Fatal("")
|
||||
}
|
||||
|
||||
//try to assign datacap to the same client should fail for actor v4 and below
|
||||
params, err = actors.SerializeParams(&verifreg4.AddVerifiedClientParams{Address: clientAddress, Allowance: datacap})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
msg = &types.Message{
|
||||
To: verifreg.Address,
|
||||
From: verifier,
|
||||
Method: verifreg.Methods.AddVerifiedClient,
|
||||
Params: params,
|
||||
Value: big.Zero(),
|
||||
}
|
||||
|
||||
if _, err = api.MpoolPushMessage(ctx, msg, nil); !strings.Contains(err.Error(), "verified client already exists") {
|
||||
t.Fatal("Add datacap to an exist verified client should fail")
|
||||
}
|
||||
t.Run("nv12", test(network.Version12, false))
|
||||
t.Run("nv13", test(network.Version13, true))
|
||||
}
|
||||
|
@ -152,6 +152,8 @@ func VersionForNetwork(ver network.Version) (types.StateTreeVersion, error) {
|
||||
return types.StateTreeVersion2, nil
|
||||
case network.Version12:
|
||||
return types.StateTreeVersion3, nil
|
||||
case network.Version13:
|
||||
return types.StateTreeVersion4, nil
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported network version %d", ver))
|
||||
}
|
||||
@ -162,7 +164,7 @@ func NewStateTree(cst cbor.IpldStore, ver types.StateTreeVersion) (*StateTree, e
|
||||
switch ver {
|
||||
case types.StateTreeVersion0:
|
||||
// info is undefined
|
||||
case types.StateTreeVersion1, types.StateTreeVersion2, types.StateTreeVersion3:
|
||||
case types.StateTreeVersion1, types.StateTreeVersion2, types.StateTreeVersion3, types.StateTreeVersion4:
|
||||
var err error
|
||||
info, err = cst.Put(context.TODO(), new(types.StateInfo0))
|
||||
if err != nil {
|
||||
|
@ -1533,9 +1533,9 @@ USAGE:
|
||||
lotus-miner sectors batching command [command options] [arguments...]
|
||||
|
||||
COMMANDS:
|
||||
pending-commit list sectors waiting in commit batch queue
|
||||
pending-precommit list sectors waiting in precommit batch queue
|
||||
help, h Shows a list of commands or help for one command
|
||||
commit list sectors waiting in commit batch queue
|
||||
precommit list sectors waiting in precommit batch queue
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
OPTIONS:
|
||||
--help, -h show help (default: false)
|
||||
@ -1543,13 +1543,13 @@ OPTIONS:
|
||||
|
||||
```
|
||||
|
||||
#### lotus-miner sectors batching pending-commit
|
||||
#### lotus-miner sectors batching commit
|
||||
```
|
||||
NAME:
|
||||
lotus-miner sectors batching pending-commit - list sectors waiting in commit batch queue
|
||||
lotus-miner sectors batching commit - list sectors waiting in commit batch queue
|
||||
|
||||
USAGE:
|
||||
lotus-miner sectors batching pending-commit [command options] [arguments...]
|
||||
lotus-miner sectors batching commit [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--publish-now send a batch now (default: false)
|
||||
@ -1557,13 +1557,13 @@ OPTIONS:
|
||||
|
||||
```
|
||||
|
||||
#### lotus-miner sectors batching pending-precommit
|
||||
#### lotus-miner sectors batching precommit
|
||||
```
|
||||
NAME:
|
||||
lotus-miner sectors batching pending-precommit - list sectors waiting in precommit batch queue
|
||||
lotus-miner sectors batching precommit - list sectors waiting in precommit batch queue
|
||||
|
||||
USAGE:
|
||||
lotus-miner sectors batching pending-precommit [command options] [arguments...]
|
||||
lotus-miner sectors batching precommit [command options] [arguments...]
|
||||
|
||||
OPTIONS:
|
||||
--publish-now send a batch now (default: false)
|
||||
|
Loading…
Reference in New Issue
Block a user