From 172bfacae0cdc7ee51031c71bfdbacac77ddfc7c Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 14 Sep 2020 22:20:26 +0300 Subject: [PATCH] compute baseFee for check even in null rounds --- chain/messagepool/messagepool.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 984f696da..96900925f 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -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 // automatically. publish := local + + var baseFee big.Int if len(curTs.Blocks()) > 0 { - baseFee := curTs.Blocks()[0].ParentBaseFee - 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) - } + baseFee = curTs.Blocks()[0].ParentBaseFee + } else { + var err error + baseFee, err = mp.api.ChainComputeBaseFee(context.TODO(), curTs) + if err != nil { + return false, xerrors.Errorf("computing basefee: %w", err) + } + } + + 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) } }