diff --git a/cmd/juno/dbcmd.go b/cmd/juno/dbcmd.go index d9892b6be1..a29485d94e 100644 --- a/cmd/juno/dbcmd.go +++ b/cmd/juno/dbcmd.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "errors" "fmt" "os" @@ -265,7 +266,7 @@ func getNetwork(head *core.Block, stateDiff *core.StateDiff) string { func openDB(path string) (db.DB, error) { _, err := os.Stat(path) if os.IsNotExist(err) { - return nil, fmt.Errorf("database path does not exist") + return nil, errors.New("database path does not exist") } database, err := pebble.New(path) diff --git a/core/trie/key.go b/core/trie/key.go index 2d94c4ad73..0d0ca7aa88 100644 --- a/core/trie/key.go +++ b/core/trie/key.go @@ -3,6 +3,7 @@ package trie import ( "bytes" "encoding/hex" + "errors" "fmt" "math/big" @@ -111,7 +112,7 @@ func (k *Key) shiftRight(n uint8) { // MostSignificantBits returns a new key with the most significant n bits of the current key. func (k *Key) MostSignificantBits(n uint8) (*Key, error) { if n > k.len { - return nil, fmt.Errorf("cannot get more bits than the key length") + return nil, errors.New("cannot get more bits than the key length") } keyCopy := k.Copy() diff --git a/core/trie/trie.go b/core/trie/trie.go index 0dd6f4c77c..c21168c505 100644 --- a/core/trie/trie.go +++ b/core/trie/trie.go @@ -191,7 +191,7 @@ func (s *StorageNodeSet) Get(key Key) (*StorageNode, bool) { // Put adds a new StorageNode or updates an existing one. func (s *StorageNodeSet) Put(key Key, node *StorageNode) error { if node == nil { - return fmt.Errorf("cannot put nil node") + return errors.New("cannot put nil node") } // If key exists, update the node diff --git a/p2p/starknet/iterator.go b/p2p/starknet/iterator.go index 62bdb8f1c9..7e0d511364 100644 --- a/p2p/starknet/iterator.go +++ b/p2p/starknet/iterator.go @@ -2,7 +2,6 @@ package starknet import ( "errors" - "fmt" "github.com/NethermindEth/juno/blockchain" "github.com/NethermindEth/juno/core" @@ -23,10 +22,10 @@ type iterator struct { func newIteratorByNumber(bcReader blockchain.Reader, blockNumber, limit, step uint64, forward bool) (*iterator, error) { if step == 0 { - return nil, fmt.Errorf("step is zero") + return nil, errors.New("step is zero") } if limit == 0 { - return nil, fmt.Errorf("limit is zero") + return nil, errors.New("limit is zero") } return &iterator{ @@ -41,7 +40,7 @@ func newIteratorByNumber(bcReader blockchain.Reader, blockNumber, limit, step ui func newIteratorByHash(bcReader blockchain.Reader, blockHash *felt.Felt, limit, step uint64, forward bool) (*iterator, error) { if blockHash == nil { - return nil, fmt.Errorf("block hash is nil") + return nil, errors.New("block hash is nil") } block, err := bcReader.BlockByHash(blockHash) diff --git a/rpc/l1.go b/rpc/l1.go index 908b9e2a78..4438c6e7d5 100644 --- a/rpc/l1.go +++ b/rpc/l1.go @@ -2,6 +2,7 @@ package rpc import ( "context" + "errors" "fmt" "math/big" @@ -81,7 +82,7 @@ func (h *Handler) GetMessageStatus(ctx context.Context, l1TxnHash *common.Hash) func (h *Handler) messageToL2Logs(ctx context.Context, txHash *common.Hash) ([]*common.Hash, *jsonrpc.Error) { if h.l1Client == nil { - return nil, jsonrpc.Err(jsonrpc.InternalError, fmt.Errorf("11 client not found, cannot serve starknet_getMessage")) + return nil, jsonrpc.Err(jsonrpc.InternalError, errors.New("11 client not found, cannot serve starknet_getMessage")) } receipt, err := h.l1Client.TransactionReceipt(ctx, *txHash) diff --git a/rpc/transaction.go b/rpc/transaction.go index 311955b890..0610671299 100644 --- a/rpc/transaction.go +++ b/rpc/transaction.go @@ -609,7 +609,7 @@ func (h *Handler) AddTransaction(ctx context.Context, tx BroadcastedTransaction) }, nil } -var errTransactionNotFound = fmt.Errorf("transaction not found") +var errTransactionNotFound = errors.New("transaction not found") func (h *Handler) TransactionStatus(ctx context.Context, hash felt.Felt) (*TransactionStatus, *jsonrpc.Error) { receipt, txErr := h.TransactionReceiptByHash(hash)