diff --git a/pkg/compiler/analysis.go b/pkg/compiler/analysis.go index b95139510..112c6945d 100644 --- a/pkg/compiler/analysis.go +++ b/pkg/compiler/analysis.go @@ -302,10 +302,6 @@ func isInteropPath(s string) bool { return strings.HasPrefix(s, interopPrefix) } -func isNativeHelpersPath(s string) bool { - return strings.HasPrefix(s, interopPrefix+"/native") -} - // canConvert returns true if type doesn't need to be converted on type assertion. func canConvert(s string) bool { if len(s) != 0 && s[0] == '*' { diff --git a/pkg/consensus/recovery_message_test.go b/pkg/consensus/recovery_message_test.go index 3af23db91..9fe19e263 100644 --- a/pkg/consensus/recovery_message_test.go +++ b/pkg/consensus/recovery_message_test.go @@ -7,7 +7,6 @@ import ( "github.com/nspcc-dev/dbft/payload" "github.com/nspcc-dev/neo-go/internal/testchain" "github.com/nspcc-dev/neo-go/pkg/config/netmode" - "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/stretchr/testify/require" ) @@ -157,16 +156,3 @@ func TestRecoveryMessage_Decode(t *testing.T) { require.Equal(t, gio.EOF, buf.Err) } */ - -func getKeys(t *testing.T, n int) []*privateKey { - privs := make([]*privateKey, 0, n) - for i := 0; i < n; i++ { - priv, err := keys.NewPrivateKey() - require.NoError(t, err) - require.NotNil(t, priv) - - privs = append(privs, &privateKey{PrivateKey: priv}) - } - - return privs -} diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index 41b0da005..32a470175 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -15,7 +15,6 @@ import ( "time" "github.com/nspcc-dev/neo-go/internal/testchain" - "github.com/nspcc-dev/neo-go/internal/testserdes" "github.com/nspcc-dev/neo-go/pkg/compiler" "github.com/nspcc-dev/neo-go/pkg/config" "github.com/nspcc-dev/neo-go/pkg/core/block" @@ -28,7 +27,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/core/transaction" - "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" @@ -180,51 +178,6 @@ func TestBug1728(t *testing.T) { require.Equal(t, aer.VMState, vm.HaltState) } -func getDecodedBlock(t *testing.T, i int) *block.Block { - data, err := getBlockData(i) - require.NoError(t, err) - - b, err := hex.DecodeString(data["raw"].(string)) - require.NoError(t, err) - - block := block.New(false) - require.NoError(t, testserdes.DecodeBinary(b, block)) - - return block -} - -func getBlockData(i int) (map[string]interface{}, error) { - b, err := ioutil.ReadFile(fmt.Sprintf("test_data/block_%d.json", i)) - if err != nil { - return nil, err - } - var data map[string]interface{} - if err := json.Unmarshal(b, &data); err != nil { - return nil, err - } - return data, err -} - -func newDumbBlock() *block.Block { - return &block.Block{ - Header: block.Header{ - Version: 0, - PrevHash: hash.Sha256([]byte("a")), - MerkleRoot: hash.Sha256([]byte("b")), - Timestamp: 100500, - Index: 1, - NextConsensus: hash.Hash160([]byte("a")), - Script: transaction.Witness{ - VerificationScript: []byte{0x51}, // PUSH1 - InvocationScript: []byte{0x61}, // NOP - }, - }, - Transactions: []*transaction.Transaction{ - transaction.New([]byte{byte(opcode.PUSH1)}, 0), - }, - } -} - // This function generates "../rpc/testdata/testblocks.acc" file which contains data // for RPC unit tests. It also is a nice integration test. // To generate new "../rpc/testdata/testblocks.acc", follow the steps: diff --git a/pkg/core/interop_system_test.go b/pkg/core/interop_system_test.go index 7c6f714ef..298bf29e9 100644 --- a/pkg/core/interop_system_test.go +++ b/pkg/core/interop_system_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/nspcc-dev/neo-go/internal/random" - "github.com/nspcc-dev/neo-go/pkg/core/block" "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/contract" @@ -451,27 +450,6 @@ func createVM(t *testing.T) (*vm.VM, *interop.Context, *Blockchain) { return v, context, chain } -func createVMAndPushBlock(t *testing.T) (*vm.VM, *block.Block, *interop.Context, *Blockchain) { - v, block, context, chain := createVMAndBlock(t) - v.Estack().PushVal(stackitem.NewInterop(block)) - return v, block, context, chain -} - -func createVMAndBlock(t *testing.T) (*vm.VM, *block.Block, *interop.Context, *Blockchain) { - block := newDumbBlock() - chain := newTestChain(t) - d := dao.NewSimple(storage.NewMemoryStore(), chain.GetConfig().StateRootInHeader) - context := chain.newInteropContext(trigger.Application, d, block, nil) - v := context.SpawnVM() - return v, block, context, chain -} - -func createVMAndPushTX(t *testing.T) (*vm.VM, *transaction.Transaction, *interop.Context, *Blockchain) { - v, tx, context, chain := createVMAndTX(t) - v.Estack().PushVal(stackitem.NewInterop(tx)) - return v, tx, context, chain -} - func createVMAndContractState(t *testing.T) (*vm.VM, *state.Contract, *interop.Context, *Blockchain) { script := []byte("testscript") m := manifest.NewManifest("Test") diff --git a/pkg/core/native/ledger.go b/pkg/core/native/ledger.go index 88e86f87e..4dfd6b313 100644 --- a/pkg/core/native/ledger.go +++ b/pkg/core/native/ledger.go @@ -25,14 +25,7 @@ type Ledger struct { interop.ContractMD } -const ( - ledgerContractID = -4 - - prefixBlockHash = 9 - prefixCurrentBlock = 12 - prefixBlock = 5 - prefixTransaction = 11 -) +const ledgerContractID = -4 // newLedger creates new Ledger native contract. func newLedger() *Ledger { diff --git a/pkg/core/native/util.go b/pkg/core/native/util.go index af7ffd6e7..73ac7f316 100644 --- a/pkg/core/native/util.go +++ b/pkg/core/native/util.go @@ -1,13 +1,11 @@ package native import ( - "encoding/binary" "encoding/hex" "fmt" "math/big" "github.com/nspcc-dev/neo-go/pkg/core/dao" - "github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/storage" "github.com/nspcc-dev/neo-go/pkg/encoding/bigint" "github.com/nspcc-dev/neo-go/pkg/io" @@ -36,34 +34,6 @@ func putSerializableToDAO(id int32, d dao.DAO, key []byte, item io.Serializable) return d.PutStorageItem(id, key, w.Bytes()) } -func getInt64WithKey(id int32, d dao.DAO, key []byte, defaultValue int64) int64 { - si := d.GetStorageItem(id, key) - if si == nil { - return defaultValue - } - return int64(binary.LittleEndian.Uint64(si)) -} - -func setInt64WithKey(id int32, dao dao.DAO, key []byte, value int64) error { - si := make(state.StorageItem, 8) - binary.LittleEndian.PutUint64(si, uint64(value)) - return dao.PutStorageItem(id, key, si) -} - -func getUint32WithKey(id int32, dao dao.DAO, key []byte, defaultValue uint32) uint32 { - si := dao.GetStorageItem(id, key) - if si == nil { - return defaultValue - } - return binary.LittleEndian.Uint32(si) -} - -func setUint32WithKey(id int32, dao dao.DAO, key []byte, value uint32) error { - si := make(state.StorageItem, 4) - binary.LittleEndian.PutUint32(si, value) - return dao.PutStorageItem(id, key, si) -} - func setIntWithKey(id int32, dao dao.DAO, key []byte, value int64) error { return dao.PutStorageItem(id, key, bigint.ToBytes(big.NewInt(value))) } diff --git a/pkg/core/util.go b/pkg/core/util.go index 2c1750ab8..325bac560 100644 --- a/pkg/core/util.go +++ b/pkg/core/util.go @@ -14,17 +14,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/vm/opcode" ) -var ( - // governingTokenTX represents transaction that is used to create - // governing (NEO) token. It's a part of the genesis block. - governingTokenTX transaction.Transaction - - // utilityTokenTX represents transaction that is used to create - // utility (GAS) token. It's a part of the genesis block. It's mostly - // useful for its hash that represents GAS asset ID. - utilityTokenTX transaction.Transaction -) - // createGenesisBlock creates a genesis block based on the given configuration. func createGenesisBlock(cfg config.ProtocolConfiguration) (*block.Block, error) { validators, err := validatorsFromConfig(cfg) diff --git a/pkg/encoding/fixedn/fixed8.go b/pkg/encoding/fixedn/fixed8.go index ff92e6b6d..01abc8720 100644 --- a/pkg/encoding/fixedn/fixed8.go +++ b/pkg/encoding/fixedn/fixed8.go @@ -1,7 +1,6 @@ package fixedn import ( - "errors" "strconv" "strings" @@ -13,8 +12,6 @@ const ( decimals = 100000000 ) -var errInvalidString = errors.New("fixed8 must satisfy following regex \\d+(\\.\\d{1,8})?") - // Fixed8 represents a fixed-point number with precision 10^-8. type Fixed8 int64 diff --git a/pkg/io/size.go b/pkg/io/size.go index 93f7021f8..3075a77db 100644 --- a/pkg/io/size.go +++ b/pkg/io/size.go @@ -5,18 +5,6 @@ import ( "reflect" ) -var ( - bit8 byte - ui8 uint8 - ui16 uint16 - ui32 uint32 - ui64 uint64 - i8 int8 - i16 int16 - i32 int32 - i64 int64 -) - // This structure is used to calculate the wire size of the serializable // structure. It's an io.Writer that doesn't do any real writes, but instead // just counts the number of bytes to be written. diff --git a/pkg/network/payload/extensible.go b/pkg/network/payload/extensible.go index 529a8dc37..66891e7e7 100644 --- a/pkg/network/payload/extensible.go +++ b/pkg/network/payload/extensible.go @@ -2,7 +2,6 @@ package payload import ( "errors" - "math" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" @@ -10,10 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/util" ) -const ( - maxExtensibleCategorySize = 32 - maxExtensibleDataSize = math.MaxUint16 -) +const maxExtensibleCategorySize = 32 // Extensible represents payload containing arbitrary data. type Extensible struct { diff --git a/pkg/network/server.go b/pkg/network/server.go index e5f9f8e96..3e5d00808 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -41,12 +41,10 @@ const ( var ( errAlreadyConnected = errors.New("already connected") errIdenticalID = errors.New("identical node id") - errInvalidHandshake = errors.New("invalid handshake") errInvalidNetwork = errors.New("invalid network") errMaxPeers = errors.New("max peers reached") errServerShutdown = errors.New("server shutdown") errInvalidInvType = errors.New("invalid inventory type") - errInvalidHashStart = errors.New("invalid requested HashStart") ) type ( diff --git a/pkg/rpc/client/client.go b/pkg/rpc/client/client.go index bccd0d4a5..d112ef33c 100644 --- a/pkg/rpc/client/client.go +++ b/pkg/rpc/client/client.go @@ -21,7 +21,6 @@ import ( const ( defaultDialTimeout = 4 * time.Second defaultRequestTimeout = 4 * time.Second - defaultClientVersion = "2.0" // number of blocks after which cache is expired cacheTimeout = 100 ) diff --git a/pkg/rpc/server/server_test.go b/pkg/rpc/server/server_test.go index 526c54f2a..bd9df957b 100644 --- a/pkg/rpc/server/server_test.go +++ b/pkg/rpc/server/server_test.go @@ -46,11 +46,6 @@ type executor struct { httpSrv *httptest.Server } -const ( - defaultJSONRPC = "2.0" - defaultID = 1 -) - type rpcTestCase struct { name string params string @@ -66,7 +61,6 @@ const genesisBlockHash = "73fe50b5564d57118296cbab0a78fe7cb11c97b7699d07a9a21fab const verifyContractHash = "c50082e0d8364d61ce6933bd24027a3363474dce" const verifyContractAVM = "VwMAQS1RCDAhcAwU7p6iLCfjS9AUj8QQjgj3To9QSLLbMHFoE87bKGnbKJdA" const verifyWithArgsContractHash = "8744ffdd07af8e9f18ab90685c8c2ebfd37c6415" -const verifyWithArgsContractAVM = "VwIDeAwLZ29vZF9zdHJpbmeXJA15FSgJehHbIJciBRHbIHBoQA==" const invokescriptContractAVM = "VwcADBQBDAMOBQYMDQIODw0DDgcJAAAAANswcGhB+CfsjCGqJgQRQAwUDQ8DAgkAAgEDBwMEBQIBAA4GDAnbMHFpQfgn7IwhqiYEEkATQA==" var rpcTestCases = map[string][]rpcTestCase{ diff --git a/pkg/services/oracle/neofs/neofs.go b/pkg/services/oracle/neofs/neofs.go index ee09ae424..199310569 100644 --- a/pkg/services/oracle/neofs/neofs.go +++ b/pkg/services/oracle/neofs/neofs.go @@ -3,7 +3,6 @@ package neofs import ( "bytes" "context" - "crypto/sha256" "errors" "fmt" "net/url" @@ -24,10 +23,6 @@ const ( // URIScheme is the name of neofs URI scheme. URIScheme = "neofs" - // containerIDSize is the size of container id in bytes. - containerIDSize = sha256.Size - // objectIDSize is the size of container id in bytes. - objectIDSize = sha256.Size // rangeSep is a separator between offset and length. rangeSep = '|' diff --git a/pkg/util/bitfield/bitfield.go b/pkg/util/bitfield/bitfield.go index 8766c8d60..c2de953b4 100644 --- a/pkg/util/bitfield/bitfield.go +++ b/pkg/util/bitfield/bitfield.go @@ -10,7 +10,6 @@ type Field []uint64 // Bits and bytes count in a basic element of Field. const elemBits = 64 -const elemBytes = 8 // New creates a new bit field of specified length. Actual field length // can be rounded to the next multiple of 64, so it's a responsibility diff --git a/pkg/wallet/account.go b/pkg/wallet/account.go index 93f0c983f..f67a4fc17 100644 --- a/pkg/wallet/account.go +++ b/pkg/wallet/account.go @@ -61,18 +61,6 @@ type Contract struct { Deployed bool `json:"deployed"` } -// contract is an intermediate struct used for json unmarshalling. -type contract struct { - // Script is a hex-encoded script of the contract. - Script string `json:"script"` - - // A list of parameters used deploying this contract. - Parameters []ContractParam `json:"parameters"` - - // Indicates whether the contract has been deployed to the blockchain. - Deployed bool `json:"deployed"` -} - // ContractParam is a descriptor of a contract parameter // containing type and optional name. type ContractParam struct {