d3594835c4
This patch starts adding support for network upgrades. * It adds an actors abstraction layer for loading abstract (cross-version) actors. * It starts switching over to a shared deadline type. * It adds an abstraction for ADTs (hamt/amt). * It removes the callback-based API in the StateManager (difficult to abstract across actor versions). * It _does not_ actually add support for actors v2. We can do that in a followup patch but that should be relatively easy. This patch is heavily WIP and does not compile. Feel free to push changes directly to this branch. Notes: * State tree access now needs a network version, because the HAMT type will change. * I haven't figured out a nice way to abstract over changes to the _message_ types. However, many of them will be type aliased to actors v0 in actors v2 so we can likely continue using the v0 versions (or use the v2 versions everywhere). I've been renaming imports to `v0*` to make it clear that we're importing types from a _specific_ actors version. TODO: * Consider merging incremental improvements? We'd have to get this compiling again first but we could merge in the new abstractions, and slowly switch over. * Finish migrating to the new abstractions. * Remove all actor state types from the public API. See `miner.State.Info()` for the planned approach here. * Fix the tests. This is likely going to be a massive pain.
60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
package miner
|
|
|
|
import (
|
|
"github.com/filecoin-project/go-bitfield"
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
"golang.org/x/xerrors"
|
|
|
|
v0builtin "github.com/filecoin-project/specs-actors/actors/builtin"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
)
|
|
|
|
func Load(store adt.Store, act *types.Actor) (st State, err error) {
|
|
switch act.Code {
|
|
case v0builtin.StorageMinerActorCodeID:
|
|
out := v0State{store: store}
|
|
err := store.Get(store.Context(), act.Head, &out)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &out, nil
|
|
}
|
|
return nil, xerrors.Errorf("unknown actor code %s", act.Code)
|
|
}
|
|
|
|
type State interface {
|
|
cbor.Marshaler
|
|
|
|
LoadDeadline(idx uint64) (Deadline, error)
|
|
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
|
|
NumDeadlines() (uint64, error)
|
|
}
|
|
|
|
type Deadline interface {
|
|
LoadPartition(idx uint64) (Partition, error)
|
|
ForEachPartition(cb func(idx uint64, part Partition) error) error
|
|
}
|
|
|
|
type Partition interface {
|
|
AllSectors() (bitfield.BitField, error)
|
|
FaultySectors() (bitfield.BitField, error)
|
|
RecoveringSectors() (bitfield.BitField, error)
|
|
LiveSectors() (bitfield.BitField, error)
|
|
ActiveSectors() (bitfield.BitField, error)
|
|
}
|
|
|
|
type MinerInfo struct {
|
|
Owner address.Address // Must be an ID-address.
|
|
Worker address.Address // Must be an ID-address.
|
|
NewWorker address.Address // Must be an ID-address.
|
|
ControlAddresses []address.Address // Must be an ID-addresses.
|
|
WorkerChangeEpoch abi.ChainEpoch
|
|
PeerId *peer.ID
|
|
Multiaddrs []abi.Multiaddrs
|
|
SealProofType abi.RegisteredSealProof
|
|
SectorSize abi.SectorSize
|
|
WindowPoStPartitionSectors uint64
|
|
}
|