Merge pull request #3557 from filecoin-project/fix/mpool-repub-negative

republish messages even if the chains have negative performance
This commit is contained in:
Łukasz Magiera 2020-09-05 21:48:39 +02:00 committed by GitHub
commit f58cbc2594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 19 deletions

View File

@ -67,12 +67,6 @@ func (mp *MessagePool) republishPendingMessages() error {
return chains[i].Before(chains[j]) return chains[i].Before(chains[j])
}) })
// we don't republish negative performing chains; this is an error that will be screamed
// at the user
if chains[0].gasPerf < 0 {
return xerrors.Errorf("skipping republish: all message chains have negative gas performance; best gas performance: %f", chains[0].gasPerf)
}
gasLimit := int64(build.BlockGasLimit) gasLimit := int64(build.BlockGasLimit)
minGas := int64(gasguess.MinGas) minGas := int64(gasguess.MinGas)
var msgs []*types.SignedMessage var msgs []*types.SignedMessage
@ -89,12 +83,6 @@ func (mp *MessagePool) republishPendingMessages() error {
break break
} }
// we don't republish negative performing chains, as they won't be included in
// a block anyway
if chain.gasPerf < 0 {
break
}
// has the chain been invalidated? // has the chain been invalidated?
if !chain.valid { if !chain.valid {
i++ i++
@ -111,7 +99,7 @@ func (mp *MessagePool) republishPendingMessages() error {
// we can't fit the current chain but there is gas to spare // we can't fit the current chain but there is gas to spare
// trim it and push it down // trim it and push it down
chain.Trim(gasLimit, mp, baseFee, ts) chain.Trim(gasLimit, mp, baseFee, true)
for j := i; j < len(chains)-1; j++ { for j := i; j < len(chains)-1; j++ {
if chains[j].Before(chains[j+1]) { if chains[j].Before(chains[j+1]) {
break break

View File

@ -217,7 +217,7 @@ tailLoop:
for gasLimit >= minGas && last < len(chains) { for gasLimit >= minGas && last < len(chains) {
// trim if necessary // trim if necessary
if chains[last].gasLimit > gasLimit { if chains[last].gasLimit > gasLimit {
chains[last].Trim(gasLimit, mp, baseFee, ts) chains[last].Trim(gasLimit, mp, baseFee, false)
} }
// push down if it hasn't been invalidated // push down if it hasn't been invalidated
@ -284,7 +284,7 @@ tailLoop:
} }
// dependencies fit, just trim it // dependencies fit, just trim it
chain.Trim(gasLimit-depGasLimit, mp, baseFee, ts) chain.Trim(gasLimit-depGasLimit, mp, baseFee, false)
last += i last += i
continue tailLoop continue tailLoop
} }
@ -389,7 +389,7 @@ func (mp *MessagePool) selectMessagesGreedy(curTs, ts *types.TipSet) ([]*types.S
tailLoop: tailLoop:
for gasLimit >= minGas && last < len(chains) { for gasLimit >= minGas && last < len(chains) {
// trim // trim
chains[last].Trim(gasLimit, mp, baseFee, ts) chains[last].Trim(gasLimit, mp, baseFee, false)
// push down if it hasn't been invalidated // push down if it hasn't been invalidated
if chains[last].valid { if chains[last].valid {
@ -497,7 +497,7 @@ func (mp *MessagePool) selectPriorityMessages(pending map[address.Address]map[ui
tailLoop: tailLoop:
for gasLimit >= minGas && last < len(chains) { for gasLimit >= minGas && last < len(chains) {
// trim, discarding negative performing messages // trim, discarding negative performing messages
chains[last].Trim(gasLimit, mp, baseFee, ts) chains[last].Trim(gasLimit, mp, baseFee, false)
// push down if it hasn't been invalidated // push down if it hasn't been invalidated
if chains[last].valid { if chains[last].valid {
@ -775,9 +775,9 @@ func (mc *msgChain) Before(other *msgChain) bool {
(mc.gasPerf == other.gasPerf && mc.gasReward.Cmp(other.gasReward) > 0) (mc.gasPerf == other.gasPerf && mc.gasReward.Cmp(other.gasReward) > 0)
} }
func (mc *msgChain) Trim(gasLimit int64, mp *MessagePool, baseFee types.BigInt, ts *types.TipSet) { func (mc *msgChain) Trim(gasLimit int64, mp *MessagePool, baseFee types.BigInt, allowNegative bool) {
i := len(mc.msgs) - 1 i := len(mc.msgs) - 1
for i >= 0 && (mc.gasLimit > gasLimit || mc.gasPerf < 0) { for i >= 0 && (mc.gasLimit > gasLimit || (!allowNegative && mc.gasPerf < 0)) {
gasReward := mp.getGasReward(mc.msgs[i], baseFee) gasReward := mp.getGasReward(mc.msgs[i], baseFee)
mc.gasReward = new(big.Int).Sub(mc.gasReward, gasReward) mc.gasReward = new(big.Int).Sub(mc.gasReward, gasReward)
mc.gasLimit -= mc.msgs[i].Message.GasLimit mc.gasLimit -= mc.msgs[i].Message.GasLimit