test: genesis actors version
Properly handle genesis in actors tests. Fast-forward upgrading to actors v13 doesn't work because there needs to be at least a day between v0 genesis and v13 (due to differences in miner cron).
This commit is contained in:
parent
3235dbfaee
commit
dcff06bd91
@ -26,7 +26,6 @@ const UnixfsLinksPerLevel = 1024
|
||||
|
||||
const AllowableClockDriftSecs = uint64(1)
|
||||
const NewestNetworkVersion = network.Version13
|
||||
const ActorUpgradeNetworkVersion = network.Version4
|
||||
|
||||
// Epochs
|
||||
const ForkLengthThreshold = Finality
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
@ -34,9 +33,7 @@ func TestWorkerKeyChange(t *testing.T) {
|
||||
kit.QuietMiningLogs()
|
||||
|
||||
blocktime := 1 * time.Millisecond
|
||||
client1, client2, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs(),
|
||||
kit.ConstructorOpts(kit.InstantaneousNetworkVersion(network.Version13)),
|
||||
)
|
||||
client1, client2, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs())
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
output := bytes.NewBuffer(nil)
|
||||
|
@ -186,7 +186,7 @@ func (ts *apiSuite) testNonGenesisMiner(t *testing.T) {
|
||||
var newMiner kit.TestMiner
|
||||
ens.Miner(&newMiner, full,
|
||||
kit.OwnerAddr(full.DefaultKey),
|
||||
kit.ProofType(abi.RegisteredSealProof_StackedDrg2KiBV1), // we're using v0 actors with old proofs.
|
||||
kit.ProofType(abi.RegisteredSealProof_StackedDrg2KiBV1_1),
|
||||
kit.WithAllSubsystems(),
|
||||
).Start().InterconnectAll()
|
||||
|
||||
|
@ -19,8 +19,7 @@ func TestCCUpgrade(t *testing.T) {
|
||||
for _, height := range []abi.ChainEpoch{
|
||||
-1, // before
|
||||
162, // while sealing
|
||||
530, // after upgrade deal
|
||||
5000, // after
|
||||
560, // after upgrade deal
|
||||
} {
|
||||
height := height // make linters happy by copying
|
||||
t.Run(fmt.Sprintf("upgrade-%d", height), func(t *testing.T) {
|
||||
@ -33,8 +32,7 @@ func runTestCCUpgrade(t *testing.T, upgradeHeight abi.ChainEpoch) {
|
||||
ctx := context.Background()
|
||||
blockTime := 5 * time.Millisecond
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(upgradeHeight))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.LatestActorsAt(upgradeHeight))
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
|
||||
maddr, err := miner.ActorAddress(ctx)
|
||||
|
@ -75,9 +75,8 @@ func TestDeadlineToggling(t *testing.T) {
|
||||
minerD kit.TestMiner
|
||||
minerE kit.TestMiner
|
||||
)
|
||||
opts := []kit.NodeOpt{kit.ConstructorOpts(kit.NetworkUpgradeAt(network.Version12, upgradeH))}
|
||||
opts = append(opts, kit.WithAllSubsystems())
|
||||
ens := kit.NewEnsemble(t, kit.MockProofs()).
|
||||
opts := []kit.NodeOpt{kit.WithAllSubsystems()}
|
||||
ens := kit.NewEnsemble(t, kit.MockProofs(), kit.TurboUpgradeAt(upgradeH)).
|
||||
FullNode(&client, opts...).
|
||||
Miner(&minerA, &client, opts...).
|
||||
Start().
|
||||
|
@ -27,6 +27,7 @@ func TestDealWithMarketAndMinerNode(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test in short mode")
|
||||
}
|
||||
|
||||
t.Skip("skipping due to flakiness: see #6956")
|
||||
|
||||
kit.QuietMiningLogs()
|
||||
|
@ -49,7 +49,6 @@ func TestPublishDealsBatching(t *testing.T) {
|
||||
DisableOwnerFallback: true,
|
||||
DisableWorkerFallback: true,
|
||||
})),
|
||||
kit.LatestActorsAt(-1),
|
||||
)
|
||||
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.Account(publisherKey, types.FromFil(10)), kit.MockProofs(), kit.ConstructorOpts(opts))
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
|
||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/wallet"
|
||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||
@ -114,6 +115,7 @@ type Ensemble struct {
|
||||
bms map[*TestMiner]*BlockMiner
|
||||
}
|
||||
genesis struct {
|
||||
version network.Version
|
||||
miners []genesis.Miner
|
||||
accounts []genesis.Actor
|
||||
}
|
||||
@ -130,6 +132,12 @@ func NewEnsemble(t *testing.T, opts ...EnsembleOpt) *Ensemble {
|
||||
n := &Ensemble{t: t, options: &options}
|
||||
n.active.bms = make(map[*TestMiner]*BlockMiner)
|
||||
|
||||
for _, up := range options.upgradeSchedule {
|
||||
if up.Height < 0 {
|
||||
n.genesis.version = up.Network
|
||||
}
|
||||
}
|
||||
|
||||
// add accounts from ensemble options to genesis.
|
||||
for _, acc := range options.accounts {
|
||||
n.genesis.accounts = append(n.genesis.accounts, genesis.Actor{
|
||||
@ -173,7 +181,7 @@ func (n *Ensemble) FullNode(full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
||||
|
||||
// Miner enrolls a new miner, using the provided full node for chain
|
||||
// interactions.
|
||||
func (n *Ensemble) Miner(miner *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
||||
func (n *Ensemble) Miner(minerNode *TestMiner, full *TestFullNode, opts ...NodeOpt) *Ensemble {
|
||||
require.NotNil(n.t, full, "full node required when instantiating miner")
|
||||
|
||||
options := DefaultNodeOpts
|
||||
@ -208,11 +216,15 @@ func (n *Ensemble) Miner(miner *TestMiner, full *TestFullNode, opts ...NodeOpt)
|
||||
genm *genesis.Miner
|
||||
)
|
||||
|
||||
// Default 2KiB sector for the network version
|
||||
proofType, err := miner.SealProofTypeFromSectorSize(2<<10, n.genesis.version)
|
||||
require.NoError(n.t, err)
|
||||
|
||||
// create the preseal commitment.
|
||||
if n.options.mockProofs {
|
||||
genm, k, err = mockstorage.PreSeal(abi.RegisteredSealProof_StackedDrg2KiBV1, actorAddr, sectors)
|
||||
genm, k, err = mockstorage.PreSeal(proofType, actorAddr, sectors)
|
||||
} else {
|
||||
genm, k, err = seed.PreSeal(actorAddr, abi.RegisteredSealProof_StackedDrg2KiBV1, 0, sectors, tdir, []byte("make genesis mem random"), nil, true)
|
||||
genm, k, err = seed.PreSeal(actorAddr, proofType, 0, sectors, tdir, []byte("make genesis mem random"), nil, true)
|
||||
}
|
||||
require.NoError(n.t, err)
|
||||
|
||||
@ -237,7 +249,7 @@ func (n *Ensemble) Miner(miner *TestMiner, full *TestFullNode, opts ...NodeOpt)
|
||||
rl, err := net.Listen("tcp", "127.0.0.1:")
|
||||
require.NoError(n.t, err)
|
||||
|
||||
*miner = TestMiner{
|
||||
*minerNode = TestMiner{
|
||||
t: n.t,
|
||||
ActorAddr: actorAddr,
|
||||
OwnerKey: ownerKey,
|
||||
@ -247,10 +259,10 @@ func (n *Ensemble) Miner(miner *TestMiner, full *TestFullNode, opts ...NodeOpt)
|
||||
RemoteListener: rl,
|
||||
}
|
||||
|
||||
miner.Libp2p.PeerID = peerId
|
||||
miner.Libp2p.PrivKey = privkey
|
||||
minerNode.Libp2p.PeerID = peerId
|
||||
minerNode.Libp2p.PrivKey = privkey
|
||||
|
||||
n.inactive.miners = append(n.inactive.miners, miner)
|
||||
n.inactive.miners = append(n.inactive.miners, minerNode)
|
||||
|
||||
return n
|
||||
}
|
||||
@ -283,6 +295,9 @@ func (n *Ensemble) Start() *Ensemble {
|
||||
|
||||
// so that we subscribe to pubsub topics immediately
|
||||
node.Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(true)),
|
||||
|
||||
// upgrades
|
||||
node.Override(new(stmgr.UpgradeSchedule), n.options.upgradeSchedule),
|
||||
}
|
||||
|
||||
// append any node builder options.
|
||||
@ -510,6 +525,9 @@ func (n *Ensemble) Start() *Ensemble {
|
||||
scfg.Storage.ResourceFiltering = sectorstorage.ResourceFilteringDisabled
|
||||
return scfg.Storage
|
||||
}),
|
||||
|
||||
// upgrades
|
||||
node.Override(new(stmgr.UpgradeSchedule), n.options.upgradeSchedule),
|
||||
}
|
||||
|
||||
// append any node builder options.
|
||||
@ -693,7 +711,7 @@ func (n *Ensemble) generateGenesis() *genesis.Template {
|
||||
}
|
||||
|
||||
templ := &genesis.Template{
|
||||
NetworkVersion: network.Version0,
|
||||
NetworkVersion: n.genesis.version,
|
||||
Accounts: n.genesis.accounts,
|
||||
Miners: n.genesis.miners,
|
||||
NetworkName: "test",
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
"github.com/filecoin-project/lotus/chain/wallet"
|
||||
)
|
||||
|
||||
@ -19,10 +21,16 @@ type ensembleOpts struct {
|
||||
verifiedRoot genesisAccount
|
||||
accounts []genesisAccount
|
||||
mockProofs bool
|
||||
|
||||
upgradeSchedule stmgr.UpgradeSchedule
|
||||
}
|
||||
|
||||
var DefaultEnsembleOpts = ensembleOpts{
|
||||
pastOffset: 10000000 * time.Second, // time sufficiently in the past to trigger catch-up mining.
|
||||
upgradeSchedule: stmgr.UpgradeSchedule{{
|
||||
Height: -1,
|
||||
Network: build.NewestNetworkVersion,
|
||||
}},
|
||||
}
|
||||
|
||||
// MockProofs activates mock proofs for the entire ensemble.
|
||||
|
58
itests/kit/ensemble_opts_nv.go
Normal file
58
itests/kit/ensemble_opts_nv.go
Normal file
@ -0,0 +1,58 @@
|
||||
package kit
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
)
|
||||
|
||||
func UpgradeSchedule(upgrades ...stmgr.Upgrade) EnsembleOpt {
|
||||
return func(opts *ensembleOpts) error {
|
||||
opts.upgradeSchedule = upgrades
|
||||
return opts.upgradeSchedule.Validate()
|
||||
}
|
||||
}
|
||||
|
||||
// GenesisNetworkVersion sets the network version of genesis.
|
||||
func GenesisNetworkVersion(nv network.Version) EnsembleOpt {
|
||||
return UpgradeSchedule(stmgr.Upgrade{
|
||||
Network: nv,
|
||||
Height: -1,
|
||||
})
|
||||
}
|
||||
|
||||
func SDRUpgradeAt(calico, persian abi.ChainEpoch) EnsembleOpt {
|
||||
return UpgradeSchedule(stmgr.Upgrade{
|
||||
Network: network.Version6,
|
||||
Height: -1,
|
||||
}, stmgr.Upgrade{
|
||||
Network: network.Version7,
|
||||
Height: calico,
|
||||
Migration: stmgr.UpgradeCalico,
|
||||
}, stmgr.Upgrade{
|
||||
Network: network.Version8,
|
||||
Height: persian,
|
||||
})
|
||||
}
|
||||
|
||||
func LatestActorsAt(upgradeHeight abi.ChainEpoch) EnsembleOpt {
|
||||
return UpgradeSchedule(stmgr.Upgrade{
|
||||
Network: network.Version12,
|
||||
Height: -1,
|
||||
}, stmgr.Upgrade{
|
||||
Network: network.Version13,
|
||||
Height: upgradeHeight,
|
||||
Migration: stmgr.UpgradeActorsV5,
|
||||
})
|
||||
}
|
||||
|
||||
func TurboUpgradeAt(upgradeHeight abi.ChainEpoch) EnsembleOpt {
|
||||
return UpgradeSchedule(stmgr.Upgrade{
|
||||
Network: network.Version11,
|
||||
Height: -1,
|
||||
}, stmgr.Upgrade{
|
||||
Network: network.Version12,
|
||||
Height: upgradeHeight,
|
||||
Migration: stmgr.UpgradeActorsV4,
|
||||
})
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package kit
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/node"
|
||||
"github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
// DefaultTestUpgradeSchedule
|
||||
var DefaultTestUpgradeSchedule = stmgr.UpgradeSchedule{{
|
||||
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,
|
||||
}}
|
||||
|
||||
func LatestActorsAt(upgradeHeight abi.ChainEpoch) node.Option {
|
||||
// Attention: Update this when introducing new actor versions or your tests will be sad
|
||||
return NetworkUpgradeAt(network.Version13, upgradeHeight)
|
||||
}
|
||||
|
||||
// InstantaneousNetworkVersion starts the network instantaneously at the
|
||||
// specified version in height 1.
|
||||
func InstantaneousNetworkVersion(version network.Version) node.Option {
|
||||
// composes all migration functions
|
||||
var mf stmgr.MigrationFunc = func(ctx context.Context, sm *stmgr.StateManager, cache stmgr.MigrationCache, cb stmgr.ExecMonitor, oldState cid.Cid, height abi.ChainEpoch, ts *types.TipSet) (newState cid.Cid, err error) {
|
||||
var state = oldState
|
||||
for _, u := range DefaultTestUpgradeSchedule {
|
||||
if u.Network > version {
|
||||
break
|
||||
}
|
||||
state, err = u.Migration(ctx, sm, cache, cb, state, height, ts)
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
}
|
||||
}
|
||||
return state, nil
|
||||
}
|
||||
return node.Override(new(stmgr.UpgradeSchedule), stmgr.UpgradeSchedule{
|
||||
{Network: version, Height: 1, Migration: mf},
|
||||
})
|
||||
}
|
||||
|
||||
func NetworkUpgradeAt(version network.Version, upgradeHeight abi.ChainEpoch) node.Option {
|
||||
schedule := stmgr.UpgradeSchedule{}
|
||||
for _, upgrade := range DefaultTestUpgradeSchedule {
|
||||
if upgrade.Network > version {
|
||||
break
|
||||
}
|
||||
|
||||
schedule = append(schedule, upgrade)
|
||||
}
|
||||
|
||||
if upgradeHeight > 0 {
|
||||
schedule[len(schedule)-1].Height = upgradeHeight
|
||||
}
|
||||
|
||||
return node.Override(new(stmgr.UpgradeSchedule), schedule)
|
||||
}
|
||||
|
||||
func SDRUpgradeAt(calico, persian abi.ChainEpoch) node.Option {
|
||||
return node.Override(new(stmgr.UpgradeSchedule), stmgr.UpgradeSchedule{{
|
||||
Network: network.Version6,
|
||||
Height: 1,
|
||||
Migration: stmgr.UpgradeActorsV2,
|
||||
}, {
|
||||
Network: network.Version7,
|
||||
Height: calico,
|
||||
Migration: stmgr.UpgradeCalico,
|
||||
}, {
|
||||
Network: network.Version8,
|
||||
Height: persian,
|
||||
}})
|
||||
}
|
@ -30,8 +30,10 @@ func TestSDRUpgrade(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(kit.SDRUpgradeAt(500, 1000))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t,
|
||||
kit.MockProofs(),
|
||||
kit.SDRUpgradeAt(500, 1000),
|
||||
)
|
||||
ens.InterconnectAll()
|
||||
|
||||
build.Clock.Sleep(time.Second)
|
||||
|
@ -30,7 +30,6 @@ func TestMinerBalanceCollateral(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(
|
||||
kit.LatestActorsAt(-1),
|
||||
node.ApplyIf(node.IsType(repo.StorageMiner), node.Override(new(dtypes.GetSealingConfigFunc), func() (dtypes.GetSealingConfigFunc, error) {
|
||||
return func() (sealiface.Config, error) {
|
||||
return sealiface.Config{
|
||||
@ -59,6 +58,7 @@ func TestMinerBalanceCollateral(t *testing.T) {
|
||||
})),
|
||||
)
|
||||
full, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
full.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/itests/kit"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -59,8 +60,7 @@ func TestPledgeBatching(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
|
||||
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
||||
@ -117,8 +117,7 @@ func TestPledgeMaxBatching(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
||||
client, full, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs(), opts)
|
||||
_, full, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs())
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
m, ok := miner.StorageMiner.(*impl.StorageMinerAPI)
|
||||
require.True(t, ok)
|
||||
@ -127,8 +126,6 @@ func TestPledgeMaxBatching(t *testing.T) {
|
||||
cfg.MinCommitBatch = miner5.MaxAggregatedSectors
|
||||
require.NoError(t, m.SetSealingConfigFunc(cfg))
|
||||
|
||||
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
||||
|
||||
toCheck := miner.StartPledge(ctx, nSectors, 0, nil)
|
||||
var lastSectorNo abi.SectorNumber
|
||||
|
||||
@ -191,8 +188,8 @@ func TestPledgeBeforeNv13(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(1000000000))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
|
||||
kit.GenesisNetworkVersion(network.Version12))
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
||||
|
@ -24,8 +24,7 @@ func TestTerminate(t *testing.T) {
|
||||
ctx = context.Background()
|
||||
)
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.PresealSectors(nSectors), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.PresealSectors(nSectors))
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
maddr, err := miner.ActorAddress(ctx)
|
||||
@ -50,7 +49,7 @@ func TestTerminate(t *testing.T) {
|
||||
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||
require.NoError(t, err)
|
||||
|
||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod + 20 // 20 is some slack for the proof to be submitted + applied
|
||||
waitUntil := di.Open + di.WPoStProvingPeriod
|
||||
t.Logf("End for head.Height > %d", waitUntil)
|
||||
|
||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
@ -62,7 +61,7 @@ func TestTerminate(t *testing.T) {
|
||||
p, err = client.StateMinerPower(ctx, maddr, types.EmptyTSK)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, p.MinerPower, p.TotalPower)
|
||||
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(nSectors)))
|
||||
require.Equal(t, types.NewInt(uint64(ssz)*uint64(nSectors)), p.MinerPower.RawBytePower)
|
||||
|
||||
t.Log("Terminate a sector")
|
||||
|
||||
|
@ -8,10 +8,8 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||
"github.com/filecoin-project/lotus/itests/kit"
|
||||
"github.com/filecoin-project/lotus/node"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -30,20 +28,12 @@ func testTapeFix(t *testing.T, blocktime time.Duration, after bool) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
upgradeSchedule := stmgr.UpgradeSchedule{{
|
||||
Network: build.ActorUpgradeNetworkVersion,
|
||||
Height: 1,
|
||||
Migration: stmgr.UpgradeActorsV2,
|
||||
}}
|
||||
networkVersion := network.Version4
|
||||
if after {
|
||||
upgradeSchedule = append(upgradeSchedule, stmgr.Upgrade{
|
||||
Network: network.Version5,
|
||||
Height: 2,
|
||||
})
|
||||
networkVersion = network.Version5
|
||||
}
|
||||
|
||||
nopts := kit.ConstructorOpts(node.Override(new(stmgr.UpgradeSchedule), upgradeSchedule))
|
||||
_, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), nopts)
|
||||
_, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(networkVersion))
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
sid, err := miner.PledgeSector(ctx)
|
||||
|
@ -42,7 +42,7 @@ func TestVerifiedClientTopUp(t *testing.T) {
|
||||
node, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
|
||||
kit.RootVerifier(rootKey, abi.NewTokenAmount(bal.Int64())),
|
||||
kit.Account(verifierKey, abi.NewTokenAmount(bal.Int64())), // assign some balance to the verifier so they can send an AddClient message.
|
||||
kit.ConstructorOpts(kit.InstantaneousNetworkVersion(nv)))
|
||||
kit.GenesisNetworkVersion(nv))
|
||||
|
||||
ens.InterconnectAll().BeginMining(blockTime)
|
||||
|
||||
|
@ -39,8 +39,7 @@ func TestWindowPostDispute(t *testing.T) {
|
||||
// it doesn't submit proofs.
|
||||
//
|
||||
// Then we're going to manually submit bad proofs.
|
||||
opts := []kit.NodeOpt{kit.ConstructorOpts(kit.LatestActorsAt(-1))}
|
||||
opts = append(opts, kit.WithAllSubsystems())
|
||||
opts := []kit.NodeOpt{kit.WithAllSubsystems()}
|
||||
ens := kit.NewEnsemble(t, kit.MockProofs()).
|
||||
FullNode(&client, opts...).
|
||||
Miner(&chainMiner, &client, opts...).
|
||||
@ -220,8 +219,7 @@ func TestWindowPostDisputeFails(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
defaultFrom, err := client.WalletDefaultAddress(ctx)
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@ -47,8 +48,9 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(upgradeHeight))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t,
|
||||
kit.MockProofs(),
|
||||
kit.LatestActorsAt(upgradeHeight))
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
miner.PledgeSectors(ctx, nSectors, 0, nil)
|
||||
@ -63,7 +65,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Log("Running one proving period")
|
||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod + 2
|
||||
waitUntil := di.Open + di.WPoStProvingPeriod
|
||||
t.Logf("End for head.Height > %d", waitUntil)
|
||||
|
||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
@ -139,7 +141,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Log("Go through another PP, wait for sectors to become faulty")
|
||||
waitUntil = di.PeriodStart + di.WPoStProvingPeriod + 2
|
||||
waitUntil = di.Open + di.WPoStProvingPeriod
|
||||
t.Logf("End for head.Height > %d", waitUntil)
|
||||
|
||||
ts = client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
@ -161,7 +163,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
|
||||
di, err = client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||
require.NoError(t, err)
|
||||
|
||||
waitUntil = di.PeriodStart + di.WPoStProvingPeriod + 2
|
||||
waitUntil = di.Open + di.WPoStProvingPeriod
|
||||
t.Logf("End for head.Height > %d", waitUntil)
|
||||
|
||||
ts = client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
@ -184,7 +186,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
|
||||
di, err = client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||
require.NoError(t, err)
|
||||
|
||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod + 2
|
||||
waitUntil := di.Open + di.WPoStProvingPeriod
|
||||
t.Logf("End for head.Height > %d\n", waitUntil)
|
||||
|
||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||
@ -213,18 +215,13 @@ func TestWindowPostBaseFeeNoBurn(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
sched := kit.DefaultTestUpgradeSchedule
|
||||
lastUpgradeHeight := sched[len(sched)-1].Height
|
||||
|
||||
och := build.UpgradeClausHeight
|
||||
build.UpgradeClausHeight = lastUpgradeHeight + 1
|
||||
build.UpgradeClausHeight = 0
|
||||
t.Cleanup(func() { build.UpgradeClausHeight = och })
|
||||
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(network.Version9))
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
// Wait till all upgrades are done and we've passed the clause epoch.
|
||||
client.WaitTillChain(ctx, kit.HeightAtLeast(build.UpgradeClausHeight+1))
|
||||
|
||||
maddr, err := miner.ActorAddress(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -256,8 +253,6 @@ waitForProof:
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, pmr.GasCost.BaseFeeBurn, big.Zero())
|
||||
|
||||
build.UpgradeClausHeight = och
|
||||
}
|
||||
|
||||
func TestWindowPostBaseFeeBurn(t *testing.T) {
|
||||
@ -270,16 +265,9 @@ func TestWindowPostBaseFeeBurn(t *testing.T) {
|
||||
|
||||
blocktime := 2 * time.Millisecond
|
||||
|
||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||
ens.InterconnectAll().BeginMining(blocktime)
|
||||
|
||||
// Ideally we'd be a bit more precise here, but getting the information we need from the
|
||||
// test framework is more work than it's worth.
|
||||
//
|
||||
// We just need to wait till all upgrades are done.
|
||||
client.WaitTillChain(ctx, kit.HeightAtLeast(20))
|
||||
|
||||
maddr, err := miner.ActorAddress(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user