eth/catalyst: ensure TxPool is synced in Fork

This should fix an occasional test failure in ethclient/simulated.TestForkResendTx.
Inspection of logs revealed the cause of the failure to be that the txpool was not done
reorganizing by the time Fork is called.
This commit is contained in:
Felix Lange 2024-05-29 14:33:10 +02:00
parent 06263b1b35
commit c5cdf489b8

View file

@ -279,9 +279,12 @@ func (c *SimulatedBeacon) Rollback() {
// Fork sets the head to the provided hash. // Fork sets the head to the provided hash.
func (c *SimulatedBeacon) Fork(parentHash common.Hash) error { func (c *SimulatedBeacon) Fork(parentHash common.Hash) error {
// Ensure no pending transactions.
c.eth.TxPool().Sync()
if len(c.eth.TxPool().Pending(txpool.PendingFilter{})) != 0 { if len(c.eth.TxPool().Pending(txpool.PendingFilter{})) != 0 {
return errors.New("pending block dirty") return errors.New("pending block dirty")
} }
parent := c.eth.BlockChain().GetBlockByHash(parentHash) parent := c.eth.BlockChain().GetBlockByHash(parentHash)
if parent == nil { if parent == nil {
return errors.New("parent not found") return errors.New("parent not found")