From 1234fcfd4f9ea8bf057b02fba72a92d80e0afff8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 21 Feb 2022 14:39:11 +0000 Subject: [PATCH] fix: mempool: check messages against the next block's height Previously, we checked message gas/validity with the previous block's height. This doesn't affect consensus, but will help us avoid adding messages to the message pool that shouldn't be there. --- chain/messagepool/check.go | 2 +- chain/messagepool/messagepool.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/messagepool/check.go b/chain/messagepool/check.go index 283c0d119..92cfb458a 100644 --- a/chain/messagepool/check.go +++ b/chain/messagepool/check.go @@ -106,7 +106,7 @@ func (mp *MessagePool) checkMessages(ctx context.Context, msgs []*types.Message, curTs := mp.curTs mp.curTsLk.Unlock() - epoch := curTs.Height() + epoch := curTs.Height() + 1 var baseFee big.Int if len(curTs.Blocks()) > 0 { diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 76647e331..1520d45b4 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -628,7 +628,7 @@ func (mp *MessagePool) addLocal(ctx context.Context, m *types.SignedMessage) err // For non local messages, if the message cannot be included in the next 20 blocks it returns // a (soft) validation error. func (mp *MessagePool) verifyMsgBeforeAdd(m *types.SignedMessage, curTs *types.TipSet, local bool) (bool, error) { - epoch := curTs.Height() + epoch := curTs.Height() + 1 minGas := vm.PricelistByEpoch(epoch).OnChainMessage(m.ChainLength()) if err := m.VMMessage().ValidForBlockInclusion(minGas.Total(), build.NewestNetworkVersion); err != nil {