This commit is contained in:
Anton Evangelatov 2021-06-22 12:05:59 +02:00
parent 6720463799
commit 5e10d53ca8
5 changed files with 40 additions and 32 deletions

View File

@ -30,7 +30,7 @@ func TestDealCyclesConcurrent(t *testing.T) {
kit.QuietMiningLogs()
//blockTime := 10 * time.Millisecond
blockTime := 10 * time.Millisecond
// For these tests where the block time is artificially short, just use
// a deal start epoch that is guaranteed to be far enough in the future
@ -38,7 +38,7 @@ func TestDealCyclesConcurrent(t *testing.T) {
startEpoch := abi.ChainEpoch(2 << 12)
runTest := func(t *testing.T, n int, fastRetrieval bool, carExport bool) {
//api.RunningNodeType = api.NodeMiner // TODO(anteva): fix me
api.RunningNodeType = api.NodeMiner // TODO(anteva): fix me
////TODO: add miner
//client, main, _, _ := kit2.EnsembleWithMarket(t, kit2.MockProofs(), kit2.ThroughRPC())
@ -109,7 +109,7 @@ func TestDealsWithSealingAndRPC(t *testing.T) {
var blockTime = 1 * time.Second
client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC()) // no mock proofs.
client, miner, ens := kit.EnsembleMinimal(t, kit.ThroughRPC(), kit.WithAllSubsystems()) // no mock proofs.
ens.InterconnectAll().BeginMining(blockTime)
dh := kit.NewDealHarness(t, client, miner)

View File

@ -502,11 +502,12 @@ func (n *Ensemble) Start() *Ensemble {
// disable resource filtering so that local worker gets assigned tasks
// regardless of system pressure.
node.Override(new(sectorstorage.SealerConfig), func() sectorstorage.SealerConfig {
scfg := config.DefaultStorageMiner()
scfg.Storage.ResourceFiltering = sectorstorage.ResourceFilteringDisabled
return scfg.Storage
}),
// TODO: (anteva) this is missing???
//node.Override(new(sectorstorage.SealerConfig), func() sectorstorage.SealerConfig {
//scfg := config.DefaultStorageMiner()
//scfg.Storage.ResourceFiltering = sectorstorage.ResourceFilteringDisabled
//return scfg.Storage
//}),
}
// append any node builder options.

View File

@ -11,6 +11,8 @@ import (
// This function supports passing both ensemble and node functional options.
// Functional options are applied to all nodes.
func EnsembleMinimal(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *Ensemble) {
opts = append(opts, WithAllSubsystems())
eopts, nopts := siftOptions(t, opts)
var (
@ -50,6 +52,8 @@ func EnsembleWithMarket(t *testing.T, opts ...interface{}) (*TestFullNode, *Test
// This function supports passing both ensemble and node functional options.
// Functional options are applied to all nodes.
func EnsembleTwoOne(t *testing.T, opts ...interface{}) (*TestFullNode, *TestFullNode, *TestMiner, *Ensemble) {
opts = append(opts, WithAllSubsystems())
eopts, nopts := siftOptions(t, opts)
var (
@ -66,6 +70,8 @@ func EnsembleTwoOne(t *testing.T, opts ...interface{}) (*TestFullNode, *TestFull
// This function supports passing both ensemble and node functional options.
// Functional options are applied to all nodes.
func EnsembleOneTwo(t *testing.T, opts ...interface{}) (*TestFullNode, *TestMiner, *TestMiner, *Ensemble) {
opts = append(opts, WithAllSubsystems())
eopts, nopts := siftOptions(t, opts)
var (

View File

@ -18,7 +18,7 @@ import (
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/extern/sector-storage/mock"
"github.com/filecoin-project/lotus/itests/kit2"
"github.com/filecoin-project/lotus/itests/kit"
"github.com/filecoin-project/lotus/node/impl"
)
@ -27,7 +27,7 @@ func TestWindowedPost(t *testing.T) {
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
}
kit2.QuietMiningLogs()
kit.QuietMiningLogs()
var (
blocktime = 2 * time.Millisecond
@ -50,8 +50,8 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
opts := kit2.ConstructorOpts(kit2.LatestActorsAt(upgradeHeight))
client, miner, ens := kit2.EnsembleMinimal(t, kit2.MockProofs(), opts)
opts := kit.ConstructorOpts(kit.LatestActorsAt(upgradeHeight))
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
ens.InterconnectAll().BeginMining(blocktime)
miner.PledgeSectors(ctx, nSectors, 0, nil)
@ -69,7 +69,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
waitUntil := di.PeriodStart + di.WPoStProvingPeriod + 2
t.Logf("End for head.Height > %d", waitUntil)
ts := client.WaitTillChain(ctx, kit2.HeightAtLeast(waitUntil))
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
t.Logf("Now head.Height = %d", ts.Height())
p, err := client.StateMinerPower(ctx, maddr, types.EmptyTSK)
@ -79,7 +79,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
require.NoError(t, err)
require.Equal(t, p.MinerPower, p.TotalPower)
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(nSectors+kit2.DefaultPresealsPerBootstrapMiner)))
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(nSectors+kit.DefaultPresealsPerBootstrapMiner)))
t.Log("Drop some sectors")
@ -145,8 +145,8 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
waitUntil = di.PeriodStart + di.WPoStProvingPeriod + 2
t.Logf("End for head.Height > %d", waitUntil)
height = kit2.WaitTillChainHeight(ctx, t, client, blocktime, int(waitUntil))
t.Logf("Now head.Height = %d", height)
ts = client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
t.Logf("Now head.Height = %d", ts.Height())
p, err = client.StateMinerPower(ctx, maddr, types.EmptyTSK)
require.NoError(t, err)
@ -154,7 +154,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
require.Equal(t, p.MinerPower, p.TotalPower)
sectors := p.MinerPower.RawBytePower.Uint64() / uint64(ssz)
require.Equal(t, nSectors+kit2.DefaultPresealsPerBootstrapMiner-3, int(sectors)) // -3 just removed sectors
require.Equal(t, nSectors+kit.DefaultPresealsPerBootstrapMiner-3, int(sectors)) // -3 just removed sectors
t.Log("Recover one sector")
@ -167,8 +167,8 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
waitUntil = di.PeriodStart + di.WPoStProvingPeriod + 2
t.Logf("End for head.Height > %d", waitUntil)
height = kit2.WaitTillChainHeight(ctx, t, client, blocktime, int(waitUntil))
t.Logf("Now head.Height = %d", height)
ts = client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
t.Logf("Now head.Height = %d", ts.Height())
p, err = client.StateMinerPower(ctx, maddr, types.EmptyTSK)
require.NoError(t, err)
@ -176,7 +176,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
require.Equal(t, p.MinerPower, p.TotalPower)
sectors = p.MinerPower.RawBytePower.Uint64() / uint64(ssz)
require.Equal(t, nSectors+kit2.DefaultPresealsPerBootstrapMiner-2, int(sectors)) // -2 not recovered sectors
require.Equal(t, nSectors+kit.DefaultPresealsPerBootstrapMiner-2, int(sectors)) // -2 not recovered sectors
// pledge a sector after recovery
@ -190,8 +190,8 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
waitUntil := di.PeriodStart + di.WPoStProvingPeriod + 2
t.Logf("End for head.Height > %d\n", waitUntil)
height = kit2.WaitTillChainHeight(ctx, t, client, blocktime, int(waitUntil))
t.Logf("Now head.Height = %d", height)
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
t.Logf("Now head.Height = %d", ts.Height())
}
p, err = client.StateMinerPower(ctx, maddr, types.EmptyTSK)
@ -200,7 +200,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
require.Equal(t, p.MinerPower, p.TotalPower)
sectors = p.MinerPower.RawBytePower.Uint64() / uint64(ssz)
require.Equal(t, nSectors+kit2.DefaultPresealsPerBootstrapMiner-2+1, int(sectors)) // -2 not recovered sectors + 1 just pledged
require.Equal(t, nSectors+kit.DefaultPresealsPerBootstrapMiner-2+1, int(sectors)) // -2 not recovered sectors + 1 just pledged
}
func TestWindowPostBaseFeeNoBurn(t *testing.T) {
@ -208,7 +208,7 @@ func TestWindowPostBaseFeeNoBurn(t *testing.T) {
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
}
kit2.QuietMiningLogs()
kit.QuietMiningLogs()
var (
blocktime = 2 * time.Millisecond
@ -221,7 +221,7 @@ func TestWindowPostBaseFeeNoBurn(t *testing.T) {
och := build.UpgradeClausHeight
build.UpgradeClausHeight = 10
client, miner, ens := kit2.EnsembleMinimal(t, kit2.MockProofs())
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
ens.InterconnectAll().BeginMining(blocktime)
maddr, err := miner.ActorAddress(ctx)
@ -264,15 +264,15 @@ func TestWindowPostBaseFeeBurn(t *testing.T) {
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
}
kit2.QuietMiningLogs()
kit.QuietMiningLogs()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
blocktime := 2 * time.Millisecond
opts := kit2.ConstructorOpts(kit2.LatestActorsAt(-1))
client, miner, ens := kit2.EnsembleMinimal(t, kit2.MockProofs(), opts)
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
ens.InterconnectAll().BeginMining(blocktime)
maddr, err := miner.ActorAddress(ctx)

View File

@ -103,12 +103,13 @@ func (rpn *retrievalProviderNode) GetChainHead(ctx context.Context) (shared.TipS
}
func (rpn *retrievalProviderNode) IsUnsealed(ctx context.Context, sectorID abi.SectorNumber, offset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize) (bool, error) {
si, err := rpn.miner.GetSectorInfo(sectorID)
//TODO(anteva): maybe true? show on chain info??
si, err := rpn.secb.SectorsStatus(ctx, sectorID, false)
if err != nil {
return false, xerrors.Errorf("failed to get sectorinfo, err=%s", err)
return false, xerrors.Errorf("failed to get sector info: %w", err)
}
mid, err := address.IDFromAddress(rpn.miner.Address())
mid, err := address.IDFromAddress(rpn.maddr)
if err != nil {
return false, err
}
@ -118,7 +119,7 @@ func (rpn *retrievalProviderNode) IsUnsealed(ctx context.Context, sectorID abi.S
Miner: abi.ActorID(mid),
Number: sectorID,
},
ProofType: si.SectorType,
ProofType: si.SealProof, //TODO: confirm this is correct
}
log.Debugf("will call IsUnsealed now sector=%+v, offset=%d, size=%d", sectorID, offset, length)