core: replace the empty fmt.Errorf with errors.New (#32274)

The `errors.new` function does not require string formatting, so its
performance is better than that of `fmt.Errorf`.
This commit is contained in:
nthumann 2025-07-28 02:13:50 +01:00 committed by GitHub
parent b369a855fb
commit 29eebb5eac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -682,7 +682,7 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()] predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
if predefinedPoint == nil || freezerTail != predefinedPoint.BlockNumber { if predefinedPoint == nil || freezerTail != predefinedPoint.BlockNumber {
log.Error("Chain history database is pruned with unknown configuration", "tail", freezerTail) log.Error("Chain history database is pruned with unknown configuration", "tail", freezerTail)
return fmt.Errorf("unexpected database tail") return errors.New("unexpected database tail")
} }
bc.historyPrunePoint.Store(predefinedPoint) bc.historyPrunePoint.Store(predefinedPoint)
return nil return nil
@ -695,15 +695,15 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
// action to happen. So just tell them how to do it. // action to happen. So just tell them how to do it.
log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is not pruned.", bc.cfg.ChainHistoryMode.String())) log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is not pruned.", bc.cfg.ChainHistoryMode.String()))
log.Error(fmt.Sprintf("Run 'geth prune-history' to prune pre-merge history.")) log.Error(fmt.Sprintf("Run 'geth prune-history' to prune pre-merge history."))
return fmt.Errorf("history pruning requested via configuration") return errors.New("history pruning requested via configuration")
} }
predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()] predefinedPoint := history.PrunePoints[bc.genesisBlock.Hash()]
if predefinedPoint == nil { if predefinedPoint == nil {
log.Error("Chain history pruning is not supported for this network", "genesis", bc.genesisBlock.Hash()) log.Error("Chain history pruning is not supported for this network", "genesis", bc.genesisBlock.Hash())
return fmt.Errorf("history pruning requested for unknown network") return errors.New("history pruning requested for unknown network")
} else if freezerTail > 0 && freezerTail != predefinedPoint.BlockNumber { } else if freezerTail > 0 && freezerTail != predefinedPoint.BlockNumber {
log.Error("Chain history database is pruned to unknown block", "tail", freezerTail) log.Error("Chain history database is pruned to unknown block", "tail", freezerTail)
return fmt.Errorf("unexpected database tail") return errors.New("unexpected database tail")
} }
bc.historyPrunePoint.Store(predefinedPoint) bc.historyPrunePoint.Store(predefinedPoint)
return nil return nil

View file

@ -515,7 +515,7 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
} }
// enforce size cap for inputs // enforce size cap for inputs
if c.eip7823 && max(baseLen, expLen, modLen) > 1024 { if c.eip7823 && max(baseLen, expLen, modLen) > 1024 {
return nil, fmt.Errorf("one or more of base/exponent/modulus length exceeded 1024 bytes") return nil, errors.New("one or more of base/exponent/modulus length exceeded 1024 bytes")
} }
// Retrieve the operands and execute the exponentiation // Retrieve the operands and execute the exponentiation
var ( var (