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

Fixes locking issues when creating channel / adding funds #2640

Merged
merged 10 commits into from
Aug 6, 2020
Prev Previous commit
Next Next commit
feat(markets): update for new paych logic
Update adapter to use wait methods provided by paych adapter
hannahhoward authored and dirkmc committed Aug 6, 2020
commit b048fcd7c17a62985f789bf841648e8822d5e03f
30 changes: 3 additions & 27 deletions markets/retrievaladapter/client.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package retrievaladapter

import (
"bytes"
"context"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/shared"
"github.com/filecoin-project/specs-actors/actors/abi"
initactor "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-multiaddr"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/node/impl/full"
payapi "github.com/filecoin-project/lotus/node/impl/paych"
@@ -76,31 +71,12 @@ func (rcn *retrievalClientNode) GetChainHead(ctx context.Context) (shared.TipSet
// WaitForPaymentChannelAddFunds waits messageCID to appear on chain. If it doesn't appear within
// defaultMsgWaitTimeout it returns error
func (rcn *retrievalClientNode) WaitForPaymentChannelAddFunds(messageCID cid.Cid) error {
_, mr, err := rcn.chainAPI.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)

if err != nil {
return err
}
if mr.ExitCode != exitcode.Ok {
return xerrors.Errorf("wait for payment channel to add funds failed. exit code: %d", mr.ExitCode)
}
return nil
_, err := rcn.payAPI.PaychMgr.GetPaychWaitReady(context.TODO(), messageCID)
return err
}

func (rcn *retrievalClientNode) WaitForPaymentChannelCreation(messageCID cid.Cid) (address.Address, error) {
_, mr, err := rcn.chainAPI.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)

if err != nil {
return address.Undef, err
}
if mr.ExitCode != exitcode.Ok {
return address.Undef, xerrors.Errorf("payment channel creation failed. exit code: %d", mr.ExitCode)
}
var retval initactor.ExecReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(mr.Return)); err != nil {
return address.Undef, err
}
return retval.RobustAddress, nil
return rcn.payAPI.PaychMgr.GetPaychWaitReady(context.TODO(), messageCID)
}

func (rcn *retrievalClientNode) GetKnownAddresses(ctx context.Context, p retrievalmarket.RetrievalPeer, encodedTs shared.TipSetToken) ([]multiaddr.Multiaddr, error) {