specs-actors: Fix most compilation errors
This commit is contained in:
parent
41daf5ad28
commit
c72727b4fd
@ -112,17 +112,17 @@ type FullNode interface {
|
||||
StateMinerPower(context.Context, address.Address, *types.TipSet) (MinerPower, error)
|
||||
StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error)
|
||||
StateMinerPeerID(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error)
|
||||
StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error)
|
||||
StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (abi.ChainEpoch, error)
|
||||
StateMinerSectorSize(context.Context, address.Address, *types.TipSet) (abi.SectorSize, error)
|
||||
StateMinerFaults(context.Context, address.Address, *types.TipSet) ([]uint64, error)
|
||||
StateMinerFaults(context.Context, address.Address, *types.TipSet) ([]abi.SectorNumber, error)
|
||||
StatePledgeCollateral(context.Context, *types.TipSet) (types.BigInt, error)
|
||||
StateWaitMsg(context.Context, cid.Cid) (*MsgWait, error)
|
||||
StateListMiners(context.Context, *types.TipSet) ([]address.Address, error)
|
||||
StateListActors(context.Context, *types.TipSet) ([]address.Address, error)
|
||||
StateMarketBalance(context.Context, address.Address, *types.TipSet) (MarketBalance, error)
|
||||
StateMarketParticipants(context.Context, *types.TipSet) (map[string]MarketBalance, error)
|
||||
StateMarketDeals(context.Context, *types.TipSet) (map[string]market.DealProposal, error)
|
||||
StateMarketStorageDeal(context.Context, abi.DealID, *types.TipSet) (*market.DealProposal, error)
|
||||
StateMarketDeals(context.Context, *types.TipSet) (map[string]MarketDeal, error)
|
||||
StateMarketStorageDeal(context.Context, abi.DealID, *types.TipSet) (*MarketDeal, error)
|
||||
StateLookupID(context.Context, address.Address, *types.TipSet) (address.Address, error)
|
||||
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error)
|
||||
StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error)
|
||||
@ -190,7 +190,7 @@ type Message struct {
|
||||
}
|
||||
|
||||
type ChainSectorInfo struct {
|
||||
SectorID uint64
|
||||
SectorID abi.SectorNumber
|
||||
CommD []byte
|
||||
CommR []byte
|
||||
}
|
||||
@ -269,6 +269,11 @@ type MarketBalance struct {
|
||||
Locked big.Int
|
||||
}
|
||||
|
||||
type MarketDeal struct {
|
||||
Proposal market.DealProposal
|
||||
State market.DealState
|
||||
}
|
||||
|
||||
type RetrievalOrder struct {
|
||||
// TODO: make this less unixfs specific
|
||||
Root cid.Cid
|
||||
|
@ -88,20 +88,20 @@ type StorageMiner interface {
|
||||
|
||||
ActorAddress(context.Context) (address.Address, error)
|
||||
|
||||
ActorSectorSize(context.Context, address.Address) (uint64, error)
|
||||
ActorSectorSize(context.Context, address.Address) (abi.SectorSize, error)
|
||||
|
||||
// Temp api for testing
|
||||
PledgeSector(context.Context) error
|
||||
|
||||
// Get the status of a given sector by ID
|
||||
SectorsStatus(context.Context, uint64) (SectorInfo, error)
|
||||
SectorsStatus(context.Context, abi.SectorNumber) (SectorInfo, error)
|
||||
|
||||
// List all staged sectors
|
||||
SectorsList(context.Context) ([]uint64, error)
|
||||
SectorsList(context.Context) ([]abi.SectorNumber, error)
|
||||
|
||||
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
||||
|
||||
SectorsUpdate(context.Context, uint64, SectorState) error
|
||||
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
|
||||
|
||||
WorkerStats(context.Context) (sectorbuilder.WorkerStats, error)
|
||||
|
||||
@ -121,12 +121,12 @@ type SectorLog struct {
|
||||
}
|
||||
|
||||
type SectorInfo struct {
|
||||
SectorID uint64
|
||||
SectorID abi.SectorNumber
|
||||
State SectorState
|
||||
CommD []byte
|
||||
CommR []byte
|
||||
Proof []byte
|
||||
Deals []uint64
|
||||
Deals []abi.DealID
|
||||
Ticket sectorbuilder.SealTicket
|
||||
Seed sectorbuilder.SealSeed
|
||||
Retries uint64
|
||||
|
@ -3,9 +3,9 @@ package apistruct
|
||||
import (
|
||||
"context"
|
||||
|
||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
|
||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
@ -100,9 +100,9 @@ type FullNodeStruct struct {
|
||||
StateMinerPower func(context.Context, address.Address, *types.TipSet) (api.MinerPower, error) `perm:"read"`
|
||||
StateMinerWorker func(context.Context, address.Address, *types.TipSet) (address.Address, error) `perm:"read"`
|
||||
StateMinerPeerID func(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) `perm:"read"`
|
||||
StateMinerElectionPeriodStart func(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) `perm:"read"`
|
||||
StateMinerElectionPeriodStart func(ctx context.Context, actor address.Address, ts *types.TipSet) (abi.ChainEpoch, error) `perm:"read"`
|
||||
StateMinerSectorSize func(context.Context, address.Address, *types.TipSet) (abi.SectorSize, error) `perm:"read"`
|
||||
StateMinerFaults func(context.Context, address.Address, *types.TipSet) ([]uint64, error) `perm:"read"`
|
||||
StateMinerFaults func(context.Context, address.Address, *types.TipSet) ([]abi.SectorNumber, error) `perm:"read"`
|
||||
StateCall func(context.Context, *types.Message, *types.TipSet) (*api.MethodCall, error) `perm:"read"`
|
||||
StateReplay func(context.Context, *types.TipSet, cid.Cid) (*api.ReplayResults, error) `perm:"read"`
|
||||
StateGetActor func(context.Context, address.Address, *types.TipSet) (*types.Actor, error) `perm:"read"`
|
||||
@ -113,8 +113,8 @@ type FullNodeStruct struct {
|
||||
StateListActors func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"`
|
||||
StateMarketBalance func(context.Context, address.Address, *types.TipSet) (api.MarketBalance, error) `perm:"read"`
|
||||
StateMarketParticipants func(context.Context, *types.TipSet) (map[string]api.MarketBalance, error) `perm:"read"`
|
||||
StateMarketDeals func(context.Context, *types.TipSet) (map[string]market.DealProposal, error) `perm:"read"`
|
||||
StateMarketStorageDeal func(context.Context, abi.DealID, *types.TipSet) (*market.DealProposal, error) `perm:"read"`
|
||||
StateMarketDeals func(context.Context, *types.TipSet) (map[string]api.MarketDeal, error) `perm:"read"`
|
||||
StateMarketStorageDeal func(context.Context, abi.DealID, *types.TipSet) (*api.MarketDeal, error) `perm:"read"`
|
||||
StateLookupID func(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) `perm:"read"`
|
||||
StateChangedActors func(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) `perm:"read"`
|
||||
StateGetReceipt func(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"`
|
||||
@ -150,15 +150,15 @@ type StorageMinerStruct struct {
|
||||
CommonStruct
|
||||
|
||||
Internal struct {
|
||||
ActorAddress func(context.Context) (address.Address, error) `perm:"read"`
|
||||
ActorSectorSize func(context.Context, address.Address) (uint64, error) `perm:"read"`
|
||||
ActorAddress func(context.Context) (address.Address, error) `perm:"read"`
|
||||
ActorSectorSize func(context.Context, address.Address) (abi.SectorSize, error) `perm:"read"`
|
||||
|
||||
PledgeSector func(context.Context) error `perm:"write"`
|
||||
|
||||
SectorsStatus func(context.Context, uint64) (api.SectorInfo, error) `perm:"read"`
|
||||
SectorsList func(context.Context) ([]uint64, error) `perm:"read"`
|
||||
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
|
||||
SectorsUpdate func(context.Context, uint64, api.SectorState) error `perm:"write"`
|
||||
SectorsStatus func(context.Context, abi.SectorNumber) (api.SectorInfo, error) `perm:"read"`
|
||||
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
|
||||
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
|
||||
SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"write"`
|
||||
|
||||
WorkerStats func(context.Context) (sectorbuilder.WorkerStats, error) `perm:"read"`
|
||||
|
||||
@ -412,7 +412,7 @@ func (c *FullNodeStruct) StateMinerPeerID(ctx context.Context, m address.Address
|
||||
return c.Internal.StateMinerPeerID(ctx, m, ts)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) {
|
||||
func (c *FullNodeStruct) StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (abi.ChainEpoch, error) {
|
||||
return c.Internal.StateMinerElectionPeriodStart(ctx, actor, ts)
|
||||
}
|
||||
|
||||
@ -420,7 +420,7 @@ func (c *FullNodeStruct) StateMinerSectorSize(ctx context.Context, actor address
|
||||
return c.Internal.StateMinerSectorSize(ctx, actor, ts)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, ts *types.TipSet) ([]uint64, error) {
|
||||
func (c *FullNodeStruct) StateMinerFaults(ctx context.Context, actor address.Address, ts *types.TipSet) ([]abi.SectorNumber, error) {
|
||||
return c.Internal.StateMinerFaults(ctx, actor, ts)
|
||||
}
|
||||
|
||||
@ -463,11 +463,11 @@ func (c *FullNodeStruct) StateMarketParticipants(ctx context.Context, ts *types.
|
||||
return c.Internal.StateMarketParticipants(ctx, ts)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[string]market.DealProposal, error) {
|
||||
func (c *FullNodeStruct) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[string]api.MarketDeal, error) {
|
||||
return c.Internal.StateMarketDeals(ctx, ts)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) StateMarketStorageDeal(ctx context.Context, dealid abi.DealID, ts *types.TipSet) (*market.DealProposal, error) {
|
||||
func (c *FullNodeStruct) StateMarketStorageDeal(ctx context.Context, dealid abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
|
||||
return c.Internal.StateMarketStorageDeal(ctx, dealid, ts)
|
||||
}
|
||||
|
||||
@ -551,7 +551,7 @@ func (c *StorageMinerStruct) ActorAddress(ctx context.Context) (address.Address,
|
||||
return c.Internal.ActorAddress(ctx)
|
||||
}
|
||||
|
||||
func (c *StorageMinerStruct) ActorSectorSize(ctx context.Context, addr address.Address) (uint64, error) {
|
||||
func (c *StorageMinerStruct) ActorSectorSize(ctx context.Context, addr address.Address) (abi.SectorSize, error) {
|
||||
return c.Internal.ActorSectorSize(ctx, addr)
|
||||
}
|
||||
|
||||
@ -560,12 +560,12 @@ func (c *StorageMinerStruct) PledgeSector(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Get the status of a given sector by ID
|
||||
func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid uint64) (api.SectorInfo, error) {
|
||||
func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid abi.SectorNumber) (api.SectorInfo, error) {
|
||||
return c.Internal.SectorsStatus(ctx, sid)
|
||||
}
|
||||
|
||||
// List all staged sectors
|
||||
func (c *StorageMinerStruct) SectorsList(ctx context.Context) ([]uint64, error) {
|
||||
func (c *StorageMinerStruct) SectorsList(ctx context.Context) ([]abi.SectorNumber, error) {
|
||||
return c.Internal.SectorsList(ctx)
|
||||
}
|
||||
|
||||
@ -573,7 +573,7 @@ func (c *StorageMinerStruct) SectorsRefs(ctx context.Context) (map[string][]api.
|
||||
return c.Internal.SectorsRefs(ctx)
|
||||
}
|
||||
|
||||
func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id uint64, state api.SectorState) error {
|
||||
func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
||||
return c.Internal.SectorsUpdate(ctx, id, state)
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ type StorageMinerActorState struct {
|
||||
// The height at which this miner was slashed at.
|
||||
SlashedAt uint64
|
||||
|
||||
ElectionPeriodStart uint64
|
||||
ElectionPeriodStart abi.ChainEpoch
|
||||
}
|
||||
|
||||
// 46356:
|
||||
@ -355,7 +355,7 @@ func (sma StorageMinerActor) ProveCommitSector(act *types.Actor, vmctx types.VMC
|
||||
self.ProvingSet = self.Sectors
|
||||
// TODO: probably want to wait until the miner is above a certain
|
||||
// threshold before starting this
|
||||
self.ElectionPeriodStart = uint64(vmctx.BlockHeight())
|
||||
self.ElectionPeriodStart = (vmctx.BlockHeight())
|
||||
}
|
||||
|
||||
nstate, err := vmctx.Storage().Put(self)
|
||||
@ -411,7 +411,7 @@ func (sma StorageMinerActor) SubmitFallbackPoSt(act *types.Actor, vmctx types.VM
|
||||
var seed [sectorbuilder.CommLen]byte
|
||||
{
|
||||
randHeight := self.ElectionPeriodStart + build.FallbackPoStDelay
|
||||
if uint64(vmctx.BlockHeight()) <= randHeight {
|
||||
if (vmctx.BlockHeight()) <= randHeight {
|
||||
// TODO: spec, retcode
|
||||
return nil, aerrors.Newf(1, "submit fallback PoSt called too early (%d < %d)", vmctx.BlockHeight(), randHeight)
|
||||
}
|
||||
@ -974,7 +974,7 @@ func onSuccessfulPoSt2(self *StorageMinerActorState, vmctx types.VMContext, acti
|
||||
enc, err := SerializeParams(&UpdateStorageParams{
|
||||
Delta: delta,
|
||||
NextSlashDeadline: uint64(vmctx.BlockHeight()) + build.SlashablePowerDelay,
|
||||
PreviousSlashDeadline: prevSlashingDeadline,
|
||||
PreviousSlashDeadline: uint64(prevSlashingDeadline),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -985,7 +985,7 @@ func onSuccessfulPoSt2(self *StorageMinerActorState, vmctx types.VMContext, acti
|
||||
return aerrors.Wrap(err, "updating storage failed")
|
||||
}
|
||||
|
||||
self.ElectionPeriodStart = uint64(vmctx.BlockHeight())
|
||||
self.ElectionPeriodStart = vmctx.BlockHeight()
|
||||
}
|
||||
|
||||
var ncid cid.Cid
|
||||
@ -1121,7 +1121,7 @@ type UpdatePeerIDParams struct {
|
||||
}
|
||||
|
||||
func isLate(height uint64, self *StorageMinerActorState) bool {
|
||||
return self.ElectionPeriodStart > 0 && height >= self.ElectionPeriodStart+build.SlashablePowerDelay
|
||||
return self.ElectionPeriodStart > 0 && height >= uint64(self.ElectionPeriodStart+build.SlashablePowerDelay)
|
||||
}
|
||||
|
||||
type CheckMinerParams struct {
|
||||
|
@ -459,7 +459,6 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error {
|
||||
if maj != cbg.MajUnsignedInt {
|
||||
return fmt.Errorf("wrong type for uint64 field")
|
||||
}
|
||||
t.ElectionPeriodStart = uint64(extra)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
|
||||
var commRa [32]byte
|
||||
copy(commRa[:], s.CommR)
|
||||
sinfos = append(sinfos, ffi.PublicSectorInfo{
|
||||
SectorID: s.SectorID,
|
||||
SectorID: uint64(s.SectorID),
|
||||
CommR: commRa,
|
||||
})
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ func GetMinerWorker(ctx context.Context, sm *StateManager, ts *types.TipSet, mad
|
||||
return address.NewFromBytes(recp.Return)
|
||||
}
|
||||
|
||||
func GetMinerElectionPeriodStart(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (uint64, error) {
|
||||
func GetMinerElectionPeriodStart(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (abi.ChainEpoch, error) {
|
||||
var mas actors.StorageMinerActorState
|
||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||
if err != nil {
|
||||
@ -222,7 +222,7 @@ func GetSectorsForElectionPost(ctx context.Context, sm *StateManager, ts *types.
|
||||
var uselessBuffer [32]byte
|
||||
copy(uselessBuffer[:], s.CommR)
|
||||
uselessOtherArray = append(uselessOtherArray, ffi.PublicSectorInfo{
|
||||
SectorID: s.SectorID,
|
||||
SectorID: uint64(s.SectorID),
|
||||
CommR: uselessBuffer,
|
||||
})
|
||||
}
|
||||
@ -257,7 +257,7 @@ func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, ma
|
||||
return mas.SlashedAt, nil
|
||||
}
|
||||
|
||||
func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]uint64, error) {
|
||||
func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]abi.SectorNumber, error) {
|
||||
var mas actors.StorageMinerActorState
|
||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||
if err != nil {
|
||||
@ -269,10 +269,20 @@ func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, mad
|
||||
return nil, aerrors.HandleExternalError(lerr, "could not load proving set node")
|
||||
}
|
||||
|
||||
return mas.FaultSet.All(2 * ss.Count)
|
||||
faults, err := mas.FaultSet.All(2 * ss.Count)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("reading fault bit set: %w", err)
|
||||
}
|
||||
|
||||
out := make([]abi.SectorNumber, len(faults))
|
||||
for i, fault := range faults {
|
||||
out[i] = abi.SectorNumber(fault)
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func GetStorageDeal(ctx context.Context, sm *StateManager, dealId uint64, ts *types.TipSet) (*market.DealProposal, error) {
|
||||
func GetStorageDeal(ctx context.Context, sm *StateManager, dealId abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
|
||||
var state actors.StorageMarketState
|
||||
if _, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil {
|
||||
return nil, err
|
||||
@ -283,12 +293,25 @@ func GetStorageDeal(ctx context.Context, sm *StateManager, dealId uint64, ts *ty
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var ocd market.DealProposal
|
||||
if err := da.Get(ctx, dealId, &ocd); err != nil {
|
||||
var dp market.DealProposal
|
||||
if err := da.Get(ctx, uint64(dealId), &dp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ocd, nil
|
||||
sa, err := amt.LoadAMT(ctx, cbor.NewCborStore(sm.ChainStore().Blockstore()), state.States)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var st market.DealState
|
||||
if err := sa.Get(ctx, uint64(dealId), &st); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &api.MarketDeal{
|
||||
Proposal: dp,
|
||||
State: st,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([]address.Address, error) {
|
||||
@ -319,7 +342,7 @@ func LoadSectorsFromSet(ctx context.Context, bs blockstore.Blockstore, ssc cid.C
|
||||
return err
|
||||
}
|
||||
sset = append(sset, &api.ChainSectorInfo{
|
||||
SectorID: i,
|
||||
SectorID: abi.SectorNumber(i),
|
||||
CommR: comms[0],
|
||||
CommD: comms[1],
|
||||
})
|
||||
|
@ -43,7 +43,7 @@ var infoCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Sector Size: %s\n", types.NewInt(sizeByte).SizeStr())
|
||||
fmt.Printf("Sector Size: %s\n", types.SizeStr(types.NewInt(uint64(sizeByte))))
|
||||
|
||||
pow, err := api.StateMinerPower(ctx, maddr, nil)
|
||||
if err != nil {
|
||||
@ -51,7 +51,7 @@ var infoCmd = &cli.Command{
|
||||
}
|
||||
|
||||
percI := types.BigDiv(types.BigMul(pow.MinerPower, types.NewInt(1000000)), pow.TotalPower)
|
||||
fmt.Printf("Power: %s / %s (%0.4f%%)\n", pow.MinerPower.SizeStr(), pow.TotalPower.SizeStr(), float64(percI.Int64())/10000)
|
||||
fmt.Printf("Power: %s / %s (%0.4f%%)\n", types.SizeStr(pow.MinerPower), types.SizeStr(pow.TotalPower), float64(percI.Int64())/10000)
|
||||
|
||||
secCounts, err := api.StateMinerSectorCount(ctx, maddr, nil)
|
||||
if err != nil {
|
||||
@ -62,13 +62,13 @@ var infoCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("\tCommitted: %s\n", types.BigMul(types.NewInt(secCounts.Sset), types.NewInt(sizeByte)).SizeStr())
|
||||
fmt.Printf("\tCommitted: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Sset), types.NewInt(uint64(sizeByte)))))
|
||||
if len(faults) == 0 {
|
||||
fmt.Printf("\tProving: %s\n", types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(sizeByte)).SizeStr())
|
||||
fmt.Printf("\tProving: %s\n", types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset), types.NewInt(uint64(sizeByte)))))
|
||||
} else {
|
||||
fmt.Printf("\tProving: %s (%s Faulty, %.2f%%)\n",
|
||||
types.BigMul(types.NewInt(secCounts.Pset-uint64(len(faults))), types.NewInt(sizeByte)).SizeStr(),
|
||||
types.BigMul(types.NewInt(uint64(len(faults))), types.NewInt(sizeByte)).SizeStr(),
|
||||
types.SizeStr(types.BigMul(types.NewInt(secCounts.Pset-uint64(len(faults))), types.NewInt(uint64(sizeByte)))),
|
||||
types.SizeStr(types.BigMul(types.NewInt(uint64(len(faults))), types.NewInt(uint64(sizeByte)))),
|
||||
float64(10000*uint64(len(faults))/secCounts.Pset)/100.)
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
deals "github.com/filecoin-project/go-fil-markets/storagemarket/impl"
|
||||
paramfetch "github.com/filecoin-project/go-paramfetch"
|
||||
"github.com/filecoin-project/go-sectorbuilder"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/ipfs/go-datastore"
|
||||
"github.com/ipfs/go-datastore/namespace"
|
||||
badger "github.com/ipfs/go-ds-badger2"
|
||||
@ -89,7 +90,7 @@ var initCmd = &cli.Command{
|
||||
Action: func(cctx *cli.Context) error {
|
||||
log.Info("Initializing lotus storage miner")
|
||||
|
||||
ssize := cctx.Uint64("sector-size")
|
||||
ssize := abi.SectorSize(cctx.Uint64("sector-size"))
|
||||
|
||||
symlink := cctx.Bool("symlink-imported-sectors")
|
||||
if symlink {
|
||||
@ -97,7 +98,7 @@ var initCmd = &cli.Command{
|
||||
}
|
||||
|
||||
log.Info("Checking proof parameters")
|
||||
if err := paramfetch.GetParams(build.ParametersJson(), ssize); err != nil {
|
||||
if err := paramfetch.GetParams(build.ParametersJson(), uint64(ssize)); err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
||||
@ -256,7 +257,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
|
||||
Pieces: []sealing.Piece{
|
||||
{
|
||||
DealID: dealID,
|
||||
Size: meta.SectorSize,
|
||||
Size: abi.PaddedPieceSize(meta.SectorSize).Unpadded(),
|
||||
CommP: sector.CommD[:],
|
||||
},
|
||||
},
|
||||
@ -314,7 +315,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin
|
||||
return nil
|
||||
}
|
||||
|
||||
func findMarketDealID(ctx context.Context, api lapi.FullNode, deal actors.StorageDealProposal) (uint64, error) {
|
||||
func findMarketDealID(ctx context.Context, api lapi.FullNode, deal actors.StorageDealProposal) (abi.DealID, error) {
|
||||
// TODO: find a better way
|
||||
// (this is only used by genesis miners)
|
||||
|
||||
@ -546,7 +547,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
||||
params, err := actors.SerializeParams(&actors.CreateStorageMinerParams{
|
||||
Owner: owner,
|
||||
Worker: worker,
|
||||
SectorSize: ssize,
|
||||
SectorSize: abi.SectorSize(ssize),
|
||||
PeerID: peerid,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"golang.org/x/xerrors"
|
||||
"gopkg.in/urfave/cli.v2"
|
||||
|
||||
@ -67,7 +68,7 @@ var sectorsStatusCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
status, err := nodeApi.SectorsStatus(ctx, id)
|
||||
status, err := nodeApi.SectorsStatus(ctx, abi.SectorNumber(id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -133,7 +134,7 @@ var sectorsListCmd = &cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
provingIDs := make(map[uint64]struct{}, len(pset))
|
||||
provingIDs := make(map[abi.SectorNumber]struct{}, len(pset))
|
||||
for _, info := range pset {
|
||||
provingIDs[info.SectorID] = struct{}{}
|
||||
}
|
||||
@ -142,7 +143,7 @@ var sectorsListCmd = &cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
commitedIDs := make(map[uint64]struct{}, len(pset))
|
||||
commitedIDs := make(map[abi.SectorNumber]struct{}, len(pset))
|
||||
for _, info := range sset {
|
||||
commitedIDs[info.SectorID] = struct{}{}
|
||||
}
|
||||
@ -239,7 +240,7 @@ var sectorsUpdateCmd = &cli.Command{
|
||||
}
|
||||
}
|
||||
|
||||
return nodeApi.SectorsUpdate(ctx, id, st)
|
||||
return nodeApi.SectorsUpdate(ctx, abi.SectorNumber(id), st)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@ import (
|
||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||
retrievaltoken "github.com/filecoin-project/go-fil-markets/shared/tokenamount"
|
||||
retrievaltypes "github.com/filecoin-project/go-fil-markets/shared/types"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
|
||||
"github.com/filecoin-project/go-sectorbuilder"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/markets/utils"
|
||||
@ -26,7 +28,7 @@ func NewRetrievalProviderNode(miner *storage.Miner, sb sectorbuilder.Interface,
|
||||
return &retrievalProviderNode{miner, sb, full}
|
||||
}
|
||||
|
||||
func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID uint64, offset uint64, length uint64) (io.ReadCloser, error) {
|
||||
func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi.SectorNumber, offset uint64, length uint64) (io.ReadCloser, error) {
|
||||
si, err := rpn.miner.GetSectorInfo(sectorID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
@ -13,7 +15,7 @@ import (
|
||||
"github.com/filecoin-project/go-fil-markets/shared/tokenamount"
|
||||
sharedtypes "github.com/filecoin-project/go-fil-markets/shared/types"
|
||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/events"
|
||||
@ -98,7 +100,7 @@ func (n *ClientNodeAdapter) ListClientDeals(ctx context.Context, addr address.Ad
|
||||
var out []storagemarket.StorageDeal
|
||||
|
||||
for _, deal := range allDeals {
|
||||
storageDeal := utils.FromOnChainDeal(deal)
|
||||
storageDeal := utils.FromOnChainDeal(deal.Proposal, deal.State)
|
||||
if storageDeal.Client == addr {
|
||||
out = append(out, storageDeal)
|
||||
}
|
||||
@ -215,19 +217,19 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return res.DealIDs[dealIdx], nil
|
||||
return uint64(res.IDs[dealIdx]), nil
|
||||
}
|
||||
|
||||
func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealId uint64, cb storagemarket.DealSectorCommittedCallback) error {
|
||||
checkFunc := func(ts *types.TipSet) (done bool, more bool, err error) {
|
||||
sd, err := stmgr.GetStorageDeal(ctx, c.StateManager, dealId, ts)
|
||||
sd, err := stmgr.GetStorageDeal(ctx, c.StateManager, abi.DealID(dealId), ts)
|
||||
|
||||
if err != nil {
|
||||
// TODO: This may be fine for some errors
|
||||
return false, false, xerrors.Errorf("failed to look up deal on chain: %w", err)
|
||||
}
|
||||
|
||||
if sd.ActivationEpoch > 0 {
|
||||
if sd.Proposal.StartEpoch > 0 {
|
||||
cb(nil)
|
||||
return true, false, nil
|
||||
}
|
||||
@ -235,7 +237,7 @@ func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider
|
||||
return false, true, nil
|
||||
}
|
||||
|
||||
called := func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (more bool, err error) {
|
||||
called := func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
cb(xerrors.Errorf("handling applied event: %w", err))
|
||||
@ -247,16 +249,16 @@ func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider
|
||||
return false, nil
|
||||
}
|
||||
|
||||
sd, err := stmgr.GetStorageDeal(ctx, c.StateManager, dealId, ts)
|
||||
sd, err := stmgr.GetStorageDeal(ctx, c.StateManager, abi.DealID(dealId), ts)
|
||||
if err != nil {
|
||||
return false, xerrors.Errorf("failed to look up deal on chain: %w", err)
|
||||
}
|
||||
|
||||
if sd.ActivationEpoch == 0 {
|
||||
if sd.Proposal.StartEpoch == 0 {
|
||||
return false, xerrors.Errorf("deal wasn't active: deal=%d, parentState=%s, h=%d", dealId, ts.ParentState(), ts.Height())
|
||||
}
|
||||
|
||||
log.Infof("Storage deal %d activated at epoch %d", dealId, sd.ActivationEpoch)
|
||||
log.Infof("Storage deal %d activated at epoch %d", dealId, sd.State.SectorStartEpoch)
|
||||
|
||||
cb(nil)
|
||||
|
||||
@ -278,14 +280,14 @@ func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider
|
||||
return false, nil
|
||||
}
|
||||
|
||||
var params actors.SectorProveCommitInfo
|
||||
var params miner.SectorPreCommitInfo
|
||||
if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
var found bool
|
||||
for _, dealID := range params.DealIDs {
|
||||
if dealID == dealId {
|
||||
if uint64(dealID) == dealId {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
@ -302,19 +304,7 @@ func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider
|
||||
}
|
||||
|
||||
func (n *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Address, proposal *storagemarket.StorageDealProposal) error {
|
||||
localProposal, err := utils.FromSharedStorageDealProposal(proposal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = api.SignWith(ctx, n.Wallet.Sign, signer, localProposal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
signature, err := utils.ToSharedSignature(localProposal.ProposerSignature)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
proposal.ProposerSignature = signature
|
||||
// TODO: output spec signed proposal
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,9 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/ipfs/go-cid"
|
||||
logging "github.com/ipfs/go-log"
|
||||
"golang.org/x/xerrors"
|
||||
@ -60,7 +63,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
|
||||
return 0, cid.Undef, err
|
||||
}
|
||||
params, err := actors.SerializeParams(&actors.PublishStorageDealsParams{
|
||||
Deals: []actors.StorageDealProposal{*localProposal},
|
||||
Deals: []market.ClientDealProposal{*localProposal},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
@ -91,16 +94,15 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
|
||||
if err := resp.UnmarshalCBOR(bytes.NewReader(r.Receipt.Return)); err != nil {
|
||||
return 0, cid.Undef, err
|
||||
}
|
||||
if len(resp.DealIDs) != 1 {
|
||||
if len(resp.IDs) != 1 {
|
||||
return 0, cid.Undef, xerrors.Errorf("got unexpected number of DealIDs from")
|
||||
}
|
||||
|
||||
return storagemarket.DealID(resp.DealIDs[0]), smsg.Cid(), nil
|
||||
return resp.IDs[0], smsg.Cid(), nil
|
||||
}
|
||||
|
||||
func (n *ProviderNodeAdapter) OnDealComplete(ctx context.Context, deal storagemarket.MinerDeal, pieceSize uint64, pieceData io.Reader) error {
|
||||
|
||||
_, err := n.secb.AddPiece(ctx, pieceSize, pieceData, deal.DealID)
|
||||
_, err := n.secb.AddPiece(ctx, abi.UnpaddedPieceSize(pieceSize), pieceData, deal.DealID)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("AddPiece failed: %s", err)
|
||||
}
|
||||
@ -118,7 +120,7 @@ func (n *ProviderNodeAdapter) ListProviderDeals(ctx context.Context, addr addres
|
||||
var out []storagemarket.StorageDeal
|
||||
|
||||
for _, deal := range allDeals {
|
||||
sharedDeal := utils.FromOnChainDeal(deal)
|
||||
sharedDeal := utils.FromOnChainDeal(deal.Proposal, deal.State)
|
||||
if sharedDeal.Provider == addr {
|
||||
out = append(out, sharedDeal)
|
||||
}
|
||||
@ -186,7 +188,7 @@ func (n *ProviderNodeAdapter) GetBalance(ctx context.Context, addr address.Addre
|
||||
|
||||
func (n *ProviderNodeAdapter) LocatePieceForDealWithinSector(ctx context.Context, dealID uint64) (sectorID uint64, offset uint64, length uint64, err error) {
|
||||
|
||||
refs, err := n.secb.GetRefs(dealID)
|
||||
refs, err := n.secb.GetRefs(abi.DealID(dealID))
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
}
|
||||
@ -211,19 +213,19 @@ func (n *ProviderNodeAdapter) LocatePieceForDealWithinSector(ctx context.Context
|
||||
if bestSi.State == api.UndefinedSectorState {
|
||||
return 0, 0, 0, xerrors.New("no sealed sector found")
|
||||
}
|
||||
return best.SectorID, best.Offset, best.Size, nil
|
||||
return uint64(best.SectorID), best.Offset, uint64(best.Size), nil
|
||||
}
|
||||
|
||||
func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID uint64, cb storagemarket.DealSectorCommittedCallback) error {
|
||||
checkFunc := func(ts *types.TipSet) (done bool, more bool, err error) {
|
||||
sd, err := n.StateMarketStorageDeal(ctx, dealID, ts)
|
||||
sd, err := n.StateMarketStorageDeal(ctx, abi.DealID(dealID), ts)
|
||||
|
||||
if err != nil {
|
||||
// TODO: This may be fine for some errors
|
||||
return false, false, xerrors.Errorf("failed to look up deal on chain: %w", err)
|
||||
}
|
||||
|
||||
if sd.ActivationEpoch > 0 {
|
||||
if sd.State.SectorStartEpoch > 0 {
|
||||
cb(nil)
|
||||
return true, false, nil
|
||||
}
|
||||
@ -231,7 +233,7 @@ func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provide
|
||||
return false, true, nil
|
||||
}
|
||||
|
||||
called := func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH uint64) (more bool, err error) {
|
||||
called := func(msg *types.Message, rec *types.MessageReceipt, ts *types.TipSet, curH abi.ChainEpoch) (more bool, err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
cb(xerrors.Errorf("handling applied event: %w", err))
|
||||
@ -243,16 +245,16 @@ func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provide
|
||||
return false, nil
|
||||
}
|
||||
|
||||
sd, err := n.StateMarketStorageDeal(ctx, dealID, ts)
|
||||
sd, err := n.StateMarketStorageDeal(ctx, abi.DealID(dealID), ts)
|
||||
if err != nil {
|
||||
return false, xerrors.Errorf("failed to look up deal on chain: %w", err)
|
||||
}
|
||||
|
||||
if sd.ActivationEpoch == 0 {
|
||||
if sd.State.SectorStartEpoch < 1 {
|
||||
return false, xerrors.Errorf("deal wasn't active: deal=%d, parentState=%s, h=%d", dealID, ts.ParentState(), ts.Height())
|
||||
}
|
||||
|
||||
log.Infof("Storage deal %d activated at epoch %d", dealID, sd.ActivationEpoch)
|
||||
log.Infof("Storage deal %d activated at epoch %d", dealID, sd.State.SectorStartEpoch)
|
||||
|
||||
cb(nil)
|
||||
|
||||
@ -274,14 +276,14 @@ func (n *ProviderNodeAdapter) OnDealSectorCommitted(ctx context.Context, provide
|
||||
return false, nil
|
||||
}
|
||||
|
||||
var params actors.SectorProveCommitInfo
|
||||
var params miner.SectorPreCommitInfo
|
||||
if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
var found bool
|
||||
for _, did := range params.DealIDs {
|
||||
if did == dealID {
|
||||
if did == abi.DealID(dealID) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
sharedamount "github.com/filecoin-project/go-fil-markets/shared/tokenamount"
|
||||
sharedtypes "github.com/filecoin-project/go-fil-markets/shared/types"
|
||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
@ -129,10 +130,10 @@ func FromOnChainDeal(proposal market.DealProposal, state market.DealState) stora
|
||||
}
|
||||
}
|
||||
|
||||
func ToSharedBalance(escrow, locked abi.TokenAmount) storagemarket.Balance {
|
||||
func ToSharedBalance(bal api.MarketBalance) storagemarket.Balance {
|
||||
return storagemarket.Balance{
|
||||
Locked: ToSharedTokenAmount(locked),
|
||||
Available: ToSharedTokenAmount(big.Sub(escrow, locked)),
|
||||
Locked: ToSharedTokenAmount(bal.Locked),
|
||||
Available: ToSharedTokenAmount(big.Sub(bal.Escrow, bal.Locked)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,16 +151,7 @@ func ToSharedStorageDealProposal(proposal *actors.StorageDealProposal) (*storage
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func FromSharedStorageDealProposal(proposal *storagemarket.StorageDealProposal) (*actors.StorageDealProposal, error) {
|
||||
var encoded bytes.Buffer
|
||||
err := proposal.MarshalCBOR(&encoded)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var out actors.StorageDealProposal
|
||||
err = out.UnmarshalCBOR(&encoded)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &out, nil
|
||||
func FromSharedStorageDealProposal(proposal *storagemarket.StorageDealProposal) (*market.ClientDealProposal, error) {
|
||||
panic("todo")
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func (a *StateAPI) StateMinerPeerID(ctx context.Context, m address.Address, ts *
|
||||
return stmgr.GetMinerPeerID(ctx, a.StateManager, ts, m)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) {
|
||||
func (a *StateAPI) StateMinerElectionPeriodStart(ctx context.Context, actor address.Address, ts *types.TipSet) (abi.ChainEpoch, error) {
|
||||
return stmgr.GetMinerElectionPeriodStart(ctx, a.StateManager, ts, actor)
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ func (a *StateAPI) StateMinerSectorSize(ctx context.Context, actor address.Addre
|
||||
return stmgr.GetMinerSectorSize(ctx, a.StateManager, ts, actor)
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMinerFaults(ctx context.Context, addr address.Address, ts *types.TipSet) ([]uint64, error) {
|
||||
func (a *StateAPI) StateMinerFaults(ctx context.Context, addr address.Address, ts *types.TipSet) ([]abi.SectorNumber, error) {
|
||||
return stmgr.GetMinerFaults(ctx, a.StateManager, ts, addr)
|
||||
}
|
||||
|
||||
@ -288,8 +288,8 @@ func (a *StateAPI) StateMarketParticipants(ctx context.Context, ts *types.TipSet
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[string]market.DealProposal, error) {
|
||||
out := map[string]market.DealProposal{}
|
||||
func (a *StateAPI) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[string]api.MarketDeal, error) {
|
||||
out := map[string]api.MarketDeal{}
|
||||
|
||||
var state actors.StorageMarketState
|
||||
if _, err := a.StateManager.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil {
|
||||
@ -302,12 +302,25 @@ func (a *StateAPI) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sa, err := amt.LoadAMT(ctx, blks, state.States)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := da.ForEach(ctx, func(i uint64, v *cbg.Deferred) error {
|
||||
var d market.DealProposal
|
||||
if err := d.UnmarshalCBOR(bytes.NewReader(v.Raw)); err != nil {
|
||||
return err
|
||||
}
|
||||
out[strconv.FormatInt(int64(i), 10)] = d
|
||||
|
||||
var s market.DealState
|
||||
if err := sa.Get(ctx, i, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
out[strconv.FormatInt(int64(i), 10)] = api.MarketDeal{
|
||||
Proposal: d,
|
||||
State: s,
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
@ -315,7 +328,7 @@ func (a *StateAPI) StateMarketDeals(ctx context.Context, ts *types.TipSet) (map[
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMarketStorageDeal(ctx context.Context, dealId uint64, ts *types.TipSet) (*market.DealProposal, error) {
|
||||
func (a *StateAPI) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
|
||||
return stmgr.GetStorageDeal(ctx, a.StateManager, dealId, ts)
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/gorilla/mux"
|
||||
files "github.com/ipfs/go-ipfs-files"
|
||||
|
||||
@ -63,7 +64,7 @@ func (sm *StorageMinerAPI) remoteGetSector(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
path, err := sm.SectorBuilder.SectorPath(fs.DataType(vars["type"]), id)
|
||||
path, err := sm.SectorBuilder.SectorPath(fs.DataType(vars["type"]), abi.SectorNumber(id))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
w.WriteHeader(500)
|
||||
@ -110,7 +111,7 @@ func (sm *StorageMinerAPI) remotePutSector(w http.ResponseWriter, r *http.Reques
|
||||
|
||||
// This is going to get better with worker-to-worker transfers
|
||||
|
||||
path, err := sm.SectorBuilder.SectorPath(fs.DataType(vars["type"]), id)
|
||||
path, err := sm.SectorBuilder.SectorPath(fs.DataType(vars["type"]), abi.SectorNumber(id))
|
||||
if err != nil {
|
||||
if err != fs.ErrNotFound {
|
||||
log.Error(err)
|
||||
@ -118,7 +119,7 @@ func (sm *StorageMinerAPI) remotePutSector(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
path, err = sm.SectorBuilder.AllocSectorPath(fs.DataType(vars["type"]), id, true)
|
||||
path, err = sm.SectorBuilder.AllocSectorPath(fs.DataType(vars["type"]), abi.SectorNumber(id), true)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
w.WriteHeader(500)
|
||||
@ -168,7 +169,7 @@ func (sm *StorageMinerAPI) ActorAddress(context.Context) (address.Address, error
|
||||
return sm.SectorBuilderConfig.Miner, nil
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) ActorSectorSize(ctx context.Context, addr address.Address) (uint64, error) {
|
||||
func (sm *StorageMinerAPI) ActorSectorSize(ctx context.Context, addr address.Address) (abi.SectorSize, error) {
|
||||
return sm.Full.StateMinerSectorSize(ctx, addr, nil)
|
||||
}
|
||||
|
||||
@ -176,13 +177,13 @@ func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) error {
|
||||
return sm.Miner.PledgeSector()
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid uint64) (api.SectorInfo, error) {
|
||||
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumber) (api.SectorInfo, error) {
|
||||
info, err := sm.Miner.GetSectorInfo(sid)
|
||||
if err != nil {
|
||||
return api.SectorInfo{}, err
|
||||
}
|
||||
|
||||
deals := make([]uint64, len(info.Pieces))
|
||||
deals := make([]abi.DealID, len(info.Pieces))
|
||||
for i, piece := range info.Pieces {
|
||||
deals[i] = piece.DealID
|
||||
}
|
||||
@ -214,13 +215,13 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid uint64) (api.S
|
||||
}
|
||||
|
||||
// List all staged sectors
|
||||
func (sm *StorageMinerAPI) SectorsList(context.Context) ([]uint64, error) {
|
||||
func (sm *StorageMinerAPI) SectorsList(context.Context) ([]abi.SectorNumber, error) {
|
||||
sectors, err := sm.Miner.ListSectors()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := make([]uint64, len(sectors))
|
||||
out := make([]abi.SectorNumber, len(sectors))
|
||||
for i, sector := range sectors {
|
||||
out[i] = sector.SectorID
|
||||
}
|
||||
@ -243,7 +244,7 @@ func (sm *StorageMinerAPI) SectorsRefs(context.Context) (map[string][]api.Sealed
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) SectorsUpdate(ctx context.Context, id uint64, state api.SectorState) error {
|
||||
func (sm *StorageMinerAPI) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
||||
return sm.Miner.ForceSectorState(ctx, id, state)
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ func minerAddrFromDS(ds dtypes.MetadataDS) (address.Address, error) {
|
||||
}
|
||||
|
||||
func GetParams(sbc *sectorbuilder.Config) error {
|
||||
if err := paramfetch.GetParams(build.ParametersJson(), sbc.SectorSize); err != nil {
|
||||
if err := paramfetch.GetParams(build.ParametersJson(), uint64(sbc.SectorSize)); err != nil {
|
||||
return xerrors.Errorf("fetching proof parameters: %w", err)
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ func SealTicketGen(api api.FullNode) sealing.TicketFn {
|
||||
}
|
||||
|
||||
return §orbuilder.SealTicket{
|
||||
BlockHeight: ts.Height(),
|
||||
BlockHeight: uint64(ts.Height()),
|
||||
TicketBytes: tkt,
|
||||
}, nil
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ func (s *FPoStScheduler) sortedSectorInfo(ctx context.Context, ts *types.TipSet)
|
||||
copy(commR[:], sector.CommR)
|
||||
|
||||
sbsi[k] = ffi.PublicSectorInfo{
|
||||
SectorID: sector.SectorID,
|
||||
SectorID: uint64(sector.SectorID),
|
||||
CommR: commR,
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/go-datastore"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
@ -51,7 +50,7 @@ type storageMinerApi interface {
|
||||
StateWaitMsg(context.Context, cid.Cid) (*api.MsgWait, error) // TODO: removeme eventually
|
||||
StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error)
|
||||
StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error)
|
||||
StateMarketStorageDeal(context.Context, abi.DealID, *types.TipSet) (*market.DealProposal, error)
|
||||
StateMarketStorageDeal(context.Context, abi.DealID, *types.TipSet) (*api.MarketDeal, error)
|
||||
StateMinerFaults(context.Context, address.Address, *types.TipSet) ([]abi.SectorNumber, error)
|
||||
|
||||
MpoolPushMessage(context.Context, *types.Message) (*types.SignedMessage, error)
|
||||
|
@ -24,7 +24,7 @@ func (m *Miner) ListSectors() ([]sealing.SectorInfo, error) {
|
||||
return m.sealing.ListSectors()
|
||||
}
|
||||
|
||||
func (m *Miner) GetSectorInfo(sid uint64) (sealing.SectorInfo, error) {
|
||||
func (m *Miner) GetSectorInfo(sid abi.SectorNumber) (sealing.SectorInfo, error) {
|
||||
return m.sealing.GetSectorInfo(sid)
|
||||
}
|
||||
|
||||
@ -32,6 +32,6 @@ func (m *Miner) PledgeSector() error {
|
||||
return m.sealing.PledgeSector()
|
||||
}
|
||||
|
||||
func (m *Miner) ForceSectorState(ctx context.Context, id uint64, state api.SectorState) error {
|
||||
func (m *Miner) ForceSectorState(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
||||
return m.sealing.ForceSectorState(ctx, id, state)
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func checkPieces(ctx context.Context, si SectorInfo, api sealingApi) error {
|
||||
return &ErrApi{xerrors.Errorf("getting deal %d for piece %d: %w", piece.DealID, i, err)}
|
||||
}
|
||||
|
||||
h, err := multihash.Decode(deal.PieceCID.Hash())
|
||||
h, err := multihash.Decode(deal.Proposal.PieceCID.Hash())
|
||||
if err != nil {
|
||||
return &ErrInvalidDeals{xerrors.Errorf("decoding piece CID: %w", err)}
|
||||
}
|
||||
@ -49,12 +49,12 @@ func checkPieces(ctx context.Context, si SectorInfo, api sealingApi) error {
|
||||
return &ErrInvalidDeals{xerrors.Errorf("piece %d (or %d) of sector %d refers deal %d with wrong CommP: %x != %x", i, len(si.Pieces), si.SectorID, piece.DealID, piece.CommP, h.Digest)}
|
||||
}
|
||||
|
||||
if piece.Size != deal.PieceSize.Unpadded() {
|
||||
return &ErrInvalidDeals{xerrors.Errorf("piece %d (or %d) of sector %d refers deal %d with different size: %d != %d", i, len(si.Pieces), si.SectorID, piece.DealID, piece.Size, deal.PieceSize)}
|
||||
if piece.Size != deal.Proposal.PieceSize.Unpadded() {
|
||||
return &ErrInvalidDeals{xerrors.Errorf("piece %d (or %d) of sector %d refers deal %d with different size: %d != %d", i, len(si.Pieces), si.SectorID, piece.DealID, piece.Size, deal.Proposal.PieceSize)}
|
||||
}
|
||||
|
||||
if head.Height() >= deal.StartEpoch {
|
||||
return &ErrExpiredDeals{xerrors.Errorf("piece %d (or %d) of sector %d refers expired deal %d - should start at %d, head %d", i, len(si.Pieces), si.SectorID, piece.DealID, deal.StartEpoch, head.Height())}
|
||||
if head.Height() >= deal.Proposal.StartEpoch {
|
||||
return &ErrExpiredDeals{xerrors.Errorf("piece %d (or %d) of sector %d refers expired deal %d - should start at %d, head %d", i, len(si.Pieces), si.SectorID, piece.DealID, deal.Proposal.StartEpoch, head.Height())}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@ -237,7 +238,7 @@ func (m *Sealing) restartSectors(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Sealing) ForceSectorState(ctx context.Context, id uint64, state api.SectorState) error {
|
||||
func (m *Sealing) ForceSectorState(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
||||
return m.sectors.Send(id, SectorForceState{state})
|
||||
}
|
||||
|
||||
|
@ -5,15 +5,15 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-sectorbuilder"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/go-datastore"
|
||||
"github.com/ipfs/go-datastore/namespace"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-sectorbuilder"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/events"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
@ -39,7 +39,7 @@ type sealingApi interface { // TODO: trim down
|
||||
StateWaitMsg(context.Context, cid.Cid) (*api.MsgWait, error) // TODO: removeme eventually
|
||||
StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error)
|
||||
StateGetReceipt(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error)
|
||||
StateMarketStorageDeal(context.Context, abi.DealID, *types.TipSet) (*market.DealProposal, error)
|
||||
StateMarketStorageDeal(context.Context, abi.DealID, *types.TipSet) (*api.MarketDeal, error)
|
||||
|
||||
MpoolPushMessage(context.Context, *types.Message) (*types.SignedMessage, error)
|
||||
|
||||
|
@ -94,7 +94,7 @@ func (m *Sealing) ListSectors() ([]SectorInfo, error) {
|
||||
return sectors, nil
|
||||
}
|
||||
|
||||
func (m *Sealing) GetSectorInfo(sid uint64) (SectorInfo, error) {
|
||||
func (m *Sealing) GetSectorInfo(sid abi.SectorNumber) (SectorInfo, error) {
|
||||
var out SectorInfo
|
||||
err := m.sectors.Get(sid).Get(&out)
|
||||
return out, err
|
||||
|
Loading…
Reference in New Issue
Block a user