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

Refactor revalidators v2 #322

Merged
merged 4 commits into from
May 11, 2022
Merged

Refactor revalidators v2 #322

merged 4 commits into from
May 11, 2022

Conversation

hannahhoward
Copy link
Collaborator

Goals

This PR was written during the course of implementing the voucher refactor in go-fil-markets.

Implementation

The main goal in refactoring the go-fil-markets retrieval provider was to drive towards clear, easy to reason about logic with very clear event structure and idempotent code that restarts easily.

What became clear is that fundamentally, voucher revalidation needs to happen asynchronously. So now, the consuming library simply monitors data transfer events and updates validation status as new vouchers come in. We changed Revalidate to ValidateRestart -- so that it only covers restarts, while removing synchronous revalidation entirely. Now, we simply save new vouchers, and we've added an UpdateValidationStatus method to change validation parameters when the markets software processes all vouchers.

Moreover, the idea of Pausing in validation needs to be separated from DataLimits and Finalization. The way to unpause a request held on a data limit is to increase the data limit. The way to end finalization is to set RequiresFinalization to false. The pause property is renamed from LeaveRequestPaused to ForcePause, clearly identifying that the markets library is explicitly applying it's own logic around pausing -- in this case, pausing to Unseal.

Finally I did a minor reorderng of validation events to promote more predictable behavior near the end of a transfer (not accidentally completing the channel before events get processed)

impl/impl.go Outdated Show resolved Hide resolved
impl/impl.go Show resolved Hide resolved
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

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

looks OK from a superficial perspective and the rationale makes sense

it's just a dramatic change; I'll have to take these two big refactors into account in my work which has already diverged quite a bit from master

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2022

Codecov Report

Merging #322 (4cffb16) into v2 (a4c58c5) will decrease coverage by 0.38%.
The diff coverage is 67.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v2     #322      +/-   ##
==========================================
- Coverage   65.26%   64.88%   -0.39%     
==========================================
  Files          30       30              
  Lines        3501     3528      +27     
==========================================
+ Hits         2285     2289       +4     
- Misses        850      868      +18     
- Partials      366      371       +5     
Impacted Files Coverage Δ
message/message1_1prime/message.go 48.25% <0.00%> (ø)
impl/impl.go 63.81% <67.34%> (+0.75%) ⬆️
impl/receiving_requests.go 66.89% <68.57%> (-0.58%) ⬇️
impl/restart.go 58.13% <100.00%> (ø)
impl/utils.go 79.62% <0.00%> (-9.26%) ⬇️
impl/receiver.go 72.64% <0.00%> (-4.72%) ⬇️
network/libp2p_impl.go 66.47% <0.00%> (-2.36%) ⬇️

hannahhoward and others added 4 commits May 11, 2022 15:29
move to all revalidation being asynchronous
causes datalimit exceeded and requires finalization to leave request paused, regardless of where
LeaveRequestPaused is set
reorder validation events so all get record when transfer finishes
Co-authored-by: Rod Vagg <rod@vagg.org>
@hannahhoward hannahhoward changed the base branch from refactor-revalidators to v2 May 11, 2022 22:30
@hannahhoward hannahhoward merged commit 5253bfe into v2 May 11, 2022
hannahhoward added a commit that referenced this pull request Oct 7, 2022
* refactor(validators): remove revalidation

move to all revalidation being asynchronous

* feat(validators): implied pauses

causes datalimit exceeded and requires finalization to leave request paused, regardless of where
LeaveRequestPaused is set

* refactor(events): reorder events

reorder validation events so all get record when transfer finishes

* Update impl/impl.go

Co-authored-by: Rod Vagg <rod@vagg.org>

Co-authored-by: Rod Vagg <rod@vagg.org>
hannahhoward added a commit that referenced this pull request Oct 8, 2022
* chore(v2): setup the v2 release

given the expected breaking changes, it's time to setup the v2 release

BREAKING CHANGE: v2 modules

* Refactor revalidators (#308)

* feat(revalidators): initial refactor

refactor revalidation process -- removing independent revalidations, making validations results more
clear

* refactor(rename): RevalidateToComplete -> RequiresFinalization

* refactor(datatransfer): enhance validator comments

* refactor(message): revert message response changes

* refactor(impl): comment and refactor on events

add comments to event processing and also extract functions for receiving requests to a new file

* refactor(message): s/IsVoucherResult/IsValidationResult

rename the IsVoucherResult to is 'IsValidationResult' also add a method for generating messages from
validation results

* feat(events): only dispatch events on change

Only dispatch Pause, Resume, SetDataLimit, and RequiresFinalization on change

* style(imports): fix imports

* feat(events): add DataLimitExceeded event

* Update channels/channel_state.go

Co-authored-by: dirkmc <dirkmdev@gmail.com>

* Update manager.go

Co-authored-by: dirkmc <dirkmdev@gmail.com>

* Update manager.go

Co-authored-by: dirkmc <dirkmdev@gmail.com>

* Update statuses.go

Co-authored-by: Rod Vagg <rod@vagg.org>

Co-authored-by: dirkmc <dirkmdev@gmail.com>
Co-authored-by: Rod Vagg <rod@vagg.org>

* Refactor revalidators v2 (#322)

* refactor(validators): remove revalidation

move to all revalidation being asynchronous

* feat(validators): implied pauses

causes datalimit exceeded and requires finalization to leave request paused, regardless of where
LeaveRequestPaused is set

* refactor(events): reorder events

reorder validation events so all get record when transfer finishes

* Update impl/impl.go

Co-authored-by: Rod Vagg <rod@vagg.org>

Co-authored-by: Rod Vagg <rod@vagg.org>

* chore(message): delete old message format code (#330)

* feat(ipld): vouchers as plain ipld.Node (#325)

* feat(ipld): vouchers as plain ipld.Node

* feat: add ValidationResult#Equals() utility

* feat(ipld): introduce TypedVoucher tuple type

* chore(ipld): ipld.Node -> datamodel.Node

* chore: remove RegisterVoucherResultType

* fix: minor staticcheck fixes

* refactor(channelstate): use cborgencompatiblenode (#336)

use cborgencomptaiblenode to simply channelstate interface

* feat(ipld): use bindnode/registry (#340)

* chore(deps): update libp2p v0.19.4 (#341)

* feat(ipld): use bindnode/registry

Co-authored-by: Hannah Howard <hannah@hannahhoward.net>

* refactor(v2): port graphsync w/o transport refactor

Ports state machine and graphsync changes without the big transport refactor

* fix(pr): respond to pr comments

* chore(deps): upgrade libp2p v0.22

also upgrades graphsync and removes go-libp2p-core paths

* fix(deps): use tagged go-ipld-prime

Co-authored-by: dirkmc <dirkmdev@gmail.com>
Co-authored-by: Rod Vagg <rod@vagg.org>
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