Skip to content

Commit

Permalink
pool:check executable against next block number (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
libotony authored Sep 20, 2024
1 parent 5b3db3a commit fd5e569
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions txpool/tx_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit fd5e569

Please sign in to comment.