Miner migration

This commit is contained in:
Aayush Rajasekaran 2020-09-16 22:34:13 -04:00
parent 81004ea39e
commit b5ba7a0fad
35 changed files with 288 additions and 162 deletions

View File

@ -5,7 +5,7 @@ package build
import ( import (
"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/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
) )
@ -21,7 +21,7 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
func init() { func init() {
v0power.ConsensusMinerMinPower = big.NewInt(2048) v0power.ConsensusMinerMinPower = big.NewInt(2048)
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
} }
verifreg.MinVerifiedDealSize = big.NewInt(256) verifreg.MinVerifiedDealSize = big.NewInt(256)

View File

@ -6,14 +6,14 @@ import (
"github.com/libp2p/go-libp2p-core/protocol" "github.com/libp2p/go-libp2p-core/protocol"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/dtypes"
) )
func DefaultSectorSize() abi.SectorSize { func DefaultSectorSize() abi.SectorSize {
szs := make([]abi.SectorSize, 0, len(miner.SupportedProofTypes)) szs := make([]abi.SectorSize, 0, len(v0miner.SupportedProofTypes))
for spt := range miner.SupportedProofTypes { for spt := range v0miner.SupportedProofTypes {
ss, err := spt.SectorSize() ss, err := spt.SectorSize()
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -9,7 +9,7 @@ import (
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
) )
// ///// // /////
@ -23,6 +23,7 @@ const UnixfsLinksPerLevel = 1024
const AllowableClockDriftSecs = uint64(1) const AllowableClockDriftSecs = uint64(1)
const NewestNetworkVersion = network.Version2 const NewestNetworkVersion = network.Version2
const ActorUpgradeNetworkVersion = network.Version3
// Epochs // Epochs
const ForkLengthThreshold = Finality const ForkLengthThreshold = Finality
@ -31,7 +32,7 @@ const ForkLengthThreshold = Finality
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch) var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
// Epochs // Epochs
const Finality = miner.ChainFinality const Finality = v0miner.ChainFinality
const MessageConfidence = uint64(5) const MessageConfidence = uint64(5)
// constants for Weight calculation // constants for Weight calculation

View File

@ -13,7 +13,7 @@ import (
"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/go-state-types/network"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
) )
var ( var (
@ -32,7 +32,7 @@ var (
AllowableClockDriftSecs = uint64(1) AllowableClockDriftSecs = uint64(1)
Finality = miner.ChainFinality Finality = v0miner.ChainFinality
ForkLengthThreshold = Finality ForkLengthThreshold = Finality
SlashablePowerDelay = 20 SlashablePowerDelay = 20

View File

@ -8,7 +8,7 @@ import (
"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/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
) )
@ -24,7 +24,7 @@ const UpgradeSmokeHeight = 51000
func init() { func init() {
v0power.ConsensusMinerMinPower = big.NewInt(10 << 40) v0power.ConsensusMinerMinPower = big.NewInt(10 << 40)
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg32GiBV1: {}, abi.RegisteredSealProof_StackedDrg32GiBV1: {},
abi.RegisteredSealProof_StackedDrg64GiBV1: {}, abi.RegisteredSealProof_StackedDrg64GiBV1: {},
} }

View File

@ -38,7 +38,9 @@ type State interface {
FindSector(abi.SectorNumber) (*SectorLocation, error) FindSector(abi.SectorNumber) (*SectorLocation, error)
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error) GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) ([]*ChainSectorInfo, error) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) (adt.Array, error)
LoadPreCommittedSectorsFromSet(filter *bitfield.BitField, filterOut bool) (adt.Map, error)
IsAllocated(abi.SectorNumber) (bool, error)
LoadDeadline(idx uint64) (Deadline, error) LoadDeadline(idx uint64) (Deadline, error)
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
@ -65,6 +67,15 @@ type Partition interface {
type SectorOnChainInfo = v0miner.SectorOnChainInfo type SectorOnChainInfo = v0miner.SectorOnChainInfo
type SectorPreCommitInfo = v0miner.SectorPreCommitInfo type SectorPreCommitInfo = v0miner.SectorPreCommitInfo
type SectorPreCommitOnChainInfo = v0miner.SectorPreCommitOnChainInfo type SectorPreCommitOnChainInfo = v0miner.SectorPreCommitOnChainInfo
type PoStPartition = v0miner.PoStPartition
type RecoveryDeclaration = v0miner.RecoveryDeclaration
type FaultDeclaration = v0miner.FaultDeclaration
// Params
type DeclareFaultsParams = v0miner.DeclareFaultsParams
type DeclareFaultsRecoveredParams = v0miner.DeclareFaultsRecoveredParams
type SubmitWindowedPoStParams = v0miner.SubmitWindowedPoStParams
type ProveCommitSectorParams = v0miner.ProveCommitSectorParams
type MinerInfo struct { type MinerInfo struct {
Owner address.Address // Must be an ID-address. Owner address.Address // Must be an ID-address.

View File

@ -1,7 +1,6 @@
package miner package miner
import ( import (
"bytes"
"errors" "errors"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
@ -132,13 +131,12 @@ func (s *v0State) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitO
return info, nil return info, nil
} }
func (s *v0State) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) ([]*ChainSectorInfo, error) { func (s *v0State) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) (adt.Array, error) {
a, err := v0adt.AsArray(s.store, s.State.Sectors) a, err := v0adt.AsArray(s.store, s.State.Sectors)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var sset []*ChainSectorInfo
var v cbg.Deferred var v cbg.Deferred
if err := a.ForEach(&v, func(i int64) error { if err := a.ForEach(&v, func(i int64) error {
if filter != nil { if filter != nil {
@ -147,24 +145,31 @@ func (s *v0State) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool)
return xerrors.Errorf("filter check error: %w", err) return xerrors.Errorf("filter check error: %w", err)
} }
if set == filterOut { if set == filterOut {
return nil err = a.Delete(uint64(i))
if err != nil {
return xerrors.Errorf("filtering error: %w", err)
} }
} }
var oci v0miner.SectorOnChainInfo
if err := oci.UnmarshalCBOR(bytes.NewReader(v.Raw)); err != nil {
return err
} }
sset = append(sset, &ChainSectorInfo{
Info: oci,
ID: abi.SectorNumber(i),
})
return nil return nil
}); err != nil { }); err != nil {
return nil, err return nil, err
} }
return sset, nil return a, nil
}
func (s *v0State) LoadPreCommittedSectors() (adt.Map, error) {
return v0adt.AsMap(s.store, s.State.PreCommittedSectors)
}
func (s *v0State) IsAllocated(num abi.SectorNumber) (bool, error) {
var allocatedSectors bitfield.BitField
if err := s.store.Get(s.store.Context(), s.State.AllocatedSectors, &allocatedSectors); err != nil {
return false, err
}
return allocatedSectors.IsSet(uint64(num))
} }
func (s *v0State) LoadDeadline(idx uint64) (Deadline, error) { func (s *v0State) LoadDeadline(idx uint64) (Deadline, error) {

View File

@ -4,6 +4,10 @@ import (
"bytes" "bytes"
"context" "context"
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"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"
@ -12,7 +16,6 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/actors/builtin/paych"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init" init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0adt "github.com/filecoin-project/specs-actors/actors/util/adt" v0adt "github.com/filecoin-project/specs-actors/actors/util/adt"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
typegen "github.com/whyrusleeping/cbor-gen" typegen "github.com/whyrusleeping/cbor-gen"
@ -387,28 +390,18 @@ func (m *MinerSectorChanges) Remove(key uint64, val *typegen.Deferred) error {
func (sp *StatePredicates) OnMinerSectorChange() DiffMinerActorStateFunc { func (sp *StatePredicates) OnMinerSectorChange() DiffMinerActorStateFunc {
return func(ctx context.Context, oldState, newState *miner.State) (changed bool, user UserData, err error) { return func(ctx context.Context, oldState, newState *miner.State) (changed bool, user UserData, err error) {
ctxStore := &contextStore{
ctx: ctx,
cst: sp.cst,
}
sectorChanges := &MinerSectorChanges{ sectorChanges := &MinerSectorChanges{
Added: []miner.SectorOnChainInfo{}, Added: []miner.SectorOnChainInfo{},
Extended: []SectorExtensions{}, Extended: []SectorExtensions{},
Removed: []miner.SectorOnChainInfo{}, Removed: []miner.SectorOnChainInfo{},
} }
// no sector changes oldSectors, err := oldState.LoadSectorsFromSet(nil, false)
if oldState.Sectors.Equals(newState.Sectors) {
return false, nil, nil
}
oldSectors, err := v0adt.AsArray(ctxStore, oldState.Sectors)
if err != nil { if err != nil {
return false, nil, err return false, nil, err
} }
newSectors, err := v0adt.AsArray(ctxStore, newState.Sectors) newSectors, err := newState.LoadSectorsFromSet(nil, false)
if err != nil { if err != nil {
return false, nil, err return false, nil, err
} }
@ -436,7 +429,7 @@ func (m *MinerPreCommitChanges) AsKey(key string) (abi.Keyer, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
return miner.SectorKey(abi.SectorNumber(sector)), nil return v0miner.SectorKey(abi.SectorNumber(sector)), nil
} }
func (m *MinerPreCommitChanges) Add(key string, val *typegen.Deferred) error { func (m *MinerPreCommitChanges) Add(key string, val *typegen.Deferred) error {
@ -465,26 +458,17 @@ func (m *MinerPreCommitChanges) Remove(key string, val *typegen.Deferred) error
func (sp *StatePredicates) OnMinerPreCommitChange() DiffMinerActorStateFunc { func (sp *StatePredicates) OnMinerPreCommitChange() DiffMinerActorStateFunc {
return func(ctx context.Context, oldState, newState *miner.State) (changed bool, user UserData, err error) { return func(ctx context.Context, oldState, newState *miner.State) (changed bool, user UserData, err error) {
ctxStore := &contextStore{
ctx: ctx,
cst: sp.cst,
}
precommitChanges := &MinerPreCommitChanges{ precommitChanges := &MinerPreCommitChanges{
Added: []miner.SectorPreCommitOnChainInfo{}, Added: []miner.SectorPreCommitOnChainInfo{},
Removed: []miner.SectorPreCommitOnChainInfo{}, Removed: []miner.SectorPreCommitOnChainInfo{},
} }
if oldState.PreCommittedSectors.Equals(newState.PreCommittedSectors) { oldPrecommits, err := oldState.LoadPreCommittedSectors()
return false, nil, nil
}
oldPrecommits, err := v0adt.AsMap(ctxStore, oldState.PreCommittedSectors)
if err != nil { if err != nil {
return false, nil, err return false, nil, err
} }
newPrecommits, err := v0adt.AsMap(ctxStore, newState.PreCommittedSectors) newPrecommits, err := newState.LoadPreCommittedSectors()
if err != nil { if err != nil {
return false, nil, err return false, nil, err
} }

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"testing" "testing"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-bitfield"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -20,7 +22,7 @@ import (
v0builtin "github.com/filecoin-project/specs-actors/actors/builtin" v0builtin "github.com/filecoin-project/specs-actors/actors/builtin"
v0market "github.com/filecoin-project/specs-actors/actors/builtin/market" v0market "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/util/adt" "github.com/filecoin-project/specs-actors/actors/util/adt"
tutils "github.com/filecoin-project/specs-actors/support/testing" tutils "github.com/filecoin-project/specs-actors/support/testing"
@ -375,12 +377,12 @@ func TestMinerSectorChange(t *testing.T) {
} }
owner, worker := nextIDAddrF(), nextIDAddrF() owner, worker := nextIDAddrF(), nextIDAddrF()
si0 := newSectorOnChainInfo(0, tutils.MakeCID("0", &miner.SealedCIDPrefix), big.NewInt(0), abi.ChainEpoch(0), abi.ChainEpoch(10)) si0 := newSectorOnChainInfo(0, tutils.MakeCID("0", &v0miner.SealedCIDPrefix), big.NewInt(0), abi.ChainEpoch(0), abi.ChainEpoch(10))
si1 := newSectorOnChainInfo(1, tutils.MakeCID("1", &miner.SealedCIDPrefix), big.NewInt(1), abi.ChainEpoch(1), abi.ChainEpoch(11)) si1 := newSectorOnChainInfo(1, tutils.MakeCID("1", &v0miner.SealedCIDPrefix), big.NewInt(1), abi.ChainEpoch(1), abi.ChainEpoch(11))
si2 := newSectorOnChainInfo(2, tutils.MakeCID("2", &miner.SealedCIDPrefix), big.NewInt(2), abi.ChainEpoch(2), abi.ChainEpoch(11)) si2 := newSectorOnChainInfo(2, tutils.MakeCID("2", &v0miner.SealedCIDPrefix), big.NewInt(2), abi.ChainEpoch(2), abi.ChainEpoch(11))
oldMinerC := createMinerState(ctx, t, store, owner, worker, []miner.SectorOnChainInfo{si0, si1, si2}) oldMinerC := createMinerState(ctx, t, store, owner, worker, []miner.SectorOnChainInfo{si0, si1, si2})
si3 := newSectorOnChainInfo(3, tutils.MakeCID("3", &miner.SealedCIDPrefix), big.NewInt(3), abi.ChainEpoch(3), abi.ChainEpoch(12)) si3 := newSectorOnChainInfo(3, tutils.MakeCID("3", &v0miner.SealedCIDPrefix), big.NewInt(3), abi.ChainEpoch(3), abi.ChainEpoch(12))
// 0 delete // 0 delete
// 1 extend // 1 extend
// 2 same // 2 same
@ -545,20 +547,20 @@ func createMinerState(ctx context.Context, t *testing.T, store adt.Store, owner,
return stateC return stateC
} }
func createEmptyMinerState(ctx context.Context, t *testing.T, store adt.Store, owner, worker address.Address) *miner.State { func createEmptyMinerState(ctx context.Context, t *testing.T, store adt.Store, owner, worker address.Address) *v0miner.State {
emptyArrayCid, err := adt.MakeEmptyArray(store).Root() emptyArrayCid, err := adt.MakeEmptyArray(store).Root()
require.NoError(t, err) require.NoError(t, err)
emptyMap, err := adt.MakeEmptyMap(store).Root() emptyMap, err := adt.MakeEmptyMap(store).Root()
require.NoError(t, err) require.NoError(t, err)
emptyDeadline, err := store.Put(store.Context(), miner.ConstructDeadline(emptyArrayCid)) emptyDeadline, err := store.Put(store.Context(), v0miner.ConstructDeadline(emptyArrayCid))
require.NoError(t, err) require.NoError(t, err)
emptyVestingFunds := miner.ConstructVestingFunds() emptyVestingFunds := v0miner.ConstructVestingFunds()
emptyVestingFundsCid, err := store.Put(store.Context(), emptyVestingFunds) emptyVestingFundsCid, err := store.Put(store.Context(), emptyVestingFunds)
require.NoError(t, err) require.NoError(t, err)
emptyDeadlines := miner.ConstructDeadlines(emptyDeadline) emptyDeadlines := v0miner.ConstructDeadlines(emptyDeadline)
emptyDeadlinesCid, err := store.Put(store.Context(), emptyDeadlines) emptyDeadlinesCid, err := store.Put(store.Context(), emptyDeadlines)
require.NoError(t, err) require.NoError(t, err)
@ -568,7 +570,7 @@ func createEmptyMinerState(ctx context.Context, t *testing.T, store adt.Store, o
emptyBitfieldCid, err := store.Put(store.Context(), emptyBitfield) emptyBitfieldCid, err := store.Put(store.Context(), emptyBitfield)
require.NoError(t, err) require.NoError(t, err)
state, err := miner.ConstructState(minerInfo, 123, emptyBitfieldCid, emptyArrayCid, emptyMap, emptyDeadlinesCid, emptyVestingFundsCid) state, err := v0miner.ConstructState(minerInfo, 123, emptyBitfieldCid, emptyArrayCid, emptyMap, emptyDeadlinesCid, emptyVestingFundsCid)
require.NoError(t, err) require.NoError(t, err)
return state return state

View File

@ -14,7 +14,7 @@ import (
"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/crypto" "github.com/filecoin-project/go-state-types/crypto"
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
block "github.com/ipfs/go-block-format" block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-blockservice" "github.com/ipfs/go-blockservice"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
@ -121,7 +121,7 @@ var DefaultRemainderAccountActor = genesis.Actor{
} }
func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) { func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
} }

View File

@ -5,7 +5,7 @@ import (
"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/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
@ -14,7 +14,7 @@ import (
) )
func init() { func init() {
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
} }
v0power.ConsensusMinerMinPower = big.NewInt(2048) v0power.ConsensusMinerMinPower = big.NewInt(2048)

View File

@ -6,6 +6,8 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
@ -18,7 +20,7 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/reward" "github.com/filecoin-project/specs-actors/actors/builtin/reward"
"github.com/filecoin-project/specs-actors/actors/runtime" "github.com/filecoin-project/specs-actors/actors/runtime"
@ -123,9 +125,10 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
} }
minerInfos[i].maddr = ma.IDAddress minerInfos[i].maddr = ma.IDAddress
err = vm.MutateState(ctx, minerInfos[i].maddr, func(cst cbor.IpldStore, st *miner.State) error { // TODO: ActorUpgrade
maxPeriods := miner.MaxSectorExpirationExtension / miner.WPoStProvingPeriod err = vm.MutateState(ctx, minerInfos[i].maddr, func(cst cbor.IpldStore, st *v0miner.State) error {
minerInfos[i].presealExp = (maxPeriods-1)*miner.WPoStProvingPeriod + st.ProvingPeriodStart - 1 maxPeriods := v0miner.MaxSectorExpirationExtension / v0miner.WPoStProvingPeriod
minerInfos[i].presealExp = (maxPeriods-1)*v0miner.WPoStProvingPeriod + st.ProvingPeriodStart - 1
return nil return nil
}) })
@ -201,7 +204,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err) return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
} }
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight) sectorWeight := v0miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
qaPow = types.BigAdd(qaPow, sectorWeight) qaPow = types.BigAdd(qaPow, sectorWeight)
} }
@ -246,7 +249,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err) return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
} }
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight) sectorWeight := v0miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
// we've added fake power for this sector above, remove it now // we've added fake power for this sector above, remove it now
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *v0power.State) error { err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *v0power.State) error {
@ -268,9 +271,9 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
return cid.Undef, xerrors.Errorf("getting current total power: %w", err) return cid.Undef, xerrors.Errorf("getting current total power: %w", err)
} }
pcd := miner.PreCommitDepositForPower(epochReward.ThisEpochRewardSmoothed, tpow.QualityAdjPowerSmoothed, sectorWeight) pcd := v0miner.PreCommitDepositForPower(epochReward.ThisEpochRewardSmoothed, tpow.QualityAdjPowerSmoothed, sectorWeight)
pledge := miner.InitialPledgeForPower( pledge := v0miner.InitialPledgeForPower(
sectorWeight, sectorWeight,
epochReward.ThisEpochBaselinePower, epochReward.ThisEpochBaselinePower,
tpow.PledgeCollateral, tpow.PledgeCollateral,

View File

@ -10,7 +10,7 @@ import (
"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/crypto" "github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
@ -22,7 +22,7 @@ import (
) )
func init() { func init() {
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
} }
v0power.ConsensusMinerMinPower = big.NewInt(2048) v0power.ConsensusMinerMinPower = big.NewInt(2048)

View File

@ -20,7 +20,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/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
@ -43,7 +43,7 @@ func init() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
} }
v0power.ConsensusMinerMinPower = big.NewInt(2048) v0power.ConsensusMinerMinPower = big.NewInt(2048)

View File

@ -20,7 +20,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin/cron" "github.com/filecoin-project/specs-actors/actors/builtin/cron"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init" init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/multisig" "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
"github.com/filecoin-project/specs-actors/actors/builtin/paych" "github.com/filecoin-project/specs-actors/actors/builtin/paych"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
@ -52,7 +52,7 @@ func NewInvoker() *Invoker {
inv.Register(builtin.CronActorCodeID, cron.Actor{}, cron.State{}) inv.Register(builtin.CronActorCodeID, cron.Actor{}, cron.State{})
inv.Register(builtin.StoragePowerActorCodeID, v0power.Actor{}, v0power.State{}) inv.Register(builtin.StoragePowerActorCodeID, v0power.Actor{}, v0power.State{})
inv.Register(builtin.StorageMarketActorCodeID, market.Actor{}, market.State{}) inv.Register(builtin.StorageMarketActorCodeID, market.Actor{}, market.State{})
inv.Register(builtin.StorageMinerActorCodeID, miner.Actor{}, miner.State{}) inv.Register(builtin.StorageMinerActorCodeID, v0miner.Actor{}, v0miner.State{})
inv.Register(builtin.MultisigActorCodeID, multisig.Actor{}, multisig.State{}) inv.Register(builtin.MultisigActorCodeID, multisig.Actor{}, multisig.State{})
inv.Register(builtin.PaymentChannelActorCodeID, paych.Actor{}, paych.State{}) inv.Register(builtin.PaymentChannelActorCodeID, paych.Actor{}, paych.State{})
inv.Register(builtin.VerifiedRegistryActorCodeID, verifreg.Actor{}, verifreg.State{}) inv.Register(builtin.VerifiedRegistryActorCodeID, verifreg.Actor{}, verifreg.State{})

View File

@ -7,6 +7,8 @@ import (
goruntime "runtime" goruntime "runtime"
"sync" "sync"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/runtime/proof" "github.com/filecoin-project/specs-actors/actors/runtime/proof"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
@ -21,9 +23,7 @@ import (
"github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/sigs" "github.com/filecoin-project/lotus/lib/sigs"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/runtime" "github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
) )
@ -197,7 +197,7 @@ func (ss *syscallShim) VerifyBlockSig(blk *types.BlockHeader) error {
return err return err
} }
info, err := mas.GetInfo(adt.WrapStore(ss.ctx, ss.cst)) info, err := mas.Info()
if err != nil { if err != nil {
return err return err
} }

View File

@ -15,7 +15,7 @@ import (
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
@ -41,7 +41,7 @@ import (
func init() { func init() {
v0power.ConsensusMinerMinPower = big.NewInt(2048) v0power.ConsensusMinerMinPower = big.NewInt(2048)
saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
} }
verifreg.MinVerifiedDealSize = big.NewInt(256) verifreg.MinVerifiedDealSize = big.NewInt(256)

View File

@ -12,6 +12,11 @@ import (
"strconv" "strconv"
"time" "time"
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
@ -24,7 +29,6 @@ import (
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
@ -321,6 +325,7 @@ type refunderNodeApi interface {
StateMinerInitialPledgeCollateral(ctx context.Context, addr address.Address, precommitInfo miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) StateMinerInitialPledgeCollateral(ctx context.Context, addr address.Address, precommitInfo miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error)
StateSectorPreCommitInfo(ctx context.Context, addr address.Address, sector abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) StateSectorPreCommitInfo(ctx context.Context, addr address.Address, sector abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error)
MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error)
GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)
WalletBalance(ctx context.Context, addr address.Address) (types.BigInt, error) WalletBalance(ctx context.Context, addr address.Address) (types.BigInt, error)
@ -389,14 +394,28 @@ func (r *refunder) ProcessTipset(ctx context.Context, tipset *types.TipSet, refu
continue continue
} }
var proveCommitSector miner.ProveCommitSectorParams var sn abi.SectorNumber
nv, err := r.api.StateNetworkVersion(ctx, tipset.Key())
if err != nil {
log.Warnw("failed to get network version")
continue
}
if nv < build.ActorUpgradeNetworkVersion {
var proveCommitSector v0miner.ProveCommitSectorParams
if err := proveCommitSector.UnmarshalCBOR(bytes.NewBuffer(m.Params)); err != nil { if err := proveCommitSector.UnmarshalCBOR(bytes.NewBuffer(m.Params)); err != nil {
log.Warnw("failed to decode provecommit params", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To) log.Warnw("failed to decode provecommit params", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To)
continue continue
} }
sn = proveCommitSector.SectorNumber
} else {
// TODO: ActorUpgrade
}
// We use the parent tipset key because precommit information is removed when ProveCommitSector is executed // We use the parent tipset key because precommit information is removed when ProveCommitSector is executed
precommitChainInfo, err := r.api.StateSectorPreCommitInfo(ctx, m.To, proveCommitSector.SectorNumber, tipset.Parents()) precommitChainInfo, err := r.api.StateSectorPreCommitInfo(ctx, m.To, sn, tipset.Parents())
if err != nil { if err != nil {
log.Warnw("failed to get precommit info for sector", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", proveCommitSector.SectorNumber) log.Warnw("failed to get precommit info for sector", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To, "sector_number", proveCommitSector.SectorNumber)
continue continue

View File

@ -4,6 +4,9 @@ import (
"bytes" "bytes"
"context" "context"
"github.com/filecoin-project/lotus/build"
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0proof "github.com/filecoin-project/specs-actors/actors/runtime/proof" v0proof "github.com/filecoin-project/specs-actors/actors/runtime/proof"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -13,7 +16,6 @@ import (
"github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
"github.com/filecoin-project/lotus/extern/sector-storage/zerocomm" "github.com/filecoin-project/lotus/extern/sector-storage/zerocomm"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
) )
// TODO: For now we handle this by halting state execution, when we get jsonrpc reconnecting // TODO: For now we handle this by halting state execution, when we get jsonrpc reconnecting
@ -93,7 +95,19 @@ func checkPrecommit(ctx context.Context, maddr address.Address, si SectorInfo, t
return &ErrBadCommD{xerrors.Errorf("on chain CommD differs from sector: %s != %s", commD, si.CommD)} return &ErrBadCommD{xerrors.Errorf("on chain CommD differs from sector: %s != %s", commD, si.CommD)}
} }
if height-(si.TicketEpoch+SealRandomnessLookback) > SealRandomnessLookbackLimit(si.SectorType) { nv, err := api.StateNetworkVersion(ctx, tok)
if err != nil {
return &ErrApi{xerrors.Errorf("calling StateNetworkVersion: %w", err)}
}
var msd abi.ChainEpoch
if nv < build.ActorUpgradeNetworkVersion {
msd = v0miner.MaxSealDuration[si.SectorType]
} else {
// TODO: ActorUpgrade
}
if height-(si.TicketEpoch+SealRandomnessLookback) > msd {
return &ErrExpiredTicket{xerrors.Errorf("ticket expired: seal height: %d, head: %d", si.TicketEpoch+SealRandomnessLookback, height)} return &ErrExpiredTicket{xerrors.Errorf("ticket expired: seal height: %d, head: %d", si.TicketEpoch+SealRandomnessLookback, height)}
} }
@ -139,8 +153,13 @@ func (m *Sealing) checkCommit(ctx context.Context, si SectorInfo, proof []byte,
return &ErrNoPrecommit{xerrors.Errorf("precommit info not found on-chain")} return &ErrNoPrecommit{xerrors.Errorf("precommit info not found on-chain")}
} }
if pci.PreCommitEpoch+miner.PreCommitChallengeDelay != si.SeedEpoch { pccd, err := m.getPreCommitChallengeDelay(ctx, tok)
return &ErrBadSeed{xerrors.Errorf("seed epoch doesn't match on chain info: %d != %d", pci.PreCommitEpoch+miner.PreCommitChallengeDelay, si.SeedEpoch)} if err != nil {
return xerrors.Errorf("failed to get precommit challenge delay: %w", err)
}
if pci.PreCommitEpoch+pccd != si.SeedEpoch {
return &ErrBadSeed{xerrors.Errorf("seed epoch doesn't match on chain info: %d != %d", pci.PreCommitEpoch+pccd, si.SeedEpoch)}
} }
buf := new(bytes.Buffer) buf := new(bytes.Buffer)

View File

@ -1,17 +1,11 @@
package sealing package sealing
import ( import (
"github.com/filecoin-project/go-state-types/abi" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
) )
// Epochs // Epochs
const SealRandomnessLookback = miner.ChainFinality const SealRandomnessLookback = v0miner.ChainFinality
// Epochs
func SealRandomnessLookbackLimit(spt abi.RegisteredSealProof) abi.ChainEpoch {
return miner.MaxSealDuration[spt]
}
// Epochs // Epochs
const InteractivePoRepConfidence = 6 const InteractivePoRepConfidence = 6

View File

@ -1,12 +1,12 @@
package sealing package sealing
import ( import (
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"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/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/specs-storage/storage"
) )

View File

@ -3,8 +3,11 @@ package sealing
import ( import (
"context" "context"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
) )
type PreCommitPolicy interface { type PreCommitPolicy interface {
@ -13,6 +16,7 @@ type PreCommitPolicy interface {
type Chain interface { type Chain interface {
ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error) ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error)
StateNetworkVersion(ctx context.Context, tok TipSetToken) (network.Version, error)
} }
// BasicPreCommitPolicy satisfies PreCommitPolicy. It has two modes: // BasicPreCommitPolicy satisfies PreCommitPolicy. It has two modes:
@ -48,9 +52,9 @@ func NewBasicPreCommitPolicy(api Chain, duration abi.ChainEpoch, provingBoundary
// Expiration produces the pre-commit sector expiration epoch for an encoded // Expiration produces the pre-commit sector expiration epoch for an encoded
// replica containing the provided enumeration of pieces and deals. // replica containing the provided enumeration of pieces and deals.
func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, ps ...Piece) (abi.ChainEpoch, error) { func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, ps ...Piece) (abi.ChainEpoch, error) {
_, epoch, err := p.api.ChainHead(ctx) tok, epoch, err := p.api.ChainHead(ctx)
if err != nil { if err != nil {
return 0, nil return 0, err
} }
var end *abi.ChainEpoch var end *abi.ChainEpoch
@ -76,7 +80,19 @@ func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, ps ...Piece) (abi
end = &tmp end = &tmp
} }
*end += miner.WPoStProvingPeriod - (*end % miner.WPoStProvingPeriod) + p.provingBoundary - 1 nv, err := p.api.StateNetworkVersion(ctx, tok)
if err != nil {
return 0, err
}
var wpp abi.ChainEpoch
if nv < build.ActorUpgradeNetworkVersion {
wpp = v0miner.WPoStProvingPeriod
} else {
// TODO: ActorUpgrade
}
*end += wpp - (*end % wpp) + p.provingBoundary - 1
return *end, nil return *end, nil
} }

View File

@ -8,6 +8,10 @@ import (
"sync" "sync"
"time" "time"
"github.com/filecoin-project/lotus/build"
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/go-state-types/network"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/namespace" "github.com/ipfs/go-datastore/namespace"
@ -20,10 +24,10 @@ import (
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/crypto"
statemachine "github.com/filecoin-project/go-statemachine" statemachine "github.com/filecoin-project/go-statemachine"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage" sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
"github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
) )
const SectorStorePrefix = "/sectors" const SectorStorePrefix = "/sectors"
@ -53,6 +57,7 @@ type SealingAPI interface {
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, TipSetToken) (big.Int, error) StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, TipSetToken) (big.Int, error)
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, TipSetToken) (big.Int, error) StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, TipSetToken) (big.Int, error)
StateMarketStorageDeal(context.Context, abi.DealID, TipSetToken) (market.DealProposal, error) StateMarketStorageDeal(context.Context, abi.DealID, TipSetToken) (market.DealProposal, error)
StateNetworkVersion(ctx context.Context, tok TipSetToken) (network.Version, error)
SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error)
ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error) ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error)
ChainGetRandomnessFromBeacon(ctx context.Context, tok TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) ChainGetRandomnessFromBeacon(ctx context.Context, tok TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
@ -417,3 +422,18 @@ func getDealPerSectorLimit(size abi.SectorSize) uint64 {
} }
return 512 return 512
} }
func (m *Sealing) getPreCommitChallengeDelay(ctx context.Context, tok TipSetToken) (abi.ChainEpoch, error) {
nv, err := m.api.StateNetworkVersion(ctx, tok)
if err != nil {
return -1, xerrors.Errorf("failed to get network version: %w", err)
}
if nv < build.ActorUpgradeNetworkVersion {
return v0miner.PreCommitChallengeDelay, nil
} else {
// TODO: ActorUpgrade
return -1, nil
}
}

View File

@ -4,13 +4,14 @@ import (
"bytes" "bytes"
"time" "time"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/go-statemachine" "github.com/filecoin-project/go-statemachine"
"github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/lotus/extern/sector-storage/zerocomm" "github.com/filecoin-project/lotus/extern/sector-storage/zerocomm"
) )

View File

@ -4,6 +4,10 @@ import (
"bytes" "bytes"
"context" "context"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
@ -12,7 +16,6 @@ import (
"github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/go-statemachine" "github.com/filecoin-project/go-statemachine"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/specs-storage/storage"
) )
@ -180,7 +183,21 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
// Sectors must last _at least_ MinSectorExpiration + MaxSealDuration. // Sectors must last _at least_ MinSectorExpiration + MaxSealDuration.
// TODO: The "+10" allows the pre-commit to take 10 blocks to be accepted. // TODO: The "+10" allows the pre-commit to take 10 blocks to be accepted.
if minExpiration := height + miner.MaxSealDuration[sector.SectorType] + miner.MinSectorExpiration + 10; expiration < minExpiration { nv, err := m.api.StateNetworkVersion(ctx.Context(), tok)
if err != nil {
return ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("failed to get network version: %w", err)})
}
var msd abi.ChainEpoch
var mse abi.ChainEpoch
if nv < build.ActorUpgradeNetworkVersion {
msd = v0miner.MaxSealDuration[sector.SectorType]
mse = v0miner.MinSectorExpiration
} else {
// TODO: ActorUpgrade
}
if minExpiration := height + msd + mse + 10; expiration < minExpiration {
expiration = minExpiration expiration = minExpiration
} }
// TODO: enforce a reasonable _maximum_ sector lifetime? // TODO: enforce a reasonable _maximum_ sector lifetime?
@ -253,7 +270,7 @@ func (m *Sealing) handlePreCommitWait(ctx statemachine.Context, sector SectorInf
func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) error { func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) error {
tok, _, err := m.api.ChainHead(ctx.Context()) tok, _, err := m.api.ChainHead(ctx.Context())
if err != nil { if err != nil {
log.Errorf("handleCommitting: api error, not proceeding: %+v", err) log.Errorf("handleWaitSeed: api error, not proceeding: %+v", err)
return nil return nil
} }
@ -265,7 +282,17 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er
return ctx.Send(SectorChainPreCommitFailed{error: xerrors.Errorf("precommit info not found on chain")}) return ctx.Send(SectorChainPreCommitFailed{error: xerrors.Errorf("precommit info not found on chain")})
} }
randHeight := pci.PreCommitEpoch + miner.PreCommitChallengeDelay nv, err := m.api.StateNetworkVersion(ctx.Context(), tok)
if err != nil {
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("failed to get network version: %w", err)})
}
pccd, err := m.getPreCommitChallengeDelay(ctx.Context(), tok)
if err != nil {
return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("failed to get precommit challenge delay: %w", err)})
}
randHeight := pci.PreCommitEpoch + pccd
err = m.events.ChainAt(func(ectx context.Context, _ TipSetToken, curH abi.ChainEpoch) error { err = m.events.ChainAt(func(ectx context.Context, _ TipSetToken, curH abi.ChainEpoch) error {
// in case of null blocks the randomness can land after the tipset we // in case of null blocks the randomness can land after the tipset we
@ -356,15 +383,24 @@ func (m *Sealing) handleSubmitCommit(ctx statemachine.Context, sector SectorInfo
return ctx.Send(SectorCommitFailed{xerrors.Errorf("commit check error: %w", err)}) return ctx.Send(SectorCommitFailed{xerrors.Errorf("commit check error: %w", err)})
} }
params := &miner.ProveCommitSectorParams{ nv, err := m.api.StateNetworkVersion(ctx.Context(), tok)
if err != nil {
return ctx.Send(SectorCommitFailed{xerrors.Errorf("failed to get network version: %w", err)})
}
enc := new(bytes.Buffer)
if nv < build.ActorUpgradeNetworkVersion {
params := &v0miner.ProveCommitSectorParams{
SectorNumber: sector.SectorNumber, SectorNumber: sector.SectorNumber,
Proof: sector.Proof, Proof: sector.Proof,
} }
enc := new(bytes.Buffer)
if err := params.MarshalCBOR(enc); err != nil { if err := params.MarshalCBOR(enc); err != nil {
return ctx.Send(SectorCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", err)}) return ctx.Send(SectorCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", err)})
} }
} else {
// TODO: ActorUpgrade
}
waddr, err := m.api.StateMinerWorkerAddress(ctx.Context(), m.maddr, tok) waddr, err := m.api.StateMinerWorkerAddress(ctx.Context(), m.maddr, tok)
if err != nil { if err != nil {

View File

@ -3,11 +3,12 @@ package sealing
import ( import (
"context" "context"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"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/specs-actors/actors/builtin/miner"
) )
func (m *Sealing) IsMarkedForUpgrade(id abi.SectorNumber) bool { func (m *Sealing) IsMarkedForUpgrade(id abi.SectorNumber) bool {

View File

@ -6,6 +6,8 @@ import (
"bytes" "bytes"
"context" "context"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/big"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -29,7 +31,6 @@ import (
"github.com/filecoin-project/lotus/node/impl/full" "github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
samarket "github.com/filecoin-project/specs-actors/actors/builtin/market" samarket "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
) )

View File

@ -8,6 +8,8 @@ import (
"io" "io"
"time" "time"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
"golang.org/x/xerrors" "golang.org/x/xerrors"
@ -20,7 +22,6 @@ import (
"github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"

View File

@ -41,7 +41,7 @@ import (
"github.com/filecoin-project/go-multistore" "github.com/filecoin-project/go-multistore"
"github.com/filecoin-project/go-padreader" "github.com/filecoin-project/go-padreader"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
marketevents "github.com/filecoin-project/lotus/markets/loggers" marketevents "github.com/filecoin-project/lotus/markets/loggers"
@ -87,7 +87,7 @@ func calcDealExpiration(minDuration uint64, md *dline.Info, startEpoch abi.Chain
minExp := startEpoch + abi.ChainEpoch(minDuration) minExp := startEpoch + abi.ChainEpoch(minDuration)
// Align on miners ProvingPeriodBoundary // Align on miners ProvingPeriodBoundary
return minExp + miner.WPoStProvingPeriod - (minExp % miner.WPoStProvingPeriod) + (md.PeriodStart % miner.WPoStProvingPeriod) - 1 return minExp + v0miner.WPoStProvingPeriod - (minExp % v0miner.WPoStProvingPeriod) + (md.PeriodStart % v0miner.WPoStProvingPeriod) - 1
} }
func (a *API) imgr() *importmgr.Mgr { func (a *API) imgr() *importmgr.Mgr {

View File

@ -10,7 +10,7 @@ import (
"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/lotus/lib/lotuslog" "github.com/filecoin-project/lotus/lib/lotuslog"
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power" v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg" "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
@ -22,7 +22,7 @@ func init() {
_ = logging.SetLogLevel("*", "INFO") _ = logging.SetLogLevel("*", "INFO")
v0power.ConsensusMinerMinPower = big.NewInt(2048) v0power.ConsensusMinerMinPower = big.NewInt(2048)
saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{ v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {}, abi.RegisteredSealProof_StackedDrg2KiBV1: {},
} }
verifreg.MinVerifiedDealSize = big.NewInt(256) verifreg.MinVerifiedDealSize = big.NewInt(256)
@ -68,7 +68,7 @@ func TestAPIDealFlowReal(t *testing.T) {
logging.SetLogLevel("sub", "ERROR") logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR") logging.SetLogLevel("storageminer", "ERROR")
saminer.PreCommitChallengeDelay = 5 v0miner.PreCommitChallengeDelay = 5
t.Run("basic", func(t *testing.T) { t.Run("basic", func(t *testing.T) {
test.TestDealFlow(t, builder.Builder, time.Second, false, false) test.TestDealFlow(t, builder.Builder, time.Second, false, false)

View File

@ -37,7 +37,7 @@ import (
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/mockstorage" "github.com/filecoin-project/lotus/storage/mockstorage"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
"github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
@ -83,7 +83,7 @@ func CreateTestStorageNode(ctx context.Context, t *testing.T, waddr address.Addr
peerid, err := peer.IDFromPrivateKey(pk) peerid, err := peer.IDFromPrivateKey(pk)
require.NoError(t, err) require.NoError(t, err)
enc, err := actors.SerializeParams(&miner.ChangePeerIDParams{NewID: abi.PeerID(peerid)}) enc, err := actors.SerializeParams(&v0miner.ChangePeerIDParams{NewID: abi.PeerID(peerid)})
require.NoError(t, err) require.NoError(t, err)
msg := &types.Message{ msg := &types.Message{

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/network"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
@ -16,7 +16,6 @@ import (
"github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/market" "github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/apibstore" "github.com/filecoin-project/lotus/api/apibstore"
@ -84,7 +83,7 @@ func (s SealingAPIAdapter) StateMinerWorkerAddress(ctx context.Context, maddr ad
return mi.Worker, nil return mi.Worker, nil
} }
func (s SealingAPIAdapter) StateMinerDeadlines(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) ([]*miner.Deadline, error) { func (s SealingAPIAdapter) StateMinerDeadlines(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) ([]miner.Deadline, error) {
tsk, err := types.TipSetKeyFromBytes(tok) tsk, err := types.TipSetKeyFromBytes(tok)
if err != nil { if err != nil {
return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err) return nil, xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
@ -185,23 +184,13 @@ func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr a
if err != nil { if err != nil {
return nil, xerrors.Errorf("handleSealFailed(%d): temp error: loading miner state: %+v", sectorNumber, err) return nil, xerrors.Errorf("handleSealFailed(%d): temp error: loading miner state: %+v", sectorNumber, err)
} }
stor := store.ActorStore(ctx, apibstore.NewAPIBlockstore(s.delegate))
precommits, err := adt.AsMap(stor, state.PreCommittedSectors)
if err != nil {
return nil, err
}
var pci miner.SectorPreCommitOnChainInfo pci, err := state.GetPrecommittedSector(sectorNumber)
ok, err := precommits.Get(abi.UIntKey(uint64(sectorNumber)), &pci)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !ok { if pci != nil {
var allocated bitfield.BitField set, err := state.IsAllocated(sectorNumber)
if err := stor.Get(ctx, state.AllocatedSectors, &allocated); err != nil {
return nil, xerrors.Errorf("loading allocated sector bitfield: %w", err)
}
set, err := allocated.IsSet(uint64(sectorNumber))
if err != nil { if err != nil {
return nil, xerrors.Errorf("checking if sector is allocated: %w", err) return nil, xerrors.Errorf("checking if sector is allocated: %w", err)
} }
@ -212,7 +201,7 @@ func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr a
return nil, nil return nil, nil
} }
return &pci, nil return pci, nil
} }
func (s SealingAPIAdapter) StateSectorGetInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok sealing.TipSetToken) (*miner.SectorOnChainInfo, error) { func (s SealingAPIAdapter) StateSectorGetInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok sealing.TipSetToken) (*miner.SectorOnChainInfo, error) {
@ -258,6 +247,15 @@ func (s SealingAPIAdapter) StateMarketStorageDeal(ctx context.Context, dealID ab
return deal.Proposal, nil return deal.Proposal, nil
} }
func (s SealingAPIAdapter) StateNetworkVersion(ctx context.Context, tok sealing.TipSetToken) (network.Version, error) {
tsk, err := types.TipSetKeyFromBytes(tok)
if err != nil {
return -1, err
}
return s.delegate.StateNetworkVersion(ctx, tsk)
}
func (s SealingAPIAdapter) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error) { func (s SealingAPIAdapter) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error) {
msg := types.Message{ msg := types.Message{
To: to, To: to,

View File

@ -5,6 +5,10 @@ import (
"errors" "errors"
"time" "time"
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-bitfield"
@ -71,7 +75,8 @@ type storageMinerApi interface {
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error) StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*miner.SectorLocation, error)
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error) StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]miner.Deadline, error)
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) StateMinerPreCommitDepositForPower(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
@ -83,6 +88,7 @@ type storageMinerApi interface {
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error) StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
MpoolPushMessage(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error) MpoolPushMessage(context.Context, *types.Message, *api.MessageSendSpec) (*types.SignedMessage, error)
@ -139,7 +145,8 @@ func (m *Miner) Run(ctx context.Context) error {
evts := events.NewEvents(ctx, m.api) evts := events.NewEvents(ctx, m.api)
adaptedAPI := NewSealingAPIAdapter(m.api) adaptedAPI := NewSealingAPIAdapter(m.api)
pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, miner.MaxSectorExpirationExtension-(miner.WPoStProvingPeriod*2), md.PeriodStart%miner.WPoStProvingPeriod) // TODO: Maybe we update this policy after actor upgrades?
pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, v0miner.MaxSectorExpirationExtension-(v0miner.WPoStProvingPeriod*2), md.PeriodStart%v0miner.WPoStProvingPeriod)
m.sealing = sealing.New(adaptedAPI, fc, NewEventsAdapter(evts), m.maddr, m.ds, m.sealer, m.sc, m.verif, &pcp, sealing.GetSealingConfigFunc(m.getSealConfig), m.handleSealingNotifications) m.sealing = sealing.New(adaptedAPI, fc, NewEventsAdapter(evts), m.maddr, m.ds, m.sealer, m.sc, m.verif, &pcp, sealing.GetSealingConfigFunc(m.getSealConfig), m.handleSealingNotifications)
go m.sealing.Run(ctx) //nolint:errcheck // logged intside the function go m.sealing.Run(ctx) //nolint:errcheck // logged intside the function

View File

@ -3,7 +3,7 @@ package storage
import ( import (
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
) )

View File

@ -14,20 +14,18 @@ import (
"github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-actors/actors/runtime/proof" "github.com/filecoin-project/specs-actors/actors/runtime/proof"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/apibstore" "github.com/filecoin-project/lotus/api/apibstore"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
iminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/journal" "github.com/filecoin-project/lotus/journal"
@ -155,7 +153,7 @@ func (s *WindowPoStScheduler) checkSectors(ctx context.Context, check bitfield.B
return sbf, nil return sbf, nil
} }
func (s *WindowPoStScheduler) checkNextRecoveries(ctx context.Context, dlIdx uint64, partitions []iminer.Partition) ([]miner.RecoveryDeclaration, *types.SignedMessage, error) { func (s *WindowPoStScheduler) checkNextRecoveries(ctx context.Context, dlIdx uint64, partitions []miner.Partition) ([]miner.RecoveryDeclaration, *types.SignedMessage, error) {
ctx, span := trace.StartSpan(ctx, "storage.checkNextRecoveries") ctx, span := trace.StartSpan(ctx, "storage.checkNextRecoveries")
defer span.End() defer span.End()
@ -167,11 +165,11 @@ func (s *WindowPoStScheduler) checkNextRecoveries(ctx context.Context, dlIdx uin
for partIdx, partition := range partitions { for partIdx, partition := range partitions {
faults, err := partition.FaultySectors() faults, err := partition.FaultySectors()
if err != nil { if err != nil {
return xerrors.Errorf("getting faults: %w", err) return nil, nil, xerrors.Errorf("getting faults: %w", err)
} }
recovering, err := partition.RecoveringSectors() recovering, err := partition.RecoveringSectors()
if err != nil { if err != nil {
return xerrors.Errorf("getting recovering: %w", err) return nil, nil, xerrors.Errorf("getting recovering: %w", err)
} }
unrecovered, err := bitfield.SubtractBitField(faults, recovering) unrecovered, err := bitfield.SubtractBitField(faults, recovering)
if err != nil { if err != nil {
@ -254,7 +252,7 @@ func (s *WindowPoStScheduler) checkNextRecoveries(ctx context.Context, dlIdx uin
return recoveries, sm, nil return recoveries, sm, nil
} }
func (s *WindowPoStScheduler) checkNextFaults(ctx context.Context, dlIdx uint64, partitions []iminer.Partition) ([]miner.FaultDeclaration, *types.SignedMessage, error) { func (s *WindowPoStScheduler) checkNextFaults(ctx context.Context, dlIdx uint64, partitions []miner.Partition) ([]miner.FaultDeclaration, *types.SignedMessage, error) {
ctx, span := trace.StartSpan(ctx, "storage.checkNextFaults") ctx, span := trace.StartSpan(ctx, "storage.checkNextFaults")
defer span.End() defer span.End()
@ -348,7 +346,7 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
return nil, xerrors.Errorf("resolving actor: %w", err) return nil, xerrors.Errorf("resolving actor: %w", err)
} }
mas, err := iminer.Load(stor, act) mas, err := miner.Load(stor, act)
if err != nil { if err != nil {
return nil, xerrors.Errorf("getting miner state: %w", err) return nil, xerrors.Errorf("getting miner state: %w", err)
} }
@ -365,8 +363,8 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
log.Errorf("loading deadline: %v", err) log.Errorf("loading deadline: %v", err)
return return
} }
var partitions []iminer.Partition var partitions []miner.Partition
err = dl.ForEachPartition(func(_ uint64, part iminer.Partition) error { err = dl.ForEachPartition(func(_ uint64, part miner.Partition) error {
partitions = append(partitions, part) partitions = append(partitions, part)
return nil return nil
}) })
@ -435,9 +433,9 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
return nil, xerrors.Errorf("loading deadline: %w", err) return nil, xerrors.Errorf("loading deadline: %w", err)
} }
var partitions []iminer.Partitions var partitions []miner.Partition
err = dl.ForEachPartition(func(_ uint64, part iminer.Partition) error { err = dl.ForEachPartition(func(_ uint64, part miner.Partition) error {
partitions = apppend(partitions, part) partitions = append(partitions, part)
return nil return nil
}) })
if err != nil { if err != nil {
@ -465,7 +463,11 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
return nil, xerrors.Errorf("getting active sectors: %w", err) return nil, xerrors.Errorf("getting active sectors: %w", err)
} }
toProve, err = bitfield.MergeBitFields(toProve, partition.Recoveries) recs, err := partition.RecoveringSectors()
if err != nil {
return nil, xerrors.Errorf("getting recovering sectors: %w", err)
}
toProve, err = bitfield.MergeBitFields(toProve, recs)
if err != nil { if err != nil {
return nil, xerrors.Errorf("adding recoveries to set of sectors to prove: %w", err) return nil, xerrors.Errorf("adding recoveries to set of sectors to prove: %w", err)
} }
@ -492,7 +494,12 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di dline.Info, ts *ty
skipCount += sc skipCount += sc
ssi, err := s.sectorsForProof(ctx, good, partition.Sectors, ts) partitionSectors, err := partition.AllSectors()
if err != nil {
return nil, xerrors.Errorf("getting partition sectors: %w", err)
}
ssi, err := s.sectorsForProof(ctx, good, partitionSectors, ts)
if err != nil { if err != nil {
return nil, xerrors.Errorf("getting sorted sector info: %w", err) return nil, xerrors.Errorf("getting sorted sector info: %w", err)
} }