From 114c0ea85c0497a62286f59ab0fc68e21b6f4c48 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 4 Sep 2020 15:42:12 +0200 Subject: [PATCH 1/3] Fix GasPremium capping logic Cap it just to FeeCap, there is no reason to cap it proportionally Signed-off-by: Jakub Sztandera --- node/impl/full/gas.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/node/impl/full/gas.go b/node/impl/full/gas.go index d0fae9afc..778c2c4eb 100644 --- a/node/impl/full/gas.go +++ b/node/impl/full/gas.go @@ -217,16 +217,11 @@ func capGasFee(msg *types.Message, maxFee abi.TokenAmount) { gl := types.NewInt(uint64(msg.GasLimit)) totalFee := types.BigMul(msg.GasFeeCap, gl) - minerFee := types.BigMul(msg.GasPremium, gl) if totalFee.LessThanEqual(maxFee) { return } - // scale chain/miner fee down proportionally to fit in our budget - // TODO: there are probably smarter things we can do here to optimize - // message inclusion latency - msg.GasFeeCap = big.Div(maxFee, gl) - msg.GasPremium = big.Div(big.Div(big.Mul(minerFee, maxFee), totalFee), gl) + msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap } From 4cf52ea02558fe051df262a9e30f40a8e11b7735 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 4 Sep 2020 15:52:50 +0200 Subject: [PATCH 2/3] Add 0.1FIL cap too DefaultMessageSendSpec Signed-off-by: Jakub Sztandera --- api/types.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/types.go b/api/types.go index 0ef5d7acf..37cc4a7fa 100644 --- a/api/types.go +++ b/api/types.go @@ -6,8 +6,8 @@ import ( "github.com/filecoin-project/go-address" datatransfer "github.com/filecoin-project/go-data-transfer" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/specs-actors/actors/abi" - "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/ipfs/go-cid" @@ -96,7 +96,8 @@ type MessageSendSpec struct { } var DefaultMessageSendSpec = MessageSendSpec{ - MaxFee: big.Zero(), + // MaxFee of 0.1FIL + MaxFee: abi.NewTokenAmount(int64(build.FilecoinPrecision) / 10), } func (ms *MessageSendSpec) Get() MessageSendSpec { From 20801263ec19dde04370b9e89a559584dff155bc Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 4 Sep 2020 18:13:09 +0200 Subject: [PATCH 3/3] Fix paych tests Signed-off-by: Jakub Sztandera --- cli/paych_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/paych_test.go b/cli/paych_test.go index 8eaeb0f13..43cc34122 100644 --- a/cli/paych_test.go +++ b/cli/paych_test.go @@ -127,7 +127,7 @@ func TestPaymentChannelStatus(t *testing.T) { go func() { // creator: paych get cmd = []string{creatorAddr.String(), receiverAddr.String(), fmt.Sprintf("%d", channelAmt)} - create <- creatorCLI.runCmd(paychGetCmd, cmd) + create <- creatorCLI.runCmd(paychAddFundsCmd, cmd) }() // Wait for the output to stop being "Channel does not exist" @@ -347,7 +347,7 @@ func TestPaymentChannelVoucherCreateShortfall(t *testing.T) { // creator: paych get channelAmt := 100 cmd := []string{creatorAddr.String(), receiverAddr.String(), fmt.Sprintf("%d", channelAmt)} - chstr := creatorCLI.runCmd(paychGetCmd, cmd) + chstr := creatorCLI.runCmd(paychAddFundsCmd, cmd) chAddr, err := address.NewFromString(chstr) require.NoError(t, err)