api: handle no-precommit in StateSectorPreCommitInfo gracefully
This commit is contained in:
parent
06b3e555c5
commit
9c4d10ec73
@ -457,10 +457,15 @@ type FullNode interface {
|
|||||||
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) //perm:read
|
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) //perm:read
|
||||||
// StateMinerAvailableBalance returns the portion of a miner's balance that can be withdrawn or spent
|
// StateMinerAvailableBalance returns the portion of a miner's balance that can be withdrawn or spent
|
||||||
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) //perm:read
|
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) //perm:read
|
||||||
// StateMinerSectorAllocated checks if a sector is allocated
|
// StateMinerSectorAllocated checks if a sector number is marked as allocated.
|
||||||
StateMinerSectorAllocated(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (bool, error) //perm:read
|
StateMinerSectorAllocated(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (bool, error) //perm:read
|
||||||
// StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector
|
// StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector.
|
||||||
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) //perm:read
|
// Returns nil and no error if the sector isn't precommitted.
|
||||||
|
//
|
||||||
|
// Note that the sector number may be allocated while PreCommitInfo is nil. This means that either allocated sector
|
||||||
|
// numbers were compacted, and the sector number was marked as allocated in order to reduce size of the allocated
|
||||||
|
// sectors bitfield, or that the sector was precommitted, but the precommit has expired.
|
||||||
|
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) //perm:read
|
||||||
// StateSectorGetInfo returns the on-chain info for the specified miner's sector. Returns null in case the sector info isn't found
|
// StateSectorGetInfo returns the on-chain info for the specified miner's sector. Returns null in case the sector info isn't found
|
||||||
// NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate
|
// NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate
|
||||||
// expiration epoch
|
// expiration epoch
|
||||||
|
@ -2949,10 +2949,10 @@ func (mr *MockFullNodeMockRecorder) StateSectorPartition(arg0, arg1, arg2, arg3
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StateSectorPreCommitInfo mocks base method.
|
// StateSectorPreCommitInfo mocks base method.
|
||||||
func (m *MockFullNode) StateSectorPreCommitInfo(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
|
func (m *MockFullNode) StateSectorPreCommitInfo(arg0 context.Context, arg1 address.Address, arg2 abi.SectorNumber, arg3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "StateSectorPreCommitInfo", arg0, arg1, arg2, arg3)
|
ret := m.ctrl.Call(m, "StateSectorPreCommitInfo", arg0, arg1, arg2, arg3)
|
||||||
ret0, _ := ret[0].(miner.SectorPreCommitOnChainInfo)
|
ret0, _ := ret[0].(*miner.SectorPreCommitOnChainInfo)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ type FullNodeStruct struct {
|
|||||||
|
|
||||||
StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"`
|
StateSectorPartition func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*lminer.SectorLocation, error) `perm:"read"`
|
||||||
|
|
||||||
StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
StateSectorPreCommitInfo func(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
||||||
|
|
||||||
StateVMCirculatingSupplyInternal func(p0 context.Context, p1 types.TipSetKey) (CirculatingSupply, error) `perm:"read"`
|
StateVMCirculatingSupplyInternal func(p0 context.Context, p1 types.TipSetKey) (CirculatingSupply, error) `perm:"read"`
|
||||||
|
|
||||||
@ -2895,15 +2895,15 @@ func (s *FullNodeStub) StateSectorPartition(p0 context.Context, p1 address.Addre
|
|||||||
return nil, ErrNotSupported
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStruct) StateSectorPreCommitInfo(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
|
func (s *FullNodeStruct) StateSectorPreCommitInfo(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) {
|
||||||
if s.Internal.StateSectorPreCommitInfo == nil {
|
if s.Internal.StateSectorPreCommitInfo == nil {
|
||||||
return *new(miner.SectorPreCommitOnChainInfo), ErrNotSupported
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
return s.Internal.StateSectorPreCommitInfo(p0, p1, p2, p3)
|
return s.Internal.StateSectorPreCommitInfo(p0, p1, p2, p3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStub) StateSectorPreCommitInfo(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
|
func (s *FullNodeStub) StateSectorPreCommitInfo(p0 context.Context, p1 address.Address, p2 abi.SectorNumber, p3 types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) {
|
||||||
return *new(miner.SectorPreCommitOnChainInfo), ErrNotSupported
|
return nil, ErrNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *FullNodeStruct) StateVMCirculatingSupplyInternal(p0 context.Context, p1 types.TipSetKey) (CirculatingSupply, error) {
|
func (s *FullNodeStruct) StateVMCirculatingSupplyInternal(p0 context.Context, p1 types.TipSetKey) (CirculatingSupply, error) {
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
"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/builtin/v8/miner"
|
||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -24,6 +25,18 @@ type WrapperV1Full struct {
|
|||||||
v1api.FullNode
|
v1api.FullNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *WrapperV1Full) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, s abi.SectorNumber, tsk types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) {
|
||||||
|
pi, err := w.FullNode.StateSectorPreCommitInfo(ctx, maddr, s, tsk)
|
||||||
|
if err != nil {
|
||||||
|
return miner.SectorPreCommitOnChainInfo{}, err
|
||||||
|
}
|
||||||
|
if pi == nil {
|
||||||
|
return miner.SectorPreCommitOnChainInfo{}, xerrors.Errorf("precommit info does not exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
return *pi, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (w *WrapperV1Full) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
|
func (w *WrapperV1Full) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
|
||||||
return w.FullNode.StateSearchMsg(ctx, types.EmptyTSK, msg, api.LookbackNoLimit, true)
|
return w.FullNode.StateSearchMsg(ctx, types.EmptyTSK, msg, api.LookbackNoLimit, true)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func VersionForType(nodeType NodeType) (Version, error) {
|
|||||||
// semver versions of the rpc api exposed
|
// semver versions of the rpc api exposed
|
||||||
var (
|
var (
|
||||||
FullAPIVersion0 = newVer(1, 5, 0)
|
FullAPIVersion0 = newVer(1, 5, 0)
|
||||||
FullAPIVersion1 = newVer(2, 2, 0)
|
FullAPIVersion1 = newVer(2, 3, 0)
|
||||||
|
|
||||||
MinerAPIVersion0 = newVer(1, 5, 0)
|
MinerAPIVersion0 = newVer(1, 5, 0)
|
||||||
WorkerAPIVersion0 = newVer(1, 6, 0)
|
WorkerAPIVersion0 = newVer(1, 6, 0)
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -233,7 +233,7 @@ Response:
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"Version": "string value",
|
"Version": "string value",
|
||||||
"APIVersion": 131584,
|
"APIVersion": 131840,
|
||||||
"BlockDelay": 42
|
"BlockDelay": 42
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -1460,7 +1460,7 @@ Perms: admin
|
|||||||
|
|
||||||
Inputs: `null`
|
Inputs: `null`
|
||||||
|
|
||||||
Response: `131584`
|
Response: `131840`
|
||||||
|
|
||||||
## Add
|
## Add
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ Response:
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"Version": "string value",
|
"Version": "string value",
|
||||||
"APIVersion": 131584,
|
"APIVersion": 131840,
|
||||||
"BlockDelay": 42
|
"BlockDelay": 42
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -300,7 +300,7 @@ Response:
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"Version": "string value",
|
"Version": "string value",
|
||||||
"APIVersion": 131584,
|
"APIVersion": 131840,
|
||||||
"BlockDelay": 42
|
"BlockDelay": 42
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -6477,7 +6477,7 @@ Response:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### StateMinerSectorAllocated
|
### StateMinerSectorAllocated
|
||||||
StateMinerSectorAllocated checks if a sector is allocated
|
StateMinerSectorAllocated checks if a sector number is marked as allocated.
|
||||||
|
|
||||||
|
|
||||||
Perms: read
|
Perms: read
|
||||||
@ -6990,7 +6990,12 @@ Response:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### StateSectorPreCommitInfo
|
### StateSectorPreCommitInfo
|
||||||
StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector
|
StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector.
|
||||||
|
Returns nil and no error if the sector isn't precommitted.
|
||||||
|
|
||||||
|
Note that the sector number may be allocated while PreCommitInfo is nil. This means that either allocated sector
|
||||||
|
numbers were compacted, and the sector number was marked as allocated in order to reduce size of the allocated
|
||||||
|
sectors bitfield, or that the sector was precommitted, but the precommit has expired.
|
||||||
|
|
||||||
|
|
||||||
Perms: read
|
Perms: read
|
||||||
|
@ -880,20 +880,18 @@ func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Addre
|
|||||||
return api.MinerSectors{Live: liveCount, Active: activeCount, Faulty: faultyCount}, nil
|
return api.MinerSectors{Live: liveCount, Active: activeCount, Faulty: faultyCount}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (minertypes.SectorPreCommitOnChainInfo, error) {
|
func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return minertypes.SectorPreCommitOnChainInfo{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pci, err := stmgr.PreCommitInfo(ctx, a.StateManager, maddr, n, ts)
|
pci, err := stmgr.PreCommitInfo(ctx, a.StateManager, maddr, n, ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return minertypes.SectorPreCommitOnChainInfo{}, err
|
return nil, err
|
||||||
} else if pci == nil {
|
|
||||||
return minertypes.SectorPreCommitOnChainInfo{}, xerrors.Errorf("precommit info is not exists")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return *pci, err
|
return pci, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *StateModule) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error) {
|
func (m *StateModule) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error) {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"golang.org/x/xerrors"
|
|
||||||
|
|
||||||
"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"
|
||||||
@ -15,9 +14,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/blockstore"
|
|
||||||
"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/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
pipeline "github.com/filecoin-project/lotus/storage/pipeline"
|
pipeline "github.com/filecoin-project/lotus/storage/pipeline"
|
||||||
)
|
)
|
||||||
@ -118,36 +115,7 @@ func (s SealingAPIAdapter) StateSectorPartition(ctx context.Context, maddr addre
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
func (s SealingAPIAdapter) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||||
|
return s.delegate.StateSectorPreCommitInfo(ctx, maddr, sectorNumber, tsk)
|
||||||
act, err := s.delegate.StateGetActor(ctx, maddr, tsk)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("handleSealFailed(%d): temp error: %+v", sectorNumber, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
stor := store.ActorStore(ctx, blockstore.NewAPIBlockstore(s.delegate))
|
|
||||||
|
|
||||||
state, err := miner.Load(stor, act)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("handleSealFailed(%d): temp error: loading miner state: %+v", sectorNumber, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
pci, err := state.GetPrecommittedSector(sectorNumber)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if pci == nil {
|
|
||||||
set, err := state.IsAllocated(sectorNumber)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("checking if sector is allocated: %w", err)
|
|
||||||
}
|
|
||||||
if set {
|
|
||||||
return nil, pipeline.ErrSectorAllocated
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return pci, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -82,7 +82,7 @@ type fullNodeFilteredAPI interface {
|
|||||||
// Call a read only method on actors (no interaction with the chain required)
|
// Call a read only method on actors (no interaction with the chain required)
|
||||||
StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error)
|
StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error)
|
||||||
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
|
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
|
||||||
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) (*lminer.SectorLocation, error)
|
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*lminer.SectorLocation, error)
|
||||||
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
||||||
|
@ -107,10 +107,6 @@ func checkPrecommit(ctx context.Context, maddr address.Address, si SectorInfo, t
|
|||||||
|
|
||||||
pci, err := api.StateSectorPreCommitInfo(ctx, maddr, si.SectorNumber, tok)
|
pci, err := api.StateSectorPreCommitInfo(ctx, maddr, si.SectorNumber, tok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrSectorAllocated {
|
|
||||||
//committed P2 message but commit C2 message too late, pci should be null in this case
|
|
||||||
return &ErrSectorNumberAllocated{err}
|
|
||||||
}
|
|
||||||
return &ErrApi{xerrors.Errorf("getting precommit info: %w", err)}
|
return &ErrApi{xerrors.Errorf("getting precommit info: %w", err)}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +118,15 @@ func checkPrecommit(ctx context.Context, maddr address.Address, si SectorInfo, t
|
|||||||
return &ErrPrecommitOnChain{xerrors.Errorf("precommit already on chain")}
|
return &ErrPrecommitOnChain{xerrors.Errorf("precommit already on chain")}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alloc, err := api.StateMinerSectorAllocated(ctx, maddr, si.SectorNumber, tok)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("checking if sector is allocated: %w", err)
|
||||||
|
}
|
||||||
|
if alloc {
|
||||||
|
//committed P2 message but commit C2 message too late, pci should be null in this case
|
||||||
|
return &ErrSectorNumberAllocated{xerrors.Errorf("sector %d is allocated, but PreCommit info wasn't found on chain", si.SectorNumber)}
|
||||||
|
}
|
||||||
|
|
||||||
//never commit P2 message before, check ticket expiration
|
//never commit P2 message before, check ticket expiration
|
||||||
ticketEarliest := height - policy.MaxPreCommitRandomnessLookback
|
ticketEarliest := height - policy.MaxPreCommitRandomnessLookback
|
||||||
|
|
||||||
@ -137,7 +142,16 @@ func (m *Sealing) checkCommit(ctx context.Context, si SectorInfo, proof []byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pci, err := m.Api.StateSectorPreCommitInfo(ctx, m.maddr, si.SectorNumber, tok)
|
pci, err := m.Api.StateSectorPreCommitInfo(ctx, m.maddr, si.SectorNumber, tok)
|
||||||
if err == ErrSectorAllocated {
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting precommit info: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if pci == nil {
|
||||||
|
alloc, err := m.Api.StateMinerSectorAllocated(ctx, m.maddr, si.SectorNumber, tok)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("checking if sector is allocated: %w", err)
|
||||||
|
}
|
||||||
|
if alloc {
|
||||||
// not much more we can check here, basically try to wait for commit,
|
// not much more we can check here, basically try to wait for commit,
|
||||||
// and hope that this will work
|
// and hope that this will work
|
||||||
|
|
||||||
@ -145,13 +159,9 @@ func (m *Sealing) checkCommit(ctx context.Context, si SectorInfo, proof []byte,
|
|||||||
return &ErrCommitWaitFailed{err}
|
return &ErrCommitWaitFailed{err}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return xerrors.Errorf("sector %d is allocated, but PreCommit info wasn't found on chain", si.SectorNumber)
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("getting precommit info: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if pci == nil {
|
|
||||||
return &ErrNoPrecommit{xerrors.Errorf("precommit info not found on-chain")}
|
return &ErrNoPrecommit{xerrors.Errorf("precommit info not found on-chain")}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
|
gomock "github.com/golang/mock/gomock"
|
||||||
|
cid "github.com/ipfs/go-cid"
|
||||||
|
|
||||||
address "github.com/filecoin-project/go-address"
|
address "github.com/filecoin-project/go-address"
|
||||||
abi "github.com/filecoin-project/go-state-types/abi"
|
abi "github.com/filecoin-project/go-state-types/abi"
|
||||||
big "github.com/filecoin-project/go-state-types/big"
|
big "github.com/filecoin-project/go-state-types/big"
|
||||||
@ -15,11 +18,10 @@ import (
|
|||||||
crypto "github.com/filecoin-project/go-state-types/crypto"
|
crypto "github.com/filecoin-project/go-state-types/crypto"
|
||||||
dline "github.com/filecoin-project/go-state-types/dline"
|
dline "github.com/filecoin-project/go-state-types/dline"
|
||||||
network "github.com/filecoin-project/go-state-types/network"
|
network "github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
api "github.com/filecoin-project/lotus/api"
|
api "github.com/filecoin-project/lotus/api"
|
||||||
miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
types "github.com/filecoin-project/lotus/chain/types"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
cid "github.com/ipfs/go-cid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockSealingAPI is a mock of SealingAPI interface.
|
// MockSealingAPI is a mock of SealingAPI interface.
|
||||||
@ -45,21 +47,6 @@ func (m *MockSealingAPI) EXPECT() *MockSealingAPIMockRecorder {
|
|||||||
return m.recorder
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChainBaseFee mocks base method.
|
|
||||||
func (m *MockSealingAPI) ChainBaseFee(arg0 context.Context, arg1 types.TipSetKey) (big.Int, error) {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "ChainBaseFee", arg0, arg1)
|
|
||||||
ret0, _ := ret[0].(big.Int)
|
|
||||||
ret1, _ := ret[1].(error)
|
|
||||||
return ret0, ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChainBaseFee indicates an expected call of ChainBaseFee.
|
|
||||||
func (mr *MockSealingAPIMockRecorder) ChainBaseFee(arg0, arg1 interface{}) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainBaseFee", reflect.TypeOf((*MockSealingAPI)(nil).ChainBaseFee), arg0, arg1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChainGetMessage mocks base method.
|
// ChainGetMessage mocks base method.
|
||||||
func (m *MockSealingAPI) ChainGetMessage(arg0 context.Context, arg1 cid.Cid) (*types.Message, error) {
|
func (m *MockSealingAPI) ChainGetMessage(arg0 context.Context, arg1 cid.Cid) (*types.Message, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
@ -8,15 +8,17 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
|
gomock "github.com/golang/mock/gomock"
|
||||||
|
cid "github.com/ipfs/go-cid"
|
||||||
|
|
||||||
address "github.com/filecoin-project/go-address"
|
address "github.com/filecoin-project/go-address"
|
||||||
abi "github.com/filecoin-project/go-state-types/abi"
|
abi "github.com/filecoin-project/go-state-types/abi"
|
||||||
big "github.com/filecoin-project/go-state-types/big"
|
big "github.com/filecoin-project/go-state-types/big"
|
||||||
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||||
network "github.com/filecoin-project/go-state-types/network"
|
network "github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
api "github.com/filecoin-project/lotus/api"
|
api "github.com/filecoin-project/lotus/api"
|
||||||
types "github.com/filecoin-project/lotus/chain/types"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
cid "github.com/ipfs/go-cid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockCommitBatcherApi is a mock of CommitBatcherApi interface.
|
// MockCommitBatcherApi is a mock of CommitBatcherApi interface.
|
||||||
|
@ -8,14 +8,16 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
|
gomock "github.com/golang/mock/gomock"
|
||||||
|
cid "github.com/ipfs/go-cid"
|
||||||
|
|
||||||
address "github.com/filecoin-project/go-address"
|
address "github.com/filecoin-project/go-address"
|
||||||
abi "github.com/filecoin-project/go-state-types/abi"
|
abi "github.com/filecoin-project/go-state-types/abi"
|
||||||
big "github.com/filecoin-project/go-state-types/big"
|
big "github.com/filecoin-project/go-state-types/big"
|
||||||
network "github.com/filecoin-project/go-state-types/network"
|
network "github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
api "github.com/filecoin-project/lotus/api"
|
api "github.com/filecoin-project/lotus/api"
|
||||||
types "github.com/filecoin-project/lotus/chain/types"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
cid "github.com/ipfs/go-cid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockPreCommitBatcherApi is a mock of PreCommitBatcherApi interface.
|
// MockPreCommitBatcherApi is a mock of PreCommitBatcherApi interface.
|
||||||
|
@ -2,7 +2,6 @@ package sealing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -37,8 +36,6 @@ var ErrTooManySectorsSealing = xerrors.New("too many sectors sealing")
|
|||||||
|
|
||||||
var log = logging.Logger("sectors")
|
var log = logging.Logger("sectors")
|
||||||
|
|
||||||
var ErrSectorAllocated = errors.New("sectorNumber is allocated, but PreCommit info wasn't found on chain")
|
|
||||||
|
|
||||||
//go:generate go run github.com/golang/mock/mockgen -destination=mocks/api.go -package=mocks . SealingAPI
|
//go:generate go run github.com/golang/mock/mockgen -destination=mocks/api.go -package=mocks . SealingAPI
|
||||||
|
|
||||||
type SealingAPI interface {
|
type SealingAPI interface {
|
||||||
|
@ -3,7 +3,6 @@ package sealing
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -20,6 +19,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/dline"
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
|
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user