From e191e9f66d81d214aafc204cee9271560455e2c7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 10 Mar 2025 12:48:32 +0100 Subject: [PATCH] Address more review feedback Use `errors.Is` instead of `errors.As` since we don't need to access special fields in the custom error type. Rather than generating a new error to wrap, just capture the exisitng error. --- eth/catalyst/simulated_beacon.go | 4 ++-- eth/catalyst/simulated_beacon_api.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/eth/catalyst/simulated_beacon.go b/eth/catalyst/simulated_beacon.go index 7aa45914a7..e4e2ca7746 100644 --- a/eth/catalyst/simulated_beacon.go +++ b/eth/catalyst/simulated_beacon.go @@ -88,7 +88,7 @@ type errTxPoolTerminated struct { // Error returns the message from the wrapped error. func (t *errTxPoolTerminated) Error() string { - return t.error.Error() + return fmt.Errorf("failed to sync txpool: %w", t.error).Error() } // SimulatedBeacon drives an Ethereum instance as if it were a real beacon @@ -192,7 +192,7 @@ func (c *SimulatedBeacon) sealBlock(withdrawals []*types.Withdrawal, timestamp u // behavior, the pool will be explicitly blocked on its reset before // continuing to the block production below. if err := c.eth.APIBackend.TxPool().Sync(); err != nil { - return &errTxPoolTerminated{fmt.Errorf("failed to sync txpool: %w", err)} + return &errTxPoolTerminated{err} } version := payloadVersion(c.eth.BlockChain().Config(), timestamp) diff --git a/eth/catalyst/simulated_beacon_api.go b/eth/catalyst/simulated_beacon_api.go index bc8d1cb159..34047a964c 100644 --- a/eth/catalyst/simulated_beacon_api.go +++ b/eth/catalyst/simulated_beacon_api.go @@ -73,8 +73,7 @@ func (a *simulatedBeaconAPI) loop() { } // Avoids spinlooping if the txPool is alredy terminated. if _, err := a.sim.commit(); err != nil { - var txpTermErr *errTxPoolTerminated - if errors.As(err, &txpTermErr) { + if errors.Is(err, &errTxPoolTerminated{}) { break } }