mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 13:47:19 +00:00
*: use multierror wrapping where possible
Revert 5f6c01336c
, remove all multierror
related nolint comments and use multierror wrapping instead.
Close #2906.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
13ff95a3d3
commit
0c6627f13d
9 changed files with 32 additions and 32 deletions
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue