From 9839d5701ba55785b647dfd1e76e34c841e1933f Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Tue, 6 Jul 2021 15:22:08 +0200 Subject: [PATCH] fix SectorsStatus to query full node for on-chain data --- itests/paych_cli_test.go | 7 ------ markets/retrievaladapter/provider.go | 37 +++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/itests/paych_cli_test.go b/itests/paych_cli_test.go index 91b7e305d..82955e6c1 100644 --- a/itests/paych_cli_test.go +++ b/itests/paych_cli_test.go @@ -17,7 +17,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin/paych" - "github.com/filecoin-project/lotus/chain/actors/policy" cbor "github.com/ipfs/go-ipld-cbor" "github.com/stretchr/testify/require" @@ -27,12 +26,6 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -func init() { - policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1) - policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048)) - policy.SetMinVerifiedDealSize(abi.NewStoragePower(256)) -} - // TestPaymentChannelsBasic does a basic test to exercise the payment channel CLI // commands func TestPaymentChannelsBasic(t *testing.T) { diff --git a/markets/retrievaladapter/provider.go b/markets/retrievaladapter/provider.go index da5fb4a64..3fbb9b635 100644 --- a/markets/retrievaladapter/provider.go +++ b/markets/retrievaladapter/provider.go @@ -4,6 +4,7 @@ import ( "context" "io" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api/v1api" "github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/storage/sectorblocks" @@ -52,7 +53,7 @@ func (rpn *retrievalProviderNode) GetMinerWorkerAddress(ctx context.Context, min func (rpn *retrievalProviderNode) UnsealSector(ctx context.Context, sectorID abi.SectorNumber, offset abi.UnpaddedPieceSize, length abi.UnpaddedPieceSize) (io.ReadCloser, error) { log.Debugf("get sector %d, offset %d, length %d", sectorID, offset, length) - si, err := rpn.secb.SectorsStatus(ctx, sectorID, false) + si, err := rpn.sectorsStatus(ctx, sectorID, true) if err != nil { return nil, err } @@ -166,3 +167,37 @@ func (rpn *retrievalProviderNode) GetRetrievalPricingInput(ctx context.Context, return resp, nil } + +func (rpn *retrievalProviderNode) sectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) { + sInfo, err := rpn.secb.SectorsStatus(ctx, sid, false) + if err != nil { + return api.SectorInfo{}, err + } + + if !showOnChainInfo { + return sInfo, nil + } + + onChainInfo, err := rpn.full.StateSectorGetInfo(ctx, rpn.maddr, sid, types.EmptyTSK) + if err != nil { + return sInfo, err + } + if onChainInfo == nil { + return sInfo, nil + } + sInfo.SealProof = onChainInfo.SealProof + sInfo.Activation = onChainInfo.Activation + sInfo.Expiration = onChainInfo.Expiration + sInfo.DealWeight = onChainInfo.DealWeight + sInfo.VerifiedDealWeight = onChainInfo.VerifiedDealWeight + sInfo.InitialPledge = onChainInfo.InitialPledge + + ex, err := rpn.full.StateSectorExpiration(ctx, rpn.maddr, sid, types.EmptyTSK) + if err != nil { + return sInfo, nil + } + sInfo.OnTime = ex.OnTime + sInfo.Early = ex.Early + + return sInfo, nil +}