Commit graph

165 commits

Author SHA1 Message Date
Evgenii Stratonikov
9be4312d8d cli: implement AddressFlag
This makes code less verbose and performs all parsing
before invoking main function.
2020-03-06 13:50:34 +03:00
Evgenii Stratonikov
a9783d05f5 cli: implement wallet multisig sign command
Implement ability to sign transactions with multisig address.
This should be done in several steps:
1. Create TX with `wallet transfer --out <file>`
2. Sign TX with `wallet multisign sign --in <file> --out <file2>`.
3. Repeat 2 for every party.
Input file contains transaction with possibly incomplete
set of the signatures. Output file will contain the same tx
with updated signature set.
When --rpc flag is provided, result transaction is sent
via `sendrawtransaction`.
2020-03-05 09:45:34 +03:00
Evgenii Stratonikov
0d4ad9f76c cli: add --out flag to the wallet transfer command
When transferring assets from multisig accounts,
it is useful to export tx into a file, so that
other participants can sign it too.
2020-03-05 09:45:12 +03:00
Evgenii Stratonikov
7eaeb18f18 transaction: marshal ContractTX even if Data is nil
It contains no information so it doesn't matter anyway.
2020-03-04 20:01:26 +03:00
Roman Khimov
e41d434a49 *: move all packages from CityOfZion to nspcc-dev 2020-03-03 17:21:42 +03:00
Roman Khimov
4c8d327353 rpc: drop duplicating Invoke* structures
And use smartcontract.Parameter instead of vm.StackItem where
appropriate. Closes #689.
2020-03-03 15:38:03 +03:00
Evgenii Stratonikov
05a3625b7d wallet: implement (*Account).SignTx
It is used in both CLI and RPC.
2020-03-02 18:03:56 +03:00
Evgenii Stratonikov
ed190dcfd3 cli: add command for asset transfer
It uses getunspents RPC for getting UTXO and
forming transaction.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
907d599edb cli: add command for GAS claiming
GAS can be claimed via `wallet claim` command.
This will claim first get all claimable outputs via
`getclaimable` RPC and then form a transaction signed
byte the private key from the wallet.
2020-03-02 18:01:49 +03:00
Anna Shaleva
648e0bb242 rpc/smartcontract: merge contract parameter types
Merged two types:
	- smartcontract.ParamType
	- rpc.StackParamType
into single one:
	- smartcontract.ParamType
as they duplicated the functionality.

NOTE: type smartcontract.MapType was added (as in C# implementation).

From now, list of supported smartcontract parameter types:
	UnknownType
	SignatureType
	BoolType
	IntegerType
	Hash160Type
	Hash256Type
	ByteArrayType
	PublicKeyType
	StringType
	ArrayType
	MapType
	InteropInterfaceType
	VoidType
2020-03-02 17:25:21 +03:00
Roman Khimov
3fa9de764b rpc/client: only return the Result from calls, handle Error internally
Adjust structures accordingly and throw away most of them, they're useless.
2020-02-21 15:23:11 +03:00
Evgenii Stratonikov
b50704fd3b rpc: move server-related code to a separate package 2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
d24c6d1d9e rpc: move client-related code to a separate package
This includes Client struct with RPC methods and
BalanceGetter implementation with NeoSCAN.
2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
b6bc4e580a rpc: move functions for Tx building in request package/ 2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
98a1e2170a rpc: move ContractDetails to request/ package 2020-02-21 15:12:04 +03:00
Roman Khimov
f330f2f40b rpc: separate out request and response structures
Mostly as is, no real effort done yet to optimize them, so there are still a
lot of duplicates there, but at least we sort them out into different smaller
packages.
2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
2fc6375958 cli: provide separate function for opening wallet 2020-02-21 12:14:53 +03:00
Evgenii Stratonikov
3d67d52537 cli: support account creation in existing wallet 2020-02-21 12:14:53 +03:00
Evgenii Stratonikov
20c98411fd cli: implement wallet WIF/NEP2 export
One positional argument can be provided. If so, it is
interpreted as address and only WIFs corresponding to it
are exported. If address is provided '--decrypt' flag can be
specified to export unencrypted WIFs.
2020-02-21 12:14:52 +03:00
Evgenii Stratonikov
a030411310 cli: implement multisig import to wallet 2020-02-21 12:14:33 +03:00
Evgenii Stratonikov
baa68e1d46 cli: implement wallet WIF import 2020-02-21 11:19:34 +03:00
Evgenii Stratonikov
a71c2c4bfd cli: move password getting to a separate function
Also do not ignore errors from `terminal.ReadPassword`.
2020-02-21 10:45:58 +03:00
Evgenii Stratonikov
02954285c1 cli: declare wallet path flag once 2020-02-20 15:52:07 +03:00
Evgenii Stratonikov
0a894db7f8 storage: add Exists flag to KeyValue in batch
Set Exists flag if an item with the specified key was already
present in storage before persisting.
2020-02-12 12:16:31 +03:00
Evgenii Stratonikov
b1d9e1132d cli: dump storage changes into JSON files 2020-02-12 12:16:31 +03:00
Roman Khimov
ea3b76ded1 network: make NewServer return an error, fix #612
It can return nil in two cases, so we're better return an error and handle
it.
2020-01-22 11:17:51 +03:00
Evgenii Stratonikov
63c56cca5c core: refactor out Block, BlockBase and Header structs
See #597.
2020-01-16 10:16:24 +03:00
Roman Khimov
a52e016c22 cli/server: disable sampling completely
It's not safe, we don't want to lose messages and we don't have that many of
them to try to figure out what is the better value than the default 100.
2020-01-13 17:32:44 +03:00
Roman Khimov
565c1940e3
Merge pull request #587 from nspcc-dev/feature/zap
Closes #284.
2020-01-10 14:50:09 +03:00
Evgenii Stratonikov
289cb1c1d9 rpc: use zap.Logger 2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
aecdf470e7 cli,pkg: use zap.Logger 2020-01-10 11:14:27 +03:00
Roman Khimov
aad0d3792d wallet: implement dump command
Mostly a testing tool for the moment.
2020-01-09 18:40:30 +03:00
Roman Khimov
f15a2401b1 cli/server: close the chain gracefully on restore even on error
Not an issue for dumper, but when restoring we should correctly save
everything already imported even if the subsequent block fails.
2019-12-27 12:38:07 +03:00
Roman Khimov
1f4b7b366e cli/server: skip genesis block on restore if it matches ours
Enables more convenient imports without skipping over the block 0.
2019-12-27 12:25:39 +03:00
Roman Khimov
ae003a1578 cli/server: fix db restorer math wrt skip
Given `-s 1` with a dump of 6001 blocks it skipped the first one and then
tried to import the next 6001 which failed with EOF because there are only
6000 blocks left.
2019-12-27 12:15:47 +03:00
Roman Khimov
b706130175 cli/server: redo dumper to dump blocks from 0
NGD dumps are all zero-based and even though I don't like it (genesys block
should not be imported, it's the root of chain trust), we have to conform to
this convention for interoperability with C# nodes (otherwise they're not able
to import our dumps).

This also renames `skip` dumper parameter to `start` which is more logical
now, the default is to start the dump from block number zero.
2019-12-27 12:11:57 +03:00
Roman Khimov
7aa7490fb2 cli: fix wrong db dump format
It was broken by 03ff2976ed that changed fixed
32-bit length encoding to VarBytes.
2019-12-26 20:03:06 +03:00
Roman Khimov
89b6cbf795 address: make Prefix overridable
As it should be, it's specified in the configuration file (and it should be
treated as byte in the config)
2019-12-25 15:42:18 +03:00
Vsevolod Brekelov
9541029303 cli: add metrics to dump and restore calls 2019-12-17 14:13:07 +03:00
Vsevolod Brekelov
0085831ec5 network: add Pprof metrics
Since we have some perf issues from time to time it is good to have pprof debugger. Disabled by default.
2019-12-17 14:13:07 +03:00
Roman Khimov
54d888ba70 io: add type-specific read/write methods
This seriously improves the serialization/deserialization performance for
several reasons:
 * no time spent in `binary` reflection
 * no memory allocations being made on every read/write
 * uses fast ReadBytes everywhere it's appropriate

It also makes Fixed8 Serializable just for convenience.
2019-12-12 20:19:50 +03:00
Evgenii Stratonikov
7179e4ba9f util: add LE suffix to Uint256 methods 2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
57efad912c util: add LE suffix to Uint160 methods 2019-12-06 12:16:55 +03:00
Roman Khimov
c8aa061421 cli/wallet: use more secure way to read passwords
They were printed in plaintext, believe it or not. Also, `ssh/terminal` does
some proper magic to really read something from the terminal.
2019-12-03 20:04:52 +03:00
Roman Khimov
852e6a335b compiler: move it up from vm
It really deserves it, I think. Especially given that it doesn't have any
direct usage of `vm` package now.
2019-12-03 18:23:46 +03:00
Roman Khimov
f48228ef7d
Merge pull request #467 from nspcc-dev/errcheck_297
This patchset closes #297 and #457.
2019-12-03 15:06:11 +03:00
Vsevolod Brekelov
f5e2401984 vm: removed logging to fix #457 2019-12-03 13:49:49 +03:00
Vsevolod Brekelov
03ff2976ed io: refactoring for using WriteVarBytes instead of WriteLE
goal is to be consistent with C# implementation.
For writing []byte WriteBytes used and for byte - WriteVarByte.
2019-12-03 13:49:33 +03:00
Roman Khimov
53e7807d2d smartcontract: implement non-test invokers
Do something real, yeah!
2019-11-29 19:00:24 +03:00
Roman Khimov
82c658613e cli/smartcontract: allow float gas specification
It can be useful for non-deployment transactions.
2019-11-29 18:28:03 +03:00
Roman Khimov
fd93986503 cli/smartcontract: move common endpoint parameter definition
Put more emphasys on that it should be trusted and use localhost example
(because you usually do trust it).
2019-11-29 18:16:46 +03:00
Roman Khimov
d8ef9ba0ec cli/smartcontract: make smartContractTmpl a constant
As it can be a constant and should be a constant.
2019-11-29 18:11:49 +03:00
Roman Khimov
8a5ac12df8 rpc: make generic SignAndPushInvocationTx out of DeployContract
SignAndPushInvocationTx() is gonna be used for more than just deploying
contracts.
2019-11-29 17:59:07 +03:00
Roman Khimov
b0a22cf1e7 cli/smartcontract: add testinvoke cli command
That uses new 'invoke' RPC method.
2019-11-28 19:40:13 +03:00
Roman Khimov
e63b25d5ad smartcontract: add user-facing testinvokefunction command
With a very special syntax.
2019-11-27 15:12:15 +03:00
Roman Khimov
d7d7215392 cli: rename testinvoke to testinvokescript
To not confuse it with future testinvokefunction.
2019-11-27 13:00:11 +03:00
Roman Khimov
aae3e217a8 rpc/cli: implement contract deployment, fix #474
It's used like this:
./bin/neo-go contract deploy -i 1-print.avm -c neo-go.yml -e http://localhost:20331 -w KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr -g 100
2019-11-20 16:12:40 +03:00
Roman Khimov
3adc9150d3 cli: rework smart contract configs
Use plain yaml structure.
2019-11-20 16:12:40 +03:00
Vsevolod Brekelov
7b6756cb7e cli: compatible with NGD reading/writing blockchain dump 2019-11-11 13:15:34 +03:00
Roman Khimov
4736dad8f0 cli: fix skip usage in DB dump/restore
It was failing to process any blocks at all when (skip >= count) and in other
cases it processed wrong number of blocks.
2019-11-08 17:00:02 +03:00
Roman Khimov
b05754deac core: add Close() to blockchainer, implement it to properly close chain
Before it the deferred function in Run() was actually never able to properly
close the Store, so we weren't synching the latest state to the disk.
2019-11-08 12:19:54 +03:00
Vsevolod Brekelov
d799c98cfe io: move common function and add unit tests for it 2019-11-06 17:12:33 +03:00
Vsevolod Brekelov
11ce73af28 server: add log-path and address configuration
- LogPath can be configured through config
- node,rpc and monitoring address can be configured thought command line
or config
2019-11-06 15:58:54 +03:00
Roman Khimov
b46dd295bc rpc: add CORS workaround for RPC
This one enables our RPC to be called from the browser if there is a
need. It's insecure and not standards-compliant, thus this behaviour is
configurable is not enabled by default. It makes our node with this workaround
enabled compatible with neo-mon monitoring.

Originally debugged by @anatoly-bogatyrev in #464.
2019-11-01 13:39:47 +03:00
Roman Khimov
2f6e678a19
Merge pull request #463 from nspcc-dev/smartcontract-fixes
Smartcontract RPC fixes
2019-10-29 20:54:46 +03:00
Vsevolod Brekelov
d374175170 monitoring: add prometheus monitoring
add init metrics service which uses prometheus;
add configuration for metrics service;
add monitoring metrics for blockchain,rpc,server;
2019-10-29 20:51:17 +03:00
Roman Khimov
2b3fb14a4a smartcontract: allow RPC endpoint to be specified, fix #363
We already have support for running scripts inside VM CLI, so here we can just
make RPC endpoint configurable and be done with it. It also allows to use
local RPC endpoint if there is a need to.
2019-10-29 16:32:49 +03:00
Roman Khimov
579aa31ddd compiler: drop useless options parameter to Compile()
It's not used in any way there.
2019-10-29 13:02:54 +03:00
Roman Khimov
e319c6c638 cli: move avm inspect from vm to contract command
Make inspect work with avms by default and with go files if told so. In the
end this makes our CLI interface more consistent and usable. Drop useless
CompileAndInspect() compiler method along the way.
2019-10-29 12:56:44 +03:00
Roman Khimov
3cbb699eb7
Merge pull request #426 from nspcc-dev/logger_247
Change fmt.Println to log, close #247.
2019-10-22 14:41:30 +03:00
Vsevolod Brekelov
e2bfff8666 vm: removed mute mode and pushed logging to upper lvl
VM should be responsible for code execution and in case anyone interested in additional logging or errors they could handle them like we do it iin cli.
2019-10-22 13:44:14 +03:00
Roman Khimov
f1750d117b
Merge pull request #440 from nspcc-dev/db-dump-restore
DB dump and restore, fixes #436.
2019-10-21 15:42:05 +03:00
Roman Khimov
c885a69edb cli: add db dump/restore commands
Dump given number of blocks (from the given offset) to file and restore them
from it. Fixes #436.
2019-10-21 14:18:09 +03:00
Roman Khimov
dafd385f57 cli: extend NewCommand() to NewCommands()
So that each module could now return an array of commands. It's gonna be used
in the future to extend them.
2019-10-19 23:58:45 +03:00
Vsevolod Brekelov
59e3bd2fa9 codestyle: fix error string should not be capitalized 2019-10-18 18:34:58 +03:00
Roman Khimov
dca332f333 vm: use new Context.Next() to properly dump programs
Fix #295, deduplicate code and add `inspect` parameter to the vm command to
dump AVMs (`contract inspect` works with Go code).
2019-10-04 16:13:39 +03:00
Roman Khimov
c68a254eba
Merge pull request #404 from nspcc-dev/move-user-docs
Move user docs, fix #339.
2019-09-18 12:50:06 +03:00
Roman Khimov
acb25fb880 cli: move README to docs, refs. #339 2019-09-17 19:07:25 +03:00
Vsevolod Brekelov
adc880d323 blockchain: server runs goroutine instead of blockchain init
rework initBlockChain in order to have controllable way of running
blockchain;
remove context from initBlockChain func;
2019-09-17 15:27:40 +03:00
Vsevolod Brekelov
264dfef370 storage: close function
add close function to storage interface
add common defer function call which will close db connection
remove context as soon as it's not needed anymore
updated unit tests
2019-09-16 18:52:47 +03:00
Vsevolod Brekelov
4f680703a4 storage: multiple DB support and Redis support
add config which closes #336
add redis db support
2019-09-10 17:22:21 +03:00
Roman Khimov
a9b9c9226d *: add/fix godoc comments to satisfy golint
Fixes things like:
 * exported type/method/function X should have comment or be unexported
 * comment on exported type/method/function X should be of the form "X ..."
   (with optional leading article)

Refs. #213.
2019-09-03 17:57:51 +03:00
Vsevolod Brekelov
51b93a9a55 Add neo-go cli documentation
Comments fix
2019-09-02 18:32:11 +03:00
Vsevolod Brekelov
b43b4497cc Fix config for RPC port and default configPath 2019-08-30 11:22:11 +03:00
Evgeniy Kulikov
902125cbeb
Change the way to receive version
- Used git to receive version from tags (see #304)
- Version now displayed when start node (fix #102)

Example:

→ ./bin/node --version
neo-go version 0.44.10-245-g67d5e9f

→ ./bin/node -v
neo-go version 0.44.10-245-g67d5e9f
2019-08-26 19:32:09 +03:00
Roman Khimov
57c7df4dff *: remove remaining references to neo-storm, update README
README update partially reverts c8d7671d26 and
updates it with current commands and sample output.
2019-08-15 19:51:07 +03:00
Roman Khimov
a1e3655560 interop: move into pkg/interop, replace pkg/vm/api
neo-storm has developed more wrappers for syscall APIs, so they can and should
be used as a drop-in replacement for pkg/vm/api. Moving it out of vm, as it's
not exactly related to the VM itself.
2019-08-15 19:41:51 +03:00
Roman Khimov
01330e7ed7 cli: add error return check for compiler.CompileAndInspect()
GolangCI complains:
  Error return value of compiler.CompileAndInspect is not checked (from errcheck)
2019-08-14 20:29:32 +03:00
Anthony De Meulemeester
459d3654a2 fixed missing syscall transaction.GetHash() (CityOfZion/neo-storm#43)
Several bug fixes and improvements

Imported from CityOfZion/neo-storm (8e8fe5c215bfaed51452482f4f28cc9956a1f69b).
2019-08-14 19:14:07 +03:00
Anthony De Meulemeester
0880e88fa5 Fixed bug in else stmts (CityOfZion/neo-storm#42)
* Fixed bug in else stmts

* Fixed if else bug

* Back to %v for formatting instructions

Imported from CityOfZion/neo-storm (ea8440e1454207753c8d209ce7c2cf724fd4ea16).
2019-08-14 19:14:07 +03:00
Anthony De Meulemeester
f547708e10 Implemented detailed init command (CityOfZion/neo-storm#37)
* Implemented detailed init command

* add command for skipping contract information

Imported from CityOfZion/neo-storm (0ef8b983ef43ef2eb8e9f190f1f36dc0e839bbc1).
2019-08-14 19:14:07 +03:00
Ankur Srivastava
3fc25e1431 fixes CityOfZion/neo-storm#16
* A new command `cli init --name testcontract` now creates a directory testcontract/main.go

Imported from CityOfZion/neo-storm (331585e51ce13b6fe902b7a352b150c5b457a4f5).
2019-08-14 19:14:06 +03:00
Evgeniy Kulikov
9c24bf9139 Blockchain graceful shutdown (#139)
* Blockchain graceful shutdown

- fix #138
- stop blockchain goroutine
- close leveldb database

* fix possible context leak (go vet)
2019-02-19 12:48:48 +01:00
Evgeniy Kulikov
67cbcac643 Fix typos (#133)
* Fix typos

* revert chains/unit_testnet

* revert chains

* fix review comments (thx @AlexVanin)
2019-02-13 18:01:10 +00:00
Evgeniy Kulikov
f000b76879 [FIX] Formatting and code-style (#118)
* [FIX] Formatting and code-style

- gofmt
- import resort
- prealloc slices
- simplify code

* fix vet
2019-01-25 12:20:35 +01:00
dauTT
1360e1de68 Added rpc unit tests (#107)
* Fixed small incosistencies related to comments and variable name

* For testing purposes we have to move the method newBlockchain from the cli/server/server.go to  pkg/core/blockchain.go. In addition we have to rename it to NewBlockchainLevelDB in order to be able to export it and avoid naming conflicts. In future we still need to think how to switch between different blockchain implementation easily but for the time being this is not possible.

* Added unit tests for the rpc server

* Added unit_testnet chain fixture

* fixed port number

* Added errors handling

* move unit_testnet chain from 'cli/chains' to 'pkg/rpc/chains'
2019-01-22 13:14:52 +01:00
Sathvik Birudavolu
5b57a10250 Fix NEP2Encrypt add Unit Tests (#108)
* fix NEP2 add unit tests

* version update
2018-12-05 12:30:13 +01:00
dauTT
e2f42e92a0 Implemented rcp method GetAssetState (#103)
* Fix missing dot in configPath

* Add rpc GetAssetState method

* Update rpc README.md

* Update version to 0.45.10
2018-11-26 22:12:33 +01:00
suzumi49n
2bc023b7e0 Fix/args config path (#91)
* fix args config path

* update version
2018-07-22 08:46:49 +02:00
Anthony De Meulemeester
931388b687
Cross platform virtual machine implementation (#60)
* Virtual machine for the NEO blockhain.

* fixed big.Int numeric operation pointer issue.

* added appcall

* Added README for vm package.

* removed main.go

* started VM cli (prompt) integration

* added support for printing the stack.

* moved cli to vm package

* fixed vet errors

* updated readme

* added more test for VM and fixed some edge cases.

* bumped version -> 0.37.0
2018-03-30 18:15:06 +02:00