Merge pull request #3766 from filecoin-project/fix/mpool-prune

refactor getBaseFeeLowerBound, use it to prune less aggressively
This commit is contained in:
Łukasz Magiera 2020-09-11 11:40:26 +02:00 committed by GitHub
commit 4410da98be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View File

@ -416,7 +416,7 @@ func (mp *MessagePool) verifyMsgBeforeAdd(m *types.SignedMessage, curTs *types.T
publish := local publish := local
if strictBaseFeeValidation && len(curTs.Blocks()) > 0 { if strictBaseFeeValidation && len(curTs.Blocks()) > 0 {
baseFee := curTs.Blocks()[0].ParentBaseFee baseFee := curTs.Blocks()[0].ParentBaseFee
baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor) baseFeeLowerBound := getBaseFeeLowerBound(baseFee)
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) { if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
if local { if local {
log.Warnf("local message will not be immediately published because GasFeeCap doesn't meet the lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s)", log.Warnf("local message will not be immediately published because GasFeeCap doesn't meet the lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s)",
@ -1299,3 +1299,12 @@ func (mp *MessagePool) Clear(local bool) {
delete(mp.pending, a) delete(mp.pending, a)
} }
} }
func getBaseFeeLowerBound(baseFee types.BigInt) types.BigInt {
baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor)
if baseFeeLowerBound.LessThan(minimumBaseFee) {
baseFeeLowerBound = minimumBaseFee
}
return baseFeeLowerBound
}

View File

@ -46,6 +46,7 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro
if err != nil { if err != nil {
return xerrors.Errorf("computing basefee: %w", err) return xerrors.Errorf("computing basefee: %w", err)
} }
baseFeeLowerBound := getBaseFeeLowerBound(baseFee)
pending, _ := mp.getPendingMessages(ts, ts) pending, _ := mp.getPendingMessages(ts, ts)
@ -72,7 +73,7 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro
for _, m := range mset { for _, m := range mset {
pruneMsgs[m.Message.Cid()] = m pruneMsgs[m.Message.Cid()] = m
} }
actorChains := mp.createMessageChains(actor, mset, baseFee, ts) actorChains := mp.createMessageChains(actor, mset, baseFeeLowerBound, ts)
chains = append(chains, actorChains...) chains = append(chains, actorChains...)
} }

View File

@ -27,11 +27,7 @@ func (mp *MessagePool) republishPendingMessages() error {
mp.curTsLk.Unlock() mp.curTsLk.Unlock()
return xerrors.Errorf("computing basefee: %w", err) return xerrors.Errorf("computing basefee: %w", err)
} }
baseFeeLowerBound := getBaseFeeLowerBound(baseFee)
baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor)
if baseFeeLowerBoundFactor.LessThan(minimumBaseFee) {
baseFeeLowerBound = minimumBaseFee
}
pending := make(map[address.Address]map[uint64]*types.SignedMessage) pending := make(map[address.Address]map[uint64]*types.SignedMessage)
mp.lk.Lock() mp.lk.Lock()