2021-12-10 10:33:29 +00:00
|
|
|
//stm: #integration
|
2021-10-06 11:43:38 +00:00
|
|
|
package itests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
"github.com/filecoin-project/lotus/chain/wallet"
|
|
|
|
"github.com/filecoin-project/lotus/itests/kit"
|
|
|
|
"github.com/filecoin-project/lotus/markets/storageadapter"
|
|
|
|
"github.com/filecoin-project/lotus/node"
|
|
|
|
"github.com/filecoin-project/lotus/node/config"
|
|
|
|
"github.com/filecoin-project/lotus/node/modules"
|
|
|
|
"github.com/filecoin-project/lotus/storage"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
publishPeriod = 1 * time.Second
|
|
|
|
maxDealsPerMsg = uint64(2) // Set max deals per publish deals message to 2
|
|
|
|
|
2021-10-08 09:54:37 +00:00
|
|
|
blockTime = 3 * time.Millisecond
|
2021-10-06 11:43:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDealsRetryLackOfFunds(t *testing.T) {
|
2021-12-13 12:41:04 +00:00
|
|
|
//stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001,
|
|
|
|
//stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01
|
|
|
|
//stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001
|
|
|
|
//stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001
|
2021-12-14 10:33:33 +00:00
|
|
|
|
|
|
|
//stm: @CHAIN_INCOMING_HANDLE_INCOMING_BLOCKS_001, @CHAIN_INCOMING_VALIDATE_BLOCK_PUBSUB_001, @CHAIN_INCOMING_VALIDATE_MESSAGE_PUBSUB_001
|
2021-12-16 13:36:02 +00:00
|
|
|
//stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001
|
2021-10-06 11:43:38 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
oldDelay := policy.GetPreCommitChallengeDelay()
|
2022-04-22 08:46:37 +00:00
|
|
|
policy.SetPreCommitChallengeDelay(10)
|
2021-10-06 11:43:38 +00:00
|
|
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
policy.SetPreCommitChallengeDelay(oldDelay)
|
|
|
|
})
|
|
|
|
|
|
|
|
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg8MiBV1)
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
|
|
|
|
// Allow 8MB sectors
|
|
|
|
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
|
|
|
|
|
|
|
publishStorageDealKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
opts := node.Options(
|
|
|
|
node.Override(new(*storageadapter.DealPublisher),
|
|
|
|
storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{
|
|
|
|
Period: publishPeriod,
|
|
|
|
MaxDealsPerMsg: maxDealsPerMsg,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
|
|
|
DealPublishControl: []string{
|
|
|
|
publishStorageDealKey.Address.String(),
|
|
|
|
},
|
|
|
|
DisableOwnerFallback: true,
|
|
|
|
DisableWorkerFallback: true,
|
|
|
|
})),
|
|
|
|
)
|
|
|
|
|
2021-10-08 10:44:20 +00:00
|
|
|
publishStorageAccountFunds := types.NewInt(1020000000000)
|
|
|
|
minerFullNode, clientFullNode, miner, ens := kit.EnsembleTwoOne(t, kit.Account(publishStorageDealKey, publishStorageAccountFunds), kit.ConstructorOpts(opts), kit.MockProofs(), eightMBSectorsOpt)
|
2021-10-06 11:43:38 +00:00
|
|
|
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
|
|
|
|
ens.
|
|
|
|
Start().
|
|
|
|
InterconnectAll().
|
|
|
|
BeginMining(blockTime)
|
|
|
|
|
|
|
|
_, err = minerFullNode.WalletImport(ctx, &publishStorageDealKey.KeyInfo)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
miner.SetControlAddresses(publishStorageDealKey.Address)
|
|
|
|
|
|
|
|
dh := kit.NewDealHarness(t, clientFullNode, miner, miner)
|
|
|
|
|
|
|
|
res, _ := clientFullNode.CreateImportFile(ctx, 0, 4<<20) // 4MiB file.
|
|
|
|
list, err := clientFullNode.ClientListImports(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, list, 1)
|
|
|
|
require.Equal(t, res.Root, *list[0].Root)
|
|
|
|
|
|
|
|
dp := dh.DefaultStartDealParams()
|
|
|
|
dp.Data.Root = res.Root
|
|
|
|
dp.FastRetrieval = true
|
|
|
|
dp.EpochPrice = abi.NewTokenAmount(62500000) // minimum asking price.
|
|
|
|
deal := dh.StartDeal(ctx, dp)
|
|
|
|
|
|
|
|
propcid := *deal
|
|
|
|
|
|
|
|
go func() {
|
2021-10-08 09:54:37 +00:00
|
|
|
time.Sleep(3 * time.Second)
|
2021-10-06 11:43:38 +00:00
|
|
|
|
|
|
|
kit.SendFunds(ctx, t, minerFullNode, publishStorageDealKey.Address, types.FromFil(1))
|
|
|
|
|
|
|
|
err := miner.MarketRetryPublishDeal(ctx, propcid)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
dh.WaitDealSealed(ctx, deal, false, false, nil)
|
|
|
|
}
|
2021-10-08 10:44:20 +00:00
|
|
|
|
|
|
|
func TestDealsRetryLackOfFunds_blockInPublishDeal(t *testing.T) {
|
2021-12-13 12:41:04 +00:00
|
|
|
//stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001,
|
|
|
|
//stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01
|
|
|
|
//stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001
|
|
|
|
//stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001
|
2021-12-16 13:36:02 +00:00
|
|
|
//stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001
|
2021-10-08 10:44:20 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
oldDelay := policy.GetPreCommitChallengeDelay()
|
2022-04-22 08:46:37 +00:00
|
|
|
policy.SetPreCommitChallengeDelay(10)
|
2021-10-08 10:44:20 +00:00
|
|
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
policy.SetPreCommitChallengeDelay(oldDelay)
|
|
|
|
})
|
|
|
|
|
|
|
|
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg8MiBV1)
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
|
|
|
|
// Allow 8MB sectors
|
|
|
|
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
|
|
|
|
|
|
|
publishStorageDealKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
opts := node.Options(
|
|
|
|
node.Override(new(*storageadapter.DealPublisher),
|
|
|
|
storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{
|
|
|
|
Period: publishPeriod,
|
|
|
|
MaxDealsPerMsg: maxDealsPerMsg,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
|
|
|
DealPublishControl: []string{
|
|
|
|
publishStorageDealKey.Address.String(),
|
|
|
|
},
|
|
|
|
DisableOwnerFallback: true,
|
|
|
|
DisableWorkerFallback: true,
|
|
|
|
})),
|
|
|
|
)
|
|
|
|
|
|
|
|
publishStorageAccountFunds := types.NewInt(1020000000000)
|
|
|
|
minerFullNode, clientFullNode, miner, ens := kit.EnsembleTwoOne(t, kit.Account(publishStorageDealKey, publishStorageAccountFunds), kit.ConstructorOpts(opts), kit.MockProofs(), eightMBSectorsOpt)
|
|
|
|
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
|
|
|
|
ens.
|
|
|
|
Start().
|
|
|
|
InterconnectAll().
|
|
|
|
BeginMining(blockTime)
|
|
|
|
|
|
|
|
_, err = minerFullNode.WalletImport(ctx, &publishStorageDealKey.KeyInfo)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
miner.SetControlAddresses(publishStorageDealKey.Address)
|
|
|
|
|
|
|
|
dh := kit.NewDealHarness(t, clientFullNode, miner, miner)
|
|
|
|
|
|
|
|
res, _ := clientFullNode.CreateImportFile(ctx, 0, 4<<20) // 4MiB file.
|
|
|
|
list, err := clientFullNode.ClientListImports(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, list, 1)
|
|
|
|
require.Equal(t, res.Root, *list[0].Root)
|
|
|
|
|
|
|
|
dp := dh.DefaultStartDealParams()
|
|
|
|
dp.Data.Root = res.Root
|
|
|
|
dp.FastRetrieval = true
|
|
|
|
dp.EpochPrice = abi.NewTokenAmount(62500000) // minimum asking price.
|
|
|
|
deal := dh.StartDeal(ctx, dp)
|
|
|
|
|
|
|
|
dealSealed := make(chan struct{})
|
|
|
|
go func() {
|
2021-10-08 10:52:56 +00:00
|
|
|
dh.WaitDealSealedQuiet(ctx, deal, false, false, nil)
|
2021-10-08 10:44:20 +00:00
|
|
|
dealSealed <- struct{}{}
|
|
|
|
}()
|
|
|
|
|
|
|
|
select {
|
|
|
|
case <-dealSealed:
|
|
|
|
t.Fatal("deal shouldn't have sealed")
|
|
|
|
case <-time.After(time.Second * 15):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDealsRetryLackOfFunds_belowLimit(t *testing.T) {
|
2021-12-13 12:41:04 +00:00
|
|
|
//stm: @CHAIN_SYNCER_LOAD_GENESIS_001, @CHAIN_SYNCER_FETCH_TIPSET_001,
|
|
|
|
//stm: @CHAIN_SYNCER_START_001, @CHAIN_SYNCER_SYNC_001, @BLOCKCHAIN_BEACON_VALIDATE_BLOCK_VALUES_01
|
|
|
|
//stm: @CHAIN_SYNCER_COLLECT_CHAIN_001, @CHAIN_SYNCER_COLLECT_HEADERS_001, @CHAIN_SYNCER_VALIDATE_TIPSET_001
|
|
|
|
//stm: @CHAIN_SYNCER_NEW_PEER_HEAD_001, @CHAIN_SYNCER_VALIDATE_MESSAGE_META_001, @CHAIN_SYNCER_STOP_001
|
2021-12-16 13:36:02 +00:00
|
|
|
//stm: @CLIENT_STORAGE_DEALS_LIST_IMPORTS_001
|
2021-10-08 10:44:20 +00:00
|
|
|
ctx := context.Background()
|
|
|
|
oldDelay := policy.GetPreCommitChallengeDelay()
|
2022-04-22 08:46:37 +00:00
|
|
|
policy.SetPreCommitChallengeDelay(10)
|
2021-10-08 10:44:20 +00:00
|
|
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
policy.SetPreCommitChallengeDelay(oldDelay)
|
|
|
|
})
|
|
|
|
|
|
|
|
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg8MiBV1)
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
|
|
|
|
// Allow 8MB sectors
|
|
|
|
eightMBSectorsOpt := kit.SectorSize(8 << 20)
|
|
|
|
|
|
|
|
publishStorageDealKey, err := wallet.GenerateKey(types.KTSecp256k1)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
opts := node.Options(
|
|
|
|
node.Override(new(*storageadapter.DealPublisher),
|
|
|
|
storageadapter.NewDealPublisher(nil, storageadapter.PublishMsgConfig{
|
|
|
|
Period: publishPeriod,
|
|
|
|
MaxDealsPerMsg: maxDealsPerMsg,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
node.Override(new(*storage.AddressSelector), modules.AddressSelector(&config.MinerAddressConfig{
|
|
|
|
DealPublishControl: []string{
|
|
|
|
publishStorageDealKey.Address.String(),
|
|
|
|
},
|
|
|
|
DisableOwnerFallback: true,
|
|
|
|
DisableWorkerFallback: true,
|
|
|
|
})),
|
|
|
|
)
|
|
|
|
|
|
|
|
publishStorageAccountFunds := types.NewInt(1)
|
|
|
|
minerFullNode, clientFullNode, miner, ens := kit.EnsembleTwoOne(t, kit.Account(publishStorageDealKey, publishStorageAccountFunds), kit.ConstructorOpts(opts), kit.MockProofs(), eightMBSectorsOpt)
|
|
|
|
|
|
|
|
kit.QuietMiningLogs()
|
|
|
|
|
|
|
|
ens.
|
|
|
|
Start().
|
|
|
|
InterconnectAll().
|
|
|
|
BeginMining(blockTime)
|
|
|
|
|
|
|
|
_, err = minerFullNode.WalletImport(ctx, &publishStorageDealKey.KeyInfo)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
miner.SetControlAddresses(publishStorageDealKey.Address)
|
|
|
|
|
|
|
|
dh := kit.NewDealHarness(t, clientFullNode, miner, miner)
|
|
|
|
|
|
|
|
res, _ := clientFullNode.CreateImportFile(ctx, 0, 4<<20) // 4MiB file.
|
|
|
|
list, err := clientFullNode.ClientListImports(ctx)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, list, 1)
|
|
|
|
require.Equal(t, res.Root, *list[0].Root)
|
|
|
|
|
|
|
|
dp := dh.DefaultStartDealParams()
|
|
|
|
dp.Data.Root = res.Root
|
|
|
|
dp.FastRetrieval = true
|
|
|
|
dp.EpochPrice = abi.NewTokenAmount(62500000) // minimum asking price.
|
|
|
|
deal := dh.StartDeal(ctx, dp)
|
|
|
|
|
2022-05-15 19:26:52 +00:00
|
|
|
err = dh.ExpectDealFailure(ctx, deal, "Actor balance less than needed")
|
2021-10-08 10:44:20 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|