From 99a8aeeeb1213c1b65e69531a26edf46571c96a3 Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Thu, 30 May 2024 17:07:11 +0100 Subject: [PATCH] Enclave: fix panic on uninitialised mempool (#1940) --- go/enclave/txpool/txpool.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/enclave/txpool/txpool.go b/go/enclave/txpool/txpool.go index 8653d9626f..6deca4a1a4 100644 --- a/go/enclave/txpool/txpool.go +++ b/go/enclave/txpool/txpool.go @@ -51,7 +51,7 @@ func NewTxPool(blockchain *ethchainadapter.EthChainAdapter, gasTip *big.Int, log // Start starts the pool // can only be started after t.blockchain has at least one block inside func (t *TxPool) Start() error { - if t.pool != nil { + if t.running { return fmt.Errorf("tx pool already started") } @@ -75,6 +75,9 @@ func (t *TxPool) PendingTransactions() map[gethcommon.Address][]*gethtxpool.Lazy // Add adds a new transactions to the pool func (t *TxPool) Add(transaction *common.L2Tx) error { + if !t.running { + return fmt.Errorf("tx pool not running") + } var strErrors []string for _, err := range t.pool.Add([]*types.Transaction{transaction}, false, false) { if err != nil {