9e03fcab83
* Initial work supporting DDO pieces in lotus-miner * sealing: Update pipeline input to operate on UniversalPiece * sealing: Update pipeline checks/sealing states to operate on UniversalPiece * sealing: Make pipeline build with UniversalPiece * move PieceDealInfo out of api * make gen * make sealing pipeline unit tests pass * fix itest ensemble build * don't panic in SectorsStatus with deals * stop linter from complaining about checkPieces * fix sector import tests * mod tidy * sealing: Add logic for (pre)committing DDO sectors * sealing: state-types with method defs * DDO non-snap pipeline works(?), DDO Itests * DDO support in snapdeals pipeline * make gen * update actor bundles * update the gst market fix * fix: chain: use PreCommitSectorsBatch2 when setting up genesis * some bug fixes * integration working changes * update actor bundles * Make TestOnboardRawPieceSnap pass * Appease the linter * Make deadlines test pass with v12 actors * Update go-state-types, abstract market DealState * make gen * mod tidy, lint fixes * Fix some more tests * Bump version in master Bump version in master * Make gen Make gen * fix sender * fix: lotus-provider: Fix winning PoSt * fix: sql Scan cannot write to an object * Actually show miner-addrs in info-log Actually show miner-addrs in lotus-provider info-log * [WIP] feat: Add nv22 skeleton Addition of Network Version 22 skeleton * update FFI * ddo is now nv22 * make gen * temp actor bundle with ddo * use working go-state-types * gst with v13 market migration * update bundle, builtin.MethodsMiner.ProveCommitSectors2 -> 3 * actually working v13 migration, v13 migration itest * Address review * sealing: Correct DDO snap pledge math * itests: Mixed ddo itest * pipeline: Fix sectorWeight * sealing: convert market deals into PAMs in mixed sectors * sealing: make market to ddo conversion work * fix lint * update gst * Update actors and GST to lastest integ branch * commit batcher: Update ProveCommitSectors3Params builder logic * make gen * use builtin-actors master * ddo: address review * itests: Add commd assertions to ddo tests * make gen * gst with fixed types * config knobs for RequireActivationSuccess * storage: Drop obsolete flaky tasts --------- Co-authored-by: Jennifer Wang <jiayingw703@gmail.com> Co-authored-by: Aayush <arajasek94@gmail.com> Co-authored-by: Shrenuj Bansal <shrenuj.bansal@protocol.ai> Co-authored-by: Phi <orjan.roren@gmail.com> Co-authored-by: Andrew Jackson (Ajax) <snadrus@gmail.com> Co-authored-by: TippyFlits <james.bluett@protocol.ai>
318 lines
13 KiB
Plaintext
318 lines
13 KiB
Plaintext
package miner
|
|
|
|
import (
|
|
"github.com/ipfs/go-cid"
|
|
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
|
"github.com/filecoin-project/go-state-types/big"
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
"github.com/filecoin-project/lotus/chain/actors"
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
"golang.org/x/xerrors"
|
|
|
|
"github.com/filecoin-project/go-bitfield"
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
"github.com/filecoin-project/go-state-types/cbor"
|
|
"github.com/filecoin-project/go-state-types/dline"
|
|
"github.com/filecoin-project/go-state-types/proof"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
minertypes13 "github.com/filecoin-project/go-state-types/builtin/v13/miner"
|
|
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
|
"github.com/filecoin-project/go-state-types/manifest"
|
|
|
|
{{range .versions}}
|
|
{{if (le . 7)}}
|
|
builtin{{.}} "github.com/filecoin-project/specs-actors{{import .}}actors/builtin"
|
|
{{end}}
|
|
{{end}}
|
|
)
|
|
|
|
func Load(store adt.Store, act *types.Actor) (State, error) {
|
|
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
|
|
if name != manifest.MinerKey {
|
|
return nil, xerrors.Errorf("actor code is not miner: %s", name)
|
|
}
|
|
|
|
switch av {
|
|
{{range .versions}}
|
|
{{if (ge . 8)}}
|
|
case actorstypes.Version{{.}}:
|
|
return load{{.}}(store, act.Head)
|
|
{{end}}
|
|
{{end}}
|
|
}
|
|
}
|
|
|
|
switch act.Code {
|
|
{{range .versions}}
|
|
{{if (le . 7)}}
|
|
case builtin{{.}}.StorageMinerActorCodeID:
|
|
return load{{.}}(store, act.Head)
|
|
{{end}}
|
|
{{end}}
|
|
}
|
|
|
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
|
}
|
|
|
|
func MakeState(store adt.Store, av actors.Version) (State, error) {
|
|
switch av {
|
|
{{range .versions}}
|
|
case actors.Version{{.}}:
|
|
return make{{.}}(store)
|
|
{{end}}
|
|
}
|
|
return nil, xerrors.Errorf("unknown actor version %d", av)
|
|
}
|
|
|
|
type State interface {
|
|
cbor.Marshaler
|
|
|
|
Code() cid.Cid
|
|
ActorKey() string
|
|
ActorVersion() actorstypes.Version
|
|
|
|
// Total available balance to spend.
|
|
AvailableBalance(abi.TokenAmount) (abi.TokenAmount, error)
|
|
// Funds that will vest by the given epoch.
|
|
VestedFunds(abi.ChainEpoch) (abi.TokenAmount, error)
|
|
// Funds locked for various reasons.
|
|
LockedFunds() (LockedFunds, error)
|
|
FeeDebt() (abi.TokenAmount, error)
|
|
|
|
// Returns nil, nil if sector is not found
|
|
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
|
FindSector(abi.SectorNumber) (*SectorLocation, error)
|
|
GetSectorExpiration(abi.SectorNumber) (*SectorExpiration, error)
|
|
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
|
|
ForEachPrecommittedSector(func(SectorPreCommitOnChainInfo) error) error
|
|
LoadSectors(sectorNos *bitfield.BitField) ([]*SectorOnChainInfo, error)
|
|
NumLiveSectors() (uint64, error)
|
|
IsAllocated(abi.SectorNumber) (bool, error)
|
|
// UnallocatedSectorNumbers returns up to count unallocated sector numbers (or less than
|
|
// count if there aren't enough).
|
|
UnallocatedSectorNumbers(count int) ([]abi.SectorNumber, error)
|
|
GetAllocatedSectors() (*bitfield.BitField, error)
|
|
|
|
// Note that ProvingPeriodStart is deprecated and will be renamed / removed in a future version of actors
|
|
GetProvingPeriodStart() (abi.ChainEpoch, error)
|
|
// Testing only
|
|
EraseAllUnproven() error
|
|
|
|
LoadDeadline(idx uint64) (Deadline, error)
|
|
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
|
|
NumDeadlines() (uint64, error)
|
|
DeadlinesChanged(State) (bool, error)
|
|
|
|
Info() (MinerInfo, error)
|
|
MinerInfoChanged(State) (bool, error)
|
|
|
|
DeadlineInfo(epoch abi.ChainEpoch) (*dline.Info, error)
|
|
DeadlineCronActive() (bool, error)
|
|
|
|
// Diff helpers. Used by Diff* functions internally.
|
|
sectors() (adt.Array, error)
|
|
decodeSectorOnChainInfo(*cbg.Deferred) (SectorOnChainInfo, error)
|
|
precommits() (adt.Map, error)
|
|
decodeSectorPreCommitOnChainInfo(*cbg.Deferred) (SectorPreCommitOnChainInfo, error)
|
|
GetState() interface{}
|
|
}
|
|
|
|
type Deadline interface {
|
|
LoadPartition(idx uint64) (Partition, error)
|
|
ForEachPartition(cb func(idx uint64, part Partition) error) error
|
|
PartitionsPoSted() (bitfield.BitField, error)
|
|
|
|
PartitionsChanged(Deadline) (bool, error)
|
|
DisputableProofCount() (uint64, error)
|
|
}
|
|
|
|
type Partition interface {
|
|
// AllSectors returns all sector numbers in this partition, including faulty, unproven, and terminated sectors
|
|
AllSectors() (bitfield.BitField, error)
|
|
|
|
// Subset of sectors detected/declared faulty and not yet recovered (excl. from PoSt).
|
|
// Faults ∩ Terminated = ∅
|
|
FaultySectors() (bitfield.BitField, error)
|
|
|
|
// Subset of faulty sectors expected to recover on next PoSt
|
|
// Recoveries ∩ Terminated = ∅
|
|
RecoveringSectors() (bitfield.BitField, error)
|
|
|
|
// Live sectors are those that are not terminated (but may be faulty).
|
|
LiveSectors() (bitfield.BitField, error)
|
|
|
|
// Active sectors are those that are neither terminated nor faulty nor unproven, i.e. actively contributing power.
|
|
ActiveSectors() (bitfield.BitField, error)
|
|
|
|
// Unproven sectors in this partition. This bitfield will be cleared on
|
|
// a successful window post (or at the end of the partition's next
|
|
// deadline). At that time, any still unproven sectors will be added to
|
|
// the faulty sector bitfield.
|
|
UnprovenSectors() (bitfield.BitField, error)
|
|
}
|
|
|
|
type SectorOnChainInfo = minertypes.SectorOnChainInfo
|
|
|
|
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof, configWantSynthetic bool) (abi.RegisteredSealProof, error) {
|
|
// We added support for the new proofs in network version 7, and removed support for the old
|
|
// ones in network version 8.
|
|
if nver < network.Version7 {
|
|
switch proof {
|
|
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1:
|
|
return abi.RegisteredSealProof_StackedDrg2KiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1:
|
|
return abi.RegisteredSealProof_StackedDrg8MiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1:
|
|
return abi.RegisteredSealProof_StackedDrg512MiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1:
|
|
return abi.RegisteredSealProof_StackedDrg32GiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1:
|
|
return abi.RegisteredSealProof_StackedDrg64GiBV1, nil
|
|
default:
|
|
return -1, xerrors.Errorf("unrecognized window post type: %d", proof)
|
|
}
|
|
}
|
|
|
|
if nver < MinSyntheticPoRepVersion || !configWantSynthetic {
|
|
switch proof {
|
|
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1, abi.RegisteredPoStProof_StackedDrgWindow8MiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1, abi.RegisteredPoStProof_StackedDrgWindow512MiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil
|
|
default:
|
|
return -1, xerrors.Errorf("unrecognized window post type: %d", proof)
|
|
}
|
|
}
|
|
|
|
switch proof {
|
|
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg2KiBV1_1_Feat_SyntheticPoRep, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1, abi.RegisteredPoStProof_StackedDrgWindow8MiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg8MiBV1_1_Feat_SyntheticPoRep, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1, abi.RegisteredPoStProof_StackedDrgWindow512MiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg512MiBV1_1_Feat_SyntheticPoRep, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg32GiBV1_1_Feat_SyntheticPoRep, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1_1:
|
|
return abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep, nil
|
|
default:
|
|
return -1, xerrors.Errorf("unrecognized window post type: %d", proof)
|
|
}
|
|
}
|
|
|
|
func WinningPoStProofTypeFromWindowPoStProofType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredPoStProof, error) {
|
|
switch proof {
|
|
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1:
|
|
return abi.RegisteredPoStProof_StackedDrgWinning2KiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1, abi.RegisteredPoStProof_StackedDrgWindow8MiBV1_1:
|
|
return abi.RegisteredPoStProof_StackedDrgWinning8MiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1, abi.RegisteredPoStProof_StackedDrgWindow512MiBV1_1:
|
|
return abi.RegisteredPoStProof_StackedDrgWinning512MiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1_1:
|
|
return abi.RegisteredPoStProof_StackedDrgWinning32GiBV1, nil
|
|
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1_1:
|
|
return abi.RegisteredPoStProof_StackedDrgWinning64GiBV1, nil
|
|
default:
|
|
return -1, xerrors.Errorf("unknown proof type %d", proof)
|
|
}
|
|
}
|
|
|
|
type MinerInfo = minertypes.MinerInfo
|
|
type BeneficiaryTerm = minertypes.BeneficiaryTerm
|
|
type PendingBeneficiaryChange = minertypes.PendingBeneficiaryChange
|
|
type WorkerKeyChange = minertypes.WorkerKeyChange
|
|
type SectorPreCommitOnChainInfo = minertypes.SectorPreCommitOnChainInfo
|
|
type SectorPreCommitInfo = minertypes.SectorPreCommitInfo
|
|
type SubmitWindowedPoStParams = minertypes.SubmitWindowedPoStParams
|
|
type PoStPartition = minertypes.PoStPartition
|
|
type RecoveryDeclaration = minertypes.RecoveryDeclaration
|
|
type FaultDeclaration = minertypes.FaultDeclaration
|
|
type DeclareFaultsRecoveredParams = minertypes.DeclareFaultsRecoveredParams
|
|
type DeclareFaultsParams = minertypes.DeclareFaultsParams
|
|
type ProveCommitAggregateParams = minertypes.ProveCommitAggregateParams
|
|
type ProveCommitSectorParams = minertypes.ProveCommitSectorParams
|
|
type ProveReplicaUpdatesParams = minertypes.ProveReplicaUpdatesParams
|
|
type ProveReplicaUpdatesParams2 = minertypes.ProveReplicaUpdatesParams2
|
|
type ReplicaUpdate = minertypes.ReplicaUpdate
|
|
type ReplicaUpdate2 = minertypes.ReplicaUpdate2
|
|
type PreCommitSectorBatchParams = minertypes.PreCommitSectorBatchParams
|
|
type PreCommitSectorBatchParams2 = minertypes.PreCommitSectorBatchParams2
|
|
type ExtendSectorExpiration2Params = minertypes.ExtendSectorExpiration2Params
|
|
type SectorClaim = minertypes.SectorClaim
|
|
type ExpirationExtension2 = minertypes.ExpirationExtension2
|
|
type CompactPartitionsParams = minertypes.CompactPartitionsParams
|
|
type WithdrawBalanceParams = minertypes.WithdrawBalanceParams
|
|
|
|
type PieceActivationManifest = minertypes13.PieceActivationManifest
|
|
type ProveCommitSectors3Params = minertypes13.ProveCommitSectors3Params
|
|
type SectorActivationManifest = minertypes13.SectorActivationManifest
|
|
type ProveReplicaUpdates3Params = minertypes13.ProveReplicaUpdates3Params
|
|
type SectorUpdateManifest = minertypes13.SectorUpdateManifest
|
|
|
|
var QAPowerMax = minertypes.QAPowerMax
|
|
|
|
type WindowPostVerifyInfo = proof.WindowPoStVerifyInfo
|
|
|
|
var WPoStProvingPeriod = func() abi.ChainEpoch { return minertypes.WPoStProvingPeriod }
|
|
var WPoStChallengeWindow = func() abi.ChainEpoch { return minertypes.WPoStChallengeWindow }
|
|
|
|
const WPoStPeriodDeadlines = minertypes.WPoStPeriodDeadlines
|
|
const WPoStChallengeLookback = minertypes.WPoStChallengeLookback
|
|
const FaultDeclarationCutoff = minertypes.FaultDeclarationCutoff
|
|
const MinAggregatedSectors = minertypes.MinAggregatedSectors
|
|
const MinSectorExpiration = minertypes.MinSectorExpiration
|
|
|
|
type SectorExpiration struct {
|
|
OnTime abi.ChainEpoch
|
|
|
|
// non-zero if sector is faulty, epoch at which it will be permanently
|
|
// removed if it doesn't recover
|
|
Early abi.ChainEpoch
|
|
}
|
|
|
|
type SectorLocation struct {
|
|
Deadline uint64
|
|
Partition uint64
|
|
}
|
|
|
|
type SectorChanges struct {
|
|
Added []SectorOnChainInfo
|
|
Extended []SectorExtensions
|
|
Removed []SectorOnChainInfo
|
|
}
|
|
|
|
type SectorExtensions struct {
|
|
From SectorOnChainInfo
|
|
To SectorOnChainInfo
|
|
}
|
|
|
|
type PreCommitChanges struct {
|
|
Added []SectorPreCommitOnChainInfo
|
|
Removed []SectorPreCommitOnChainInfo
|
|
}
|
|
|
|
type LockedFunds struct {
|
|
VestingFunds abi.TokenAmount
|
|
InitialPledgeRequirement abi.TokenAmount
|
|
PreCommitDeposits abi.TokenAmount
|
|
}
|
|
|
|
func (lf LockedFunds) TotalLockedFunds() abi.TokenAmount {
|
|
return big.Add(lf.VestingFunds, big.Add(lf.InitialPledgeRequirement, lf.PreCommitDeposits))
|
|
}
|
|
|
|
func AllCodes() []cid.Cid {
|
|
return []cid.Cid{ {{range .versions}}
|
|
(&state{{.}}{}).Code(),
|
|
{{- end}}
|
|
}
|
|
}
|