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

Support Network Upgrades: Payment Channel #3877

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

hannahhoward
Copy link
Contributor

Goals

Support actor upgrades -- specifically the payment channels

This covers only the state access part -- I did not attempt to address message submission cause it's not yet addressed in the larger PR. Of particular concern to pay attention to is the use of SignedVoucher -- a fairly complex data structure which is not stored on chain but appears in message submission for the payment channel state, and is tracked off chain in the payment channel manager. The number of references in the code to this data structure is large

Implementation

  • apply patterns for other abstracted actors to make an abstracted payment channel actor
  • add a state manager method to load a payment channel actor (removes the need to have access to any ADT store in the paychmgr +1)
  • fix the state predicates, but only make them abstract for the payment channel manager so far
  • move the payment channel manager over to the new abstract actor
  • update the unit tests to support the new model and get them to pass (use a mock implementation of the actor -- this abstraction is actually quite useful for unit tests)
  • update one integration test with a compile error (but not actually able to verify it works yet)
  • there is one outstanding call to StateReadState that loads the hardcoded version of the state -- I'm not sure what the intent is in terms of what this is going to look like in the new format
  • did not attempt to do anything with testvectors -- I assume that is a seperate project

build abstraction for paych actor and switch to using it in payment channel manager and state
predicates
Copy link
Contributor

@dirkmc dirkmc left a comment

Choose a reason for hiding this comment

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

Some nice simplifications in the code and in the tests, great work Hannah 👍

Just one question about ForEachLaneState that @Stebalien may be best placed to answer

}

// Iterate lane states
func (ms *mockState) ForEachLaneState(cb func(idx uint64, dl paych.LaneState) error) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

@Stebalien does amt.ForEach break out of the loop when there's an error? Or does it continue anyway, but save the last error like the implementation of ForEachLaneState here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines -529 to +539
if !ok {
ls = &paych.LaneState{
Redeemed: types.NewInt(0),
Nonce: 0,
}
laneStates[v.Voucher.Lane] = ls
}

if v.Voucher.Nonce < ls.Nonce {
if ok && v.Voucher.Nonce < ls.Nonce() {
continue
}

ls.Nonce = v.Voucher.Nonce
ls.Redeemed = v.Voucher.Amount
laneStates[v.Voucher.Lane] = laneState{v.Voucher.Amount, v.Voucher.Nonce}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice simplification 👍

@@ -226,7 +221,7 @@ func (pm *Manager) GetChannelInfo(addr address.Address) (*ChannelInfo, error) {
return ca.getChannelInfo(addr)
}

func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher paych.SignedVoucher) (*api.VoucherCreateResult, error) {
func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher v0paych.SignedVoucher) (*api.VoucherCreateResult, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO: figure out what to do with the SignedVoucher type

@magik6k magik6k merged commit ccce1a9 into refactor/net-upgrade Sep 16, 2020
@magik6k magik6k deleted the refactor/net-upgrade-paych branch September 16, 2020 18:25
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