Evgenii Stratonikov
c6d33c5841
core: save NEP5 transfer notify index
...
TransferNotifyIndex is the index of transfer event in the list
of all transfers in a transaction.
2020-08-03 10:58:23 +03:00
Evgenii Stratonikov
f0d75afc48
rpc: provide old transfers in getnep5transfers
...
Return performed transfers even if contract was migrated.
2020-07-24 14:39:16 +03:00
Evgenii Stratonikov
7bdbfbad19
rpc: fix getnep5transfers
address check condition
2020-07-21 11:12:40 +03:00
Evgenii Stratonikov
dcb00c61f2
rpc: support raw address in getnep5transfers RPC
2020-07-03 18:44:46 +03:00
Evgenii Stratonikov
59cd19f5d4
rpc: support stringified address in getnep5balances RPC
2020-07-03 18:44:46 +03:00
Evgenii Stratonikov
78900148ee
rpc/request: add (*Param).GetUint160FromAddressOrHex()
...
Allow to get address from both representations.
2020-07-03 18:42:09 +03:00
Roman Khimov
7e5533e77e
Merge pull request #1114 from nspcc-dev/fix-test-failures-2.x
...
Fix test failures 2.x
2020-06-25 22:01:16 +03:00
Roman Khimov
8f1ddc0651
rpc/server: fix error reporting in Start
...
This error message makes no sense when shutting down the server:
2020-06-25T19:29:53.251+0300 ERROR failed to start RPC server {"error": "http: Server closed"}
And ListenAndServer is documented to always return non-nil error one of which
is http.ErrServerClosed. This should also fix the following test failure:
==================
WARNING: DATA RACE
Read at 0x00c000254243 by goroutine 49:
testing.(*common).logDepth()
/usr/local/go/src/testing/testing.go:665 +0xa1
testing.(*common).Logf()
/usr/local/go/src/testing/testing.go:658 +0x8f
testing.(*T).Logf()
<autogenerated>:1 +0x75
go.uber.org/zap/zaptest.testingWriter.Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zaptest/logger.go:130 +0x11f
go.uber.org/zap/zaptest.(*testingWriter).Write()
<autogenerated>:1 +0xa9
go.uber.org/zap/zapcore.(*ioCore).Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/core.go:90 +0x1c3
go.uber.org/zap/zapcore.(*CheckedEntry).Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/entry.go:215 +0x1e7
go.uber.org/zap.(*Logger).Error()
/go/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:203 +0x95
github.com/nspcc-dev/neo-go/pkg/rpc/server.(*Server).Start()
/go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server.go:179 +0x5c5
Previous write at 0x00c000254243 by goroutine 44:
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:900 +0x353
testing.tRunner()
/usr/local/go/src/testing/testing.go:913 +0x1bb
Goroutine 49 (running) created at:
github.com/nspcc-dev/neo-go/pkg/rpc/server.initClearServerWithInMemoryChain()
/go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_helper_test.go:69 +0x305
github.com/nspcc-dev/neo-go/pkg/rpc/server.initServerWithInMemoryChain()
/go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_helper_test.go:78 +0x3c
github.com/nspcc-dev/neo-go/pkg/rpc/server.testRPCProtocol()
/go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:805 +0x53
github.com/nspcc-dev/neo-go/pkg/rpc/server.TestRPC.func1()
/go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:793 +0x44
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
Goroutine 44 (finished) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:960 +0x651
github.com/nspcc-dev/neo-go/pkg/rpc/server.TestRPC()
/go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:792 +0x5d
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
==================
2020-06-25 19:41:29 +03:00
Evgenii Stratonikov
eb37f92881
rpc/client: support verifyproof
RPC
2020-06-25 17:07:23 +03:00
Evgenii Stratonikov
654877fb1b
rpc/client: support getproof
RPC
2020-06-25 17:04:23 +03:00
Evgenii Stratonikov
d8dddabc86
rpc/client: support getstateheight
RPC
2020-06-25 16:19:47 +03:00
Evgenii Stratonikov
b4b0ae0f51
rpc/client: support getstateroot
RPC
2020-06-25 16:19:47 +03:00
Evgenii Stratonikov
45a95b5242
rpc/server: remove debug fmt.Println()
from tests
2020-06-25 16:19:47 +03:00
Evgenii Stratonikov
f8051da0bd
core: extend Blockchainer interface with StateHeight()
...
Allow to query current verified state root height.
2020-06-22 10:53:13 +03:00
Evgenii Stratonikov
519a98039c
rpc: implement verifyproof RPC
...
Test getproof and verifyproof together.
2020-06-08 17:31:59 +03:00
Evgenii Stratonikov
8cbbddddaf
rpc: implement getproof RPC
2020-06-08 17:31:58 +03:00
Evgenii Stratonikov
fe8038e8b7
rpc/server: implement getstateheight RPC
2020-06-08 16:40:37 +03:00
Evgenii Stratonikov
53dc7f27b6
rpc/server: implement getstateroot RPC
2020-06-08 16:40:37 +03:00
Evgenii Stratonikov
dcaa82b32b
rpc: convert null
value to a defaultT
...
Right now we convert it is unmarshaler into a float64(0)
so an error is supressed.
2020-06-08 16:39:02 +03:00
Evgenii Stratonikov
7b1a54c934
rpc/server: unify boolean flag handling
...
Implement (*Param).GetBoolean() for converting parameter to bool value.
It is used for verbosity flag and is false iff it is either zero number
or empty sting.
2020-06-05 12:51:09 +03:00
Evgenii Stratonikov
44f93c7c69
rpc/server: simplify errors handling during parameter parsing
2020-06-05 12:51:09 +03:00
alexvanin
8db714785d
rpc/client: handle client creation error in new wsclient
...
Client returns error if it can't parse endpoint string. WSClient
should check client error or there could be panic at `cl.cli = nil`
expression.
2020-05-18 16:25:36 +03:00
Roman Khimov
8cd7bc7e07
rpc/client: deduplicate block/header tests a bit
...
The same data is copied at least three times here.
2020-05-14 17:28:14 +03:00
Roman Khimov
9546e021a9
rpc/block: rework the way Block is JSONized
...
Our block.Block was JSONized in a bit different fashion than result.Block in
its Nonce and NextConsensus fields. It's not good for notifications because
third-party clients would probably expect to see the same format. Also, using
completely different Block representation in result is probably making our
client a bit weaker as this representation is harder to use with other neo-go
components.
So use the same approach we took for Transactions and wrap block.Base which is
to be serialized in proper way.
2020-05-14 17:28:14 +03:00
Roman Khimov
8f55f0ac76
rpc/server: add notification filters
...
And check state string correctness on unmarshaling.
2020-05-14 17:28:14 +03:00
Roman Khimov
78716c5335
rpc/client: add support for notification filters
...
Differing a bit from #895 draft specification, we won't add `verifier` (or
signer) for Neo 2, it's not worth doing so at the moment.
2020-05-14 00:56:26 +03:00
Roman Khimov
da32cff313
rpc/server: don't panic on test failure
2020-05-14 00:56:26 +03:00
Roman Khimov
966ff28091
rpc: add subscriber queue overflow check
...
It's not practical adding server-side tests for 2.0 (as it requires generating
more blocks), so we'll leave it for 3.0.
2020-05-14 00:56:26 +03:00
Roman Khimov
5464f9c3ae
rpc/client: add notifications support for WSClient
...
It differs from #895 design in that we have Notifications channel always
exposed as WSClient field, probably it simplifies things a little.
2020-05-13 17:17:41 +03:00
Roman Khimov
e1408b6525
rpc/server: add notification subscription
...
Note that the protocol differs a bit from #895 in its notifications format,
to avoid additional server-side processing we're omitting some metadata like:
* block size and confirmations
* transaction fees, confirmations, block hash and timestamp
* application execution doesn't have ScriptHash populated
Some block fields may also differ in encoding compared to `getblock` results
(like nonce field).
I think these differences are unnoticieable for most use cases, so we can
leave them as is, but it can be changed in the future.
2020-05-13 17:17:41 +03:00
Roman Khimov
d5df1212c2
rpc/server: start and shutdown Server in tests
...
It will be important for proper subscription testing and it doesn't hurt even
though technically we've got two http servers listening after this change (one
is a regular Server's http.Server and one is httptest's Server). Reusing
rpc.Server would be nice, but it requires some changes to Start sequence to
start Listener with net.Listen and then communicate back its resulting
Addr. It's not very convenient especially given that no other code needs it,
so doing these changes just for a bit cleaner testing seems like and
overkill.
Update config appropriately. Update Start comment along the way.
2020-05-12 17:42:34 +03:00
Roman Khimov
e097e86bfa
Merge pull request #921 from nspcc-dev/rpc-websocket-2.x
...
RPC over websocket (2.x)
2020-05-04 13:55:19 +03:00
Roman Khimov
556ab39a5a
rpc/client: add minimalistic websocket client
2020-04-30 22:59:19 +03:00
Roman Khimov
6333060897
rpc/client: separate out http-related functionality
2020-04-30 22:59:19 +03:00
Roman Khimov
38f9b511ae
rpc/client: drop Version from Options
...
It makes no sense at all, it's a JSON-RPC version.
2020-04-30 22:59:19 +03:00
Roman Khimov
e32367a1c2
rpc/client: fix some comments
2020-04-30 22:59:19 +03:00
Roman Khimov
a49f2bc47c
client: remove Balancer getter/setter, make it an Option
...
Keep it internal to the client instance, it makes no sense exposing it to the
outside user.
2020-04-30 22:59:19 +03:00
Roman Khimov
00d6439eb2
client: make http.Client internal to the Client
...
Exposing it the outside users is strange, so incapsulate it completely.
Fix DialTimeout setting along the way, handle negative timeouts as invalid.
2020-04-30 22:59:01 +03:00
Roman Khimov
24b46c6041
rpc/server: add websockets support via '/ws' URL
2020-04-30 17:53:28 +03:00
Roman Khimov
3eb6d266ca
rpc/server: use httptest.Server for testing
...
Which allows to reuse it for websockets.
2020-04-30 17:52:42 +03:00
Roman Khimov
3d2a2af575
rpc: shuffle handleHttpRequest/handleRequest responsibilities
...
Make handleRequest reusable in other contexts like websockets.
2020-04-30 17:52:15 +03:00
Roman Khimov
dbe7be5b00
rpc: change handlers to always return response.Error for errors
...
As it's expected by WriteErrorResponse() actually.
2020-04-30 17:52:15 +03:00
Roman Khimov
21c31d7d24
rpc/server: refactor handler methods a little
...
request.In is a natural request representation, one can always get
request.Params from it.
2020-04-30 17:52:13 +03:00
Anna Shaleva
87b0e76a8c
rpc, smartcontract: move contract metadata to smartcontract package
2020-04-29 13:50:05 +03:00
Roman Khimov
9997661998
Merge pull request #821 from nspcc-dev/fix-cache-propagation-to-invocations
...
core: wrap cached dao properly, don't miss cached data
2020-04-06 11:52:41 +03:00
Evgenii Stratonikov
1fcc019bf3
rpc: update test chain
...
Also provide info for getblockheader RPC while
generating test chain.
2020-04-06 09:31:09 +03:00
Evgenii Stratonikov
004023920e
rpc: use Notify with varargs in the test contract
2020-04-06 09:31:09 +03:00
Roman Khimov
5f09381cf4
core: wrap cached dao properly, don't miss cached data
...
Fixes #817 where invoked contract missed updated account information because
it got it one layer below cachedDao used to process the block.
2020-04-03 10:15:11 +03:00
Roman Khimov
9b5dab57e8
Merge pull request #810 from nspcc-dev/refactor/config
...
config: move config.go out of config
2020-04-01 10:29:57 +03:00
Anna Shaleva
5a984fdf88
config: move config.go out of config/
...
closes #423
2020-03-31 17:55:59 +03:00
Roman Khimov
e41853d0a4
Merge pull request #789 from nspcc-dev/fix/tx_specific_data_marshalling
...
rpc: fix marshalling of type-specific tx data
2020-03-30 16:10:25 +03:00
Anna Shaleva
9c09ad9c89
rpc: fix marshalling of type-specific tx data
...
closes #585
2020-03-30 15:48:50 +03:00
Roman Khimov
92bafffcd8
Merge pull request #805 from nspcc-dev/fix-rpc-invocation-json
...
rpc: fix stack field name for invocation results
2020-03-29 13:41:46 +03:00
Roman Khimov
2316e2c4a7
rpc: fix stack field name for invocation results
...
Follow C# implementation:
https://docs.neo.org/docs/en-us/reference/rpc/latest-version/api/invokefunction.html
2020-03-28 13:59:42 +03:00
Anna Shaleva
0be237beb6
rpc: fix double-pointer bugs in RPC Client
...
Fixed double-pointer bug in following methods:
- GetRawTransactionVerbose
- GetBlockVerbose
- GetBlockHeader
- GetTxOut
- ValidateAddress
2020-03-27 16:04:11 +03:00
Evgenii Stratonikov
db2dccf7cb
emit: implement AppCallWithOperationAndArgs
...
It is nice to have a typical task of calling contract method
with specific arguments incapsulated inside some function.
2020-03-27 11:05:36 +03:00
Evgenii Stratonikov
4e92642dec
rpc: allow to unmarshal integer params from string
2020-03-25 17:23:13 +03:00
Evgenii Stratonikov
43495a49f4
rpc: reuse handlers map for prometheus metrics
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
57f37bc7a0
rpc: add metrics for invoke* RPCs
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
2ed417388b
rpc: unify RPC handlers
...
Move all of them to a map. This can make it easier
to add/remove RPC based on plugins and makes code less verbose.
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
8236217a01
rpc: make all handler have the same signature
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
6e801d33f0
rpc: make a separate handler for every RPC
...
Move getbestblockhash, getblockcount, getconnectioncount RPC.
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
969ed6e6e1
rpc: move getaccountstate/getunspents RPCs to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
2ec5b9f08a
rpc: move getblock RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
e442ebdb69
rpc: move getblockhash RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
90fdde4018
rpc: move getversion RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
99d02d5de0
rpc: move getpeers RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
dfb4171e3c
rpc: move getrawmempool RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
4e25c9121b
rpc: move validateaddress RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
70eb0b175a
rpc: move getassetstate RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
9e6785bed9
rpc: unify counter metrics update
2020-03-25 15:25:12 +03:00
Anna Shaleva
6998c5044b
rpc: add testing infrastructure to RPC client package
...
closes #716
NOTE: RPC client tests contain `serverResponse` json data fetched from examples
published in official C# JSON-RPC API v2.10.3 reference
(see https://docs.neo.org/docs/en-us/reference/rpc/latest-version/api.html )
2020-03-24 16:02:08 +03:00
Anna Shaleva
ca12c75b12
rpc: fix name of json nep5balance field
...
Problem: wrong json field name of result.NEP5Balances.Balances
(see for details:
https://github.com/neo-project/neo-modules/blob/master-2.x/RpcNep5Tracker/RpcNep5Tracker.cs#L295 )
Solution: rename field from `balances` to `balance` to be consistent with C# client
2020-03-24 14:55:20 +03:00
Anna Shaleva
4911837949
rpc: fix wrong script marshalling in getcontractstate RPC server
...
problem: `script` field of result.ContractState is marshalled as []byte
solution: add marshaller for result.ContractState
2020-03-24 14:55:20 +03:00
Anna Shaleva
79f7862496
rpc: fix blockheader marshalling in getblockheader RPC server
...
Problem: wrong json marshalling of `nextconsensus` field of
result.Header
Solution: change field type from util.uint160 to address string
2020-03-24 14:55:20 +03:00
Roman Khimov
751e79d480
Merge pull request #785 from nspcc-dev/feature/uint160_marshalling
...
util: JSONify uint160 using LE instead of BE
2020-03-24 12:41:07 +03:00
Anna Shaleva
2187346158
rpc: fix json marshalling of result.AssetState
...
Modified result.AssetState:
- removed `FeeMode` and `FeeAddress` fields
- fixed json name of `ID` and `AssetType` fields
to be consistent with C# RPC server
2020-03-23 17:44:15 +03:00
Anna Shaleva
2001a40312
util: JSONify uint160 using LE instead of BE
...
closes #769
2020-03-23 17:38:58 +03:00
Evgenii Stratonikov
6ed2bd63b9
core: marshal AppExecResult.Stack as an array
...
Closes #782 .
2020-03-23 16:27:47 +03:00
Evgenii Stratonikov
dfbb84ef38
rpc: support https
...
Allow to start TLS RPC server on a separate port.
Closes #702 .
2020-03-17 12:44:23 +03:00
Roman Khimov
a5e862c351
rpc/client: add TransferNEP5 method to easily transfer tokens
...
We have TransferAsset for regular tokens, so it'd be nice to have TransferNEP5
for NEP5 ones. Relates to #599 .
2020-03-16 17:52:32 +03:00
Evgenii Stratonikov
cdf025bf89
transaction: implement AddVerificationHash() method
2020-03-16 14:11:19 +03:00
Roman Khimov
e9429374aa
Merge pull request #756 from nspcc-dev/feature/unclaimed
...
core/state: do not unmarshal Unclaimed balances in account
2020-03-16 13:21:23 +03:00
Evgenii Stratonikov
e503d1001d
core/state: do not unmarshal Unclaimed balances in account
2020-03-16 12:19:32 +03:00
Evgenii Stratonikov
66727ab8fa
rpc: marshal Asset hash in LE in getnep5balances RPC
2020-03-16 10:14:55 +03:00
Roman Khimov
ba1c3bfccb
Merge pull request #758 from nspcc-dev/rpc-fix-hash160
...
rpc: fix invocations of contracts using hash160
2020-03-13 16:50:31 +03:00
Roman Khimov
c8f4eee5f4
rpc: fix invocations of contracts using hash160
...
ERROR Error encountered with rpc request {"error": "expected string size of 40 got 42",...
2020-03-13 16:47:08 +03:00
Anna Shaleva
784bac0b38
rpc: bug with empty stack marshalling in getapplicationlog
...
Problem: cannot marshall empty raw message from appExecResult.Stack
Solution: add handler for case when appExecResult.Stack is an empty string
2020-03-13 12:50:51 +03:00
Roman Khimov
d9a83373ed
Merge pull request #748 from nspcc-dev/feature/splitnep5
...
core: store NEP5 balances separately from account
2020-03-12 18:31:25 +03:00
Roman Khimov
734778c1f9
Merge pull request #747 from nspcc-dev/fix-contract-deploy-gas-parameter
...
Use wallet in smartcontract deploy/invoke commands and calculate GAS properly
2020-03-12 17:00:04 +03:00
Roman Khimov
25da5a30d8
cli: change deploy and invoke commands to use wallet
...
Passing WIF directly in the command line is not something we should be doing.
Also split netfee and sysfee in the RPC as they're different (and add a script
attribute for free transactions).
2020-03-12 16:19:12 +03:00
Anna Shaleva
307b3b162b
rpc: implement missing RPC client methods
...
Implemented following RPC client methods:
- getapplicationlog
- getassetstate
- getbestblockhash
- getblockcount
- getblockhash
- getblockheader
- getblocksysfee
- getconnectioncount
- getcontractstate
- getpeers
- getrawmempool
- getstorage
- gettransactionheight
- gettxout
- getunclaimed
- getvalidators
- getversion
- submitblock
- validateaddress
2020-03-12 15:56:59 +03:00
Evgenii Stratonikov
6e0a57075f
*: gofmt
2020-03-12 14:51:13 +03:00
Evgenii Stratonikov
df2598c8dc
core: store NEP5 balances separately
...
There is no need to take and unmarshal an account structure only
to get it's NEP5 balances.
2020-03-12 12:58:28 +03:00
Evgenii Stratonikov
d25dddc780
rpc: refactor getDecimals
...
Use existing functions to invoke smartcontract's
method instead of constructing ad-hoc script.
2020-03-12 12:19:31 +03:00
Evgenii Stratonikov
05544a1510
rpc: return empty arrays instead of null in getnep5* RPCs
2020-03-12 12:19:30 +03:00
Roman Khimov
bbd802681e
cli: make gas parameter to deployment add gas to the base price
...
That's how it was intended to behave originally. One thing questionable here
is contract price (policy thing, basically) being moved to smartcontract
package, but it's probably fine for NEO 2.0 (as it won't change) and we'll
make something better for NEO 3.0.
2020-03-11 20:34:36 +03:00
Anna Shaleva
c23a522d25
rpc: implement getunclaimed
...
closes #712
2020-03-11 18:33:15 +03:00
Evgenii Stratonikov
22e99a5b3e
rpc: implement (*Client).NEP5TokenInfo()
...
It can be useful to receive all NEP5 token info at once.
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
cdeba6d417
rpc: implement (*Client).NEP5* methods
2020-03-10 13:02:14 +03:00