From 8afceee7a99904d305a8f7d22ac8504457dbee3a Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 30 Oct 2020 19:21:25 +0100 Subject: [PATCH 1/2] Fix messagepool accounting Signed-off-by: Jakub Sztandera --- chain/messagepool/selection.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/chain/messagepool/selection.go b/chain/messagepool/selection.go index 4ade92a799c..d79ed9f553e 100644 --- a/chain/messagepool/selection.go +++ b/chain/messagepool/selection.go @@ -750,13 +750,7 @@ func (mp *MessagePool) createMessageChains(actor address.Address, mset map[uint6 break } balance = new(big.Int).Sub(balance, required) - - value := m.Message.Value.Int - if balance.Cmp(value) >= 0 { - // Note: we only account for the value if the balance doesn't drop below 0 - // otherwise the message will fail and the miner can reap the gas rewards - balance = new(big.Int).Sub(balance, value) - } + balance = new(big.Int).Sub(balance, m.Message.Value.Int) gasReward := mp.getGasReward(m, baseFee) rewards = append(rewards, gasReward) From 12f61197394a44b1779c68eba2322e26b831726e Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 30 Oct 2020 20:56:33 +0200 Subject: [PATCH 2/2] don't include messages that drop the balance below zero --- chain/messagepool/selection.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chain/messagepool/selection.go b/chain/messagepool/selection.go index d79ed9f553e..5a8200bf8c7 100644 --- a/chain/messagepool/selection.go +++ b/chain/messagepool/selection.go @@ -750,7 +750,12 @@ func (mp *MessagePool) createMessageChains(actor address.Address, mset map[uint6 break } balance = new(big.Int).Sub(balance, required) - balance = new(big.Int).Sub(balance, m.Message.Value.Int) + + value := m.Message.Value.Int + if balance.Cmp(value) < 0 { + break + } + balance = new(big.Int).Sub(balance, value) gasReward := mp.getGasReward(m, baseFee) rewards = append(rewards, gasReward)