Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test with latest actors version #6998

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const UnixfsLinksPerLevel = 1024

const AllowableClockDriftSecs = uint64(1)
const NewestNetworkVersion = network.Version13
const ActorUpgradeNetworkVersion = network.Version4

// Epochs
const ForkLengthThreshold = Finality
Expand Down
72 changes: 42 additions & 30 deletions chain/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,6 @@ import (
"fmt"
"math/rand"

power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power"

reward4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/reward"

market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market"

"github.com/filecoin-project/lotus/chain/actors"

"github.com/filecoin-project/lotus/chain/actors/builtin"

"github.com/filecoin-project/lotus/chain/actors/policy"

"github.com/filecoin-project/lotus/chain/actors/adt"

"github.com/filecoin-project/go-state-types/network"

market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"

"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/reward"

"github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"

"github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
Expand All @@ -39,12 +15,28 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/network"

builtin0 "github.com/filecoin-project/specs-actors/actors/builtin"
market0 "github.com/filecoin-project/specs-actors/actors/builtin/market"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
reward0 "github.com/filecoin-project/specs-actors/actors/builtin/reward"
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
reward2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/reward"
market4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/market"
power4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/power"
reward4 "github.com/filecoin-project/specs-actors/v4/actors/builtin/reward"
runtime5 "github.com/filecoin-project/specs-actors/v5/actors/runtime"

"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin"
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/reward"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -404,8 +396,8 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sys vm.Syscal
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
}

if av > actors.Version2 {
// post v2, we need to explicitly Claim this power since ConfirmSectorProofsValid doesn't do it anymore
if av >= actors.Version2 {
// post v0, we need to explicitly Claim this power since ConfirmSectorProofsValid doesn't do it anymore
claimParams := &power4.UpdateClaimedPowerParams{
RawByteDelta: types.NewInt(uint64(m.SectorSize)),
QualityAdjustedDelta: sectorWeight,
Expand Down Expand Up @@ -537,7 +529,6 @@ func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs [
SectorExpiry: sectorExpiry,
}

var dealWeights market0.VerifyDealsForActivationReturn
ret, err := doExecValue(ctx, vm,
market.Address,
maddr,
Expand All @@ -548,11 +539,23 @@ func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs [
if err != nil {
return big.Zero(), big.Zero(), err
}
if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
var weight, verifiedWeight abi.DealWeight
if av < actors.Version2 {
var dealWeights market0.VerifyDealsForActivationReturn
err = dealWeights.UnmarshalCBOR(bytes.NewReader(ret))
weight = dealWeights.DealWeight
verifiedWeight = dealWeights.VerifiedDealWeight
} else {
var dealWeights market2.VerifyDealsForActivationReturn
err = dealWeights.UnmarshalCBOR(bytes.NewReader(ret))
weight = dealWeights.DealWeight
verifiedWeight = dealWeights.VerifiedDealWeight
}
if err != nil {
return big.Zero(), big.Zero(), err
}

return dealWeights.DealWeight, dealWeights.VerifiedDealWeight, nil
return weight, verifiedWeight, nil
}
params := &market4.VerifyDealsForActivationParams{Sectors: []market4.SectorDeals{{
SectorExpiry: sectorExpiry,
Expand Down Expand Up @@ -584,14 +587,23 @@ func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Addre
}

// TODO: This hack should move to reward actor wrapper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this TODO still represent our current plans? If so I can look into scoping this work on the actors side. However it seems like our idea of this has changed and this is no longer considered a hack. If so let's remove the TODO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would move into the reward actor wrapper. That is, the shim in chain/actors/builtin/reward. We have some abstractions there around message sending.

if av <= actors.Version2 {
switch av {
case actors.Version0:
var epochReward reward0.ThisEpochRewardReturn

if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil {
return big.Zero(), builtin.FilterEstimate{}, err
}

return epochReward.ThisEpochBaselinePower, *epochReward.ThisEpochRewardSmoothed, nil
case actors.Version2:
var epochReward reward2.ThisEpochRewardReturn

if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil {
return big.Zero(), builtin.FilterEstimate{}, err
}

return epochReward.ThisEpochBaselinePower, builtin.FilterEstimate(epochReward.ThisEpochRewardSmoothed), nil
}

var epochReward reward4.ThisEpochRewardReturn
Expand Down
5 changes: 1 addition & 4 deletions cmd/lotus-miner/actor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion itests/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
10 changes: 4 additions & 6 deletions itests/ccupgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ func TestCCUpgrade(t *testing.T) {
kit.QuietMiningLogs()

for _, height := range []abi.ChainEpoch{
-1, // before
162, // while sealing
530, // after upgrade deal
5000, // after
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There wasn't really a point to this. It was just testing with the previous actors version.

-1, // before
162, // while sealing
560, // after upgrade deal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was happening a bit too early and causing a test failure.

} {
height := height // make linters happy by copying
t.Run(fmt.Sprintf("upgrade-%d", height), func(t *testing.T) {
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions itests/deadlines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
1 change: 1 addition & 0 deletions itests/deals_concurrent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion itests/deals_publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
34 changes: 26 additions & 8 deletions itests/kit/ensemble.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -114,6 +115,7 @@ type Ensemble struct {
bms map[*TestMiner]*BlockMiner
}
genesis struct {
version network.Version
miners []genesis.Miner
accounts []genesis.Actor
}
Expand All @@ -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{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -208,11 +216,15 @@ func (n *Ensemble) Miner(miner *TestMiner, full *TestFullNode, opts ...NodeOpt)
genm *genesis.Miner
)

// Default 2KiB sector for the network version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: seems like this should be an ensemble option so the default can be overridden, though maybe this should be left to whoever first wants to use non-2KiB sectors in an itest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm going to leave it to them.

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)

Expand All @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions itests/kit/ensemble_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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{{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the fact that this is so nicely expressed as GenesisNetworkVersion(build.NewestNetworkVersion) makes me wonder if we'd be slightly better off with a DefaultEnsembleOpts of type []EnsembleOpts applied to a zero valued ensembleOpts. The name ensembleOpts could be changed to something different, ensembleCfg?, to make this a little less confusing.

Not very important just riffing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I'd much rather have a set of default options (also avoids cases where the default "config" gets modified accidentally). But that'll be a future cleanup.

Height: -1,
Network: build.NewestNetworkVersion,
}},
}

// MockProofs activates mock proofs for the entire ensemble.
Expand Down
Loading