Commit graph

120 commits

Author SHA1 Message Date
Anna Shaleva
9a493dd2a0 rpc: add FaultException to result.Invoke
Close #1440
2020-10-08 16:12:14 +03:00
Roman Khimov
0e5a2f34c0
Merge pull request #1449 from nspcc-dev/rpc/client/getcvalidators_fix
rpc: getvalidators -> getnextblockvalidators
2020-10-02 13:30:58 +03:00
Anna Shaleva
fa0bd9f46b rpc: getvalidators -> getnextblockvalidators
We don't have `getvalidators` RPS call, there's only
`getnextblockvalidators` in the reference implementation.
2020-10-01 17:09:14 +03:00
Evgenii Stratonikov
fa09b9af7b transaction: rename FeeOnly to None
Follow missed change from neo-project/neo#1816 .
`None` may be used for any signer. Currently it is used
for sender to only pay fees, or to sign tx attributes.
2020-10-01 15:28:19 +03:00
Roman Khimov
6b7ca0ce3f rpc/server: limit the maximum number of elements for get*transfers 2020-09-22 16:45:01 +03:00
Roman Khimov
970de84130 rpc: add paging to getnep5transfers call
And add some tests.
2020-09-22 16:40:29 +03:00
Roman Khimov
c50ff7f20e rpc/server: refactor parameter parsing for getnep5transfers 2020-09-21 22:38:59 +03:00
Roman Khimov
e4b52d3947 core/rpc: add continue flag to iterating functions
Most of the time we don't need to get all transfers from the DB and
deserialize them.
2020-09-21 22:23:34 +03:00
Roman Khimov
6902003044 rpc/server: add limit to get*transfers calls
Return only N transfers requested.
2020-09-21 18:03:59 +03:00
Anna Shaleva
770c8d774c core, rpc: add GetCommittee method
Closes #1414
2020-09-21 15:56:25 +03:00
Anna Shaleva
c6f099294b core: do not marshal block hash in application log
Closes #1388
2020-09-21 14:08:15 +03:00
Evgenii Stratonikov
758a88a813 rpc: exit from Start after Listener is running
If port is dynamically allocated, `(*Server).Addr` will contain
0 port. This commit executes listener before exiting from `Start()`
and sets Addr to the actual address.
2020-09-18 12:05:31 +03:00
Roman Khimov
af17bbfeab rpc/server: encode answers more efficiently
We're at the point where even this code can clearly be seen in profiles. We
can save on some buffers (and CPU cycles) by encoding the answer once.

Another ~2% TPS for single node.
2020-09-09 20:46:31 +03:00
Anna Shaleva
acacac1b24 rpc: use state.AppExecResult for ApplicationLog marshalling
Closes #1371
2020-09-07 13:38:32 +03:00
Roman Khimov
6e252fbaae rpc: answer with zero-length when there are no registered validators
There is a huge difference between
   "result" : [],
and
   "result" : null,
2020-08-10 17:50:19 +03:00
Evgenii Stratonikov
412fc53cdd rpc: provide timestamps in getnep5transfers
Set default value for the first timestamp to a week ago.
2020-08-07 18:42:34 +03:00
Evgenii Stratonikov
807338f97e core: do not store NEP5 transfer log in memory
Traversing transfer log instead of accumulating and returning it
is faster and takes less memory.
2020-08-07 18:21:06 +03:00
Roman Khimov
0e2784cd2c always wrap errors when creating new ones with fmt.Errorf()
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
2020-08-07 12:21:52 +03:00
Roman Khimov
205f52c563 core: use error wrapping to provide more details 2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae remove github.com/pkg/errors from dependencies
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
Anna Shaleva
90825efa16 core: move transaction's sender to cosigners
Closes #1184

Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00
Evgenii Stratonikov
9cba25616d rpc: use raw stack items in invoke* RPC
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Anna Shaleva
167bd7d9df rpc: store decimals by contract ID instead of hash
And we should also cache contract scripthash to fill Asset field.
2020-07-29 15:15:48 +03:00
Anna Shaleva
0dd1730632 core: store NEP5Transfer asset by ID instead of hash
To avoid problems with retrieving decimals for migrated contracts.
2020-07-29 15:15:48 +03:00
Anna Shaleva
b9bdab8ec8 core: store nep5balances using contract id
Closes #1194
2020-07-29 15:15:48 +03:00
Anna Shaleva
1f5794b316 rpc: make getDecimals return a standard error
`getDecimals` is an internal method, wo there's no need to return
response.Error.
2020-07-29 15:14:24 +03:00
Anna Shaleva
0c424a0ed2 rpc: update getrawtransaction RPC call
Closes #1183.

Added VMState to transaction output raw.
2020-07-29 10:14:08 +03:00
Anna Shaleva
70ef733ce7 core, vm: store VMState as byte instead of string
Part of #1183
2020-07-29 10:14:08 +03:00
Anna Shaleva
990db9f205 rpc: update getrawmempool RPC-call result
Closes #1182
2020-07-29 10:14:01 +03:00
Anna Shaleva
889a5d7eb6 rpc: adjust submitblock RPC-call
It should return block hash instead of boolean.
2020-07-22 08:37:53 +03:00
Anna Shaleva
c2534b1a0b rpc: adjust sendrawtransaction RPC-call
It should return tx has instead of boolean.
2020-07-22 08:37:46 +03:00
Evgenii Stratonikov
a6fc5cfdf1 rpc: support raw address in getnep5transfers RPC 2020-07-17 18:51:13 +03:00
Evgenii Stratonikov
c4c2ce1465 rpc: support stringified address in getnep5balances RPC 2020-07-17 18:51:13 +03:00
Roman Khimov
f46ed798f0
Merge pull request #1169 from nspcc-dev/neo3/rpc/fields_names_adjustment
rpc: adjust RPC calls JSON fields
2020-07-15 18:24:54 +03:00
Anna Shaleva
2ab23dc56a rpc: adjust getunclaimedgas RPC-call
Part of #1130
2020-07-15 14:45:51 +03:00
Roman Khimov
5ba4f3ef08 rpc: set transaction's script for test invocation
GetScriptContainer() interop can try to get this transaction and this attempt
will lead to hash calculation with transaction serialization, but transaction
can't be successfully serialized if it doesn't have a script set, so this
makes test invocations fail.
2020-07-14 18:05:49 +03:00
Anna Shaleva
abe3c94b95 core: use big.Int to store NEP5 balances
closes #1133
2020-07-09 13:26:39 +03:00
Anna Shaleva
1755ce10ac rpc: make getapplicationlog error more deterministic 2020-07-06 15:04:28 +03:00
Anna Shaleva
0aaaf7f787 *: switch from fixed8 to int64 in (Blockchain).CalculateClaimable 2020-06-29 21:40:54 +03:00
Anna Shaleva
73b630db9b *: switch from fixed8 to int64
Follow C# implementation, we have to marshall JSON Fixed8 fields without
taking into account decimals.
2020-06-29 21:39:27 +03:00
Evgenii Stratonikov
bed08d3f89 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-27 12:13:06 +03:00
Evgenii Stratonikov
35f952e44f rpc/server: simplify errors handling during parameter parsing
Forward-ported from 2.x with some updates.
2020-06-27 12:11:21 +03:00
Roman Khimov
a187336830 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:35:27 +03:00
Anna Shaleva
f1cdcbc99c core: store smartcontract items by id
closes #1037
2020-06-19 20:48:45 +03:00
Evgenii Stratonikov
c0e482fe6c rpc: restructure getapplicationlog response
Move VM-related fields to top-level.
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
c9df5d3aed rpc: fix typo in getnep5transfers rpc
Omit empty address for transfers in both directions.
2020-06-18 16:31:33 +03:00
Roman Khimov
b483c38593 block/transaction: add network magic into the hash
We make it explicit in the appropriate Block/Transaction structures, not via a
singleton as C# node does. I think this approach has a bit more potential and
allows better packages reuse for different purposes.
2020-06-18 12:39:50 +03:00
Evgenii Stratonikov
a7d4fff897 vm: make (*VM).GasLimit public
VM is inherently single-threaded and replacing setter/getter methods
with public field simplifies code a bit.
2020-06-16 15:13:20 +03:00
Roman Khimov
fe31c7ed2d
Merge pull request #1047 from nspcc-dev/neo3/rpc/invoke
rpc: update invoke* RPC-calls
2020-06-11 21:39:20 +03:00
Anna Shaleva
d5355acfa9 rpc: update RPC server invoke* calls
part of #1036
2020-06-11 19:34:13 +03:00