Migrate miner actor
This commit is contained in:
parent
ccce1a9715
commit
b530f25f09
@ -4,6 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api/apibstore"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
lotusminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
|
||||||
|
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -15,7 +22,6 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/mock"
|
"github.com/filecoin-project/lotus/extern/sector-storage/mock"
|
||||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||||
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -159,7 +165,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
head, err := client.ChainHead(ctx)
|
head, err := client.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
|
if head.Height() > di.PeriodStart+(v0miner.WPoStProvingPeriod)+2 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +184,14 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
require.Equal(t, p.MinerPower, p.TotalPower)
|
require.Equal(t, p.MinerPower, p.TotalPower)
|
||||||
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(nSectors+GenesisPreseals)))
|
require.Equal(t, p.MinerPower.RawBytePower, types.NewInt(uint64(ssz)*uint64(nSectors+GenesisPreseals)))
|
||||||
|
|
||||||
|
store := cbor.NewCborStore(apibstore.NewAPIBlockstore(client))
|
||||||
|
|
||||||
|
mact, err := client.StateGetActor(ctx, maddr, types.EmptyTSK)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
minState, err := lotusminer.Load(adt.WrapStore(ctx, store), mact)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
fmt.Printf("Drop some sectors\n")
|
fmt.Printf("Drop some sectors\n")
|
||||||
|
|
||||||
// Drop 2 sectors from deadline 2 partition 0 (full partition / deadline)
|
// Drop 2 sectors from deadline 2 partition 0 (full partition / deadline)
|
||||||
@ -186,12 +200,14 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Greater(t, len(parts), 0)
|
require.Greater(t, len(parts), 0)
|
||||||
|
|
||||||
n, err := parts[0].Sectors.Count()
|
secs, err := parts[0].AllSectors()
|
||||||
|
require.NoError(t, err)
|
||||||
|
n, err := secs.Count()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, uint64(2), n)
|
require.Equal(t, uint64(2), n)
|
||||||
|
|
||||||
// Drop the partition
|
// Drop the partition
|
||||||
err = parts[0].Sectors.ForEach(func(sid uint64) error {
|
err = secs.ForEach(func(sid uint64) error {
|
||||||
return miner.StorageMiner.(*impl.StorageMinerAPI).IStorageMgr.(*mock.SectorMgr).MarkCorrupted(abi.SectorID{
|
return miner.StorageMiner.(*impl.StorageMinerAPI).IStorageMgr.(*mock.SectorMgr).MarkCorrupted(abi.SectorID{
|
||||||
Miner: abi.ActorID(mid),
|
Miner: abi.ActorID(mid),
|
||||||
Number: abi.SectorNumber(sid),
|
Number: abi.SectorNumber(sid),
|
||||||
@ -208,15 +224,17 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Greater(t, len(parts), 0)
|
require.Greater(t, len(parts), 0)
|
||||||
|
|
||||||
n, err := parts[0].Sectors.Count()
|
secs, err := parts[0].AllSectors()
|
||||||
|
require.NoError(t, err)
|
||||||
|
n, err := secs.Count()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, uint64(2), n)
|
require.Equal(t, uint64(2), n)
|
||||||
|
|
||||||
// Drop the sector
|
// Drop the sector
|
||||||
sn, err := parts[0].Sectors.First()
|
sn, err := secs.First()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
all, err := parts[0].Sectors.All(2)
|
all, err := secs.All(2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
fmt.Println("the sectors", all)
|
fmt.Println("the sectors", all)
|
||||||
|
|
||||||
@ -238,7 +256,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
head, err := client.ChainHead(ctx)
|
head, err := client.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
|
if head.Height() > di.PeriodStart+(minState.WpostProvingPeriod())+2 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +286,7 @@ func TestWindowPost(t *testing.T, b APIBuilder, blocktime time.Duration, nSector
|
|||||||
head, err := client.ChainHead(ctx)
|
head, err := client.ChainHead(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
if head.Height() > di.PeriodStart+(miner2.WPoStProvingPeriod)+2 {
|
if head.Height() > di.PeriodStart+(minState.WpostProvingPeriod())+2 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ type State interface {
|
|||||||
Info() (MinerInfo, error)
|
Info() (MinerInfo, error)
|
||||||
|
|
||||||
DeadlineInfo(epoch abi.ChainEpoch) *dline.Info
|
DeadlineInfo(epoch abi.ChainEpoch) *dline.Info
|
||||||
|
WpostProvingPeriod() abi.ChainEpoch
|
||||||
}
|
}
|
||||||
|
|
||||||
type Deadline interface {
|
type Deadline interface {
|
||||||
|
@ -14,21 +14,21 @@ import (
|
|||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
)
|
)
|
||||||
|
|
||||||
type v0State struct {
|
type v0State struct {
|
||||||
miner.State
|
v0miner.State
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
type v0Deadline struct {
|
type v0Deadline struct {
|
||||||
miner.Deadline
|
v0miner.Deadline
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
type v0Partition struct {
|
type v0Partition struct {
|
||||||
miner.Partition
|
v0miner.Partition
|
||||||
store adt.Store
|
store adt.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,13 +69,13 @@ func (s *v0State) GetSectorExpiration(num abi.SectorNumber) (out *SectorExpirati
|
|||||||
// 2. If it's faulty, it will expire early within the first 14 entries
|
// 2. If it's faulty, it will expire early within the first 14 entries
|
||||||
// of the expiration queue.
|
// of the expiration queue.
|
||||||
stopErr := errors.New("stop")
|
stopErr := errors.New("stop")
|
||||||
err = dls.ForEach(s.store, func(dlIdx uint64, dl *miner.Deadline) error {
|
err = dls.ForEach(s.store, func(dlIdx uint64, dl *v0miner.Deadline) error {
|
||||||
partitions, err := dl.PartitionsArray(s.store)
|
partitions, err := dl.PartitionsArray(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
quant := s.State.QuantSpecForDeadline(dlIdx)
|
quant := s.State.QuantSpecForDeadline(dlIdx)
|
||||||
var part miner.Partition
|
var part v0miner.Partition
|
||||||
return partitions.ForEach(&part, func(partIdx int64) error {
|
return partitions.ForEach(&part, func(partIdx int64) error {
|
||||||
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
if found, err := part.Sectors.IsSet(uint64(num)); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -89,11 +89,11 @@ func (s *v0State) GetSectorExpiration(num abi.SectorNumber) (out *SectorExpirati
|
|||||||
return stopErr
|
return stopErr
|
||||||
}
|
}
|
||||||
|
|
||||||
q, err := miner.LoadExpirationQueue(s.store, part.EarlyTerminated, quant)
|
q, err := v0miner.LoadExpirationQueue(s.store, part.EarlyTerminated, quant)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var exp miner.ExpirationSet
|
var exp v0miner.ExpirationSet
|
||||||
return q.ForEach(&exp, func(epoch int64) error {
|
return q.ForEach(&exp, func(epoch int64) error {
|
||||||
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
if early, err := exp.EarlySectors.IsSet(uint64(num)); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -151,7 +151,7 @@ func (s *v0State) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var oci miner.SectorOnChainInfo
|
var oci v0miner.SectorOnChainInfo
|
||||||
if err := oci.UnmarshalCBOR(bytes.NewReader(v.Raw)); err != nil {
|
if err := oci.UnmarshalCBOR(bytes.NewReader(v.Raw)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -184,13 +184,13 @@ func (s *v0State) ForEachDeadline(cb func(uint64, Deadline) error) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return dls.ForEach(s.store, func(i uint64, dl *miner.Deadline) error {
|
return dls.ForEach(s.store, func(i uint64, dl *v0miner.Deadline) error {
|
||||||
return cb(i, &v0Deadline{*dl, s.store})
|
return cb(i, &v0Deadline{*dl, s.store})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *v0State) NumDeadlines() (uint64, error) {
|
func (s *v0State) NumDeadlines() (uint64, error) {
|
||||||
return miner.WPoStPeriodDeadlines, nil
|
return v0miner.WPoStPeriodDeadlines, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *v0State) Info() (MinerInfo, error) {
|
func (s *v0State) Info() (MinerInfo, error) {
|
||||||
@ -230,6 +230,9 @@ func (s *v0State) Info() (MinerInfo, error) {
|
|||||||
func (s *v0State) DeadlineInfo(epoch abi.ChainEpoch) *dline.Info {
|
func (s *v0State) DeadlineInfo(epoch abi.ChainEpoch) *dline.Info {
|
||||||
return s.State.DeadlineInfo(epoch)
|
return s.State.DeadlineInfo(epoch)
|
||||||
}
|
}
|
||||||
|
func (s *v0State) WpostProvingPeriod() abi.ChainEpoch {
|
||||||
|
return v0miner.WPoStProvingPeriod
|
||||||
|
}
|
||||||
|
|
||||||
func (d *v0Deadline) LoadPartition(idx uint64) (Partition, error) {
|
func (d *v0Deadline) LoadPartition(idx uint64) (Partition, error) {
|
||||||
p, err := d.Deadline.LoadPartition(d.store, idx)
|
p, err := d.Deadline.LoadPartition(d.store, idx)
|
||||||
@ -244,7 +247,7 @@ func (d *v0Deadline) ForEachPartition(cb func(uint64, Partition) error) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var part miner.Partition
|
var part v0miner.Partition
|
||||||
return ps.ForEach(&part, func(i int64) error {
|
return ps.ForEach(&part, func(i int64) error {
|
||||||
return cb(uint64(i), &v0Partition{part, d.store})
|
return cb(uint64(i), &v0Partition{part, d.store})
|
||||||
})
|
})
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"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"
|
||||||
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"
|
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"
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
@ -33,7 +33,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)
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
"github.com/filecoin-project/specs-actors/actors/util/smoothing"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/multisig"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
|
||||||
|
Loading…
Reference in New Issue
Block a user