diff --git a/cli/vm/cli.go b/cli/vm/cli.go index 5de30ecc7..b504a51dd 100644 --- a/cli/vm/cli.go +++ b/cli/vm/cli.go @@ -616,7 +616,7 @@ func getInstructionParameter(c *cli.Context) (int, error) { } n, err := strconv.Atoi(args[0]) if err != nil { - return 0, fmt.Errorf("%w: %s", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return 0, fmt.Errorf("%w: %w", ErrInvalidParameter, err) } return n, nil } @@ -736,7 +736,7 @@ func handleLoadNEF(c *cli.Context) error { if signersStartOffset != 0 && len(args) > signersStartOffset { signers, err = cmdargs.ParseSigners(c.Args()[signersStartOffset:]) if err != nil { - return fmt.Errorf("%w: failed to parse signers: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: failed to parse signers: %w", ErrInvalidParameter, err) } } err = prepareVM(c, createFakeTransaction(nef.Script, signers)) @@ -767,7 +767,7 @@ func handleLoadBase64(c *cli.Context) error { } b, err := base64.StdEncoding.DecodeString(args[0]) if err != nil { - return fmt.Errorf("%w: %s", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } var signers []transaction.Signer if len(args) > 1 { @@ -779,7 +779,7 @@ func handleLoadBase64(c *cli.Context) error { } signers, err = cmdargs.ParseSigners(args[2:]) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } } err = prepareVM(c, createFakeTransaction(b, signers)) @@ -807,7 +807,7 @@ func handleLoadHex(c *cli.Context) error { } b, err := hex.DecodeString(args[0]) if err != nil { - return fmt.Errorf("%w: %s", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } var signers []transaction.Signer if len(args) > 1 { @@ -819,7 +819,7 @@ func handleLoadHex(c *cli.Context) error { } signers, err = cmdargs.ParseSigners(args[2:]) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } } err = prepareVM(c, createFakeTransaction(b, signers)) @@ -859,7 +859,7 @@ func handleLoadGo(c *cli.Context) error { } signers, err = cmdargs.ParseSigners(args[2:]) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } } @@ -962,7 +962,7 @@ func handleLoadDeployed(c *cli.Context) error { } signers, err = cmdargs.ParseSigners(args[2:]) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } } err = prepareVM(c, createFakeTransaction(cs.NEF.Script, signers)) // prepare VM one more time for proper IC initialization. @@ -1074,7 +1074,7 @@ func handleRun(c *cli.Context) error { _, scParams, err := cmdargs.ParseParams(args[1:], true) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } params = make([]stackitem.Item, len(scParams)) for i := range scParams { @@ -1185,7 +1185,7 @@ func handleStep(c *cli.Context) error { if len(args) > 0 { n, err = strconv.Atoi(args[0]) if err != nil { - return fmt.Errorf("%w: %s", ErrInvalidParameter, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidParameter, err) } } v.AddBreakPointRel(n) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index aa1a0f324..eaaa75fb9 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -2511,7 +2511,7 @@ func (bc *Blockchain) verifyAndPoolTx(t *transaction.Transaction, pool *mempool. // really require a chain lock. err := vm.IsScriptCorrect(t.Script, nil) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidScript, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidScript, err) } height := bc.BlockHeight() @@ -2522,7 +2522,7 @@ func (bc *Blockchain) verifyAndPoolTx(t *transaction.Transaction, pool *mempool. // Policying. if err := bc.contracts.Policy.CheckPolicy(bc.dao, t); err != nil { // Only one %w can be used. - return fmt.Errorf("%w: %v", ErrPolicy, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrPolicy, err) } if t.SystemFee > bc.config.MaxBlockSystemFee { return fmt.Errorf("%w: too big system fee (%d > MaxBlockSystemFee %d)", ErrPolicy, t.SystemFee, bc.config.MaxBlockSystemFee) @@ -2566,7 +2566,7 @@ func (bc *Blockchain) verifyAndPoolTx(t *transaction.Transaction, pool *mempool. case errors.Is(err, mempool.ErrOOM): return ErrOOM case errors.Is(err, mempool.ErrConflictsAttribute): - return fmt.Errorf("mempool: %w: %s", ErrHasConflicts, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("mempool: %w: %w", ErrHasConflicts, err) default: return err } @@ -2607,7 +2607,7 @@ func (bc *Blockchain) verifyTxAttributes(d *dao.Simple, tx *transaction.Transact case transaction.OracleResponseT: h, err := bc.contracts.Oracle.GetScriptHash(bc.dao) if err != nil || h.Equals(util.Uint160{}) { - return fmt.Errorf("%w: %v", ErrInvalidAttribute, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidAttribute, err) } hasOracle := false for i := range tx.Signers { @@ -2627,7 +2627,7 @@ func (bc *Blockchain) verifyTxAttributes(d *dao.Simple, tx *transaction.Transact resp := tx.Attributes[i].Value.(*transaction.OracleResponse) req, err := bc.contracts.Oracle.GetRequestInternal(bc.dao, resp.ID) if err != nil { - return fmt.Errorf("%w: oracle tx points to invalid request: %v", ErrInvalidAttribute, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: oracle tx points to invalid request: %w", ErrInvalidAttribute, err) } if uint64(tx.NetworkFee+tx.SystemFee) < req.GasForResponse { return fmt.Errorf("%w: oracle tx has insufficient gas", ErrInvalidAttribute) @@ -2638,7 +2638,7 @@ func (bc *Blockchain) verifyTxAttributes(d *dao.Simple, tx *transaction.Transact if isPartialTx { maxNVBDelta, err := bc.GetMaxNotValidBeforeDelta() if err != nil { - return fmt.Errorf("%w: failed to retrieve MaxNotValidBeforeDelta value from native Notary contract: %v", ErrInvalidAttribute, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: failed to retrieve MaxNotValidBeforeDelta value from native Notary contract: %w", ErrInvalidAttribute, err) } if curHeight+maxNVBDelta < nvb { return fmt.Errorf("%w: NotValidBefore (%d) bigger than MaxNVBDelta (%d) allows at height %d", ErrInvalidAttribute, nvb, maxNVBDelta, curHeight) @@ -2873,7 +2873,7 @@ func (bc *Blockchain) InitVerificationContext(ic *interop.Context, hash util.Uin } err := vm.IsScriptCorrect(witness.VerificationScript, nil) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidVerificationScript, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidVerificationScript, err) } ic.VM.LoadScriptWithHash(witness.VerificationScript, hash, callflag.ReadOnly) } else { @@ -2898,7 +2898,7 @@ func (bc *Blockchain) InitVerificationContext(ic *interop.Context, hash util.Uin if len(witness.InvocationScript) != 0 { err := vm.IsScriptCorrect(witness.InvocationScript, nil) if err != nil { - return fmt.Errorf("%w: %v", ErrInvalidInvocationScript, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidInvocationScript, err) } ic.VM.LoadScript(witness.InvocationScript) } @@ -2930,7 +2930,7 @@ func (bc *Blockchain) verifyHashAgainstScript(hash util.Uint160, witness *transa } err := interopCtx.Exec() if vm.HasFailed() { - return 0, fmt.Errorf("%w: vm execution has failed: %v", ErrVerificationFailed, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return 0, fmt.Errorf("%w: vm execution has failed: %w", ErrVerificationFailed, err) } estack := vm.Estack() if estack.Len() > 0 { diff --git a/pkg/core/interop/contract/call.go b/pkg/core/interop/contract/call.go index e1b8b72be..712b9e1d9 100644 --- a/pkg/core/interop/contract/call.go +++ b/pkg/core/interop/contract/call.go @@ -165,7 +165,7 @@ func CallFromNative(ic *interop.Context, caller util.Uint160, cs *state.Contract for !ic.VM.HasStopped() && len(ic.VM.Istack()) > startSize { if err := ic.VM.Step(); err != nil { - return fmt.Errorf("%w: %v", ErrNativeCall, err) //nolint:errorlint // non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrNativeCall, err) } } if ic.VM.HasFailed() { diff --git a/pkg/core/storage/boltdb_store.go b/pkg/core/storage/boltdb_store.go index 80de15a87..fba36ad9a 100644 --- a/pkg/core/storage/boltdb_store.go +++ b/pkg/core/storage/boltdb_store.go @@ -66,7 +66,7 @@ func NewBoltDBStore(cfg dbconfig.BoltDBOptions) (*BoltDBStore, error) { closeErr := db.Close() err = fmt.Errorf("failed to initialize BoltDB instance: %w", err) if closeErr != nil { - err = fmt.Errorf("%w, failed to close BoltDB instance: %v", err, closeErr) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + err = fmt.Errorf("%w, failed to close BoltDB instance: %w", err, closeErr) } return nil, err } diff --git a/pkg/rpcclient/waiter/waiter.go b/pkg/rpcclient/waiter/waiter.go index 716187fc6..830fe20cf 100644 --- a/pkg/rpcclient/waiter/waiter.go +++ b/pkg/rpcclient/waiter/waiter.go @@ -201,9 +201,9 @@ func (w *PollingBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.U return nil, ErrTxNotAccepted } case <-w.polling.Context().Done(): - return nil, fmt.Errorf("%w: %v", ErrContextDone, w.polling.Context().Err()) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return nil, fmt.Errorf("%w: %w", ErrContextDone, w.polling.Context().Err()) case <-ctx.Done(): - return nil, fmt.Errorf("%w: %v", ErrContextDone, ctx.Err()) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return nil, fmt.Errorf("%w: %w", ErrContextDone, ctx.Err()) } } } @@ -329,9 +329,9 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin } res = aer case <-w.ws.Context().Done(): - waitErr = fmt.Errorf("%w: %v", ErrContextDone, w.ws.Context().Err()) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + waitErr = fmt.Errorf("%w: %w", ErrContextDone, w.ws.Context().Err()) case <-ctx.Done(): - waitErr = fmt.Errorf("%w: %v", ErrContextDone, ctx.Err()) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + waitErr = fmt.Errorf("%w: %w", ErrContextDone, ctx.Err()) } } close(exit) @@ -361,7 +361,7 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin } case unsubErr := <-unsubErrs: if unsubErr != nil { - errFmt := "unsubscription error: %v" + errFmt := "unsubscription error: %w" errArgs := []any{unsubErr} if waitErr != nil { errFmt = "%w; " + errFmt @@ -393,7 +393,7 @@ func (w *EventBased) WaitAny(ctx context.Context, vub uint32, hashes ...util.Uin res, waitErr = w.polling.WaitAny(ctx, vub, hashes...) if waitErr != nil { // Wrap the poll-based error, it's more important. - waitErr = fmt.Errorf("event-based error: %v; poll-based waiter error: %w", wsWaitErr, waitErr) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + waitErr = fmt.Errorf("event-based error: %w; poll-based waiter error: %w", wsWaitErr, waitErr) } } return diff --git a/pkg/rpcclient/wsclient.go b/pkg/rpcclient/wsclient.go index 9674766da..3b131f890 100644 --- a/pkg/rpcclient/wsclient.go +++ b/pkg/rpcclient/wsclient.go @@ -943,7 +943,7 @@ func (c *WSClient) UnsubscribeAll() error { for _, id := range subs { err := c.performUnsubscription(id) if err != nil { - errFmt := "failed to unsubscribe from feed %d: %v" + errFmt := "failed to unsubscribe from feed %d: %w" errArgs := []any{err} if resErr != nil { errFmt = "%w; " + errFmt diff --git a/pkg/services/oracle/neofs/neofs.go b/pkg/services/oracle/neofs/neofs.go index a438165f2..27351ba8b 100644 --- a/pkg/services/oracle/neofs/neofs.go +++ b/pkg/services/oracle/neofs/neofs.go @@ -109,12 +109,12 @@ func parseNeoFSURL(u *url.URL) (*oid.Address, []string, error) { var containerID cid.ID if err := containerID.DecodeString(ps[0]); err != nil { - return nil, nil, fmt.Errorf("%w: %v", ErrInvalidContainer, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return nil, nil, fmt.Errorf("%w: %w", ErrInvalidContainer, err) } var objectID oid.ID if err := objectID.DecodeString(ps[1]); err != nil { - return nil, nil, fmt.Errorf("%w: %v", ErrInvalidObject, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return nil, nil, fmt.Errorf("%w: %w", ErrInvalidObject, err) } var objAddr = new(oid.Address) objAddr.SetContainer(containerID) diff --git a/pkg/services/oracle/network.go b/pkg/services/oracle/network.go index 9b69edfda..4af62d440 100644 --- a/pkg/services/oracle/network.go +++ b/pkg/services/oracle/network.go @@ -65,7 +65,7 @@ func getDefaultClient(cfg config.OracleConfiguration) *http.Client { d.Control = func(network, address string, c syscall.RawConn) error { host, _, err := net.SplitHostPort(address) if err != nil { - return fmt.Errorf("%w: failed to split address %s: %s", ErrRestrictedRedirect, address, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: failed to split address %s: %w", ErrRestrictedRedirect, address, err) } ip := net.ParseIP(host) if ip == nil { diff --git a/pkg/vm/stackitem/json.go b/pkg/vm/stackitem/json.go index c18ef002d..ef9ab6515 100644 --- a/pkg/vm/stackitem/json.go +++ b/pkg/vm/stackitem/json.go @@ -449,7 +449,7 @@ type ( ) func mkErrValue(err error) error { - return fmt.Errorf("%w: %v", ErrInvalidValue, err) //nolint:errorlint // errorlint: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors + return fmt.Errorf("%w: %w", ErrInvalidValue, err) } // FromJSONWithTypes deserializes an item from typed-json representation.