From 3287c621addf6e2374c600ff28b9aa6218d760c1 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Tue, 5 Jan 2021 16:58:12 +0100 Subject: [PATCH 1/2] fix: better withdrawal error message --- chain/market/fundmanager.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chain/market/fundmanager.go b/chain/market/fundmanager.go index 5df7589fa..090506252 100644 --- a/chain/market/fundmanager.go +++ b/chain/market/fundmanager.go @@ -2,6 +2,7 @@ package market import ( "context" + "fmt" "sync" "github.com/filecoin-project/go-address" @@ -501,7 +502,13 @@ func (a *fundedAddress) processWithdrawals(withdrawals []*fundRequest) (msgCid c // request with an error newWithdrawalAmt := types.BigAdd(withdrawalAmt, amt) if newWithdrawalAmt.GreaterThan(netAvail) { - err := xerrors.Errorf("insufficient funds for withdrawal of %d", amt) + msg := fmt.Sprintf("insufficient funds for withdrawal of %d: ", amt) + msg += fmt.Sprintf("net available (%d) = available (%d) - reserved (%d)", + types.BigSub(netAvail, withdrawalAmt), avail, a.state.AmtReserved) + if !withdrawalAmt.IsZero() { + msg += fmt.Sprintf(" - queued withdrawals (%d)", withdrawalAmt) + } + err := xerrors.Errorf(msg) a.debugf("%s", err) req.Complete(cid.Undef, err) continue From e8e4b559e9c806d21571b62863986846ae338d56 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Wed, 6 Jan 2021 09:23:54 +0100 Subject: [PATCH 2/2] fix: format fund manager message fil amounts --- chain/market/fundmanager.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/market/fundmanager.go b/chain/market/fundmanager.go index 090506252..e5fcf0b80 100644 --- a/chain/market/fundmanager.go +++ b/chain/market/fundmanager.go @@ -502,11 +502,11 @@ func (a *fundedAddress) processWithdrawals(withdrawals []*fundRequest) (msgCid c // request with an error newWithdrawalAmt := types.BigAdd(withdrawalAmt, amt) if newWithdrawalAmt.GreaterThan(netAvail) { - msg := fmt.Sprintf("insufficient funds for withdrawal of %d: ", amt) - msg += fmt.Sprintf("net available (%d) = available (%d) - reserved (%d)", - types.BigSub(netAvail, withdrawalAmt), avail, a.state.AmtReserved) + msg := fmt.Sprintf("insufficient funds for withdrawal of %s: ", types.FIL(amt)) + msg += fmt.Sprintf("net available (%s) = available (%s) - reserved (%s)", + types.FIL(types.BigSub(netAvail, withdrawalAmt)), types.FIL(avail), types.FIL(a.state.AmtReserved)) if !withdrawalAmt.IsZero() { - msg += fmt.Sprintf(" - queued withdrawals (%d)", withdrawalAmt) + msg += fmt.Sprintf(" - queued withdrawals (%s)", types.FIL(withdrawalAmt)) } err := xerrors.Errorf(msg) a.debugf("%s", err)