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

Compute new collateral for renewals in worker instead of the autopilot #811

Merged
merged 7 commits into from
Dec 12, 2023

Conversation

ChrisSchinnerl
Copy link
Member

That way we can do so after locking the contract to avoid exceeding the max collateral when uploading at the same time.
As a side - effect, since we only pass a pricetable to RPCRenew, we also use rhpv3 estimates now.

@ChrisSchinnerl ChrisSchinnerl self-assigned this Dec 11, 2023
@ChrisSchinnerl ChrisSchinnerl marked this pull request as ready for review December 11, 2023 13:49
@ChrisSchinnerl ChrisSchinnerl marked this pull request as draft December 11, 2023 14:35
@ChrisSchinnerl ChrisSchinnerl marked this pull request as ready for review December 12, 2023 09:15
@@ -1387,8 +1394,8 @@ func (c *contractor) renewContract(ctx context.Context, w Worker, ci contractInf
*budget = budget.Sub(renterFunds)

// persist the contract
contractPrice := newRevision.Revision.MissedHostPayout().Sub(newCollateral)
renewedContract, err := c.ap.bus.AddRenewedContract(ctx, newRevision, contractPrice, renterFunds, cs.BlockHeight, fcid, api.ContractStatePending)
newCollateral := resp.Contract.Revision.MissedHostPayout().Sub(resp.ContractPrice)
Copy link
Member

Choose a reason for hiding this comment

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

nit maybe move this down so it's clear this is used for logging purposes only

}

// RHPRenewResponse is the response type for the /rhp/renew endpoint.
RHPRenewResponse struct {
Error string `json:"error"`
ContractID types.FileContractID `json:"contractID"`
Contract rhpv2.ContractRevision `json:"contract"`
ContractPrice types.Currency `json:"contractPrice"`
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to drop ContractID from RHPRenewResponse ? It's duplicated info.
Does it make sense to return the renewCollateral directly instead of the ContractPrice?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ContractPrice is the thing we actually need for the next API call. So I'm returning it instead of the thing we only need for logging. At the end of the day it doesn't really matter cause the endpoint will be removed with rhpv4 anyway once we remove anything related to contracts to the bus.

@ChrisSchinnerl ChrisSchinnerl merged commit d35efda into master Dec 12, 2023
6 checks passed
@ChrisSchinnerl ChrisSchinnerl deleted the chris/max-collateral-renew branch December 12, 2023 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants