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

Track deals funding for deals that are being negotiated #336

Merged
merged 5 commits into from
Jul 30, 2020

Conversation

ingar
Copy link
Contributor

@ingar ingar commented Jul 24, 2020

Summary

Add a new interface, DealFunds, and use it to track outstanding funds needed for storage deals that are in progress.

Resolves #331

@ingar ingar force-pushed the feat/track-committed-funds branch 3 times, most recently from 54ce6f1 to 6451b34 Compare July 24, 2020 21:07
@ingar ingar marked this pull request as ready for review July 24, 2020 21:12
@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2020

Codecov Report

Merging #336 into master will decrease coverage by 0.21%.
The diff coverage is 55.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #336      +/-   ##
==========================================
- Coverage   62.66%   62.45%   -0.20%     
==========================================
  Files          40       41       +1     
  Lines        2651     2719      +68     
==========================================
+ Hits         1661     1698      +37     
- Misses        859      880      +21     
- Partials      131      141      +10     
Impacted Files Coverage Δ
storagemarket/impl/client.go 3.05% <0.00%> (-0.03%) ⬇️
storagemarket/impl/provider.go 2.57% <0.00%> (-0.02%) ⬇️
storagemarket/impl/providerstates/provider_fsm.go 90.59% <0.00%> (-4.47%) ⬇️
storagemarket/impl/clientstates/client_states.go 86.05% <40.00%> (-3.95%) ⬇️
...oragemarket/impl/providerstates/provider_states.go 85.00% <40.00%> (-2.20%) ⬇️
storagemarket/impl/funds/funds.go 77.50% <77.50%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c4c6b77...1fe5e88. Read the comment docs.

Copy link
Collaborator

@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.

Generally LGTM but we need to release funds for all failures, not just immediately if EnsureFunds fails. See strategy outlined in comments


if err != nil {
_, err2 := environment.DealFunds().Release(deal.Proposal.ClientBalanceRequirement())
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to happen in the global fail state handler (FailDeal) - any error that happens between when EnsureFunds is called and the deal is published need to release the funds

Copy link
Collaborator

Choose a reason for hiding this comment

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

to know whether to release in FailDeal may mean recording a local value of funds reserved on the deal struct -- starts at 0 when deal is created, becomes ClientBalanceRequirement here, goes back to 0 after ValidateDealPublished, and then in the FailDeal handler, if reserved > 0, release those funds


if err != nil {
_, err2 := environment.DealFunds().Release(deal.Proposal.ProviderCollateral)
Copy link
Collaborator

Choose a reason for hiding this comment

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

again this needs to happen in the global fail state handler (FailDeal) -- same comment as client

@hannahhoward hannahhoward force-pushed the feat/track-committed-funds branch from 6451b34 to 1fe5e88 Compare July 30, 2020 03:32
Release funds any time a deal fails, not just due to ensure funds error
@hannahhoward hannahhoward merged commit cca934d into master Jul 30, 2020
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.

Track total funds commited in SMA, Client and Provider
3 participants