compute baseFee for check even in null rounds

This commit is contained in:
vyzo 2020-09-14 22:20:26 +03:00
parent 0a5494dd79
commit 172bfacae0

View File

@ -441,18 +441,27 @@ func (mp *MessagePool) verifyMsgBeforeAdd(m *types.SignedMessage, curTs *types.T
// Note that for local messages, we always add them so that they can be accepted and republished // Note that for local messages, we always add them so that they can be accepted and republished
// automatically. // automatically.
publish := local publish := local
var baseFee big.Int
if len(curTs.Blocks()) > 0 { if len(curTs.Blocks()) > 0 {
baseFee := curTs.Blocks()[0].ParentBaseFee baseFee = curTs.Blocks()[0].ParentBaseFee
baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactorConservative) } else {
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) { var err error
if local { baseFee, err = mp.api.ChainComputeBaseFee(context.TODO(), curTs)
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)", if err != nil {
m.Message.GasFeeCap, baseFeeLowerBound) return false, xerrors.Errorf("computing basefee: %w", err)
publish = false }
} else { }
return false, xerrors.Errorf("GasFeeCap doesn't meet base fee lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s): %w",
m.Message.GasFeeCap, baseFeeLowerBound, ErrSoftValidationFailure) baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactorConservative)
} if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
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)",
m.Message.GasFeeCap, baseFeeLowerBound)
publish = false
} else {
return false, xerrors.Errorf("GasFeeCap doesn't meet base fee lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s): %w",
m.Message.GasFeeCap, baseFeeLowerBound, ErrSoftValidationFailure)
} }
} }