From c38882dd8fea55bf92cb03feb05de0e5a7bb0c28 Mon Sep 17 00:00:00 2001 From: ChengenH Date: Sun, 15 Dec 2024 21:20:53 +0800 Subject: [PATCH 1/2] refactor: use errors.New to replace fmt.Errorf with no parameters Signed-off-by: ChengenH --- block/block.go | 2 +- block/modes.go | 2 +- block/slvalidator.go | 2 +- cmd/dymint/commands/start.go | 3 ++- da/da.go | 4 ++-- test/loadtime/cmd/load/main.go | 5 ++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/block/block.go b/block/block.go index 4b4562794..fc9ade90e 100644 --- a/block/block.go +++ b/block/block.go @@ -142,7 +142,7 @@ func (m *Manager) applyBlock(block *types.Block, commit *types.Commit, blockMeta // Proposer cannot be empty while applying the block proposer := m.State.GetProposer() if proposer == nil { - return fmt.Errorf("logic error: got nil proposer while applying block") + return errors.New("logic error: got nil proposer while applying block") } batch := m.Store.NewBatch() diff --git a/block/modes.go b/block/modes.go index adfd56432..3e2e37d0e 100644 --- a/block/modes.go +++ b/block/modes.go @@ -62,7 +62,7 @@ func (m *Manager) runAsProposer(ctx context.Context, eg *errgroup.Group) error { return fmt.Errorf("am i proposer on SL: %w", err) } if !amIProposerOnSL { - return fmt.Errorf("the node is no longer the proposer. please restart.") + return errors.New("the node is no longer the proposer. please restart.") } // update l2 proposer from SL in case it changed after syncing diff --git a/block/slvalidator.go b/block/slvalidator.go index bf9b8ac0a..1d80d675f 100644 --- a/block/slvalidator.go +++ b/block/slvalidator.go @@ -189,7 +189,7 @@ func (v *SettlementValidator) ValidateDaBlocks(slBatch *settlement.ResultRetriev if slBatch.NextSequencer != slBatch.Sequencer { nextSequencer, found := v.blockManager.Sequencers.GetByAddress(slBatch.NextSequencer) if !found { - return fmt.Errorf("next sequencer not found") + return errors.New("next sequencer not found") } copy(expectedNextSeqHash[:], nextSequencer.MustHash()) } diff --git a/cmd/dymint/commands/start.go b/cmd/dymint/commands/start.go index 3bfa6e503..110ddb36e 100644 --- a/cmd/dymint/commands/start.go +++ b/cmd/dymint/commands/start.go @@ -6,6 +6,7 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "errors" "fmt" "io" "os" @@ -141,7 +142,7 @@ func startInProcess(config *cfg.NodeConfig, tmConfig *tmcfg.Config, logger log.L func checkGenesisHash(config *tmcfg.Config) error { if config.Genesis == "" { - return fmt.Errorf("genesis file is not set") + return errors.New("genesis file is not set") } if len(genesisHash) == 0 { diff --git a/da/da.go b/da/da.go index 3bde8023f..c15c97849 100644 --- a/da/da.go +++ b/da/da.go @@ -2,7 +2,7 @@ package da import ( "encoding/hex" - "fmt" + "errors" "strconv" "strings" @@ -113,7 +113,7 @@ func (d *DASubmitMetaData) ToPath() string { func (d *DASubmitMetaData) FromPath(path string) (*DASubmitMetaData, error) { pathParts := strings.FieldsFunc(path, func(r rune) bool { return r == rune(PathSeparator[0]) }) if len(pathParts) < 2 { - return nil, fmt.Errorf("invalid DA path") + return nil, errors.New("invalid DA path") } height, err := strconv.ParseUint(pathParts[1], 10, 64) diff --git a/test/loadtime/cmd/load/main.go b/test/loadtime/cmd/load/main.go index 456f78b1d..ead756b05 100644 --- a/test/loadtime/cmd/load/main.go +++ b/test/loadtime/cmd/load/main.go @@ -1,8 +1,7 @@ package main import ( - "fmt" - + "errors" "github.com/google/uuid" "github.com/informalsystems/tm-load-test/pkg/loadtest" @@ -51,7 +50,7 @@ func (f *ClientFactory) ValidateConfig(cfg loadtest.Config) error { return err } if psb > cfg.Size { - return fmt.Errorf("payload size exceeds configured size") + return errors.New("payload size exceeds configured size") } return nil } From 43b2b5ba807c5dd825e8d5d0180de219817cf005 Mon Sep 17 00:00:00 2001 From: ChengenH Date: Mon, 16 Dec 2024 20:34:42 +0800 Subject: [PATCH 2/2] refactor: use errors.New to replace fmt.Errorf with no parameters Signed-off-by: ChengenH --- test/loadtime/cmd/load/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/loadtime/cmd/load/main.go b/test/loadtime/cmd/load/main.go index ead756b05..80a915970 100644 --- a/test/loadtime/cmd/load/main.go +++ b/test/loadtime/cmd/load/main.go @@ -2,6 +2,7 @@ package main import ( "errors" + "github.com/google/uuid" "github.com/informalsystems/tm-load-test/pkg/loadtest"