account for message Value in balance calculation

This commit is contained in:
vyzo 2020-08-06 20:49:31 +03:00
parent 7598a9d2fe
commit 2166e9a0ff

View File

@ -313,6 +313,13 @@ func (mp *MessagePool) createMessageChains(actor address.Address, mset map[uint6
}
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)
}
gasReward := mp.getGasReward(m, ts)
rewards = append(rewards, gasReward)
}