6a0f16b084
* Initial work supporting DDO pieces in lotus-miner * sealing: Update pipeline input to operate on UniversalPiece * sealing: Update pipeline checks/sealing states to operate on UniversalPiece * sealing: Make pipeline build with UniversalPiece * move PieceDealInfo out of api * make gen * make sealing pipeline unit tests pass * fix itest ensemble build * don't panic in SectorsStatus with deals * stop linter from complaining about checkPieces * fix sector import tests * mod tidy * sealing: Add logic for (pre)committing DDO sectors * sealing: state-types with method defs * DDO non-snap pipeline works(?), DDO Itests * DDO support in snapdeals pipeline * make gen * update actor bundles * update the gst market fix * fix: chain: use PreCommitSectorsBatch2 when setting up genesis * some bug fixes * integration working changes * update actor bundles * Make TestOnboardRawPieceSnap pass * Appease the linter * Make deadlines test pass with v12 actors * Update go-state-types, abstract market DealState * make gen * mod tidy, lint fixes * Fix some more tests * Bump version in master Bump version in master * Make gen Make gen * fix sender * fix: lotus-provider: Fix winning PoSt * fix: sql Scan cannot write to an object * Actually show miner-addrs in info-log Actually show miner-addrs in lotus-provider info-log * [WIP] feat: Add nv22 skeleton Addition of Network Version 22 skeleton * update FFI * ddo is now nv22 * make gen * temp actor bundle with ddo * use working go-state-types * gst with v13 market migration * update bundle, builtin.MethodsMiner.ProveCommitSectors2 -> 3 * actually working v13 migration, v13 migration itest * Address review * sealing: Correct DDO snap pledge math * itests: Mixed ddo itest * pipeline: Fix sectorWeight * sealing: convert market deals into PAMs in mixed sectors * sealing: make market to ddo conversion work * fix lint * update gst * Update actors and GST to lastest integ branch * commit batcher: Update ProveCommitSectors3Params builder logic * make gen * use builtin-actors master * ddo: address review * itests: Add commd assertions to ddo tests * make gen * gst with fixed types * config knobs for RequireActivationSuccess * storage: Drop obsolete flaky tasts --------- Co-authored-by: Jennifer Wang <jiayingw703@gmail.com> Co-authored-by: Aayush <arajasek94@gmail.com> Co-authored-by: Shrenuj Bansal <shrenuj.bansal@protocol.ai> Co-authored-by: Phi <orjan.roren@gmail.com> Co-authored-by: Andrew Jackson (Ajax) <snadrus@gmail.com> Co-authored-by: TippyFlits <james.bluett@protocol.ai>
348 lines
9.7 KiB
Go
348 lines
9.7 KiB
Go
package itests
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"crypto/rand"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/ipfs/go-cid"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
|
"github.com/filecoin-project/go-commp-utils/nonffi"
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
"github.com/filecoin-project/go-state-types/big"
|
|
market2 "github.com/filecoin-project/go-state-types/builtin/v9/market"
|
|
"github.com/filecoin-project/go-state-types/exitcode"
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
|
minertypes "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
|
"github.com/filecoin-project/lotus/chain/consensus/filcns"
|
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
"github.com/filecoin-project/lotus/itests/kit"
|
|
"github.com/filecoin-project/lotus/lib/must"
|
|
"github.com/filecoin-project/lotus/node/config"
|
|
"github.com/filecoin-project/lotus/storage/pipeline/piece"
|
|
)
|
|
|
|
func TestActors13Migration(t *testing.T) {
|
|
|
|
var (
|
|
blocktime = 2 * time.Millisecond
|
|
ctx = context.Background()
|
|
)
|
|
client, _, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.UpgradeSchedule(stmgr.Upgrade{
|
|
Network: network.Version21,
|
|
Height: -1,
|
|
}, stmgr.Upgrade{
|
|
Network: network.Version22,
|
|
Height: 10,
|
|
Migration: filcns.UpgradeActorsV13,
|
|
}))
|
|
ens.InterconnectAll().BeginMiningMustPost(blocktime)
|
|
|
|
// mine until 15
|
|
client.WaitTillChain(ctx, kit.HeightAtLeast(15))
|
|
}
|
|
|
|
func TestOnboardRawPiece(t *testing.T) {
|
|
kit.QuietMiningLogs()
|
|
|
|
var (
|
|
blocktime = 2 * time.Millisecond
|
|
ctx = context.Background()
|
|
)
|
|
|
|
client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC())
|
|
ens.InterconnectAll().BeginMiningMustPost(blocktime)
|
|
|
|
pieceSize := abi.PaddedPieceSize(2048).Unpadded()
|
|
pieceData := make([]byte, pieceSize)
|
|
_, _ = rand.Read(pieceData)
|
|
|
|
dc, err := miner.ComputeDataCid(ctx, pieceSize, bytes.NewReader(pieceData))
|
|
require.NoError(t, err)
|
|
|
|
head, err := client.ChainHead(ctx)
|
|
require.NoError(t, err)
|
|
|
|
so, err := miner.SectorAddPieceToAny(ctx, pieceSize, bytes.NewReader(pieceData), piece.PieceDealInfo{
|
|
PublishCid: nil,
|
|
DealID: 0,
|
|
DealProposal: nil,
|
|
DealSchedule: piece.DealSchedule{
|
|
StartEpoch: head.Height() + 2880*2,
|
|
EndEpoch: head.Height() + 2880*400,
|
|
},
|
|
KeepUnsealed: true,
|
|
PieceActivationManifest: &minertypes.PieceActivationManifest{
|
|
CID: dc.PieceCID,
|
|
Size: dc.Size,
|
|
VerifiedAllocationKey: nil,
|
|
Notify: nil,
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
// wait for sector to commit
|
|
|
|
// wait for sector to commit and enter proving state
|
|
toCheck := map[abi.SectorNumber]struct{}{
|
|
so.Sector: {},
|
|
}
|
|
|
|
miner.WaitSectorsProving(ctx, toCheck)
|
|
|
|
si, err := miner.SectorsStatus(ctx, so.Sector, false)
|
|
require.NoError(t, err)
|
|
require.Equal(t, dc.PieceCID, *si.CommD)
|
|
}
|
|
|
|
func makeMarketDealProposal(t *testing.T, client *kit.TestFullNode, miner *kit.TestMiner, data cid.Cid, ps abi.PaddedPieceSize, start, end abi.ChainEpoch) market2.ClientDealProposal {
|
|
ca, err := client.WalletDefaultAddress(context.Background())
|
|
require.NoError(t, err)
|
|
|
|
ma, err := miner.ActorAddress(context.Background())
|
|
require.NoError(t, err)
|
|
|
|
dp := market2.DealProposal{
|
|
PieceCID: data,
|
|
PieceSize: ps,
|
|
VerifiedDeal: false,
|
|
Client: ca,
|
|
Provider: ma,
|
|
Label: must.One(market2.NewLabelFromString("wat")),
|
|
StartEpoch: start,
|
|
EndEpoch: end,
|
|
StoragePricePerEpoch: big.Zero(),
|
|
ProviderCollateral: abi.TokenAmount{}, // below
|
|
ClientCollateral: big.Zero(),
|
|
}
|
|
|
|
cb, err := client.StateDealProviderCollateralBounds(context.Background(), dp.PieceSize, dp.VerifiedDeal, types.EmptyTSK)
|
|
require.NoError(t, err)
|
|
dp.ProviderCollateral = big.Div(big.Mul(cb.Min, big.NewInt(2)), big.NewInt(2))
|
|
|
|
buf, err := cborutil.Dump(&dp)
|
|
require.NoError(t, err)
|
|
sig, err := client.WalletSign(context.Background(), ca, buf)
|
|
require.NoError(t, err)
|
|
|
|
return market2.ClientDealProposal{
|
|
Proposal: dp,
|
|
ClientSignature: *sig,
|
|
}
|
|
|
|
}
|
|
|
|
func TestOnboardMixedMarketDDO(t *testing.T) {
|
|
kit.QuietMiningLogs()
|
|
|
|
var (
|
|
blocktime = 2 * time.Millisecond
|
|
ctx = context.Background()
|
|
)
|
|
|
|
client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.MutateSealingConfig(func(sc *config.SealingConfig) {
|
|
sc.RequireActivationSuccess = true
|
|
sc.RequireNotificationSuccess = true
|
|
}))
|
|
ens.InterconnectAll().BeginMiningMustPost(blocktime)
|
|
|
|
maddr, err := miner.ActorAddress(ctx)
|
|
require.NoError(t, err)
|
|
|
|
mi, err := client.StateMinerInfo(ctx, maddr, types.EmptyTSK)
|
|
require.NoError(t, err)
|
|
|
|
var pieces []abi.PieceInfo
|
|
var dealID abi.DealID
|
|
|
|
{
|
|
// market piece
|
|
pieceSize := abi.PaddedPieceSize(2048 / 2).Unpadded()
|
|
pieceData := make([]byte, pieceSize)
|
|
_, _ = rand.Read(pieceData)
|
|
|
|
dc, err := miner.ComputeDataCid(ctx, pieceSize, bytes.NewReader(pieceData))
|
|
require.NoError(t, err)
|
|
pieces = append(pieces, dc)
|
|
|
|
head, err := client.ChainHead(ctx)
|
|
require.NoError(t, err)
|
|
|
|
// PSD
|
|
|
|
psdParams := market2.PublishStorageDealsParams{
|
|
Deals: []market2.ClientDealProposal{
|
|
makeMarketDealProposal(t, client, miner, dc.PieceCID, pieceSize.Padded(), head.Height()+2880*2, head.Height()+2880*400),
|
|
},
|
|
}
|
|
|
|
psdMsg := &types.Message{
|
|
To: market.Address,
|
|
From: mi.Worker,
|
|
|
|
Method: market.Methods.PublishStorageDeals,
|
|
Params: must.One(cborutil.Dump(&psdParams)),
|
|
}
|
|
|
|
smsg, err := client.MpoolPushMessage(ctx, psdMsg, nil)
|
|
require.NoError(t, err)
|
|
|
|
r, err := client.StateWaitMsg(ctx, smsg.Cid(), 1, stmgr.LookbackNoLimit, true)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, exitcode.Ok, r.Receipt.ExitCode)
|
|
|
|
nv, err := client.StateNetworkVersion(ctx, types.EmptyTSK)
|
|
require.NoError(t, err)
|
|
|
|
res, err := market.DecodePublishStorageDealsReturn(r.Receipt.Return, nv)
|
|
require.NoError(t, err)
|
|
dealID = must.One(res.DealIDs())[0]
|
|
|
|
mcid := smsg.Cid()
|
|
|
|
so, err := miner.SectorAddPieceToAny(ctx, pieceSize, bytes.NewReader(pieceData), piece.PieceDealInfo{
|
|
PublishCid: &mcid,
|
|
DealID: dealID,
|
|
DealProposal: &psdParams.Deals[0].Proposal,
|
|
DealSchedule: piece.DealSchedule{
|
|
StartEpoch: head.Height() + 2880*2,
|
|
EndEpoch: head.Height() + 2880*400,
|
|
},
|
|
PieceActivationManifest: nil,
|
|
KeepUnsealed: true,
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, abi.PaddedPieceSize(0), so.Offset)
|
|
require.Equal(t, abi.SectorNumber(2), so.Sector)
|
|
}
|
|
|
|
{
|
|
// raw ddo piece
|
|
|
|
pieceSize := abi.PaddedPieceSize(2048 / 2).Unpadded()
|
|
pieceData := make([]byte, pieceSize)
|
|
_, _ = rand.Read(pieceData)
|
|
|
|
dc, err := miner.ComputeDataCid(ctx, pieceSize, bytes.NewReader(pieceData))
|
|
require.NoError(t, err)
|
|
pieces = append(pieces, dc)
|
|
|
|
head, err := client.ChainHead(ctx)
|
|
require.NoError(t, err)
|
|
|
|
so, err := miner.SectorAddPieceToAny(ctx, pieceSize, bytes.NewReader(pieceData), piece.PieceDealInfo{
|
|
PublishCid: nil,
|
|
DealID: 0,
|
|
DealProposal: nil,
|
|
DealSchedule: piece.DealSchedule{
|
|
StartEpoch: head.Height() + 2880*2,
|
|
EndEpoch: head.Height() + 2880*400,
|
|
},
|
|
KeepUnsealed: false,
|
|
PieceActivationManifest: &minertypes.PieceActivationManifest{
|
|
CID: dc.PieceCID,
|
|
Size: dc.Size,
|
|
VerifiedAllocationKey: nil,
|
|
Notify: nil,
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, abi.PaddedPieceSize(1024), so.Offset)
|
|
require.Equal(t, abi.SectorNumber(2), so.Sector)
|
|
}
|
|
|
|
toCheck := map[abi.SectorNumber]struct{}{
|
|
2: {},
|
|
}
|
|
|
|
miner.WaitSectorsProving(ctx, toCheck)
|
|
|
|
expectCommD, err := nonffi.GenerateUnsealedCID(abi.RegisteredSealProof_StackedDrg2KiBV1_1, pieces)
|
|
require.NoError(t, err)
|
|
|
|
si, err := miner.SectorsStatus(ctx, 2, false)
|
|
require.NoError(t, err)
|
|
require.Equal(t, expectCommD, *si.CommD)
|
|
|
|
ds, err := client.StateMarketStorageDeal(ctx, dealID, types.EmptyTSK)
|
|
require.NoError(t, err)
|
|
|
|
require.NotEqual(t, -1, ds.State.SectorStartEpoch)
|
|
}
|
|
|
|
func TestOnboardRawPieceSnap(t *testing.T) {
|
|
kit.QuietMiningLogs()
|
|
|
|
var (
|
|
blocktime = 2 * time.Millisecond
|
|
ctx = context.Background()
|
|
)
|
|
|
|
client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.MutateSealingConfig(func(sc *config.SealingConfig) {
|
|
sc.PreferNewSectorsForDeals = false
|
|
sc.MakeNewSectorForDeals = false
|
|
sc.MakeCCSectorsAvailable = true
|
|
sc.AggregateCommits = false
|
|
}))
|
|
ens.InterconnectAll().BeginMiningMustPost(blocktime)
|
|
|
|
miner.PledgeSectors(ctx, 1, 0, nil)
|
|
sl, err := miner.SectorsListNonGenesis(ctx)
|
|
require.NoError(t, err)
|
|
require.Len(t, sl, 1, "expected 1 sector")
|
|
|
|
snum := sl[0]
|
|
|
|
maddr, err := miner.ActorAddress(ctx)
|
|
require.NoError(t, err)
|
|
|
|
client.WaitForSectorActive(ctx, t, snum, maddr)
|
|
|
|
pieceSize := abi.PaddedPieceSize(2048).Unpadded()
|
|
pieceData := make([]byte, pieceSize)
|
|
_, _ = rand.Read(pieceData)
|
|
|
|
dc, err := miner.ComputeDataCid(ctx, pieceSize, bytes.NewReader(pieceData))
|
|
require.NoError(t, err)
|
|
|
|
head, err := client.ChainHead(ctx)
|
|
require.NoError(t, err)
|
|
|
|
so, err := miner.SectorAddPieceToAny(ctx, pieceSize, bytes.NewReader(pieceData), piece.PieceDealInfo{
|
|
PublishCid: nil,
|
|
DealID: 0,
|
|
DealProposal: nil,
|
|
DealSchedule: piece.DealSchedule{
|
|
StartEpoch: head.Height() + 2880*2,
|
|
EndEpoch: head.Height() + 2880*400, // todo set so that it works with the sector
|
|
},
|
|
KeepUnsealed: false,
|
|
PieceActivationManifest: &minertypes.PieceActivationManifest{
|
|
CID: dc.PieceCID,
|
|
Size: dc.Size,
|
|
VerifiedAllocationKey: nil,
|
|
Notify: nil,
|
|
},
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
// wait for sector to commit
|
|
|
|
// wait for sector to commit and enter proving state
|
|
toCheck := map[abi.SectorNumber]struct{}{
|
|
so.Sector: {},
|
|
}
|
|
|
|
miner.WaitSectorsProving(ctx, toCheck)
|
|
}
|