Roman Khimov
a9d8c9e0d3
rpc/client: implement GetRawTransaction, fix #586
2020-03-03 20:43:57 +03:00
Roman Khimov
f01766131b
rpc/client: add a set of GetBlock methods
...
They differ in input and output types (and data), thus four methods are
added.
2020-03-03 20:26:56 +03:00
Roman Khimov
685e34d83c
rpc: update client documentation
...
Add missing methods, move example into something that can be compiled (and fix
it along the way).
2020-03-03 18:59:21 +03:00
Roman Khimov
f747b39bc6
docs: update RPC server documentation, add missing methods
...
And drop doc.go from server package as it duplicates docs/rpc.md and has no
value of its own (TODO list is managed with GitHub issues, really). Also, RPC
server is not really expected to be used by non-neo-go packages (contrary to
the client).
2020-03-03 18:18:56 +03:00
Roman Khimov
f5a1b928ce
pkg: fix gofmt issues
2020-03-03 17:22:15 +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
Roman Khimov
9b4fd99fbc
vm: break circular references when recursing into ToContractParameters
...
Reference types can have circular pointers to each other, thus we need to
control recursion.
2020-03-03 15:38:03 +03:00
Roman Khimov
3282c6ed41
Merge pull request #704 from nspcc-dev/feature/getrawmempool
...
rpc: implement getrawmempool RPC
2020-03-02 19:44:19 +03:00
Anna Shaleva
e1fe12a07f
rpc: implement getrawmempool RPC
...
closes #175
2020-03-02 19:35:51 +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
972e0d8ad1
core: add one more Contract tx to the test chain
...
When testing CLI it is useful to have some spent coins
on an account with a known key.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
37c2bc4733
rpc: implement (*Client).GetClaimable()
...
This is needed to form correct Claim transaction.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
9d5841df38
rpc: make (*Client).SendRawTransaction public
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
44792ed5f7
core: make test chain format compatible with mainnet
...
Write uint32 length before every block.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
51c4868641
rpc: implement getclaimable RPC
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
0e2a1f40ba
core: add ContractTX to a testchain generator
...
Simple transfer from multisig account to the account
of one of the validators.
2020-03-02 18:00:00 +03:00
Evgenii Stratonikov
72d72296c3
core: implement (*Transaction).GetSignedPart()
...
Marshalling it and taking all but last byte violates incapsulation
and is just wrong in case transaction already contains any witnesses.
2020-03-02 18:00:00 +03:00
Roman Khimov
252a9f2f31
Merge pull request #690 from nspcc-dev/feature/getapplicationlog
...
rpc: implement getapplicationlog RPC
2020-03-02 17:41:32 +03:00
Anna Shaleva
ff4384d7ff
rpc: implement getapplicationlog RPC
...
Closes #500
2020-03-02 17:25:27 +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
Evgenii Stratonikov
624a14f730
rpc: rename (*Client).SendToAddress to TransferAsset
...
SendToAddress name is similar to the `sendtoaddress` RPC call,
this can cause confusion.
Closes #686 .
2020-02-28 14:16:39 +03:00
Anna Shaleva
76a0a6e7e8
rpc: implement getblocksysfee RPC
...
Closes #341
2020-02-21 18:45:52 +03:00
Roman Khimov
8da20055d6
rpc: drop duplicating structures used in tests
...
We have proper results now, so use those. The only left is Invoke, but that
depends on another issue at the moment.
2020-02-21 15:23:11 +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
Roman Khimov
28a26d2cae
rpc/client: look into data first, then HTTP error code
...
In case of error our own server responds with an HTTP error and proper
JSON-RPC error in the body, so look there first as it has more specific data.
2020-02-21 15:12:04 +03:00
Roman Khimov
877b987ecf
rpc: omitempty some fields in TransactionOutputRaw
...
These might be undefined for mempool transactions, thus they should be defined
as omitempty.
2020-02-21 15:12:04 +03:00
Roman Khimov
bba8ac15ff
rpc: introduce proper type for sendrawtransaction, drop useless types
...
sendrawtransaction just returns a bool, sendtoaddress returns a proper
transaction and that should be the same as the one we have in
TransactionOutputRaw.
2020-02-21 15:12:04 +03:00
Roman Khimov
465476201c
rpc/response: drop duplicating AccountState structure
2020-02-21 15:12:04 +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
Evgenii Stratonikov
63751a6e6b
rpc: merge neoscan-related definitions into one file
...
It will make refactoring easier.
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
Roman Khimov
69e1ad512f
rpc: move result package into response
...
`response` is to be populated soon.
2020-02-21 15:12:04 +03:00
Roman Khimov
1801e545a0
rpc: remove wrappers package, move things to result
...
These are all RPC call results, `wrappers` package doesn't make much sense to
me.
2020-02-21 15:12:04 +03:00
Roman Khimov
b8f7ab8e6a
rpc: move Invoke to result package
...
It's just a data.
2020-02-21 15:12:04 +03:00
Roman Khimov
c189062f40
rpc: move ValidateAddress to the result package
...
Because it is a result of the RPC call.
2020-02-21 15:12:04 +03:00
Roman Khimov
bfa2d54e16
rpc: move validateAddress() function from wrappers into server
...
It's a server implementation detail, it has nothing to do with the data format
itself. It also makes no sense exporing it.
2020-02-21 15:12:04 +03:00
Roman Khimov
72a62f1292
result: add trivial test for peers management functions
2020-02-21 15:12:04 +03:00
Roman Khimov
d92e193e63
rpc/network: refactor getpeers logic
...
Deduplicate and simplify code.
2020-02-21 15:12:03 +03:00
Roman Khimov
336a94456f
rpc: make blockHeightFromParam a pointer method
...
Makes no sense copying Server here.
2020-02-21 15:12:03 +03:00
Roman Khimov
a4294f4b5f
core: export UtilityTokenID and GoverningTokenID
...
Both are very useful outside of the core, this change also makes respective
transactions initialize with the package as they don't depend on any kind of
input and it makes no sense recreating them again and again on every use.
2020-02-19 12:13:27 +03:00
Evgenii Stratonikov
9b82bbaa8a
rpc: implement getstorage RPC
2020-02-18 11:59:31 +03:00
Evgenii Stratonikov
a2f012e589
core: deploy new smart-contract in test blocks
...
Also put smart-contract sources in testdata and
add invocation TX with APPCALL and storage.Put.
2020-02-18 11:59:28 +03:00
Anna Shaleva
2b9e63c511
core: add func to generate RPC test data
...
newRPCTestChain function generates test chain "testblocks.acc" for RPC
tests
2020-02-17 23:54:25 +03:00
Anna Shaleva
c99b42f738
rpc: add tests for getcontractstate RPC
2020-02-17 23:54:25 +03:00
Anna Shaleva
3c63ef3dc3
rpc: implement getcontractstate RPC
2020-02-17 23:54:25 +03:00
Anna Shaleva
b8715ddf11
rpc: refactor code of NewAccountState function
...
Simplified reversing of scriptHash
2020-02-17 23:52:20 +03:00
Anna Shaleva
f310145612
rpc: fix getrawtransaction error returncode
...
Changed returncode of getrowtransaction method in case when transaction
with specified hash does not exists. Now it returns error with code -100
instead of -32602 (as in c# node)
2020-02-17 23:52:20 +03:00
Anna Shaleva
5dca765bd1
rpc: add custom error with code -100
...
Fixed getassetstate method: it should return error with code -100 when
asset with specified id is not found (as in c# node).
2020-02-17 23:52:20 +03:00
Evgenii Stratonikov
7ee10ecea5
rpc: implement gettxout RPC
2020-02-17 11:58:18 +03:00
Evgeniy Kulikov
64e325d9af
Update tests for getblock
action
...
- replace `GetBlockResponse.Result` with `wrappers.Block`
- update `getblock` checker and add more assets
2020-02-12 21:58:43 +03:00
Evgeniy Kulikov
41ebf12eb3
Update getblock
RPC action response
2020-02-12 19:43:51 +03:00
Evgenii Stratonikov
8243a8b3a7
emit: use io.BinWriter instead of bytes.Buffer
2020-02-06 18:45:37 +03:00
Evgenii Stratonikov
4d8a3a359b
vm: move Emit* functions to a separate package
...
Also strip 'Emit' prefix because 'emit' is now
in the package name.
2020-02-06 18:45:37 +03:00
Roman Khimov
b1b660c779
rpc: fix getaccountstate/getunspents for unknown addresses
...
Returning error string as a result (not an error) is utterly wrong, but C#
implementation just returns a zero balance for unknown addresses, so we should
follow that.
2020-01-29 19:01:00 +03:00
Evgenii Stratonikov
54e0b5a4a7
rpc: set MaxGasInvoke in config
...
Implement ability to restrict maximum amount of GAS
available for free RPC calls.
2020-01-22 14:31:57 +03:00
Evgenii Stratonikov
4718375db1
rpc: return amount of consumed GAS in invoke*
2020-01-22 14:31:57 +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
Roman Khimov
32213b1454
Merge pull request #601 from nspcc-dev/refactoring/core
...
core: refactor out Block, BlockBase and Header, closes #597 .
2020-01-20 16:19:20 +03:00
Roman Khimov
46b82b4fb5
keys: don't return error from PrivateKey.Sign
...
As it can't ever happen.
2020-01-17 17:00:30 +03:00
Evgenii Stratonikov
489b88afbb
block: rename BlockBase to Base
2020-01-16 10:16:24 +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
b5f234ddef
rpc: make rpc request logging at Debug level
...
Makes no sense polluting logs with Info. It also affects benchmarking.
2020-01-13 17:33:29 +03:00
Evgenii Stratonikov
9dc5571327
core,rpc: close Blockchain in tests
...
If blockchain is not closed, logging in defer can occur
after test has finished, which will lead to a panic with
"Log in goroutine after Test* has completed".
2020-01-10 11:47:56 +03:00
Evgenii Stratonikov
45a4524054
rpc: remove EnableCORSWorkaround from Request
2020-01-10 11:14:29 +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
9145855d2c
Merge pull request #579 from nspcc-dev/refactor-crypto
...
This moves some functionality into micro-packages, improves testing,
unexports some code and fixes bugs along the way.
2019-12-25 18:12:50 +03:00
Roman Khimov
b246653f62
address: rename functions as per #579 comments
...
Make them more clear to understand.
2019-12-25 17:34:18 +03:00
Roman Khimov
e685e9bf9a
address: move into its own package
...
Doesn't really belong to the crypto.
2019-12-25 15:22:02 +03:00
Vsevolod Brekelov
606616618f
rpc: add ability to answer as C# with block as []byte
2019-12-25 01:44:37 +03:00
Evgenii Stratonikov
884779e501
*: goimports
2019-12-17 14:51:28 +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
Vsevolod Brekelov
2d42b14a1d
core: renames entities-> state and removed State prefix
2019-12-11 13:14:18 +03:00
Vsevolod Brekelov
ec17654986
core: refactoring blockchain state and storage
...
add dao which takes care about all CRUD operations on storage
remove blockchain state since everything is stored on change
remove storage operations from structs(entities)
move structs to entities package
2019-12-11 13:05:31 +03:00
Roman Khimov
7e371588a7
core/tx: remove one layer of indirection for scripts and inouts
...
It reduces heap pressure a little for these elements as we don't have to
allocate/free them individually. And they're directly tied to transactions or
block, not being shared or anything like that, so it makes little sense for
them to be pointer-based. It only makes building transactions a little easier,
but that's obviously a minor usecase.
2019-12-09 17:14:10 +03:00
Roman Khimov
3898aadcec
rpc: simplify uint160 handling
...
Use new Uint160DecodeStringLE() function.
2019-12-06 19:47:58 +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
141d27795e
rpc: remove hardcoded pushbytes64 constant
...
Using our new and shiny opcode package.
2019-12-03 18:23:46 +03:00
Roman Khimov
138e125646
*: remove duplicate functions producing verification script
...
Drop wif.GetVerificationScript(), drop
smartcontract.CreateSignatureRedeemScript(), add GetVerificationScript()
directly to the PublicKey and use it everywhere.
2019-12-03 18:23:46 +03:00
Roman Khimov
8d4dd2d2e1
vm: move opcodes into their own package
...
This allows easier reuse of opcodes and in some cases allows to eliminate
dependencies on the whole vm package, like in compiler that only needs opcodes
and doesn't care about VM for any other purpose.
And yes, they're opcodes because an instruction is a whole thing with
operands, that's what context.Next() returns.
2019-12-03 18:22:14 +03:00
Roman Khimov
bc5beb438f
*: gofmt
...
Somehow these crept into the repository.
2019-12-02 10:10:50 +03:00
Roman Khimov
dccf440dca
rpc: skip input/outputs mangling if no gas is attached to invocation
2019-11-29 18:00:08 +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
127f8418c8
rpc: refactor out runScriptInVM() from invokers
2019-11-28 19:13:58 +03:00
Roman Khimov
e216139108
rpc: implement server-side 'invoke' method, fix #346
2019-11-28 19:08:31 +03:00
Roman Khimov
d04bc0cbe3
rpc: add marshaler for StackParamType
...
Makes stack output look better, no one cares about numbers.
2019-11-27 13:00:11 +03:00
Roman Khimov
3843451ec4
rpc: fix potential getblock handling problem, add a test for it
...
It should only accept hex strings and numbers, anything else is wrong.
2019-11-27 13:00:11 +03:00
Roman Khimov
1c883cc819
rpc: add invokescript tests
2019-11-27 13:00:11 +03:00
Roman Khimov
cf39171485
rpc: implement invokefunction, fix #347
...
Param getters were redone to return errors because otherwise bad FuncParam
values could lead to panic. FuncParam itself might be not the most elegant
solution, but it works good enough for now.
2019-11-27 13:00:11 +03:00
Roman Khimov
ea9bc22510
Merge pull request #513 from nspcc-dev/feat/rpc_param
...
This PR does 3 things:
adds array parameter unmarshalling
extend Param with convenient methods
refactor tests into using tables to make it easier add new tests
(part of #347 solution)
2019-11-22 18:47:59 +03:00
Evgenii Stratonikov
c9d5f8b89c
rpc: cover stack_param with more tests
...
Use require/assert instead of builtin facilities.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 13:20:15 +03:00
Evgenii Stratonikov
0f9024d177
rpc: make client default values constants
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:10 +03:00
Evgenii Stratonikov
3afcd784f0
rpc: refactor tests
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:07 +03:00
Evgenii Stratonikov
d5fa31cecd
rpc: trim spaces in tests once
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:03 +03:00
Evgenii Stratonikov
c8987eda32
rpc: add array param type and tests
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:56:58 +03:00