Commit graph

633 commits

Author SHA1 Message Date
Anna Shaleva
95cbddf19e cli: use custom logger to filter out runtime.Log messages
```
anna@kiwi:~/Documents/GitProjects/nspcc-dev/neo-go$ ./bin/neo-go vm -p

    _   ____________        __________      _    ____  ___
   / | / / ____/ __ \      / ____/ __ \    | |  / /  |/  /
  /  |/ / __/ / / / /_____/ / __/ / / /____| | / / /|_/ /
 / /|  / /___/ /_/ /_____/ /_/ / /_/ /_____/ |/ / /  / /
/_/ |_/_____/\____/      \____/\____/      |___/_/  /_/

NEO-GO-VM > loadgo ./1-print/1-print.go
READY: loaded 21 instructions
NEO-GO-VM 0 > run
2022-10-07T15:28:20.461+0300	INFO	runtime log	{"tx": "", "script": "db03ceb3f672ee8cd0d714989b4d103ff7eed2f3", "msg": "Hello, world!"}
[]
```
2022-10-07 15:57:33 +03:00
Anna Shaleva
b2cd007d8d cli: move handleLoggingParams to 'options' package
It will be reused by other CLI packages.
2022-10-07 15:57:33 +03:00
Anna Shaleva
b3c8192d2e cli: add 'changes' command for VM CLI 2022-10-07 15:57:31 +03:00
Anna Shaleva
cac4f6a4a6 cli: allow to dump storage diff for 'storage' VM CLI command 2022-10-07 15:56:34 +03:00
Anna Shaleva
8c78177806 vm: add 'storage' VM CLI command to dump storage items
Another nice one, very useful for debugging.
2022-10-07 15:56:34 +03:00
Anna Shaleva
ff03c33e6d vm: allow historic calls inside VM CLI 2022-10-07 15:56:34 +03:00
Anna Shaleva
79e13f73d8 core, rpc: move getFakeNextBlock to Blockchain
It's needed for VM CLI as far and may be improved later.
2022-10-07 15:56:34 +03:00
Anna Shaleva
0036c89d63 vm: add 'env' command showing state of the blockchain-backed VM CLI
A useful one.
2022-10-07 15:56:34 +03:00
Anna Shaleva
f1ecdb82cc vm: add 'events' command to VM CLI
And dump events automatically after HALTed or FAULTed end of execution.
2022-10-07 15:56:34 +03:00
Anna Shaleva
33ae8d0ddc vm: clear manifest on VM CLI reset
Fix the bug when outdated manifest was stored after new program was loaded.
2022-10-07 15:56:34 +03:00
Anna Shaleva
513821cfff vm: allow to provide state for VM CLI
Close #2528.

Also, add new simple testchain as an analogue for basicchain.
2022-10-07 15:56:34 +03:00
Anna Shaleva
0b717b0c22 vm: move vm CLI to cli/vm package 2022-10-07 15:56:34 +03:00
Anna Shaleva
70e59d83c9 docs: fix supported database types 2022-10-07 15:56:34 +03:00
Anna Shaleva
c4c93b591e cli: remove debug flag from VM CLI
It's not used.
2022-10-06 14:01:56 +03:00
Anna Shaleva
5698ce03be cli: move debug flag to options package 2022-10-06 14:01:56 +03:00
Anna Shaleva
37571162a0 cli: move config path flag to options package 2022-10-06 14:01:56 +03:00
Roman Khimov
29e858df66 cli: move nep11/nep17 tests into a package of their own
The tests are still there, coverage should counted fine, but it improves things:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.058s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.005s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.027s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/nep_test        30.443s coverage: [no statements]
ok      github.com/nspcc-dev/neo-go/cli/options 0.054s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.089s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.510s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.433s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.013s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  47.252s coverage: 63.0% of statements
2022-10-06 09:21:26 +03:00
Roman Khimov
1ac60ada19 cli: move tests to subpackages
Refs. #2379, but not completely solves it, one package seriously outweights
others:

?       github.com/nspcc-dev/neo-go/cli [no test files]
ok      github.com/nspcc-dev/neo-go/cli/app     0.036s  coverage: 100.0% of statements
ok      github.com/nspcc-dev/neo-go/cli/cmdargs 0.011s  coverage: 60.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/flags   0.009s  coverage: 97.7% of statements
?       github.com/nspcc-dev/neo-go/cli/input   [no test files]
ok      github.com/nspcc-dev/neo-go/cli/options 0.033s  coverage: 50.0% of statements
?       github.com/nspcc-dev/neo-go/cli/paramcontext    [no test files]
ok      github.com/nspcc-dev/neo-go/cli/query   2.155s  coverage: 45.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/server  1.373s  coverage: 67.8% of statements
ok      github.com/nspcc-dev/neo-go/cli/smartcontract   8.819s  coverage: 94.3% of statements
ok      github.com/nspcc-dev/neo-go/cli/util    0.006s  coverage: 10.9% of statements
?       github.com/nspcc-dev/neo-go/cli/vm      [no test files]
ok      github.com/nspcc-dev/neo-go/cli/wallet  72.103s coverage: 88.2% of statements

Still a nice thing to have.
2022-10-06 09:21:26 +03:00
Roman Khimov
d2d190913b cli: add historic abilities for all invoking commands
Notice that we can't do this for balance commands (unless we change the
interface in some manner) because they use getnepXXbalances.

Fixes #2620.
2022-09-08 19:20:18 +03:00
Roman Khimov
4403a95ae6 cli: don't return sender from invokeWithArgs
It's not really needed, deployer knows the sender exactly already.
2022-09-08 15:57:27 +03:00
Roman Khimov
541d4b49e1 context: define a constant for transaction context type 2022-09-08 14:33:04 +03:00
Roman Khimov
4f3ffe7290 golangci: enable errorlint and fix everything it found 2022-09-02 18:36:23 +03:00
Roman Khimov
58dc8d0c9b *: always close the wallet after use
Fix #2631.
2022-09-02 14:44:32 +03:00
Roman Khimov
cbc2299295 cli/wallet: add warning for dump and export commands 2022-09-02 14:44:18 +03:00
Roman Khimov
e164625a7f wallet: provide (*Account).SignHashable API
Make PrivateKey() less used and less useful.
2022-09-02 14:44:01 +03:00
Roman Khimov
e569edc841 wallet: add ScriptHash() to Account
It allows to simplify a lot of code and avoid getting a PrivateKey in some
cases.
2022-09-02 14:43:34 +03:00
Roman Khimov
fd8da6fdb9 *: do not get private key from Account to check if it CanSign()
We have this API now to performs checks.
2022-09-02 14:43:34 +03:00
Roman Khimov
8d33206bb8 *: don't get private key from account if just public one is needed
Add PublicKey() API to the Account and use it as appropriate, avoid creating
additional references to the private key.
2022-09-02 14:43:28 +03:00
Roman Khimov
411ebdf51e cli: add complete support for offline signing, fix #2662
See documentation update for an example. Some code is made generic as well,
GetCompleteTransaction can now be used directly on ParameterContext.
2022-09-01 15:30:34 +03:00
Roman Khimov
2e6bd51727 cli/wallet: add strip-keys command
To strip keys from wallets.
2022-09-01 15:30:34 +03:00
Roman Khimov
a9237659ff cli/wallet: correct error message
It can be both NEP-11 and NEP-17.
2022-09-01 15:30:33 +03:00
Roman Khimov
c2c10c111c cli/wallet: process non-out non-rpc calls to sign
And document the behavior better. Fixes #2664.
2022-09-01 15:30:33 +03:00
Roman Khimov
c316107c9f cli/wallet: avoid parsing address in signStoredTransaction
It's not needed, we already have the hash and getDecryptedAccount can't return
an account for a different one.
2022-09-01 15:30:33 +03:00
Roman Khimov
4b136e8ab1 cli/sc: tune error messages for forced save/send
Here we're either saving or sending a transaction (depending on `out`), but
not both. Refs. #2664.
2022-08-31 09:51:57 +03:00
Roman Khimov
314cd3341b
Merge pull request #2667 from nspcc-dev/rpc-nep-token-info
Drop NEPXXTokenInfo from the RPC client
2022-08-30 14:41:30 +03:00
Roman Khimov
1da4b333f6 cli/wallet: modernize nep11 balances command, unify with nep17
Make NEP-11 code use getnep11balances the same way NEP-17 code uses
getnep17balances. This command was introduced well before getnep11balances
appeared, so it required always specifying contract explicitly. Now this
constraint can be relaxed somewhat in most cases.
2022-08-30 12:52:14 +03:00
Roman Khimov
7cfcf072b8 cli/wallet: make NEP-17 token selection logic a bit more robust
1. In the single token mode compare known hashes instead of names, names can
   be misleading.
2. Hardcode NEO/GAS, they are special (if not overrided by the wallet data).
2022-08-30 12:52:14 +03:00
Roman Khimov
5f1fe72504 cli/wallet: use token data from getnepXXbalances
We have this data available since 0.99.1 while all public networks require at
least 0.99.2 for compatibility and NeoFS setups use 0.99.2+ too. This data can
simplify account handling considerably making additional requests unneccessary
in many cases.
2022-08-29 22:52:27 +03:00
Roman Khimov
e28bf55ebb cli/wallet: search for NEP-11 token name in balances
In the same way we do for NEP-17 tokens. This code predates "getnep11balances"
call, so this wasn't possible back then, but now we can improve the situation
(allow specifying names/symbols instead of hashes only).
2022-08-29 22:52:27 +03:00
Roman Khimov
ed6ed61712 neptoken: add Info to replace old NEPXXTokenInfo methods
I'm still not sure it's good to have this exposed from neptoken at all, but
let's try it this way.
2022-08-29 22:52:27 +03:00
Roman Khimov
1850c04d65 cli/server: handle SIGTERM gracefully
That's the expected and desired behavior, SIGKILL is always there to do bad
things.
2022-08-24 11:43:21 +03:00
Anna Shaleva
40315fe092 cli: check manifest for validness if it's got from user input
And adjust the test case along the way, unnamed arguments are not
allowed for valid manifest.
2022-08-22 14:59:34 +03:00
Roman Khimov
8005bfcd32 cli/wallet: compensate for CLI waiting time
Similar to ba2e7063dd.
2022-08-22 09:55:31 +03:00
Roman Khimov
f60fa02a96 cli/wallet: deduplicate some transfer code 2022-08-22 09:55:31 +03:00
Roman Khimov
7e212de41a cli: drop the use of deprecated APIs from sc/nep11/nep17 2022-08-19 21:52:43 +03:00
Roman Khimov
194933a5cc rpcclient: provide nep11 package for NEP-11 tokens
Unfortunately Go doesn't allow to easily reuse readers in full packages, still
we can have this wrapper with a little overhead (the alternative is to move
specific methods into types of their own, but I'm not sure how it's going to
be accepted user-side).
2022-08-19 10:37:22 +03:00
Roman Khimov
f011b3c3dd rpcclient: introduce NEO wrapper
Notice that int64 types are used for gas per block or registration price
because the price has to fit into the system fee limitation and gas per block
value can't be more than 10 GAS. We use int64 for votes as well in other types
since NEO is limited to 100M.
2022-08-17 22:03:09 +03:00
Roman Khimov
5c8f3a99dc rpcclient: add management wrapper for ContractManagement 2022-08-17 11:42:20 +03:00
Roman Khimov
ee72b2fa29 rpcclient: add gas package for the GAS contract
Test it with the RPC server.
2022-08-16 12:43:25 +03:00
Roman Khimov
be74cc6b55 cli: use nep17 wrapper to implement commands 2022-08-12 18:21:02 +03:00