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 AllowableClockDriftSecs = uint64(1)
|
||||||
const NewestNetworkVersion = network.Version13
|
const NewestNetworkVersion = network.Version13
|
||||||
const ActorUpgradeNetworkVersion = network.Version4
|
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const ForkLengthThreshold = Finality
|
const ForkLengthThreshold = Finality
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
@ -34,9 +33,7 @@ func TestWorkerKeyChange(t *testing.T) {
|
|||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
blocktime := 1 * time.Millisecond
|
blocktime := 1 * time.Millisecond
|
||||||
client1, client2, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs(),
|
client1, client2, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs())
|
||||||
kit.ConstructorOpts(kit.InstantaneousNetworkVersion(network.Version13)),
|
|
||||||
)
|
|
||||||
ens.InterconnectAll().BeginMining(blocktime)
|
ens.InterconnectAll().BeginMining(blocktime)
|
||||||
|
|
||||||
output := bytes.NewBuffer(nil)
|
output := bytes.NewBuffer(nil)
|
||||||
|
@ -186,7 +186,7 @@ func (ts *apiSuite) testNonGenesisMiner(t *testing.T) {
|
|||||||
var newMiner kit.TestMiner
|
var newMiner kit.TestMiner
|
||||||
ens.Miner(&newMiner, full,
|
ens.Miner(&newMiner, full,
|
||||||
kit.OwnerAddr(full.DefaultKey),
|
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(),
|
kit.WithAllSubsystems(),
|
||||||
).Start().InterconnectAll()
|
).Start().InterconnectAll()
|
||||||
|
|
||||||
|
@ -17,10 +17,9 @@ func TestCCUpgrade(t *testing.T) {
|
|||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
|
||||||
for _, height := range []abi.ChainEpoch{
|
for _, height := range []abi.ChainEpoch{
|
||||||
-1, // before
|
-1, // before
|
||||||
162, // while sealing
|
162, // while sealing
|
||||||
530, // after upgrade deal
|
560, // after upgrade deal
|
||||||
5000, // after
|
|
||||||
} {
|
} {
|
||||||
height := height // make linters happy by copying
|
height := height // make linters happy by copying
|
||||||
t.Run(fmt.Sprintf("upgrade-%d", height), func(t *testing.T) {
|
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()
|
ctx := context.Background()
|
||||||
blockTime := 5 * time.Millisecond
|
blockTime := 5 * time.Millisecond
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(upgradeHeight))
|
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.LatestActorsAt(upgradeHeight))
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
maddr, err := miner.ActorAddress(ctx)
|
maddr, err := miner.ActorAddress(ctx)
|
||||||
|
@ -75,9 +75,8 @@ func TestDeadlineToggling(t *testing.T) {
|
|||||||
minerD kit.TestMiner
|
minerD kit.TestMiner
|
||||||
minerE kit.TestMiner
|
minerE kit.TestMiner
|
||||||
)
|
)
|
||||||
opts := []kit.NodeOpt{kit.ConstructorOpts(kit.NetworkUpgradeAt(network.Version12, upgradeH))}
|
opts := []kit.NodeOpt{kit.WithAllSubsystems()}
|
||||||
opts = append(opts, kit.WithAllSubsystems())
|
ens := kit.NewEnsemble(t, kit.MockProofs(), kit.TurboUpgradeAt(upgradeH)).
|
||||||
ens := kit.NewEnsemble(t, kit.MockProofs()).
|
|
||||||
FullNode(&client, opts...).
|
FullNode(&client, opts...).
|
||||||
Miner(&minerA, &client, opts...).
|
Miner(&minerA, &client, opts...).
|
||||||
Start().
|
Start().
|
||||||
|
@ -27,6 +27,7 @@ func TestDealWithMarketAndMinerNode(t *testing.T) {
|
|||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping test in short mode")
|
t.Skip("skipping test in short mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Skip("skipping due to flakiness: see #6956")
|
t.Skip("skipping due to flakiness: see #6956")
|
||||||
|
|
||||||
kit.QuietMiningLogs()
|
kit.QuietMiningLogs()
|
||||||
|
@ -49,7 +49,6 @@ func TestPublishDealsBatching(t *testing.T) {
|
|||||||
DisableOwnerFallback: true,
|
DisableOwnerFallback: true,
|
||||||
DisableWorkerFallback: true,
|
DisableWorkerFallback: true,
|
||||||
})),
|
})),
|
||||||
kit.LatestActorsAt(-1),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.Account(publisherKey, types.FromFil(10)), kit.MockProofs(), kit.ConstructorOpts(opts))
|
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"
|
"github.com/filecoin-project/lotus/chain/gen"
|
||||||
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
|
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
|
||||||
"github.com/filecoin-project/lotus/chain/messagepool"
|
"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/types"
|
||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||||
@ -114,6 +115,7 @@ type Ensemble struct {
|
|||||||
bms map[*TestMiner]*BlockMiner
|
bms map[*TestMiner]*BlockMiner
|
||||||
}
|
}
|
||||||
genesis struct {
|
genesis struct {
|
||||||
|
version network.Version
|
||||||
miners []genesis.Miner
|
miners []genesis.Miner
|
||||||
accounts []genesis.Actor
|
accounts []genesis.Actor
|
||||||
}
|
}
|
||||||
@ -130,6 +132,12 @@ func NewEnsemble(t *testing.T, opts ...EnsembleOpt) *Ensemble {
|
|||||||
n := &Ensemble{t: t, options: &options}
|
n := &Ensemble{t: t, options: &options}
|
||||||
n.active.bms = make(map[*TestMiner]*BlockMiner)
|
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.
|
// add accounts from ensemble options to genesis.
|
||||||
for _, acc := range options.accounts {
|
for _, acc := range options.accounts {
|
||||||
n.genesis.accounts = append(n.genesis.accounts, genesis.Actor{
|
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
|
// Miner enrolls a new miner, using the provided full node for chain
|
||||||
// interactions.
|
// 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")
|
require.NotNil(n.t, full, "full node required when instantiating miner")
|
||||||
|
|
||||||
options := DefaultNodeOpts
|
options := DefaultNodeOpts
|
||||||
@ -208,11 +216,15 @@ func (n *Ensemble) Miner(miner *TestMiner, full *TestFullNode, opts ...NodeOpt)
|
|||||||
genm *genesis.Miner
|
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.
|
// create the preseal commitment.
|
||||||
if n.options.mockProofs {
|
if n.options.mockProofs {
|
||||||
genm, k, err = mockstorage.PreSeal(abi.RegisteredSealProof_StackedDrg2KiBV1, actorAddr, sectors)
|
genm, k, err = mockstorage.PreSeal(proofType, actorAddr, sectors)
|
||||||
} else {
|
} 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)
|
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:")
|
rl, err := net.Listen("tcp", "127.0.0.1:")
|
||||||
require.NoError(n.t, err)
|
require.NoError(n.t, err)
|
||||||
|
|
||||||
*miner = TestMiner{
|
*minerNode = TestMiner{
|
||||||
t: n.t,
|
t: n.t,
|
||||||
ActorAddr: actorAddr,
|
ActorAddr: actorAddr,
|
||||||
OwnerKey: ownerKey,
|
OwnerKey: ownerKey,
|
||||||
@ -247,10 +259,10 @@ func (n *Ensemble) Miner(miner *TestMiner, full *TestFullNode, opts ...NodeOpt)
|
|||||||
RemoteListener: rl,
|
RemoteListener: rl,
|
||||||
}
|
}
|
||||||
|
|
||||||
miner.Libp2p.PeerID = peerId
|
minerNode.Libp2p.PeerID = peerId
|
||||||
miner.Libp2p.PrivKey = privkey
|
minerNode.Libp2p.PrivKey = privkey
|
||||||
|
|
||||||
n.inactive.miners = append(n.inactive.miners, miner)
|
n.inactive.miners = append(n.inactive.miners, minerNode)
|
||||||
|
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
@ -283,6 +295,9 @@ func (n *Ensemble) Start() *Ensemble {
|
|||||||
|
|
||||||
// so that we subscribe to pubsub topics immediately
|
// so that we subscribe to pubsub topics immediately
|
||||||
node.Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(true)),
|
node.Override(new(dtypes.Bootstrapper), dtypes.Bootstrapper(true)),
|
||||||
|
|
||||||
|
// upgrades
|
||||||
|
node.Override(new(stmgr.UpgradeSchedule), n.options.upgradeSchedule),
|
||||||
}
|
}
|
||||||
|
|
||||||
// append any node builder options.
|
// append any node builder options.
|
||||||
@ -510,6 +525,9 @@ func (n *Ensemble) Start() *Ensemble {
|
|||||||
scfg.Storage.ResourceFiltering = sectorstorage.ResourceFilteringDisabled
|
scfg.Storage.ResourceFiltering = sectorstorage.ResourceFilteringDisabled
|
||||||
return scfg.Storage
|
return scfg.Storage
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// upgrades
|
||||||
|
node.Override(new(stmgr.UpgradeSchedule), n.options.upgradeSchedule),
|
||||||
}
|
}
|
||||||
|
|
||||||
// append any node builder options.
|
// append any node builder options.
|
||||||
@ -693,7 +711,7 @@ func (n *Ensemble) generateGenesis() *genesis.Template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
templ := &genesis.Template{
|
templ := &genesis.Template{
|
||||||
NetworkVersion: network.Version0,
|
NetworkVersion: n.genesis.version,
|
||||||
Accounts: n.genesis.accounts,
|
Accounts: n.genesis.accounts,
|
||||||
Miners: n.genesis.miners,
|
Miners: n.genesis.miners,
|
||||||
NetworkName: "test",
|
NetworkName: "test",
|
||||||
|
@ -4,6 +4,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"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"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,10 +21,16 @@ type ensembleOpts struct {
|
|||||||
verifiedRoot genesisAccount
|
verifiedRoot genesisAccount
|
||||||
accounts []genesisAccount
|
accounts []genesisAccount
|
||||||
mockProofs bool
|
mockProofs bool
|
||||||
|
|
||||||
|
upgradeSchedule stmgr.UpgradeSchedule
|
||||||
}
|
}
|
||||||
|
|
||||||
var DefaultEnsembleOpts = ensembleOpts{
|
var DefaultEnsembleOpts = ensembleOpts{
|
||||||
pastOffset: 10000000 * time.Second, // time sufficiently in the past to trigger catch-up mining.
|
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.
|
// 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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.SDRUpgradeAt(500, 1000))
|
client, miner, ens := kit.EnsembleMinimal(t,
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
kit.MockProofs(),
|
||||||
|
kit.SDRUpgradeAt(500, 1000),
|
||||||
|
)
|
||||||
ens.InterconnectAll()
|
ens.InterconnectAll()
|
||||||
|
|
||||||
build.Clock.Sleep(time.Second)
|
build.Clock.Sleep(time.Second)
|
||||||
|
@ -30,7 +30,6 @@ func TestMinerBalanceCollateral(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(
|
opts := kit.ConstructorOpts(
|
||||||
kit.LatestActorsAt(-1),
|
|
||||||
node.ApplyIf(node.IsType(repo.StorageMiner), node.Override(new(dtypes.GetSealingConfigFunc), func() (dtypes.GetSealingConfigFunc, error) {
|
node.ApplyIf(node.IsType(repo.StorageMiner), node.Override(new(dtypes.GetSealingConfigFunc), func() (dtypes.GetSealingConfigFunc, error) {
|
||||||
return func() (sealiface.Config, error) {
|
return func() (sealiface.Config, error) {
|
||||||
return sealiface.Config{
|
return sealiface.Config{
|
||||||
@ -59,6 +58,7 @@ func TestMinerBalanceCollateral(t *testing.T) {
|
|||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
full, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
full, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
||||||
|
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
full.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
full.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"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/filecoin-project/lotus/itests/kit"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -59,8 +60,7 @@ func TestPledgeBatching(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
||||||
@ -117,8 +117,7 @@ func TestPledgeMaxBatching(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
_, full, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs())
|
||||||
client, full, miner, ens := kit.EnsembleTwoOne(t, kit.MockProofs(), opts)
|
|
||||||
ens.InterconnectAll().BeginMining(blockTime)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
m, ok := miner.StorageMiner.(*impl.StorageMinerAPI)
|
m, ok := miner.StorageMiner.(*impl.StorageMinerAPI)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
@ -127,8 +126,6 @@ func TestPledgeMaxBatching(t *testing.T) {
|
|||||||
cfg.MinCommitBatch = miner5.MaxAggregatedSectors
|
cfg.MinCommitBatch = miner5.MaxAggregatedSectors
|
||||||
require.NoError(t, m.SetSealingConfigFunc(cfg))
|
require.NoError(t, m.SetSealingConfigFunc(cfg))
|
||||||
|
|
||||||
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
|
||||||
|
|
||||||
toCheck := miner.StartPledge(ctx, nSectors, 0, nil)
|
toCheck := miner.StartPledge(ctx, nSectors, 0, nil)
|
||||||
var lastSectorNo abi.SectorNumber
|
var lastSectorNo abi.SectorNumber
|
||||||
|
|
||||||
@ -191,8 +188,8 @@ func TestPledgeBeforeNv13(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(1000000000))
|
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
kit.GenesisNetworkVersion(network.Version12))
|
||||||
ens.InterconnectAll().BeginMining(blocktime)
|
ens.InterconnectAll().BeginMining(blocktime)
|
||||||
|
|
||||||
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
client.WaitTillChain(ctx, kit.HeightAtLeast(10))
|
||||||
|
@ -24,8 +24,7 @@ func TestTerminate(t *testing.T) {
|
|||||||
ctx = context.Background()
|
ctx = context.Background()
|
||||||
)
|
)
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.PresealSectors(nSectors))
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.PresealSectors(nSectors), opts)
|
|
||||||
ens.InterconnectAll().BeginMining(blocktime)
|
ens.InterconnectAll().BeginMining(blocktime)
|
||||||
|
|
||||||
maddr, err := miner.ActorAddress(ctx)
|
maddr, err := miner.ActorAddress(ctx)
|
||||||
@ -50,7 +49,7 @@ func TestTerminate(t *testing.T) {
|
|||||||
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
di, err := client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||||
require.NoError(t, err)
|
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)
|
t.Logf("End for head.Height > %d", waitUntil)
|
||||||
|
|
||||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(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)
|
p, err = client.StateMinerPower(ctx, maddr, types.EmptyTSK)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, p.MinerPower, p.TotalPower)
|
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")
|
t.Log("Terminate a sector")
|
||||||
|
|
||||||
|
@ -8,10 +8,8 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
|
||||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||||
"github.com/filecoin-project/lotus/itests/kit"
|
"github.com/filecoin-project/lotus/itests/kit"
|
||||||
"github.com/filecoin-project/lotus/node"
|
|
||||||
"github.com/stretchr/testify/require"
|
"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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
upgradeSchedule := stmgr.UpgradeSchedule{{
|
networkVersion := network.Version4
|
||||||
Network: build.ActorUpgradeNetworkVersion,
|
|
||||||
Height: 1,
|
|
||||||
Migration: stmgr.UpgradeActorsV2,
|
|
||||||
}}
|
|
||||||
if after {
|
if after {
|
||||||
upgradeSchedule = append(upgradeSchedule, stmgr.Upgrade{
|
networkVersion = network.Version5
|
||||||
Network: network.Version5,
|
|
||||||
Height: 2,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nopts := kit.ConstructorOpts(node.Override(new(stmgr.UpgradeSchedule), upgradeSchedule))
|
_, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), kit.GenesisNetworkVersion(networkVersion))
|
||||||
_, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), nopts)
|
|
||||||
ens.InterconnectAll().BeginMining(blocktime)
|
ens.InterconnectAll().BeginMining(blocktime)
|
||||||
|
|
||||||
sid, err := miner.PledgeSector(ctx)
|
sid, err := miner.PledgeSector(ctx)
|
||||||
|
@ -42,7 +42,7 @@ func TestVerifiedClientTopUp(t *testing.T) {
|
|||||||
node, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
|
node, _, ens := kit.EnsembleMinimal(t, kit.MockProofs(),
|
||||||
kit.RootVerifier(rootKey, abi.NewTokenAmount(bal.Int64())),
|
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.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)
|
ens.InterconnectAll().BeginMining(blockTime)
|
||||||
|
|
||||||
|
@ -39,8 +39,7 @@ func TestWindowPostDispute(t *testing.T) {
|
|||||||
// it doesn't submit proofs.
|
// it doesn't submit proofs.
|
||||||
//
|
//
|
||||||
// Then we're going to manually submit bad proofs.
|
// Then we're going to manually submit bad proofs.
|
||||||
opts := []kit.NodeOpt{kit.ConstructorOpts(kit.LatestActorsAt(-1))}
|
opts := []kit.NodeOpt{kit.WithAllSubsystems()}
|
||||||
opts = append(opts, kit.WithAllSubsystems())
|
|
||||||
ens := kit.NewEnsemble(t, kit.MockProofs()).
|
ens := kit.NewEnsemble(t, kit.MockProofs()).
|
||||||
FullNode(&client, opts...).
|
FullNode(&client, opts...).
|
||||||
Miner(&chainMiner, &client, opts...).
|
Miner(&chainMiner, &client, opts...).
|
||||||
@ -220,8 +219,7 @@ func TestWindowPostDisputeFails(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
|
||||||
ens.InterconnectAll().BeginMining(blocktime)
|
ens.InterconnectAll().BeginMining(blocktime)
|
||||||
|
|
||||||
defaultFrom, err := client.WalletDefaultAddress(ctx)
|
defaultFrom, err := client.WalletDefaultAddress(ctx)
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"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/specs-storage/storage"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"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())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(upgradeHeight))
|
client, miner, ens := kit.EnsembleMinimal(t,
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
kit.MockProofs(),
|
||||||
|
kit.LatestActorsAt(upgradeHeight))
|
||||||
ens.InterconnectAll().BeginMining(blocktime)
|
ens.InterconnectAll().BeginMining(blocktime)
|
||||||
|
|
||||||
miner.PledgeSectors(ctx, nSectors, 0, nil)
|
miner.PledgeSectors(ctx, nSectors, 0, nil)
|
||||||
@ -63,7 +65,7 @@ func testWindowPostUpgrade(t *testing.T, blocktime time.Duration, nSectors int,
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Log("Running one proving period")
|
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)
|
t.Logf("End for head.Height > %d", waitUntil)
|
||||||
|
|
||||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Log("Go through another PP, wait for sectors to become faulty")
|
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)
|
t.Logf("End for head.Height > %d", waitUntil)
|
||||||
|
|
||||||
ts = client.WaitTillChain(ctx, kit.HeightAtLeast(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)
|
di, err = client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
waitUntil = di.PeriodStart + di.WPoStProvingPeriod + 2
|
waitUntil = di.Open + di.WPoStProvingPeriod
|
||||||
t.Logf("End for head.Height > %d", waitUntil)
|
t.Logf("End for head.Height > %d", waitUntil)
|
||||||
|
|
||||||
ts = client.WaitTillChain(ctx, kit.HeightAtLeast(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)
|
di, err = client.StateMinerProvingDeadline(ctx, maddr, types.EmptyTSK)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
waitUntil := di.PeriodStart + di.WPoStProvingPeriod + 2
|
waitUntil := di.Open + di.WPoStProvingPeriod
|
||||||
t.Logf("End for head.Height > %d\n", waitUntil)
|
t.Logf("End for head.Height > %d\n", waitUntil)
|
||||||
|
|
||||||
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
ts := client.WaitTillChain(ctx, kit.HeightAtLeast(waitUntil))
|
||||||
@ -213,18 +215,13 @@ func TestWindowPostBaseFeeNoBurn(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
sched := kit.DefaultTestUpgradeSchedule
|
|
||||||
lastUpgradeHeight := sched[len(sched)-1].Height
|
|
||||||
|
|
||||||
och := build.UpgradeClausHeight
|
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)
|
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)
|
maddr, err := miner.ActorAddress(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -256,8 +253,6 @@ waitForProof:
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.Equal(t, pmr.GasCost.BaseFeeBurn, big.Zero())
|
require.Equal(t, pmr.GasCost.BaseFeeBurn, big.Zero())
|
||||||
|
|
||||||
build.UpgradeClausHeight = och
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWindowPostBaseFeeBurn(t *testing.T) {
|
func TestWindowPostBaseFeeBurn(t *testing.T) {
|
||||||
@ -270,16 +265,9 @@ func TestWindowPostBaseFeeBurn(t *testing.T) {
|
|||||||
|
|
||||||
blocktime := 2 * time.Millisecond
|
blocktime := 2 * time.Millisecond
|
||||||
|
|
||||||
opts := kit.ConstructorOpts(kit.LatestActorsAt(-1))
|
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs())
|
||||||
client, miner, ens := kit.EnsembleMinimal(t, kit.MockProofs(), opts)
|
|
||||||
ens.InterconnectAll().BeginMining(blocktime)
|
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)
|
maddr, err := miner.ActorAddress(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user