Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use errors.New to replace fmt.Errorf with no parameters #457

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion prover/lib/compressor/blob/v0/compress/lzss/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lzss

import (
"bytes"
"errors"
"fmt"
"math/bits"

Expand Down Expand Up @@ -352,7 +353,7 @@ func (compressor *Compressor) WrittenBytes() []byte {
// between any two calls to Revert, a call to Reset or Write should be made
func (compressor *Compressor) Revert() error {
if compressor.lastInLen == -1 {
return fmt.Errorf("cannot revert twice in a row")
return errors.New("cannot revert twice in a row")
}

compressor.inBuf.Truncate(compressor.lastInLen)
Expand Down
6 changes: 3 additions & 3 deletions prover/lib/compressor/blob/v0/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func DecodeTxFromUncompressed(r *bytes.Reader, from *common.Address) (types.TxDa
func decodeLegacyTx(fields []any, from *common.Address) (types.TxData, error) {

if len(fields) != 7 {
return nil, fmt.Errorf("unexpected number of field")
return nil, errors.New("unexpected number of field")
}

tx := new(types.LegacyTx)
Expand All @@ -204,7 +204,7 @@ func decodeLegacyTx(fields []any, from *common.Address) (types.TxData, error) {
func decodeAccessListTx(fields []any, from *common.Address) (types.TxData, error) {

if len(fields) != 8 {
return nil, fmt.Errorf("invalid number of field for a dynamic transaction")
return nil, errors.New("invalid number of field for a dynamic transaction")
}

tx := new(types.AccessListTx)
Expand All @@ -225,7 +225,7 @@ func decodeAccessListTx(fields []any, from *common.Address) (types.TxData, error
func decodeDynamicFeeTx(fields []any, from *common.Address) (types.TxData, error) {

if len(fields) != 9 {
return nil, fmt.Errorf("invalid number of field for a dynamic transaction")
return nil, errors.New("invalid number of field for a dynamic transaction")
}

tx := new(types.DynamicFeeTx)
Expand Down
4 changes: 2 additions & 2 deletions prover/lib/compressor/blob/v0/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (s *Header) WriteTo(w io.Writer) (int64, error) {
// write nbBlocksInBatch (uint16)
nbBlocksInBatch := uint16(len(batch))
if int(nbBlocksInBatch) != len(batch) {
return written, fmt.Errorf("nb blocks in batch too big: bigger than uint16")
return written, errors.New("nb blocks in batch too big: bigger than uint16")
}

if err := binary.Write(w, binary.LittleEndian, nbBlocksInBatch); err != nil {
Expand All @@ -139,7 +139,7 @@ func (s *Header) WriteTo(w io.Writer) (int64, error) {
for _, blockLength := range batch {
const maxUint24 = 1<<24 - 1
if blockLength > maxUint24 {
return written, fmt.Errorf("block length too big: bigger than uint24")
return written, errors.New("block length too big: bigger than uint24")
}

// write the blockLength on 3 bytes as a uint24 (LittleEndian)
Expand Down
6 changes: 3 additions & 3 deletions prover/lib/compressor/blob/v1/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
func EncodeBlockForCompression(block *types.Block, w io.Writer) error {

if block == nil {
return fmt.Errorf("block is nil")
return errors.New("block is nil")
}

if block.Transactions() == nil {
return fmt.Errorf("block has nil transactions")
return errors.New("block has nil transactions")
}

var (
Expand Down Expand Up @@ -54,7 +54,7 @@ func EncodeBlockForCompression(block *types.Block, w io.Writer) error {
// encodeTransaction encodes a single transaction
func EncodeTxForCompression(tx *types.Transaction, w io.Writer) error {
if tx == nil {
return fmt.Errorf("transactions is nil")
return errors.New("transactions is nil")
}

var (
Expand Down