From dbd4a1729a2a2622f6b7d06ccb9e5a396bcac7f2 Mon Sep 17 00:00:00 2001 From: ChengenH Date: Sun, 8 Dec 2024 22:31:44 +0800 Subject: [PATCH] chore: use errors.New to replace fmt.Errorf with no parameters Signed-off-by: ChengenH --- packages/chain/WaspChainConsensus.tla | 2 +- packages/chain/statemanager/sm_gpa/state_manager_gpa.go | 2 +- packages/nodeconn/nc_chain.go | 2 +- packages/util/generics.go | 4 ++-- packages/vm/vmexceptions/exceptions.go | 2 +- packages/wasmvm/wasmlib/as/wasmlib/exports.ts | 2 +- packages/wasmvm/wasmlib/src/exports.rs | 2 +- packages/wasmvm/wasmlib/ts/wasmlib/exports.ts | 2 +- tools/cluster/chain.go | 3 ++- tools/cluster/cluster.go | 2 +- tools/schema/main.go | 2 +- tools/wasp-cli/cli/config/config.go | 2 +- 12 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/chain/WaspChainConsensus.tla b/packages/chain/WaspChainConsensus.tla index c45e813821..4bb52aedaf 100644 --- a/packages/chain/WaspChainConsensus.tla +++ b/packages/chain/WaspChainConsensus.tla @@ -315,7 +315,7 @@ The committee has to handle rejects and reorgs in L1, agree on the next log entry by choosing an alias output to use as an input for the next TX. The main idea is that if the nodes consider different alias outputs to use, -after some time they will get synchronized, because L1 here the the source +after some time they will get synchronized, because L1 here the source of this information, and it will be synchronized to all the correct nodes after some time. *) diff --git a/packages/chain/statemanager/sm_gpa/state_manager_gpa.go b/packages/chain/statemanager/sm_gpa/state_manager_gpa.go index 49fa2a86a2..06914bdb45 100644 --- a/packages/chain/statemanager/sm_gpa/state_manager_gpa.go +++ b/packages/chain/statemanager/sm_gpa/state_manager_gpa.go @@ -756,7 +756,7 @@ func (smT *stateManagerGPA) updateChainOfBlocks(commitment *state.L1Commitment, smT.chainOfBlocks = cob } else if bi == nil { // origin block has been reached smT.chainOfBlocks = cob - } else if bi.trieRoot.Equals(lastKnownBi.trieRoot) { // Here is the the place to merge newest blocks chain with currently known blocks chain + } else if bi.trieRoot.Equals(lastKnownBi.trieRoot) { // Here is the place to merge newest blocks chain with currently known blocks chain // Normally newest blocks chain should contain only several (usually, 1) // block infos and currently known blocks chain should contain at least // `PruningMinStatesToKeep` block infos, but on a sudden enabling of pruning diff --git a/packages/nodeconn/nc_chain.go b/packages/nodeconn/nc_chain.go index 7f080aedf4..e636a579b6 100644 --- a/packages/nodeconn/nc_chain.go +++ b/packages/nodeconn/nc_chain.go @@ -320,7 +320,7 @@ func (ncc *ncChain) postTxLoop(ctx context.Context) { postTransaction := func(pendingTx *pendingTransaction, isReattachment bool) error { debugInfoChaining := "" - // check if the the transaction should be chained with another pending transaction + // check if the transaction should be chained with another pending transaction chainedTxBlockIDs := iotago.BlockIDs{} if pendingTx.lastPendingTx != nil { // check if the chained pending transaction is still being tracked. diff --git a/packages/util/generics.go b/packages/util/generics.go index 7e08dac160..efd178c23b 100644 --- a/packages/util/generics.go +++ b/packages/util/generics.go @@ -4,7 +4,7 @@ type Cloneable[T any] interface { Clone() T } -// CloneSlice clones every element in the the slice into cloned and returns the cloned slice. +// CloneSlice clones every element in the slice into cloned and returns the cloned slice. func CloneSlice[T Cloneable[T]](base []T) []T { cloned := make([]T, len(base)) @@ -15,7 +15,7 @@ func CloneSlice[T Cloneable[T]](base []T) []T { return cloned } -// CloneMap clones every element in the the map into cloned and returns the cloned map. +// CloneMap clones every element in the map into cloned and returns the cloned map. func CloneMap[K comparable, T Cloneable[T]](base map[K]T) map[K]T { cloned := make(map[K]T, len(base)) diff --git a/packages/vm/vmexceptions/exceptions.go b/packages/vm/vmexceptions/exceptions.go index 8e46a1a924..036f26fdb9 100644 --- a/packages/vm/vmexceptions/exceptions.go +++ b/packages/vm/vmexceptions/exceptions.go @@ -24,7 +24,7 @@ var ( // not a protocol limit error, but something went wrong after request execution var ( - ErrPostExecutionPanic = fmt.Errorf("post execution error") + ErrPostExecutionPanic = errors.New("post execution error") ) var SkipRequestErrors = []error{ diff --git a/packages/wasmvm/wasmlib/as/wasmlib/exports.ts b/packages/wasmvm/wasmlib/as/wasmlib/exports.ts index 19b6dd9e71..290c44c038 100644 --- a/packages/wasmvm/wasmlib/as/wasmlib/exports.ts +++ b/packages/wasmvm/wasmlib/as/wasmlib/exports.ts @@ -9,7 +9,7 @@ import {exportName} from './host'; // Note that we do not use the Wasm export symbol table on purpose // because Wasm does not allow us to determine whether the symbols // are meant as view or func, or meant as extra public callbacks -// generated by the compilation of the the Wasm code. +// generated by the compilation of the Wasm code. // There are only 2 symbols the ISC host will actually look for // in the export table: // on_load (which must be defined by the SC code) and diff --git a/packages/wasmvm/wasmlib/src/exports.rs b/packages/wasmvm/wasmlib/src/exports.rs index 9e68cde819..a9dea70a3e 100644 --- a/packages/wasmvm/wasmlib/src/exports.rs +++ b/packages/wasmvm/wasmlib/src/exports.rs @@ -9,7 +9,7 @@ use crate::host::*; // Note that we do not use the Wasm export symbol table on purpose // because Wasm does not allow us to determine whether the symbols // are meant as view or func, or meant as extra public callbacks -// generated by the compilation of the the Wasm code. +// generated by the compilation of the Wasm code. // There are only 2 symbols the ISC host will actually look for // in the export table: // on_load (which must be defined by the SC code) and diff --git a/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts b/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts index 19b6dd9e71..290c44c038 100644 --- a/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts +++ b/packages/wasmvm/wasmlib/ts/wasmlib/exports.ts @@ -9,7 +9,7 @@ import {exportName} from './host'; // Note that we do not use the Wasm export symbol table on purpose // because Wasm does not allow us to determine whether the symbols // are meant as view or func, or meant as extra public callbacks -// generated by the compilation of the the Wasm code. +// generated by the compilation of the Wasm code. // There are only 2 symbols the ISC host will actually look for // in the export table: // on_load (which must be defined by the SC code) and diff --git a/tools/cluster/chain.go b/tools/cluster/chain.go index bf2c17e858..1c643dd1dc 100644 --- a/tools/cluster/chain.go +++ b/tools/cluster/chain.go @@ -3,6 +3,7 @@ package cluster import ( "bytes" "context" + "errors" "fmt" "time" @@ -148,7 +149,7 @@ func (ch *Chain) DeployWasmContract(name string, progBinary []byte, initParams m return hashing.NilHash, err } if !bytes.Equal(progBinary, progBinaryBack) { - return hashing.NilHash, fmt.Errorf("!bytes.Equal(progBinary, progBinaryBack)") + return hashing.NilHash, errors.New("!bytes.Equal(progBinary, progBinaryBack)") } fmt.Printf("---- blob installed correctly len = %d\n", len(progBinaryBack)) diff --git a/tools/cluster/cluster.go b/tools/cluster/cluster.go index f08597b07b..26f725bbee 100644 --- a/tools/cluster/cluster.go +++ b/tools/cluster/cluster.go @@ -906,5 +906,5 @@ func (clu *Cluster) MintL1NFT(immutableMetadata []byte, target iotago.Address, i } } - return iotago.OutputID{}, nil, fmt.Errorf("inconsistency: couldn't find newly minted NFT in tx") + return iotago.OutputID{}, nil, errors.New("inconsistency: couldn't find newly minted NFT in tx") } diff --git a/tools/schema/main.go b/tools/schema/main.go index 6a49d1065e..6d8bf546ba 100644 --- a/tools/schema/main.go +++ b/tools/schema/main.go @@ -359,7 +359,7 @@ func runGenerator() error { } if !generated { flag.Usage() - return fmt.Errorf("schema.yaml not found") + return errors.New("schema.yaml not found") } return nil } diff --git a/tools/wasp-cli/cli/config/config.go b/tools/wasp-cli/cli/config/config.go index aaca6a872a..626082c016 100644 --- a/tools/wasp-cli/cli/config/config.go +++ b/tools/wasp-cli/cli/config/config.go @@ -206,7 +206,7 @@ func GetChain(name string) isc.ChainID { log.Check(err) if networkPrefix != parameters.L1().Protocol.Bech32HRP { - err = fmt.Errorf("target network of the L1 node does not match the wasp-cli config") + err = errors.New("target network of the L1 node does not match the wasp-cli config") } log.Check(err)