-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fixes locking issues when creating channel / adding funds #2640
Conversation
a2c541e
to
4a6362b
Compare
1e86e83
to
b41ace0
Compare
@@ -274,6 +275,7 @@ func Online() Option { | |||
|
|||
Override(new(*paychmgr.Store), paychmgr.NewStore), | |||
Override(new(*paychmgr.Manager), paychmgr.NewManager), | |||
Override(HandlePaymentChannelManagerKey, paychmgr.HandleManager), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On startup we need to restart tracking of payment channel add funds requests that have already been sent to chain
} | ||
|
||
func (pm *Manager) OutboundChanTo(from, to address.Address) (address.Address, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OutboundChanTo() wasn't being used anywhere so I removed it
|
||
// laneState gets the LaneStates from chain, then applies all vouchers in | ||
// the data store over the chain state | ||
func (ca *channelAccessor) laneState(state *paych.State, ch address.Address) (map[uint64]*paych.LaneState, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
laneState() and totalRedeemedWithVoucher() were just moved from state.go
|
||
// laneState gets the LaneStates from chain, then applies all vouchers in | ||
// the data store over the chain state | ||
func (pm *Manager) laneState(state *paych.State, ch address.Address) (map[uint64]*paych.LaneState, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
laneState() and totalRedeemedWithVoucher() were just moved to paych.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so much better!
Generally looks good, just a couple of comments.
Running go test -count 100 ./paychmgr
seems to produce some test failures on my PC -> https://gist.github.com/magik6k/2b09f76c40418a0c7553fc14ded0ae2f
// TODO: wait outside the store lock! | ||
// (tricky because we need to setup channel tracking before we know its address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
@magik6k I was able to repro the issues you were seeing when you ran 100 tests. There was a sync issue in the mocks for mempool / state wait that I believe was causing the issues, I've fixed it now and it works for me. Note that it's ok for the tests to output error logs - some of the tests are designed to trigger error cases and then test that the paych manager handles errors correctly. Please take another look and let me know if it works for you now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comments, but overall this looks really good, excited to have this in soon!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote a lot of suggestions and ideas, but generally these are improvements / future tickets rather than blocking issues.
However, the one thing I need to at minimum confirm is your intention (and if so, understand why) is keying the channels on -from->to- -- it seems like we should be using the UUID, cause otherwise we're overwriting channels potentially. I guess if they're not active that's ok, maybe even preferable, but it still feels odd to have the uuid if we're not really using it that much (I guess we're using it for messages)
} | ||
|
||
func (ps *Store) VouchersForPaych(ch address.Address) ([]*VoucherInfo, error) { | ||
ci, err := ps.getChannelInfo(ch) | ||
// TODO: This is a hack to get around not being able to CBOR marshall a nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eeek how annoying!
paychmgr/simple.go
Outdated
} | ||
|
||
// Change the state of the channel in the store | ||
func (ca *channelAccessor) mutateChannelInfo(from address.Address, to address.Address, mutate func(*ChannelInfo)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be worth looking at go-statestore even if you're not using go-statemachine
cause it provides some of this functionality in a simple form. (for the future)
if err != nil { | ||
return types.NewInt(0), err | ||
return types.BigInt{}, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Lotus still have a BigInt type of its own? I feel like at this point all our money types should come from spec-actors
abi package? Future refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an alias of the spec type, we just never got around to getting rid of it
Update adapter to use wait methods provided by paych adapter
03a258b
to
1ef9113
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM all other comments non-blocking
Currently when creating a channel or adding funds to an existing channel, the payment channel manager locks up until the messages have been confirmed on chain, which can take several minutes.
This PR resolves the locking issue:
This PR also manages the state of requests and restores them if lotus is shut down and restarted:
This PR also