-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: manual publish storage deal message #1585
Conversation
// Remove the deal from Pending | ||
p.cleanupPending(deals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest we clean up pending deals under the lock also, so that the whole operation is atomic.
Otherwise two threads could interfere with each other.
Maybe you can even refactor so that it splits the list into the items to be published and the items that will remain (you're doing this in separate for loops at the moment, probably you can do both in the same for loop).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored the code a little. Unique identifier don't go well with slice.
The new code looks more clean. It resulted in some minor changes in other functions as well.
@@ -232,6 +233,61 @@ func TestForcePublish(t *testing.T) { | |||
checkPublishedDeals(t, dpapi, dealsToPublish, []int{2}) | |||
} | |||
|
|||
func TestPublishPendingDeals(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add a test that only publishes some of the deals instead of all of them.
eg there are three pending deals, only publish two of them and verify that there is one remaining pending deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored the test to send 4 deals. 1 with ctx.Error and other 3 normal. It will try to Publish 3 deals total (2 correct ones and 1 random CID which is not in Publisher). Test will result in 2 deal Publish, 1 debug log with error about random CID (not found in publisher) and returning 1 pending deal.
Current Scenario
Currently, Boost controls when the PSD message is sent for a deal. This decision is governed by a couple of factors.
Another special case is to Publish all deals forcefully using UI button and Graphql mutation.
Feature request background
SPs have expressed interest in being able to control how the deal are published. The reason this control ranges from being able to control deal flow to miner to control the cost of PSD message
Feature
The new feature allows SPs to turn on manual PSD. Once this feature is turned on, Boost will no longer send any PSD messages unless explicitly prompted by the user. The feature can be turned on with the below config variable:
Querying the deals pending to be published
The deals which have not been published can be queried using the Graphql endpoint of the Boost. The curl for the query:
curl -X POST -H "Content-Type: application/json" -d '{"query":"query { dealPublish{ ManualPSD Deals {ID IsLegacy ClientAddress ProviderAddress CreatedAt PieceCid PieceSize ProviderCollateral StartEpoch EndEpoch ClientPeerID PublishCid Transfer { Type Size Params ClientID} Message }}}"}' http://localhost:8080/graphql/query | jq
Decision
SPs can create a decision script which queries the Graphql endpoint using the above curl and take a decision on which deal to be published.
Publishing deals
Once the decision has been taken on which deals to be published, SPs can use the Grapqhql endpoint to Publish the deals.
The mutation is:
publishPendingDeals(ids: [ID!]!): [ID!]!
which takes an array of deal UUIDs to be published and an error message is returned. The following curl can be used to publish the deal.
curl -X POST -H "Content-Type: application/json" -d '{"query":"mutation {publishPendingDeals(ids: [\"d9f849f1-d5d8-4bfc-b034-2866bddfc8cb\", \"a8eb58ef-7381-4251-ae7a-1227c032c0b9\"])}"}' http://localhost:8080/graphql/query | jq
Successful output
Failure output
Publish all deals
The publish all button in UI would have the same functionality as before. Same would be true for the Graphql mutation
dealPublishNow
UI screenshots