remove github.com/pkg/errors from dependencies

It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
This commit is contained in:
Roman Khimov 2020-08-06 17:44:08 +03:00
parent 6e5920cc09
commit 5ef08f60ae
30 changed files with 90 additions and 95 deletions

View file

@ -15,7 +15,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/network" "github.com/nspcc-dev/neo-go/pkg/network"
"github.com/nspcc-dev/neo-go/pkg/network/metrics" "github.com/nspcc-dev/neo-go/pkg/network/metrics"
"github.com/nspcc-dev/neo-go/pkg/rpc/server" "github.com/nspcc-dev/neo-go/pkg/rpc/server"
"github.com/pkg/errors"
"github.com/urfave/cli" "github.com/urfave/cli"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
@ -367,13 +366,13 @@ Main:
for { for {
select { select {
case err := <-errChan: case err := <-errChan:
shutdownErr = errors.Wrap(err, "Error encountered by server") shutdownErr = fmt.Errorf("server error: %w", err)
cancel() cancel()
case <-grace.Done(): case <-grace.Done():
serv.Shutdown() serv.Shutdown()
if serverErr := rpcServer.Shutdown(); serverErr != nil { if serverErr := rpcServer.Shutdown(); serverErr != nil {
shutdownErr = errors.Wrap(serverErr, "Error encountered whilst shutting down server") shutdownErr = fmt.Errorf("error on shutdown: %w", serverErr)
} }
prometheus.ShutDown() prometheus.ShutDown()
pprof.ShutDown() pprof.ShutDown()

View file

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -25,7 +26,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/pkg/errors"
"github.com/urfave/cli" "github.com/urfave/cli"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
) )
@ -499,7 +499,7 @@ func testInvokeScript(ctx *cli.Context) error {
} }
nefFile, err := nef.FileFromBytes(b) nefFile, err := nef.FileFromBytes(b)
if err != nil { if err != nil {
return cli.NewExitError(errors.Wrapf(err, "failed to restore .nef file"), 1) return cli.NewExitError(fmt.Errorf("failed to restore .nef file: %w", err), 1)
} }
args := ctx.Args() args := ctx.Args()
@ -570,12 +570,12 @@ func inspect(ctx *cli.Context) error {
if compile { if compile {
b, err = compiler.Compile(bytes.NewReader(b)) b, err = compiler.Compile(bytes.NewReader(b))
if err != nil { if err != nil {
return cli.NewExitError(errors.Wrap(err, "failed to compile"), 1) return cli.NewExitError(fmt.Errorf("failed to compile: %w", err), 1)
} }
} else { } else {
nefFile, err := nef.FileFromBytes(b) nefFile, err := nef.FileFromBytes(b)
if err != nil { if err != nil {
return cli.NewExitError(errors.Wrapf(err, "failed to restore .nef file"), 1) return cli.NewExitError(fmt.Errorf("failed to restore .nef file: %w", err), 1)
} }
b = nefFile.Script b = nefFile.Script
} }
@ -645,17 +645,17 @@ func contractDeploy(ctx *cli.Context) error {
} }
nefFile, err := nef.FileFromBytes(f) nefFile, err := nef.FileFromBytes(f)
if err != nil { if err != nil {
return cli.NewExitError(errors.Wrapf(err, "failed to restore .nef file"), 1) return cli.NewExitError(fmt.Errorf("failed to restore .nef file: %w", err), 1)
} }
manifestBytes, err := ioutil.ReadFile(manifestFile) manifestBytes, err := ioutil.ReadFile(manifestFile)
if err != nil { if err != nil {
return cli.NewExitError(errors.Wrapf(err, "failed to read manifest file"), 1) return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1)
} }
m := &manifest.Manifest{} m := &manifest.Manifest{}
err = json.Unmarshal(manifestBytes, m) err = json.Unmarshal(manifestBytes, m)
if err != nil { if err != nil {
return cli.NewExitError(errors.Wrapf(err, "failed to restore manifest file"), 1) return cli.NewExitError(fmt.Errorf("failed to restore manifest file: %w", err), 1)
} }
gctx, cancel := options.GetTimeoutContext(ctx) gctx, cancel := options.GetTimeoutContext(ctx)

1
go.mod
View file

@ -13,7 +13,6 @@ require (
github.com/nspcc-dev/dbft v0.0.0-20200711144034-c526ccc6f570 github.com/nspcc-dev/dbft v0.0.0-20200711144034-c526ccc6f570
github.com/nspcc-dev/rfc6979 v0.2.0 github.com/nspcc-dev/rfc6979 v0.2.0
github.com/pierrec/lz4 v2.5.2+incompatible github.com/pierrec/lz4 v2.5.2+incompatible
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.2.1 github.com/prometheus/client_golang v1.2.1
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
github.com/syndtr/goleveldb v0.0.0-20180307113352-169b1b37be73 github.com/syndtr/goleveldb v0.0.0-20180307113352-169b1b37be73

View file

@ -15,7 +15,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef" "github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
"github.com/pkg/errors"
"golang.org/x/tools/go/loader" "golang.org/x/tools/go/loader"
) )
@ -179,11 +178,11 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
if o.ManifestFile != "" { if o.ManifestFile != "" {
m, err := di.ConvertToManifest(o.ContractFeatures, o.ContractSupportedStandards...) m, err := di.ConvertToManifest(o.ContractFeatures, o.ContractSupportedStandards...)
if err != nil { if err != nil {
return b, errors.Wrap(err, "failed to convert debug info to manifest") return b, fmt.Errorf("failed to convert debug info to manifest: %w", err)
} }
mData, err := json.Marshal(m) mData, err := json.Marshal(m)
if err != nil { if err != nil {
return b, errors.Wrap(err, "failed to marshal manifest") return b, fmt.Errorf("failed to marshal manifest to JSON: %w", err)
} }
return b, ioutil.WriteFile(o.ManifestFile, mData, os.ModePerm) return b, ioutil.WriteFile(o.ManifestFile, mData, os.ModePerm)
} }

View file

@ -7,7 +7,6 @@ import (
"github.com/go-yaml/yaml" "github.com/go-yaml/yaml"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/pkg/errors"
) )
const userAgentFormat = "/NEO-GO:%s/" const userAgentFormat = "/NEO-GO:%s/"
@ -37,12 +36,12 @@ func Load(path string, netMode netmode.Magic) (Config, error) {
// LoadFile loads config from the provided path. // LoadFile loads config from the provided path.
func LoadFile(configPath string) (Config, error) { func LoadFile(configPath string) (Config, error) {
if _, err := os.Stat(configPath); os.IsNotExist(err) { if _, err := os.Stat(configPath); os.IsNotExist(err) {
return Config{}, errors.Wrap(err, "Unable to load config") return Config{}, fmt.Errorf("config '%s' doesn't exist", configPath)
} }
configData, err := ioutil.ReadFile(configPath) configData, err := ioutil.ReadFile(configPath)
if err != nil { if err != nil {
return Config{}, errors.Wrap(err, "Unable to read config") return Config{}, fmt.Errorf("unable to read config: %w", err)
} }
config := Config{ config := Config{
@ -54,7 +53,7 @@ func LoadFile(configPath string) (Config, error) {
err = yaml.Unmarshal(configData, &config) err = yaml.Unmarshal(configData, &config)
if err != nil { if err != nil {
return Config{}, errors.Wrap(err, "Problem unmarshaling config json data") return Config{}, fmt.Errorf("failed to unmarshal config YAML: %w", err)
} }
return config, nil return config, nil

View file

@ -1,6 +1,7 @@
package consensus package consensus
import ( import (
"errors"
"fmt" "fmt"
"github.com/nspcc-dev/dbft/payload" "github.com/nspcc-dev/dbft/payload"
@ -14,7 +15,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/pkg/errors"
) )
type ( type (
@ -306,7 +306,7 @@ func (m *message) DecodeBinary(r *io.BinReader) {
case recoveryMessageType: case recoveryMessageType:
m.payload = new(recoveryMessage) m.payload = new(recoveryMessage)
default: default:
r.Err = errors.Errorf("invalid type: 0x%02x", byte(m.Type)) r.Err = fmt.Errorf("invalid type: 0x%02x", byte(m.Type))
return return
} }
m.payload.DecodeBinary(r) m.payload.DecodeBinary(r)
@ -338,7 +338,7 @@ func (p *Payload) decodeData() error {
br := io.NewBinReaderFromBuf(p.data) br := io.NewBinReaderFromBuf(p.data)
m.DecodeBinary(br) m.DecodeBinary(br)
if br.Err != nil { if br.Err != nil {
return errors.Wrap(br.Err, "cannot decode data into message") return fmt.Errorf("can't decode message: %w", br.Err)
} }
p.message = m p.message = m
return nil return nil

View file

@ -1,11 +1,12 @@
package consensus package consensus
import ( import (
"errors"
"github.com/nspcc-dev/dbft/crypto" "github.com/nspcc-dev/dbft/crypto"
"github.com/nspcc-dev/dbft/payload" "github.com/nspcc-dev/dbft/payload"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/pkg/errors"
) )
type ( type (

View file

@ -1,6 +1,7 @@
package core package core
import ( import (
"errors"
"fmt" "fmt"
"math/big" "math/big"
"sort" "sort"
@ -27,7 +28,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -223,7 +223,7 @@ func (bc *Blockchain) init() error {
bc.blockHeight = bHeight bc.blockHeight = bHeight
bc.persistedHeight = bHeight bc.persistedHeight = bHeight
if err = bc.dao.InitMPT(bHeight); err != nil { if err = bc.dao.InitMPT(bHeight); err != nil {
return errors.Wrapf(err, "can't init MPT at height %d", bHeight) return fmt.Errorf("can't init MPT at height %d: %w", bHeight, err)
} }
hashes, err := bc.dao.GetHeaderHashes() hashes, err := bc.dao.GetHeaderHashes()
@ -579,9 +579,9 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
v.LoadScriptWithFlags(bc.contracts.GetPersistScript(), smartcontract.AllowModifyStates|smartcontract.AllowCall) v.LoadScriptWithFlags(bc.contracts.GetPersistScript(), smartcontract.AllowModifyStates|smartcontract.AllowCall)
v.SetPriceGetter(getPrice) v.SetPriceGetter(getPrice)
if err := v.Run(); err != nil { if err := v.Run(); err != nil {
return errors.Wrap(err, "can't persist native contracts") return fmt.Errorf("onPersist run failed: %w", err)
} else if _, err := systemInterop.DAO.Persist(); err != nil { } else if _, err := systemInterop.DAO.Persist(); err != nil {
return errors.Wrap(err, "can't persist `onPersist` changes") return fmt.Errorf("can't save onPersist changes: %w", err)
} }
for i := range systemInterop.Notifications { for i := range systemInterop.Notifications {
bc.handleNotification(&systemInterop.Notifications[i], cache, block, block.Hash()) bc.handleNotification(&systemInterop.Notifications[i], cache, block, block.Hash())
@ -597,7 +597,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
appExecResults = append(appExecResults, aer) appExecResults = append(appExecResults, aer)
err := cache.PutAppExecResult(aer) err := cache.PutAppExecResult(aer)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to Store notifications") return fmt.Errorf("failed to store onPersist exec result: %w", err)
} }
} }
@ -616,7 +616,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
if !v.HasFailed() { if !v.HasFailed() {
_, err := systemInterop.DAO.Persist() _, err := systemInterop.DAO.Persist()
if err != nil { if err != nil {
return errors.Wrap(err, "failed to persist invocation results") return fmt.Errorf("failed to persist invocation results: %w", err)
} }
for i := range systemInterop.Notifications { for i := range systemInterop.Notifications {
bc.handleNotification(&systemInterop.Notifications[i], cache, block, tx.Hash()) bc.handleNotification(&systemInterop.Notifications[i], cache, block, tx.Hash())
@ -638,7 +638,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
appExecResults = append(appExecResults, aer) appExecResults = append(appExecResults, aer)
err = cache.PutAppExecResult(aer) err = cache.PutAppExecResult(aer)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to Store notifications") return fmt.Errorf("failed to store tx exec result: %w", err)
} }
} }
@ -647,7 +647,7 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
if block.Index > 0 { if block.Index > 0 {
prev, err := bc.dao.GetStateRoot(block.Index - 1) prev, err := bc.dao.GetStateRoot(block.Index - 1)
if err != nil { if err != nil {
return errors.WithMessagef(err, "can't get previous state root") return fmt.Errorf("can't get previous state root: %w", err)
} }
prevHash = hash.DoubleSha256(prev.GetSignedPart()) prevHash = hash.DoubleSha256(prev.GetSignedPart())
} }
@ -1204,7 +1204,7 @@ func (bc *Blockchain) verifyHeader(currHeader, prevHeader *block.Header) error {
func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) error { func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) error {
height := bc.BlockHeight() height := bc.BlockHeight()
if t.ValidUntilBlock <= height || t.ValidUntilBlock > height+transaction.MaxValidUntilBlockIncrement { if t.ValidUntilBlock <= height || t.ValidUntilBlock > height+transaction.MaxValidUntilBlockIncrement {
return errors.Errorf("transaction has expired. ValidUntilBlock = %d, current height = %d", t.ValidUntilBlock, height) return fmt.Errorf("transaction has expired. ValidUntilBlock = %d, current height = %d", t.ValidUntilBlock, height)
} }
hashes, err := bc.GetScriptHashesForVerifying(t) hashes, err := bc.GetScriptHashesForVerifying(t)
if err != nil { if err != nil {
@ -1219,26 +1219,26 @@ func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) e
return !blockedAccounts[i].Less(h) return !blockedAccounts[i].Less(h)
}) })
if i != len(blockedAccounts) && blockedAccounts[i].Equals(h) { if i != len(blockedAccounts) && blockedAccounts[i].Equals(h) {
return errors.Errorf("policy check failed: account %s is blocked", h.StringLE()) return fmt.Errorf("policy check failed: account %s is blocked", h.StringLE())
} }
} }
maxBlockSystemFee := bc.contracts.Policy.GetMaxBlockSystemFeeInternal(bc.dao) maxBlockSystemFee := bc.contracts.Policy.GetMaxBlockSystemFeeInternal(bc.dao)
if maxBlockSystemFee < t.SystemFee { if maxBlockSystemFee < t.SystemFee {
return errors.Errorf("policy check failed: transaction's fee shouldn't exceed maximum block system fee %d", maxBlockSystemFee) return fmt.Errorf("policy check failed: transaction's fee shouldn't exceed maximum block system fee %d", maxBlockSystemFee)
} }
balance := bc.GetUtilityTokenBalance(t.Sender()) balance := bc.GetUtilityTokenBalance(t.Sender())
need := t.SystemFee + t.NetworkFee need := t.SystemFee + t.NetworkFee
if balance.Cmp(big.NewInt(need)) < 0 { if balance.Cmp(big.NewInt(need)) < 0 {
return errors.Errorf("insufficient funds: balance is %v, need: %v", balance, need) return fmt.Errorf("insufficient funds: balance is %v, need: %v", balance, need)
} }
size := io.GetVarSize(t) size := io.GetVarSize(t)
if size > transaction.MaxTransactionSize { if size > transaction.MaxTransactionSize {
return errors.Errorf("invalid transaction size = %d. It shoud be less then MaxTransactionSize = %d", io.GetVarSize(t), transaction.MaxTransactionSize) return fmt.Errorf("too big transaction (%d > MaxTransactionSize %d)", size, transaction.MaxTransactionSize)
} }
needNetworkFee := int64(size) * bc.FeePerByte() needNetworkFee := int64(size) * bc.FeePerByte()
netFee := t.NetworkFee - needNetworkFee netFee := t.NetworkFee - needNetworkFee
if netFee < 0 { if netFee < 0 {
return errors.Errorf("insufficient funds: net fee is %v, need %v", t.NetworkFee, needNetworkFee) return fmt.Errorf("insufficient funds: net fee is %v, need %v", t.NetworkFee, needNetworkFee)
} }
if block == nil { if block == nil {
if ok := bc.memPool.Verify(t, bc); !ok { if ok := bc.memPool.Verify(t, bc); !ok {
@ -1286,7 +1286,7 @@ func (bc *Blockchain) AddStateRoot(r *state.MPTRoot) error {
} }
} }
if err := bc.verifyStateRoot(r); err != nil { if err := bc.verifyStateRoot(r); err != nil {
return errors.WithMessage(err, "invalid state root") return fmt.Errorf("invalid state root: %w", err)
} }
if r.Index > bc.BlockHeight() { // just put it into the store for future checks if r.Index > bc.BlockHeight() { // just put it into the store for future checks
return bc.dao.PutStateRoot(&state.MPTRootState{ return bc.dao.PutStateRoot(&state.MPTRootState{
@ -1298,7 +1298,7 @@ func (bc *Blockchain) AddStateRoot(r *state.MPTRoot) error {
flag := state.Unverified flag := state.Unverified
if r.Witness != nil { if r.Witness != nil {
if err := bc.verifyStateRootWitness(r); err != nil { if err := bc.verifyStateRootWitness(r); err != nil {
return errors.WithMessage(err, "can't verify signature") return fmt.Errorf("can't verify signature: %w", err)
} }
flag = state.Verified flag = state.Verified
} }
@ -1315,7 +1315,7 @@ func (bc *Blockchain) AddStateRoot(r *state.MPTRoot) error {
func (bc *Blockchain) updateStateHeight(newHeight uint32) error { func (bc *Blockchain) updateStateHeight(newHeight uint32) error {
h, err := bc.dao.GetCurrentStateRootHeight() h, err := bc.dao.GetCurrentStateRootHeight()
if err != nil { if err != nil {
return errors.WithMessage(err, "can't get current state root height") return fmt.Errorf("can't get current state root height: %w", err)
} else if newHeight == h+1 { } else if newHeight == h+1 {
updateStateHeightMetric(newHeight) updateStateHeightMetric(newHeight)
return bc.dao.PutCurrentStateRootHeight(h + 1) return bc.dao.PutCurrentStateRootHeight(h + 1)
@ -1474,12 +1474,12 @@ func (bc *Blockchain) verifyHashAgainstScript(hash util.Uint160, witness *transa
} }
err = vm.Run() err = vm.Run()
if vm.HasFailed() { if vm.HasFailed() {
return errors.Errorf("vm failed to execute the script with error: %s", err) return fmt.Errorf("vm failed to execute the script with error: %s", err)
} }
resEl := vm.Estack().Pop() resEl := vm.Estack().Pop()
if resEl != nil { if resEl != nil {
if !resEl.Bool() { if !resEl.Bool() {
return errors.Errorf("signature check failed") return fmt.Errorf("signature check failed")
} }
if useKeys { if useKeys {
bc.keyCacheLock.RLock() bc.keyCacheLock.RLock()
@ -1492,7 +1492,7 @@ func (bc *Blockchain) verifyHashAgainstScript(hash util.Uint160, witness *transa
} }
} }
} else { } else {
return errors.Errorf("no result returned from the script") return fmt.Errorf("no result returned from the script")
} }
return nil return nil
} }
@ -1511,7 +1511,7 @@ func (bc *Blockchain) verifyTxWitnesses(t *transaction.Transaction, block *block
witnesses := t.Scripts witnesses := t.Scripts
if len(hashes) != len(witnesses) { if len(hashes) != len(witnesses) {
return errors.Errorf("expected len(hashes) == len(witnesses). got: %d != %d", len(hashes), len(witnesses)) return fmt.Errorf("expected len(hashes) == len(witnesses). got: %d != %d", len(hashes), len(witnesses))
} }
sort.Slice(hashes, func(i, j int) bool { return hashes[i].Less(hashes[j]) }) sort.Slice(hashes, func(i, j int) bool { return hashes[i].Less(hashes[j]) })
sort.Slice(witnesses, func(i, j int) bool { return witnesses[i].ScriptHash().Less(witnesses[j].ScriptHash()) }) sort.Slice(witnesses, func(i, j int) bool { return witnesses[i].ScriptHash().Less(witnesses[j].ScriptHash()) })
@ -1519,8 +1519,7 @@ func (bc *Blockchain) verifyTxWitnesses(t *transaction.Transaction, block *block
for i := 0; i < len(hashes); i++ { for i := 0; i < len(hashes); i++ {
err := bc.verifyHashAgainstScript(hashes[i], &witnesses[i], interopCtx, false, t.NetworkFee) err := bc.verifyHashAgainstScript(hashes[i], &witnesses[i], interopCtx, false, t.NetworkFee)
if err != nil { if err != nil {
numStr := fmt.Sprintf("witness #%d", i) return fmt.Errorf("witness #%d: %w", i, err)
return errors.Wrap(err, numStr)
} }
} }

View file

@ -26,7 +26,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/pkg/errors"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest" "go.uber.org/zap/zaptest"
) )
@ -396,7 +395,7 @@ func signTx(bc *Blockchain, txs ...*transaction.Transaction) error {
validators := bc.GetStandByValidators() validators := bc.GetStandByValidators()
rawScript, err := smartcontract.CreateMultiSigRedeemScript(len(bc.config.StandbyValidators)/2+1, validators) rawScript, err := smartcontract.CreateMultiSigRedeemScript(len(bc.config.StandbyValidators)/2+1, validators)
if err != nil { if err != nil {
return errors.Wrap(err, "fail to sign tx") return fmt.Errorf("failed to sign tx: %w", err)
} }
for _, tx := range txs { for _, tx := range txs {
size := io.GetVarSize(tx) size := io.GetVarSize(tx)

View file

@ -1,12 +1,13 @@
package runtime package runtime
import ( import (
"errors"
"github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop"
"github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
) )
// GasLeft returns remaining amount of GAS. // GasLeft returns remaining amount of GAS.

View file

@ -2,6 +2,8 @@ package runtime
import ( import (
"crypto/elliptic" "crypto/elliptic"
"errors"
"fmt"
"github.com/nspcc-dev/neo-go/pkg/core/dao" "github.com/nspcc-dev/neo-go/pkg/core/dao"
"github.com/nspcc-dev/neo-go/pkg/core/interop" "github.com/nspcc-dev/neo-go/pkg/core/interop"
@ -9,7 +11,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"
"github.com/pkg/errors"
) )
// CheckHashedWitness checks given hash against current list of script hashes // CheckHashedWitness checks given hash against current list of script hashes
@ -91,7 +92,7 @@ func CheckWitness(ic *interop.Context, v *vm.VM) error {
res, err = CheckHashedWitness(ic, hash) res, err = CheckHashedWitness(ic, hash)
} }
if err != nil { if err != nil {
return errors.Wrap(err, "failed to check") return fmt.Errorf("failed to check witness: %w", err)
} }
v.Estack().PushVal(res) v.Estack().PushVal(res)
return nil return nil

View file

@ -2,6 +2,7 @@ package native
import ( import (
"crypto/elliptic" "crypto/elliptic"
"errors"
"math/big" "math/big"
"sort" "sort"
"strings" "strings"
@ -18,7 +19,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
) )
// NEO represents NEO native contract. // NEO represents NEO native contract.

View file

@ -2,6 +2,7 @@ package native
import ( import (
"encoding/binary" "encoding/binary"
"errors"
"math/big" "math/big"
"sort" "sort"
"sync" "sync"
@ -15,7 +16,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
) )
const ( const (

View file

@ -6,6 +6,7 @@ import (
"crypto/x509" "crypto/x509"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"math/big" "math/big"
@ -16,7 +17,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/pkg/errors"
) )
// coordLen is the number of bytes in serialized X or Y coordinate. // coordLen is the number of bytes in serialized X or Y coordinate.
@ -267,7 +267,7 @@ func (p *PublicKey) DecodeBinary(r *io.BinReader) {
return return
} }
default: default:
r.Err = errors.Errorf("invalid prefix %d", prefix) r.Err = fmt.Errorf("invalid prefix %d", prefix)
return return
} }
if x.Cmp(curveParams.P) >= 0 || y.Cmp(curveParams.P) >= 0 { if x.Cmp(curveParams.P) >= 0 || y.Cmp(curveParams.P) >= 0 {

View file

@ -2,10 +2,10 @@ package base58
import ( import (
"bytes" "bytes"
"errors"
"github.com/mr-tron/base58" "github.com/mr-tron/base58"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/pkg/errors"
) )
// CheckDecode implements a base58-encoded string decoding with hash-based // CheckDecode implements a base58-encoded string decoding with hash-based

View file

@ -1,10 +1,11 @@
package payload package payload
import ( import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/pkg/errors"
) )
// Headers payload. // Headers payload.
@ -19,7 +20,7 @@ const (
) )
// ErrTooManyHeaders is an error returned when too many headers were received. // ErrTooManyHeaders is an error returned when too many headers were received.
var ErrTooManyHeaders = errors.Errorf("too many headers were received (max: %d)", MaxHeadersAllowed) var ErrTooManyHeaders = fmt.Errorf("too many headers were received (max: %d)", MaxHeadersAllowed)
// DecodeBinary implements Serializable interface. // DecodeBinary implements Serializable interface.
func (p *Headers) DecodeBinary(br *io.BinReader) { func (p *Headers) DecodeBinary(br *io.BinReader) {

View file

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -15,7 +16,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/rpc/request" "github.com/nspcc-dev/neo-go/pkg/rpc/request"
"github.com/nspcc-dev/neo-go/pkg/rpc/response" "github.com/nspcc-dev/neo-go/pkg/rpc/response"
"github.com/pkg/errors"
) )
const ( const (
@ -123,7 +123,7 @@ func (c *Client) SetWIF(wif string) error {
defer c.wifMu.Unlock() defer c.wifMu.Unlock()
decodedWif, err := keys.WIFDecode(wif, 0x00) decodedWif, err := keys.WIFDecode(wif, 0x00)
if err != nil { if err != nil {
return errors.Wrap(err, "Failed to decode WIF; failed to add WIF to client ") return fmt.Errorf("failed to decode WIF: %w", err)
} }
c.wif = decodedWif c.wif = decodedWif
return nil return nil
@ -176,7 +176,7 @@ func (c *Client) makeHTTPRequest(r *request.Raw) (*response.Raw, error) {
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
err = fmt.Errorf("HTTP %d/%s", resp.StatusCode, http.StatusText(resp.StatusCode)) err = fmt.Errorf("HTTP %d/%s", resp.StatusCode, http.StatusText(resp.StatusCode))
} else { } else {
err = errors.Wrap(err, "JSON decoding") err = fmt.Errorf("JSON decoding: %w", err)
} }
} }
if err != nil { if err != nil {

View file

@ -1,13 +1,13 @@
package client package client
import ( import (
"errors"
"fmt" "fmt"
"github.com/nspcc-dev/neo-go/pkg/core/native" "github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
) )
// PolicyContractHash represents a hash of native Policy contract. // PolicyContractHash represents a hash of native Policy contract.

View file

@ -2,6 +2,7 @@ package client
import ( import (
"encoding/hex" "encoding/hex"
"errors"
"fmt" "fmt"
"github.com/nspcc-dev/neo-go/pkg/core" "github.com/nspcc-dev/neo-go/pkg/core"
@ -16,7 +17,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/pkg/errors"
) )
// GetApplicationLog returns the contract log based on the specified txid. // GetApplicationLog returns the contract log based on the specified txid.
@ -428,28 +428,28 @@ func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sys
addr, err := address.StringToUint160(acc.Address) addr, err := address.StringToUint160(acc.Address)
if err != nil { if err != nil {
return txHash, errors.Wrap(err, "failed to get address") return txHash, fmt.Errorf("failed to get address: %w", err)
} }
tx.Signers = getSigners(addr, cosigners) tx.Signers = getSigners(addr, cosigners)
validUntilBlock, err := c.CalculateValidUntilBlock() validUntilBlock, err := c.CalculateValidUntilBlock()
if err != nil { if err != nil {
return txHash, errors.Wrap(err, "failed to add validUntilBlock to transaction") return txHash, fmt.Errorf("failed to add validUntilBlock to transaction: %w", err)
} }
tx.ValidUntilBlock = validUntilBlock tx.ValidUntilBlock = validUntilBlock
err = c.AddNetworkFee(tx, int64(netfee), acc) err = c.AddNetworkFee(tx, int64(netfee), acc)
if err != nil { if err != nil {
return txHash, errors.Wrapf(err, "failed to add network fee") return txHash, fmt.Errorf("failed to add network fee: %w", err)
} }
if err = acc.SignTx(tx); err != nil { if err = acc.SignTx(tx); err != nil {
return txHash, errors.Wrap(err, "failed to sign tx") return txHash, fmt.Errorf("failed to sign tx: %w", err)
} }
txHash = tx.Hash() txHash = tx.Hash()
actualHash, err := c.SendRawTransaction(tx) actualHash, err := c.SendRawTransaction(tx)
if err != nil { if err != nil {
return txHash, errors.Wrap(err, "failed sendning tx") return txHash, fmt.Errorf("failed to send tx: %w", err)
} }
if !actualHash.Equals(txHash) { if !actualHash.Equals(txHash) {
return actualHash, fmt.Errorf("sent and actual tx hashes mismatch:\n\tsent: %v\n\tactual: %v", txHash.StringLE(), actualHash.StringLE()) return actualHash, fmt.Errorf("sent and actual tx hashes mismatch:\n\tsent: %v\n\tactual: %v", txHash.StringLE(), actualHash.StringLE())
@ -505,7 +505,7 @@ func (c *Client) CalculateValidUntilBlock() (uint32, error) {
) )
blockCount, err := c.GetBlockCount() blockCount, err := c.GetBlockCount()
if err != nil { if err != nil {
return result, errors.Wrapf(err, "cannot get block count") return result, fmt.Errorf("can't get block count: %w", err)
} }
if c.cache.calculateValidUntilBlock.expiresAt > blockCount { if c.cache.calculateValidUntilBlock.expiresAt > blockCount {
@ -513,7 +513,7 @@ func (c *Client) CalculateValidUntilBlock() (uint32, error) {
} else { } else {
validators, err := c.GetValidators() validators, err := c.GetValidators()
if err != nil { if err != nil {
return result, errors.Wrapf(err, "cannot get validators") return result, fmt.Errorf("can't get validators: %w", err)
} }
validatorsCount = uint32(len(validators)) validatorsCount = uint32(len(validators))
c.cache.calculateValidUntilBlock = calculateValidUntilBlockCache{ c.cache.calculateValidUntilBlock = calculateValidUntilBlockCache{

View file

@ -28,7 +28,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -577,7 +576,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
result: func(c *Client) interface{} { result: func(c *Client) interface{} {
addr, err := address.StringToUint160("NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB") addr, err := address.StringToUint160("NMipL5VsNoLUBUJKPKLhxaEbPQVCZnyJyB")
if err != nil { if err != nil {
panic(errors.Wrap(err, "failed to parse UnclaimedGas address")) panic(fmt.Errorf("failed to parse UnclaimedGas address: %w", err))
} }
return result.UnclaimedGas{ return result.UnclaimedGas{
Address: addr, Address: addr,

View file

@ -5,6 +5,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"strconv" "strconv"
@ -12,7 +13,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/pkg/errors"
) )
type ( type (

View file

@ -2,9 +2,8 @@ package request
import ( import (
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"github.com/pkg/errors"
) )
const ( const (
@ -60,11 +59,11 @@ func (r *In) DecodeData(data io.ReadCloser) error {
err := json.NewDecoder(data).Decode(r) err := json.NewDecoder(data).Decode(r)
if err != nil { if err != nil {
return errors.Errorf("error parsing JSON payload: %s", err) return fmt.Errorf("error parsing JSON payload: %s", err)
} }
if r.JSONRPC != JSONRPCVersion { if r.JSONRPC != JSONRPCVersion {
return errors.Errorf("invalid version, expected 2.0 got: '%s'", r.JSONRPC) return fmt.Errorf("invalid version, expected 2.0 got: '%s'", r.JSONRPC)
} }
return nil return nil
@ -77,7 +76,7 @@ func (r *In) Params() (*Params, error) {
err := json.Unmarshal(r.RawParams, &params) err := json.Unmarshal(r.RawParams, &params)
if err != nil { if err != nil {
return nil, errors.Errorf("error parsing params field in payload: %s", err) return nil, fmt.Errorf("error parsing params field in payload: %s", err)
} }
return &params, nil return &params, nil

View file

@ -2,8 +2,7 @@ package response
import ( import (
"encoding/json" "encoding/json"
"errors"
"github.com/pkg/errors"
) )
type ( type (

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"math" "math"
"math/big" "math/big"
@ -30,7 +31,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result" "github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/pkg/errors"
"go.uber.org/zap" "go.uber.org/zap"
) )
@ -692,7 +692,7 @@ func (s *Server) getrawtransaction(reqParams request.Params) (interface{}, *resp
if txHash, err := reqParams.Value(0).GetUint256(); err != nil { if txHash, err := reqParams.Value(0).GetUint256(); err != nil {
resultsErr = response.ErrInvalidParams resultsErr = response.ErrInvalidParams
} else if tx, height, err := s.chain.GetTransaction(txHash); err != nil { } else if tx, height, err := s.chain.GetTransaction(txHash); err != nil {
err = errors.Wrapf(err, "Invalid transaction hash: %s", txHash) err = fmt.Errorf("invalid transaction %s: %w", txHash, err)
return nil, response.NewRPCError("Unknown transaction", err.Error(), err) return nil, response.NewRPCError("Unknown transaction", err.Error(), err)
} else if reqParams.Value(1).GetBoolean() { } else if reqParams.Value(1).GetBoolean() {
_header := s.chain.GetHeaderHash(int(height)) _header := s.chain.GetHeaderHash(int(height))

View file

@ -3,6 +3,8 @@ package smartcontract
import ( import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt"
"strconv" "strconv"
"strings" "strings"
@ -10,7 +12,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/pkg/errors"
) )
// ParamType represents the Type of the smart contract parameter. // ParamType represents the Type of the smart contract parameter.
@ -160,7 +161,7 @@ func ParseParamType(typ string) (ParamType, error) {
case "any": case "any":
return AnyType, nil return AnyType, nil
default: default:
return UnknownType, errors.Errorf("Unknown contract parameter type: %s", typ) return UnknownType, fmt.Errorf("bad parameter type: %s", typ)
} }
} }

View file

@ -5,6 +5,7 @@ import (
"encoding/binary" "encoding/binary"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"math" "math"
"math/bits" "math/bits"
@ -14,7 +15,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/pkg/errors"
) )
// PropertyState represents contract properties (flags). // PropertyState represents contract properties (flags).
@ -94,7 +94,7 @@ func (p Parameter) MarshalJSON() ([]byte, error) {
case InteropInterfaceType, AnyType: case InteropInterfaceType, AnyType:
resultRawValue = nil resultRawValue = nil
default: default:
resultErr = errors.Errorf("Marshaller for type %s not implemented", p.Type) resultErr = fmt.Errorf("can't marshal %s", p.Type)
} }
if resultErr != nil { if resultErr != nil {
return nil, resultErr return nil, resultErr
@ -183,7 +183,7 @@ func (p *Parameter) UnmarshalJSON(data []byte) (err error) {
// stub, ignore value, it can only be null // stub, ignore value, it can only be null
p.Value = nil p.Value = nil
default: default:
return errors.Errorf("Unmarshaller for type %s not implemented", p.Type) return fmt.Errorf("can't unmarshal %s", p.Type)
} }
return return
} }
@ -300,7 +300,7 @@ func (p Parameter) TryParse(dest interface{}) error {
switch p.Type { switch p.Type {
case ByteArrayType: case ByteArrayType:
if data, ok = p.Value.([]byte); !ok { if data, ok = p.Value.([]byte); !ok {
return errors.Errorf("failed to cast %s to []byte", p.Value) return fmt.Errorf("failed to cast %s to []byte", p.Value)
} }
switch dest := dest.(type) { switch dest := dest.(type) {
case *util.Uint160: case *util.Uint160:
@ -362,7 +362,7 @@ func (p Parameter) TryParse(dest interface{}) error {
*dest = string(data) *dest = string(data)
return nil return nil
default: default:
return errors.Errorf("cannot cast param of type %s to type %s", p.Type, dest) return fmt.Errorf("cannot cast param of type %s to type %s", p.Type, dest)
} }
default: default:
return errors.New("cannot define param type") return errors.New("cannot define param type")
@ -373,7 +373,7 @@ func (p Parameter) TryParse(dest interface{}) error {
func bytesToUint64(b []byte, size int) (uint64, error) { func bytesToUint64(b []byte, size int) (uint64, error) {
var length = size / 8 var length = size / 8
if len(b) > length { if len(b) > length {
return 0, errors.Errorf("input doesn't fit into %d bits", size) return 0, fmt.Errorf("input doesn't fit into %d bits", size)
} }
if len(b) < length { if len(b) < length {
data := make([]byte, length) data := make([]byte, length)
@ -412,7 +412,7 @@ func NewParameterFromString(in string) (*Parameter, error) {
} }
// We currently do not support following types: // We currently do not support following types:
if res.Type == ArrayType || res.Type == MapType || res.Type == InteropInterfaceType || res.Type == VoidType { if res.Type == ArrayType || res.Type == MapType || res.Type == InteropInterfaceType || res.Type == VoidType {
return nil, errors.Errorf("Unsupported contract parameter type: %s", res.Type) return nil, fmt.Errorf("unsupported parameter type %s", res.Type)
} }
buf.Reset() buf.Reset()
hadType = true hadType = true

View file

@ -5,6 +5,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math/big" "math/big"
@ -19,7 +20,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View file

@ -1,9 +1,8 @@
package vm package vm
import ( import (
"errors"
"strings" "strings"
"github.com/pkg/errors"
) )
// State of the VM. // State of the VM.

View file

@ -4,6 +4,7 @@ import (
"crypto/elliptic" "crypto/elliptic"
"encoding/binary" "encoding/binary"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math" "math"
@ -20,7 +21,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
) )
type errorAtInstruct struct { type errorAtInstruct struct {

View file

@ -5,6 +5,7 @@ import (
"crypto/elliptic" "crypto/elliptic"
"encoding/binary" "encoding/binary"
"encoding/hex" "encoding/hex"
"errors"
"fmt" "fmt"
"math/big" "math/big"
"math/rand" "math/rand"
@ -17,7 +18,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )