Skip to content

Commit cd0cbf2

Browse files
RiceChuanliuchuan
authored andcommitted
chore: suggest using errors.New instead of fmt.Errorf with no parameters
Signed-off-by: liuchuan <[email protected]>
1 parent 1f2b397 commit cd0cbf2

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

rollup/cmd/permissionless_batches/app/app.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package app
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"os"
78
"os/signal"
@@ -53,16 +54,16 @@ func action(ctx *cli.Context) error {
5354

5455
// Sanity check config. Make sure the required fields are set.
5556
if cfg.RecoveryConfig == nil {
56-
return fmt.Errorf("recovery config must be specified")
57+
return errors.New("recovery config must be specified")
5758
}
5859
if cfg.RecoveryConfig.L1BeaconNodeEndpoint == "" {
59-
return fmt.Errorf("L1 beacon node endpoint must be specified")
60+
return errors.New("L1 beacon node endpoint must be specified")
6061
}
6162
if cfg.RecoveryConfig.L1BlockHeight == 0 {
62-
return fmt.Errorf("L1 block height must be specified")
63+
return errors.New("L1 block height must be specified")
6364
}
6465
if cfg.RecoveryConfig.LatestFinalizedBatch == 0 {
65-
return fmt.Errorf("latest finalized batch must be specified")
66+
return errors.New("latest finalized batch must be specified")
6667
}
6768

6869
// init db connection

rollup/internal/controller/relayer/l2_relayer_sanity.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package relayer
22

33
import (
4+
"errors"
45
"fmt"
56
"math/big"
67

@@ -18,7 +19,7 @@ import (
1819
// This ensures the constructed transaction data is correct and consistent with the database state.
1920
func (r *Layer2Relayer) sanityChecksCommitBatchCodecV7CalldataAndBlobs(calldata []byte, blobs []*kzg4844.Blob) error {
2021
if r.l1RollupABI == nil {
21-
return fmt.Errorf("l1RollupABI is nil: cannot parse commitBatches calldata")
22+
return errors.New("l1RollupABI is nil: cannot parse commitBatches calldata")
2223
}
2324
calldataInfo, err := parseCommitBatchesCalldata(r.l1RollupABI, calldata)
2425
if err != nil {

rollup/internal/controller/sender/transaction_signer.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package sender
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"math/big"
78

@@ -51,7 +52,7 @@ func NewTransactionSigner(config *config.SignerConfig, chainID *big.Int) (*Trans
5152
}, nil
5253
case RemoteSignerType:
5354
if config.RemoteSignerConfig.SignerAddress == "" {
54-
return nil, fmt.Errorf("failed to create RemoteSigner, signer address is empty")
55+
return nil, errors.New("failed to create RemoteSigner, signer address is empty")
5556
}
5657
rpcClient, err := rpc.Dial(config.RemoteSignerConfig.RemoteSignerUrl)
5758
if err != nil {
@@ -94,7 +95,7 @@ func (ts *TransactionSigner) SignTransaction(ctx context.Context, tx *gethTypes.
9495
return signedTx, nil
9596
default:
9697
// this shouldn't happen, because SignerType is checked during creation
97-
return nil, fmt.Errorf("shouldn't happen, unknown signer type")
98+
return nil, errors.New("shouldn't happen, unknown signer type")
9899
}
99100
}
100101

0 commit comments

Comments
 (0)