filecoin-project / go-fil-markets

Shared Implementation of Storage and Retrieval Markets for Filecoin Node Implementations
Other
78 stars 59 forks source link

Voucher refactor integration #707

Closed hannahhoward closed 2 years ago

hannahhoward commented 2 years ago

Goals

This PR rewrites the go-fil-markets retrieval provider based on the new data transfer voucher refactor (https://github.com/filecoin-project/go-data-transfer/pull/308, https://github.com/filecoin-project/go-data-transfer/pull/322) as well as the new go-statemachine multi-event application PR (https://github.com/filecoin-project/go-statemachine/pull/37).

Implementation

The retrieval client code is unchanged for now -- this change is intended to be backward compatible for the time being -- even though we could seriously drop a ton of code if we stopped having the client wait for the provider to request payment.

All of the revalidation code is -> gone (hence the big delete/add ratio)

The validation code is mostly the same, but we set data limits + pauses + require finalization

Restarts are now handled seperately, and we handle them by simply looking at the current state of the transfer and setting validation status appropriately.

When a data limit or finalization occurs, we trigger the payment states, which in turn trigger sending an updated validation status + a voucher result that requests payment.

When a new voucher arrives, we trigger the payment states again, which processes the last payment and updates the funds received as needed, then sets validation status based on that.

The long and short of all this is we no longer do any tracking of transfer state directly in the provider -- only funds received, the unique state to this layer.

I'm also dropping all the v0 protocols, which haven't actually been in use since pre-mainnet.

rvagg commented 2 years ago

@hannahhoward

this change is intended to be backward compatible

One minor concern is that ProviderDealState is changing shape: TotalSent, CurrentInterval and LegacyProtocol are all gone now and they're not optional fields. I think this struct is only used for saving state and that cbor-gen should gracefully ignore these (both in and out) and I'm not entirely clear on how the statemachine saving stuff works so it'd be good to hear your confirmation that you think this is OK.