Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expected seal duration to custom deal logic #2384

Merged
merged 1 commit into from
Jul 16, 2020
Merged

Conversation

arajasek
Copy link
Contributor

@arajasek arajasek commented Jul 12, 2020

And reject deals that start too early.

Fixes #2048

@arajasek arajasek requested review from hannahhoward and magik6k July 12, 2020 19:24
@arajasek arajasek self-assigned this Jul 12, 2020
@@ -46,6 +46,10 @@ type StorageMiner interface {
// SectorGetSealDelay gets the time that a newly-created sector
// waits for more deals before it starts sealing
SectorGetSealDelay(context.Context) (time.Duration, error)
// SectorSetExpectedSealDuration sets the expected time for a sector to seal
SectorSetExpectedSealDuration(context.Context, time.Duration) error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably create a new Sealing namespace for some of those functions, Sector is a bit weird here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, strong agree...you okay with that being a separate PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

Copy link
Contributor

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dovetailing with the comments on the deal market PR, I would do the following:

  • make a struct to implement deal decision logic
  • supply it with appropriate dependencies as needed (Chain Height API, get current seal duration)
  • have one of its public methods be the dead decider
  • remove all the extra unrelated dependencies to the StorageProvider constructor and just provide the deal decider struct instance
  • make the markets PR simpler by just deleting the deal acceptance buffer rather than adding the extra chain height parameter.

net := smnet.NewFromLibp2pHost(h)
store, err := piecefilestore.NewLocalFileStore(piecefilestore.OsPath(r.Path()))
if err != nil {
return nil, err
}

opt := storageimpl.CustomDealDecisionLogic(func(ctx context.Context, deal storagemarket.MinerDeal) (bool, string, error) {
opt := storageimpl.CustomDealDecisionLogic(func(ctx context.Context, deal storagemarket.MinerDeal, ht abi.ChainEpoch) (bool, string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked closely at this function but it looks like it's getting pretty long to live in a constructor. I feel like you might just want to create a struct (which could store the current SealDuration in it it) and have one of its methods be the deal decider?

Also, are you sure you don't want us to expose the config options on StorageProvider after construction, so they can be changed later?

@hannahhoward
Copy link
Contributor

hannahhoward commented Jul 14, 2020

my review is not blocking for this PR but I'd like to not add the height to deal decider unless it's absolutely neccesary.

@arajasek arajasek force-pushed the asr/seal-duration branch from c2bcf4a to a5ef629 Compare July 15, 2020 21:31
Comment on lines +338 to +350
func StorageProvider(minerAddress dtypes.MinerAddress,
ffiConfig *ffiwrapper.Config,
storedAsk *storedask.StoredAsk,
h host.Host, ds dtypes.MetadataDS,
ibs dtypes.StagingBlockstore,
r repo.LockedRepo,
pieceStore dtypes.ProviderPieceStore,
dataTransfer dtypes.ProviderDataTransfer,
spn storagemarket.StorageProviderNode,
onlineOk dtypes.ConsiderOnlineStorageDealsConfigFunc,
offlineOk dtypes.ConsiderOfflineStorageDealsConfigFunc,
blocklistFunc dtypes.StorageDealPieceCidBlocklistConfigFunc,
expectedSealTimeFunc dtypes.GetExpectedSealDurationFunc) (storagemarket.StorageProvider, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably warrants a struct with fx.In (not blocking this PR)

@magik6k magik6k merged commit 6092854 into next Jul 16, 2020
@magik6k magik6k deleted the asr/seal-duration branch July 16, 2020 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants