From fd5e56947c1020271d3e90f9d8bebcd5e2d3153b Mon Sep 17 00:00:00 2001 From: libotony Date: Fri, 20 Sep 2024 17:12:32 +0800 Subject: [PATCH] pool:check executable against next block number (#834) --- txpool/tx_object.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/txpool/tx_object.go b/txpool/tx_object.go index dd511cad7..95f690625 100644 --- a/txpool/tx_object.go +++ b/txpool/tx_object.go @@ -55,7 +55,7 @@ func (o *txObject) Executable(chain *chain.Chain, state *state.State, headBlock switch { case o.Gas() > headBlock.GasLimit(): return false, errors.New("gas too large") - case o.IsExpired(headBlock.Number()): + case o.IsExpired(headBlock.Number() + 1): // Check tx expiration on top of next block return false, errors.New("expired") case o.BlockRef().Number() > headBlock.Number()+uint32(5*60/thor.BlockInterval): // reject deferred tx which will be applied after 5mins @@ -81,13 +81,11 @@ func (o *txObject) Executable(chain *chain.Chain, state *state.State, headBlock } } - if o.BlockRef().Number() > headBlock.Number() { + // Tx is considered executable when the BlockRef has passed in reference to the next block. + if o.BlockRef().Number() > headBlock.Number()+1 { return false, nil } - // checkpoint := state.NewCheckpoint() - // defer state.RevertTo(checkpoint) - if _, _, _, _, err := o.resolved.BuyGas(state, headBlock.Timestamp()+thor.BlockInterval); err != nil { return false, err }