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

Implement payment channel manager #132

Merged
merged 7 commits into from
Aug 13, 2019
Merged

Implement payment channel manager #132

merged 7 commits into from
Aug 13, 2019

Conversation

whyrusleeping
Copy link
Member

No description provided.

paych/store.go Outdated Show resolved Hide resolved
@whyrusleeping
Copy link
Member Author

Alright, This is ready for review.

return cid.Undef, err
}

// TODO: should we wait for it...?
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say no. We have ChainWait which is easy enough to use, and eventually it should allow clients to specify things like the number of confirmations, which is sort of important here.

return fmt.Errorf("nonce too low")
}

sendAmount = types.BigSub(sv.Amount, ls.Redeemed)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to allow this to be negative in case sv.Amount is somehow less than ls.Redeemed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes actually, the way the system is architected allows for money to flow in both directions. So if the target of the payment channel wants to pay money back to the creator, they can create a voucher with a lower amount, making this negative, and effectively send money back.

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this affect how we validate the signature few lines above?

paych/paych.go Outdated
ls, ok := pca.LaneStates[fmt.Sprint(sv.Lane)]
if !ok {
// TODO: should check against vouchers in our local store too
// there might be something conflicting
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably do that in both cases (ok || !ok aka. outside the if).

// the channel. I think that a common usecase here might be 'i want to pay
// person X an additional 4 FIL'. If they just pass '4' for the amount,
// and the channel already has sent some amount, they wont actually be
// sending four additional filecoin.
Copy link
Contributor

Choose a reason for hiding this comment

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

At the very least we need to make sure it's clearly documented.

We may want new api which:
A. Opens new line with this relative amount, making sure that nonce == 0, picking the lane id for us, or
B. Adds current lane amount to the specified amount

For some reason I feel kind of weird about B (not showing the user what the resulting amount is), but it's probably the right thing

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, B feels weird to me too.

I think we can keep it as is for now, and as people actually start using it, we can adjust


sv.Signature = sig

// REVIEWME: Should we immediately add this to the voucher store? or leave that to the caller?
Copy link
Contributor

Choose a reason for hiding this comment

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

Users may want to first call CheckVoucherValid, or leave that voucher for later / not use at all for whatever reason.

On the other hand not doing this will probably confuse someone at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

exactly...

I think that for the usecases where people dont want it added to the local store, its easy enough to create your own vouchers manually

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good

@whyrusleeping whyrusleeping merged commit e050d56 into master Aug 13, 2019
@whyrusleeping whyrusleeping deleted the feat/paych-manager branch August 13, 2019 19:15
nonsense added a commit that referenced this pull request Nov 6, 2020
urugang pushed a commit to fireflyblock/lotus that referenced this pull request Nov 24, 2020
…to dev

Merge pull request filecoin-project#132 from filecoin-project/fix-cpu-flag-detection

fix: update cpu feature flag detection & rust feature usage
dumikau pushed a commit to protofire/lotus that referenced this pull request Jun 8, 2023
* Revert test timeouts and update Mir with debug messages
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.

2 participants