Roman Khimov
a446821753
Merge pull request #980 from nspcc-dev/neo3/protocol/version_payload_optimisation
...
protocol: add node capabilities
2020-05-27 19:13:00 +03:00
Anna Shaleva
c590cc02f4
protocol: add capabilities to version payload
...
closes #871
2020-05-27 19:01:14 +03:00
alexvanin
aca6f2f3ad
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-26 11:36:47 +03:00
Roman Khimov
29e66925aa
rpc/client: deduplicate block/header tests a bit
...
The same data is copied at least twice here. Also use this block for header
test making it a bit more convenient.
2020-05-26 11:36:47 +03:00
Roman Khimov
5432530df4
result: use witnesses field in result.Header JSON
...
Follow new Neo 3.0 standard for these outputs.
2020-05-26 11:36:47 +03:00
Roman Khimov
7633439845
rpc/block: rework the way Block is JSONized
...
Our block.Block was JSONized in a bit different fashion than result.Block in
its NextConsensus and Index 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 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.Block which is
to be serialized in proper way.
Fix `Script` JSONization along the way, 3.0 node wraps it within `witnesses`.
2020-05-26 11:36:47 +03:00
Roman Khimov
393ce1c230
rpc/server: add notification filters
...
And check state string correctness on unmarshaling.
2020-05-26 11:36:47 +03:00
Roman Khimov
725b47ddef
rpc/client: add support for notification filters
...
Differing a bit from #895 draft specification, we won't add `sender` or
`cosigner` to `transaction_executed`.
2020-05-26 11:36:47 +03:00
Roman Khimov
c4c080d240
rpc: add subscriber queue overflow check
...
Server-side test is added, but disabled because of its unreliability.
2020-05-26 11:36:47 +03:00
Roman Khimov
bef14977a2
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-26 11:36:47 +03:00
Roman Khimov
fc22a46a4c
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-26 11:36:47 +03:00
Roman Khimov
612500ed96
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-25 00:27:39 +03:00
Anna Shaleva
9f2cb1726b
core: add witness check to nep5 transfer method
...
We have to check, whether transaction's sender is authorised to transfer
nep5 assets.
2020-05-20 23:34:27 +03:00
Anna Shaleva
1afd630169
core: add senders' fees monitor to mempool
...
In order to simplify maintainance of overall current senders` fees
in the mempool we are to keep them in a separate map.
2020-05-20 23:34:25 +03:00
Anna Shaleva
7acf5b2841
core: add SystemFee and NetworkFee to transaction
...
closes #831
2020-05-20 23:26:48 +03:00
Evgenii Stratonikov
22067d400d
rpc: update testchain
2020-05-20 17:45:56 +03:00
Evgenii Stratonikov
0cb6dc47e4
vm: implement slot-related opcodes
...
1. Slot is a new mechanism for storing variables during execution
which is more convenient than alt.stack. This commit implements
support for slot opcodes in both vm and compiler.
2. Remove old alt.stack opcodes.
3. Do not process globals at the start of every function, but instead
load them single time at main.
2020-05-12 16:23:08 +03:00
Evgenii Stratonikov
c0147c76ac
emit: remove tailCall argument from AppCall
...
There is no TAILCALL opcode in NEO3.
2020-05-07 14:59:01 +03:00
Evgenii Stratonikov
73c82584a3
vm,compiler: replace APPCALL with System.Contract.Call
...
Contract calls are performed via syscall System.Contract.Call
in NEO3. This implements this in compiler and removes APPCALL from the
VM.
2020-05-07 14:52:03 +03:00
Evgenii Stratonikov
f9f3192b48
vm: move RET and SYSCALL opcodes
2020-05-07 13:23:05 +03:00
Evgenii Stratonikov
977c431bf1
vm: implement ASSERT/ABORT opcodes
...
Rename THROWIFNOT to ASSERT, add ABORT opcode.
ABORT cannot be caught, but the implementation should be postponed until
exception handling is implemented.
2020-05-06 15:54:19 +03:00
Roman Khimov
963a70d54a
Merge pull request #926 from nspcc-dev/feature/stack
...
Implement NEO3 VM stack opcodes
2020-05-06 14:51:04 +03:00
Roman Khimov
7287c01bd0
rpc/server: rework submitblock empty test
...
The original intention here was to check for server reaction in presence of
validation errors (response.ErrValidationFailed) and it was very easy to make
validation fail for block without transactions in Neo 2. But in Neo 3
transactionless blocks are perfectly valid (see
29d321b5e1
) which broke this test even though we
didn't see it until websocket addition (which required
8cec6694ae
to make this test work initially).
So make a valid block and then spoil its verification script.
2020-05-06 14:20:35 +03:00
Roman Khimov
fd72f0635e
rpc/server: prevent test panicing in checkErrGetResult()
...
If we expect some resp.Error, then check for it explicitly.
2020-05-06 13:11:12 +03:00
Evgenii Stratonikov
dd20320615
vm: remove XSWAP/XTUCK opcodes
...
Regenerate RPC testchain as these were used in compiler.
2020-05-06 13:05:22 +03:00
Evgenii Stratonikov
525527f750
vm: reorder stack opcodes
...
Leave *ALTSTACK opcodes for now as they are needed in compiler while
slot opcodes are not yet here.
2020-05-06 13:02:14 +03:00
Roman Khimov
b04c8623c5
Merge pull request #925 from nspcc-dev/rpc-over-websocket
...
RPC over websocket
2020-05-06 12:52:58 +03:00
Roman Khimov
ec6ade4c9b
Merge pull request #920 from nspcc-dev/neo3/transaction/cosigners
...
core: implement cosigners mechanism
2020-05-04 17:15:07 +03:00
Roman Khimov
3de48d7d90
rpc/client: add minimalistic websocket client
2020-05-04 16:54:35 +03:00
Roman Khimov
a458a17748
rpc/client: separate out http-related functionality
2020-05-04 16:54:35 +03:00
Roman Khimov
6d202ad4c5
rpc/client: drop Version from Options
...
It makes no sense at all, it's a JSON-RPC version.
2020-05-04 16:54:35 +03:00
Roman Khimov
19397ec4a8
rpc/client: fix some comments
2020-05-04 16:54:35 +03:00
Roman Khimov
20d477cbd8
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-05-04 16:54:35 +03:00
Roman Khimov
315aabde56
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-05-04 16:54:35 +03:00
Roman Khimov
ec62edac68
rpc/server: add websockets support via '/ws' URL
2020-05-04 16:54:35 +03:00
Roman Khimov
8cec6694ae
rpc/server: fix test block encoding
...
The end result of the previous code wasn't even a valid JSON.
2020-05-04 16:54:35 +03:00
Roman Khimov
d275652b37
rpc/server: use httptest.Server for testing
...
Which allows to reuse it for websockets.
2020-05-04 16:54:35 +03:00
Roman Khimov
1b523be4b6
rpc: shuffle handleHttpRequest/handleRequest responsibilities
...
Make handleRequest reusable in other contexts like websockets.
2020-05-04 13:57:23 +03:00
Roman Khimov
236f3dabdd
rpc: change handlers to always return response.Error for errors
...
As it's expected by WriteErrorResponse() actually.
2020-05-04 13:57:15 +03:00
Roman Khimov
57de98e1a3
rpc/server: refactor handler methods a little
...
request.In is a natural request representation, one can always get
request.Params from it.
2020-05-04 13:57:08 +03:00
Anna Shaleva
73167999cc
core: add cosigners field to transaction
...
closes #864
2020-05-04 11:53:31 +03:00
Anna Shaleva
08f5708edb
core: remove Script attribute type
2020-05-04 11:49:14 +03:00
Anna Shaleva
861aca1547
rpc, smartcontract: move contract metadata to smartcontract package
2020-05-04 08:37:39 +03:00
Evgenii Stratonikov
a64a0f2681
vm: reorder arithmetic opcodes
2020-04-30 18:00:15 +03:00
Anna Shaleva
29d321b5e1
*: drop miner transaction
...
1. Completely remove miner transaction
2. Change validation rule for block: block without transactions is
valid.
2020-04-27 17:57:37 +03:00
Anna Shaleva
55fd9f8d24
core: change block.ConsensusData to neo3 format
...
1. Dropped `Base.ConsensusData` block field
2. Added `Block.ConsensusData` field with `Nonce` and `PrimaryIndex`
3. Removed "Neo.Header.GetConsensusData" and
"AntShares.Header.GetConsensusData" interops
2020-04-27 17:57:37 +03:00
Anna Shaleva
0de5cb1bde
core, consensus: nanoseconds-precision timestamp
...
Keep timestamp of consensus messages in nanoseconds-precision state
2020-04-27 17:57:32 +03:00
Anna Shaleva
aa554f0a9a
core: update block timestamp format
...
Changed block.Timestamp from uint32 to uint64
2020-04-27 17:56:44 +03:00
Roman Khimov
b83e84ca08
core: switch to the new voting system (via native NEO contract)
...
It has all the methods required now, so you can register, vote and get
voting results. Fixes #865 .
2020-04-27 16:06:50 +03:00
Roman Khimov
2fa3bdf6a9
core/native: move Votes from account to native NEO state
2020-04-27 12:30:39 +03:00
Anna Shaleva
869c7d6afa
core: init native interops in the genesis block
...
closes #836
2020-04-27 12:30:39 +03:00
Evgenii Stratonikov
03761421f8
vm: reorder Array/Map opcodes
...
Also SIZE can be used for both Arrays/Maps and ByteArrays.
2020-04-24 13:48:44 +03:00
Evgenii Stratonikov
d6624a92ca
vm: implement new JMP* and CALL* opcodes
...
In compiler JMP*_L opcodes are always used, as this requires less effort.
2020-04-24 10:16:41 +03:00
Evgenii Stratonikov
7caa81a81c
rpc/test: generate block for submitblock on-the-fly
...
There is no need to provide hex when chain is dumped.
2020-04-24 08:54:22 +03:00
Evgenii Stratonikov
76a6937f32
rpc: simplify getblockheader RPC test
...
Set up hash once and get header via provided chain.
2020-04-23 17:09:08 +03:00
Evgenii Stratonikov
008e6eb233
vm: implement new PUSH opcodes
2020-04-23 10:52:28 +03:00
Evgenii Stratonikov
1e50016a91
core,test: move helper functions for testchain to the internal package
...
Our test chain is used in core,rpc and (in future) interop packages.
It is better to have all related declarations in one place to avoid
code duplication.
2020-04-22 18:17:11 +03:00
Anna Shaleva
2b5c14160c
core: add sender field to transaction
...
closes #860
2020-04-20 17:21:28 +03:00
Evgenii Stratonikov
941410a840
core: change verification scripts to new format
...
Verification scripts now invoke Neo.Crypto.* interops instead of
CHECKSIG/VERIFY opcodes.
2020-04-20 11:55:24 +03:00
Anna Shaleva
b809d09b24
rpc: add validUntilBlock to transferNEP5
...
In #856 I forgot to add validUntilBlock to NEP5 transfer transaction,
so added now.
2020-04-17 13:52:23 +03:00
Evgenii Stratonikov
ceff8736f2
vm: use ID-based syscalls
...
In NEO3 SYSCALL opcode has 4-byte ID parameter.
This commit removes support for string-based syscalls and
changes SYSCALL's parameter to be fixed 4-byte value.
2020-04-17 11:46:31 +03:00
Anna Shaleva
70da3c86f1
rpc: fix typo
...
Fixed typo in annotation of CalculateInputs method of RPC Client.
2020-04-15 13:46:44 +03:00
Anna Shaleva
5fa11987d2
core: add validUntilBlock field to transaction
...
1. closes #841
2. Commented out test cases where binary transaction are used.
These test cases marked with `TODO NEO3.0: Update binary` and need to be
updated.
3. Updated other tests.
4. Added cache to calculateValidUntilBlock() RPC-client method.
2020-04-15 13:46:43 +03:00
Roman Khimov
1e3c36433f
Merge pull request #844 from nspcc-dev/neo3/nonce
...
core: add nonce field to transaction
2020-04-14 16:24:02 +03:00
Anna Shaleva
65503aa9b4
core: add nonce field to transaction
...
1. Closes #840 : added Nonce field to transaction.Transaction and
removed Nonce field from transaction.MinerTx
2. Added following methods to different tx types:
- NewMinerTx()
- NewMinerTxWithNonce(...)
- NewEnrollmentTx(...)
- NewIssueTx()
- NewPublishTx(...)
- NewRegisterTx(...)
- NewStateTx(...)
in order to avoid code duplication when new transaction is created.
3. Commented out test cases where binary transaction/block are used.
These test cases marked with `TODO NEO3.0: Update binary` and need to be
updated.
4. Updated other tests
5. Added constant Nonce to GoveringTockenTx, UtilityTokenTx and genesis
block to avoid data variability. Also marked with TODO.
2020-04-14 16:19:41 +03:00
Anna Shaleva
d1f92a585b
core: add NewTransactionFromBytes method to Transaction
...
Added `NewTransactionFromBytes(b []byte)` method to
transaction.Transaction in order to avoid code duplication.
2020-04-13 12:04:43 +03:00
Evgenii Stratonikov
a7c19d445b
core: move Blockchainer interface to a separate package
2020-04-11 10:56:36 +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
Roman Khimov
4b83e9a5cd
Merge pull request #732 from nspcc-dev/feature/getvalidators
...
rpc: implement getvalidators
2020-03-07 21:43:38 +03:00
Anna Shaleva
456a2d55fd
rpc: implement getvalidators
...
closes #714
2020-03-07 18:05:40 +03:00
Evgeniy Kulikov
b34ac22434
[rpc/server] fix getblock verbose response
...
- Nonce should not trim leading zeros
- NextConsensus should returns address (uint160 -> base58)
2020-03-06 19:53:11 +03:00
Roman Khimov
f8eee778f4
Merge pull request #724 from nspcc-dev/feature/submitblock
...
rpc: implement submitblock
2020-03-06 12:08:45 +03:00
Anna Shaleva
2031d8d103
rpc: add custom errors to sendrawtransaction
...
In case of unsuccessful relyReason sendRawTransaction should return
errors with codes [-500, ..., -505] instead of error with code -32603
2020-03-06 12:04:51 +03:00
Anna Shaleva
a746d8e6e6
rpc: implement submitblock RPC
...
closes #344
2020-03-06 12:03:08 +03:00
Anna Shaleva
ccd88c3af8
rpc: implement gettransactionheight
...
closes #713
2020-03-05 19:34:11 +03:00
Anna Shaleva
5cfa1bc2a8
rpc: fixed getblockheader tests
2020-03-05 19:16:22 +03:00
Roman Khimov
fbdc60b731
Merge pull request #723 from nspcc-dev/feature/nep5
...
core,rpc: implement NEP5-related logic
2020-03-05 18:33:58 +03:00
Evgenii Stratonikov
c019ce565f
rpc: move test contract hash to constant
...
When changing test chain it can be rather annoying
to replace all of the occurences of the contract hash.
2020-03-05 18:26:55 +03:00
Evgenii Stratonikov
547bd3bde3
rpc: display for NEP5 token amount properly
...
Every NEP5 contract MUST have `decimals` method which
is used to properly display token amount.
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
95a8fa234f
rpc: implement getnep5transfers RPC
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
2757882d26
rpc: implement getnep5balances RPC
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
6d270c4550
core,rpc: add NEP5 contract to testdata
...
Also transfer tokens between accounts.
2020-03-05 18:22:40 +03:00
Roman Khimov
b273f3126a
Merge pull request #722 from nspcc-dev/feature/getblockheader
...
rpc: implement getblockheader RPC
2020-03-05 17:18:54 +03:00
Anna Shaleva
42e2aff381
rpc: implement getblockheader RPC
...
closes #711
2020-03-05 14:47:45 +03:00
Roman Khimov
81d89cd502
core: fix SystemFee calculation for Invocation TXes
...
They have it specified right in the transaction. Unfortunately, this little
change rendered invalid our RPC test chain, but I think it became even better
after it, especially given that chain generation is a nice test by itself, so
it should be running as a regular test.
2020-03-04 19:23:23 +03:00
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