diff --git a/api/api_storage.go b/api/api_storage.go index f6efcd8af..9662e8cd8 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -5,6 +5,8 @@ import ( "context" "time" + "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/google/uuid" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/peer" @@ -165,6 +167,8 @@ type StorageMiner interface { CreateBackup(ctx context.Context, fpath string) error //perm:admin CheckProvable(ctx context.Context, pp abi.RegisteredPoStProof, sectors []storage.SectorRef, expensive bool) (map[abi.SectorNumber]string, error) //perm:admin + + ComputeProof(ctx context.Context, ssi []builtin.SectorInfo, rand abi.PoStRandomness) ([]builtin.PoStProof, error) //perm:read } var _ storiface.WorkerReturn = *new(StorageMiner) diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 34cf52fce..8fe40b574 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -20,6 +20,7 @@ import ( "github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/lotus/api" apitypes "github.com/filecoin-project/lotus/api/types" + "github.com/filecoin-project/lotus/chain/actors/builtin" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/builtin/paych" "github.com/filecoin-project/lotus/chain/types" @@ -532,6 +533,8 @@ type StorageMinerStruct struct { CheckProvable func(p0 context.Context, p1 abi.RegisteredPoStProof, p2 []storage.SectorRef, p3 bool) (map[abi.SectorNumber]string, error) `perm:"admin"` + ComputeProof func(p0 context.Context, p1 []builtin.SectorInfo, p2 abi.PoStRandomness) ([]builtin.PoStProof, error) `perm:"read"` + CreateBackup func(p0 context.Context, p1 string) error `perm:"admin"` DealsConsiderOfflineRetrievalDeals func(p0 context.Context) (bool, error) `perm:"admin"` @@ -1706,6 +1709,10 @@ func (s *StorageMinerStruct) CheckProvable(p0 context.Context, p1 abi.Registered return s.Internal.CheckProvable(p0, p1, p2, p3) } +func (s *StorageMinerStruct) ComputeProof(p0 context.Context, p1 []builtin.SectorInfo, p2 abi.PoStRandomness) ([]builtin.PoStProof, error) { + return s.Internal.ComputeProof(p0, p1, p2) +} + func (s *StorageMinerStruct) CreateBackup(p0 context.Context, p1 string) error { return s.Internal.CreateBackup(p0, p1) } diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index 4120afb7e..1e1455644 100644 Binary files a/build/openrpc/full.json.gz and b/build/openrpc/full.json.gz differ diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index 6e7698d4e..7baad0ae3 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/build/openrpc/worker.json.gz b/build/openrpc/worker.json.gz index 7bf6216a7..55bd28530 100644 Binary files a/build/openrpc/worker.json.gz and b/build/openrpc/worker.json.gz differ diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index 5e2d18ff1..f67971235 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -118,5 +118,5 @@ const PackingEfficiencyNum = 4 const PackingEfficiencyDenom = 5 // Actor consts -// TODO: Pull from actors when its made not private -var MinDealDuration = abi.ChainEpoch(180 * builtin2.EpochsInDay) +// TODO: pieceSize unused from actors +var MinDealDuration, MaxDealDuration = policy.DealDurationBounds(0) diff --git a/build/params_testground.go b/build/params_testground.go index 759b29692..5e9bc2672 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -72,8 +72,8 @@ var ( }() // Actor consts - // TODO: Pull from actors when its made not private - MinDealDuration = abi.ChainEpoch(180 * builtin2.EpochsInDay) + // TODO: pieceSize unused from actors + MinDealDuration, MaxDealDuration = policy.DealDurationBounds(0) PackingEfficiencyNum int64 = 4 PackingEfficiencyDenom int64 = 5 diff --git a/build/version.go b/build/version.go index f5e85783a..5baa4743a 100644 --- a/build/version.go +++ b/build/version.go @@ -29,7 +29,7 @@ func buildType() string { } // BuildVersion is the local build version, set by build system -const BuildVersion = "1.6.0-dev" +const BuildVersion = "1.7.0-dev" func UserVersion() string { return BuildVersion + buildType() + CurrentCommit diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index e32b36743..75badf36d 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -25,9 +25,10 @@ import ( ) const ( - ChainFinality = miner3.ChainFinality - SealRandomnessLookback = ChainFinality - PaychSettleDelay = paych3.SettleDelay + ChainFinality = miner3.ChainFinality + SealRandomnessLookback = ChainFinality + PaychSettleDelay = paych3.SettleDelay + MaxPreCommitRandomnessLookback = builtin3.EpochsInDay + SealRandomnessLookback ) // SetSupportedProofTypes sets supported proof types, across all actor versions. @@ -136,6 +137,10 @@ func DealProviderCollateralBounds( } } +func DealDurationBounds(pieceSize abi.PaddedPieceSize) (min, max abi.ChainEpoch) { + return market2.DealDurationBounds(pieceSize) +} + // Sets the challenge window and scales the proving period to match (such that // there are always 48 challenge windows in a proving period). func SetWPoStChallengeWindow(period abi.ChainEpoch) { diff --git a/cli/client.go b/cli/client.go index 5521b0d00..53baebaf7 100644 --- a/cli/client.go +++ b/cli/client.go @@ -389,6 +389,9 @@ var clientDealCmd = &cli.Command{ if abi.ChainEpoch(dur) < build.MinDealDuration { return xerrors.Errorf("minimum deal duration is %d blocks", build.MinDealDuration) } + if abi.ChainEpoch(dur) > build.MaxDealDuration { + return xerrors.Errorf("maximum deal duration is %d blocks", build.MaxDealDuration) + } var a address.Address if from := cctx.String("from"); from != "" { diff --git a/documentation/en/api-methods-miner.md b/documentation/en/api-methods-miner.md index a3f9bb5b6..9d33a55d0 100644 --- a/documentation/en/api-methods-miner.md +++ b/documentation/en/api-methods-miner.md @@ -14,6 +14,8 @@ * [AuthVerify](#AuthVerify) * [Check](#Check) * [CheckProvable](#CheckProvable) +* [Compute](#Compute) + * [ComputeProof](#ComputeProof) * [Create](#Create) * [CreateBackup](#CreateBackup) * [Deals](#Deals) @@ -295,6 +297,24 @@ Response: } ``` +## Compute + + +### ComputeProof + + +Perms: read + +Inputs: +```json +[ + null, + null +] +``` + +Response: `null` + ## Create diff --git a/extern/storage-sealing/checks.go b/extern/storage-sealing/checks.go index db2e87d0e..5ee39e58f 100644 --- a/extern/storage-sealing/checks.go +++ b/extern/storage-sealing/checks.go @@ -4,7 +4,6 @@ import ( "bytes" "context" - "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/policy" proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" @@ -94,14 +93,9 @@ func checkPrecommit(ctx context.Context, maddr address.Address, si SectorInfo, t return &ErrBadCommD{xerrors.Errorf("on chain CommD differs from sector: %s != %s", commD, si.CommD)} } - nv, err := api.StateNetworkVersion(ctx, tok) - if err != nil { - return &ErrApi{xerrors.Errorf("calling StateNetworkVersion: %w", err)} - } + ticketEarliest := height - policy.MaxPreCommitRandomnessLookback - msd := policy.GetMaxProveCommitDuration(actors.VersionForNetwork(nv), si.SectorType) - - if height-(si.TicketEpoch+policy.SealRandomnessLookback) > msd { + if si.TicketEpoch < ticketEarliest { return &ErrExpiredTicket{xerrors.Errorf("ticket expired: seal height: %d, head: %d", si.TicketEpoch+policy.SealRandomnessLookback, height)} } diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index f5bb4cae6..e371ab33f 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -12,7 +12,6 @@ import ( "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/go-statemachine" - builtin0 "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-storage/storage" "github.com/filecoin-project/lotus/api" @@ -22,7 +21,7 @@ import ( ) var DealSectorPriority = 1024 -var MaxTicketAge = abi.ChainEpoch(builtin0.EpochsInDay * 2) +var MaxTicketAge = policy.MaxPreCommitRandomnessLookback func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) error { m.inputLk.Lock() diff --git a/go.mod b/go.mod index 441b1e938..fa564df80 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( github.com/filecoin-project/go-amt-ipld/v2 v2.1.1-0.20201006184820-924ee87a1349 // indirect github.com/filecoin-project/go-bitfield v0.2.4 github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 - github.com/filecoin-project/go-commp-utils v0.0.0-20201119054358-b88f7a96a434 + github.com/filecoin-project/go-commp-utils v0.1.0 github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 github.com/filecoin-project/go-data-transfer v1.4.1 github.com/filecoin-project/go-fil-commcid v0.0.0-20201016201715-d41df56b4f6a @@ -41,7 +41,7 @@ require ( github.com/filecoin-project/go-paramfetch v0.0.2-0.20200701152213-3e0f0afdc261 github.com/filecoin-project/go-state-types v0.1.0 github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe - github.com/filecoin-project/go-statestore v0.1.1-0.20210311122610-6c7a5aedbdea + github.com/filecoin-project/go-statestore v0.1.1 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/specs-actors v0.9.13 github.com/filecoin-project/specs-actors/v2 v2.3.4 diff --git a/go.sum b/go.sum index cb8b7ec9a..77e467113 100644 --- a/go.sum +++ b/go.sum @@ -260,8 +260,9 @@ github.com/filecoin-project/go-bitfield v0.2.4 h1:uZ7MeE+XfM5lqrHJZ93OnhQKc/rveW github.com/filecoin-project/go-bitfield v0.2.4/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM= github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 h1:av5fw6wmm58FYMgJeoB/lK9XXrgdugYiTqkdxjTy9k8= github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2/go.mod h1:pqTiPHobNkOVM5thSRsHYjyQfq7O5QSCMhvuu9JoDlg= -github.com/filecoin-project/go-commp-utils v0.0.0-20201119054358-b88f7a96a434 h1:0kHszkYP3hgApcjl5x4rpwONhN9+j7XDobf6at5XfHs= github.com/filecoin-project/go-commp-utils v0.0.0-20201119054358-b88f7a96a434/go.mod h1:6s95K91mCyHY51RPWECZieD3SGWTqIFLf1mPOes9l5U= +github.com/filecoin-project/go-commp-utils v0.1.0 h1:PaDxoXYh1TXnnz5kA/xSObpAQwcJSUs4Szb72nuaNdk= +github.com/filecoin-project/go-commp-utils v0.1.0/go.mod h1:6s95K91mCyHY51RPWECZieD3SGWTqIFLf1mPOes9l5U= github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03 h1:2pMXdBnCiXjfCYx/hLqFxccPoqsSveQFxVLvNxy9bus= github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= github.com/filecoin-project/go-data-transfer v1.0.1/go.mod h1:UxvfUAY9v3ub0a21BSK9u3pB2aq30Y0KMsG+w9/ysyo= @@ -298,8 +299,8 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe h1:dF8u+LEWeIcTcfUcCf3WFVlc81Fr2JKg8zPzIbBDKDw= github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig= github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= -github.com/filecoin-project/go-statestore v0.1.1-0.20210311122610-6c7a5aedbdea h1:EvmiCrHRrPF2mxVMIRdtsxZGByqwT24aJLw7mdzEFxE= -github.com/filecoin-project/go-statestore v0.1.1-0.20210311122610-6c7a5aedbdea/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= +github.com/filecoin-project/go-statestore v0.1.1 h1:ufMFq00VqnT2CAuDpcGnwLnCX1I/c3OROw/kXVNSTZk= +github.com/filecoin-project/go-statestore v0.1.1/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg= github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8= github.com/filecoin-project/specs-actors v0.9.4/go.mod h1:BStZQzx5x7TmCkLv0Bpa07U6cPKol6fd3w9KjMPZ6Z4= diff --git a/node/impl/storminer.go b/node/impl/storminer.go index e81560059..cad886e2d 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -8,6 +8,9 @@ import ( "strconv" "time" + "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/gen" + "github.com/filecoin-project/lotus/build" "github.com/google/uuid" "github.com/ipfs/go-cid" @@ -63,7 +66,8 @@ type StorageMinerAPI struct { AddrSel *storage.AddressSelector DealPublisher *storageadapter.DealPublisher - DS dtypes.MetadataDS + Epp gen.WinningPoStProver + DS dtypes.MetadataDS ConsiderOnlineStorageDealsConfigFunc dtypes.ConsiderOnlineStorageDealsConfigFunc SetConsiderOnlineStorageDealsConfigFunc dtypes.SetConsiderOnlineStorageDealsConfigFunc @@ -696,4 +700,8 @@ func (sm *StorageMinerAPI) Discover(ctx context.Context) (apitypes.OpenRPCDocume return build.OpenRPCDiscoverJSON_Miner(), nil } +func (sm *StorageMinerAPI) ComputeProof(ctx context.Context, ssi []builtin.SectorInfo, rand abi.PoStRandomness) ([]builtin.PoStProof, error) { + return sm.Epp.ComputeProof(ctx, ssi, rand) +} + var _ api.StorageMiner = &StorageMinerAPI{}