Roman Khimov
45b353781f
rpcclient: correctly handle request channel closure
...
wsReader() closes c.done first and then goes over the list of
c.respChannels. Technically this means that any of the two can be taken in
this select.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-04-18 19:36:27 +03:00
Anna Shaleva
8149d33fef
config: use uint32 for validators/committee members count
...
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-04-13 13:42:40 +03:00
Erik van den Brink
f479b2bc57
neorpc: change peer port to int type (fixes nspcc-dev#2910)
2023-04-06 18:33:09 +02:00
Roman Khimov
c053f1a4af
Merge pull request #2957 from nspcc-dev/rm-go-17
...
*: drop go 1.17 support
2023-04-04 15:25:14 +03:00
Anna Shaleva
6b21ad9922
*: replace interface{}
with any
keyword
...
Everywhere including examples, external interop APIs, bindings generators
code and in other valuable places. A couple of `interface{}` usages are
intentionally left in the CHANGELOG.md, documentation and tests.
2023-04-04 13:22:42 +03:00
Roman Khimov
1633ae32df
Merge pull request #2954 from ZhangTao1596/fix-format
...
Fix lint jobs issues
2023-03-31 09:49:39 +03:00
ZhangTao1596
d36df15878
ci: fix lint issues ( fix #2948 )
2023-03-29 11:19:23 +08:00
ZhangTao1596
f21e618be5
rpcclient: add GetProof and VerifyProof ( fix #2942 )
2023-03-23 17:03:22 +08:00
Roman Khimov
0d5613cfcb
Merge pull request #2938 from nspcc-dev/failing-actor-test
...
actor: don't close already closed channel, fix #2932
2023-03-17 11:46:31 +03:00
Roman Khimov
da7eafd4c7
Merge pull request #2937 from nspcc-dev/copy-wsclient-filters
...
Copy wsclient filters
2023-03-17 10:49:13 +03:00
Roman Khimov
e197f3faef
rpcclient: copy subscription params, fix #2890
...
Clients can change things and we better be safe here.
2023-03-17 10:33:30 +03:00
Roman Khimov
e84ea0207d
actor: don't close already closed channel, fix #2932
...
Waiter should close its channels, but WSClient can also do that and it can do
that in a drain loop as well.
2023-03-17 09:57:41 +03:00
Roman Khimov
74623e64bc
rpcclient: improve wsclient doc, fix #2895
2023-03-16 21:27:35 +03:00
Anna Shaleva
5f6c01336c
*: add nolint comments to multiple errors wrapping
...
To be enabled after go 1.20 support is added.
2023-03-15 16:38:01 +03:00
Roman Khimov
475d9de2d5
Merge pull request #2916 from nspcc-dev/not-so-local-client
...
Not so local RPC client
2023-02-20 10:38:30 +03:00
Roman Khimov
6f7fed344b
rpcclient: add Internal client for direct RPC server calls
...
It has a special `requestF` and a special initialization function, but other
than that it's an absolutely regular WSClient. Can be used to call, can be
used to subscribe. Fixes #2909 .
2023-02-16 23:49:58 +03:00
Erik van den Brink
3bdb3a87b8
rpcclient: expose endpoint ( fixes #2912 )
2023-02-15 08:29:44 +01:00
Anna Shaleva
51a28fac8d
rpcclient: adjust new subscriptions API doc
...
Add a warning about consequences of unproper notifications reading.
Ref. https://github.com/morphbits/neofs-cdn-edge-manager/pull/88#discussion_r1088007680 .
2023-01-30 14:36:11 +03:00
Leonard Lyubich
cbdc6ba469
rpcclient/actor: Document RPCActor.CalculateNetworkFee
method
...
`Actor.MakeUnsignedUncheckedRun` method imposes restriction to
`CalculateNetworkFee` method's implementations: `Hash` or `Size` methods
must not be called on the pointer to the given transaction.
Add docs to adjust described requirement.
Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
2023-01-17 21:28:20 +03:00
Anna Shaleva
28927228f0
*: adjust subscription-related doc
...
Add a warning about received events modification where applicable.
2023-01-17 17:11:19 +03:00
Anna Shaleva
2c0844221a
rpcclient: fix filtered naive subscriptions receiver
...
We should return the filter itself instead of pointer.
2022-12-07 16:56:16 +03:00
Roman Khimov
d909cab4a4
rpcclient/management: add new methods
2022-12-02 10:57:05 +03:00
Roman Khimov
93cec0bba5
Merge pull request #2786 from nspcc-dev/simplify-getversion
...
Simplify result.Version
2022-12-02 14:07:55 +07:00
Roman Khimov
fb09670fd1
rpcclient: extract more detailed server-side on WS connection problem
...
If available. Fixes #2818 .
2022-11-23 12:19:35 +03:00
Roman Khimov
fd04b2befd
actor: don't abort waiter on "already exists" error
...
It can happen in many cases of distributed tx generation/submission, we can
just wait normally in this case and there will be some proper result.
2022-11-23 10:07:37 +03:00
Roman Khimov
cd6bb68246
actor: check for tx after the subscription in wsWaiter, fix #2805
...
Don't wait for VUB block, solve this race immediately.
2022-11-22 17:28:55 +03:00
Roman Khimov
c95d140113
rpcclient: always return tx hash from sendrawtransaction
...
Let upper-layer APIs like actor.Send() return it as well. Server can return
"already exists" which is an error and yet at the same time a very special
one, in many cases it means we can proceed with waiting for the TX to settle.
2022-11-22 15:18:37 +03:00
Anna Shaleva
1399496dfb
rpcclient: refactor event-based waiting loop
...
Avoid receiver channels locks.
2022-11-16 23:57:00 +03:00
Anna Shaleva
95e23c8e46
actor: fix event-based tx awaiting
...
If VUB-th block is received, we still can't guaranty that transaction
wasn't accepted to chain. Back this situation by rolling back to a
poll-based waiter.
2022-11-16 23:44:31 +03:00
Anna Shaleva
6dbae7edc4
rpcclient: fix WS-client unsubscription process
...
Do not block subscribers until the unsubscription request to RPC server
is completed. Otherwise, another notification may be received from the
RPC server which will block the unsubscription process.
At the same time, fix event-based waiter. We must not block the receiver
channel during unsubscription because there's a chance that subsequent
event will be sent by the server. We need to read this event in order not
to block the WSClient's readloop.
2022-11-16 23:44:30 +03:00
Anna Shaleva
3f122fd591
rpcclient: adjust WS waiter error formatting
...
Follow the other errors formatting style.
2022-11-16 12:22:18 +03:00
Roman Khimov
b5c79f4be3
unwrap: add a complete set of simple array unwrappers
...
Arrays of basic types should be covered completely.
2022-11-14 13:01:13 +03:00
Roman Khimov
7f8a79ffaa
result: drop deprecated Magic and StateRootInHeader from Version
...
It's more than a year now we have them deprecated.
2022-11-10 16:32:49 +03:00
Roman Khimov
bb47d971dc
rpcclient/nep11: make DivisibleWriter part reusable
...
Same rationale as for BaseWriter or nep17.TokenWriter, otherwise it's hard to
build on top of plain Divisible structure.
2022-11-07 10:44:39 +03:00
Roman Khimov
b590d4ca04
Merge pull request #2766 from nspcc-dev/rpc-wrapper-autogen
...
Rpc wrapper autogeneration
2022-10-28 11:54:47 +07:00
Roman Khimov
f0abc035af
unwrap: add PublicKey to unwrap public keys
...
We have this type in NEP-14 directly.
2022-10-27 18:32:00 +03:00
Anna Shaleva
4fc11c2924
rpc: revert deprecated subscriptions API changes
...
Revert deprecated subscriptions-related method signature changed in
673a495527
, 8e84bb51d5
and d7c1f3eac7
.
2022-10-26 15:32:54 +03:00
Anna Shaleva
5811687836
rpc: fix bug in Actor's waiter
...
Execution events are followed by block events, not vise versa, thus,
we can wait until VUB block to be accepted to be sure that
transaction wasn't accepted to chain.
2022-10-26 15:32:54 +03:00
Anna Shaleva
0a5905390c
rpc: refactor WSClient subscriptions API
...
Make it more specific, close #2756 .
2022-10-26 15:32:54 +03:00
Anna Shaleva
3cccc89dac
rpc: add Wait wrapper to Notary actor
2022-10-24 06:09:36 +03:00
Anna Shaleva
1a6f1c805c
rpc: fix race in TestWSClientEvents
...
```
2022-10-21T08:59:45.2219797Z === RUN TestWSClientEvents/default_ntf_channel
2022-10-21T08:59:45.2219901Z ==================
2022-10-21T08:59:45.2220017Z WARNING: DATA RACE
2022-10-21T08:59:45.2220177Z Write at 0x00c000c82778 by goroutine 371:
2022-10-21T08:59:45.2220580Z github.com/nspcc-dev/neo-go/pkg/rpcclient.TestWSClientEvents.func2()
2022-10-21T08:59:45.2221112Z /home/runner/work/neo-go/neo-go/pkg/rpcclient/wsclient_test.go:171 +0x1c4
2022-10-21T08:59:45.2221244Z testing.tRunner()
2022-10-21T08:59:45.2221617Z /opt/hostedtoolcache/go/1.18.7/x64/src/testing/testing.go:1439 +0x213
2022-10-21T08:59:45.2221759Z testing.(*T).Run.func1()
2022-10-21T08:59:45.2222124Z /opt/hostedtoolcache/go/1.18.7/x64/src/testing/testing.go:1486 +0x47
2022-10-21T08:59:45.2222138Z
2022-10-21T08:59:45.2222308Z Previous read at 0x00c000c82778 by goroutine 37:
2022-10-21T08:59:45.2222694Z github.com/nspcc-dev/neo-go/pkg/rpcclient.(*Client).StateRootInHeader()
2022-10-21T08:59:45.2223151Z /home/runner/work/neo-go/neo-go/pkg/rpcclient/rpc.go:1104 +0xb0
2022-10-21T08:59:45.2223482Z github.com/nspcc-dev/neo-go/pkg/rpcclient.(*WSClient).wsReader()
2022-10-21T08:59:45.2224077Z /home/runner/work/neo-go/neo-go/pkg/rpcclient/wsclient.go:210 +0x651
2022-10-21T08:59:45.2224416Z github.com/nspcc-dev/neo-go/pkg/rpcclient.NewWS.func2()
2022-10-21T08:59:45.2224892Z /home/runner/work/neo-go/neo-go/pkg/rpcclient/wsclient.go:149 +0x39
2022-10-21T08:59:45.2224901Z
2022-10-21T08:59:45.2225049Z Goroutine 371 (running) created at:
2022-10-21T08:59:45.2225182Z testing.(*T).Run()
2022-10-21T08:59:45.2225548Z /opt/hostedtoolcache/go/1.18.7/x64/src/testing/testing.go:1486 +0x724
2022-10-21T08:59:45.2225911Z github.com/nspcc-dev/neo-go/pkg/rpcclient.TestWSClientEvents()
2022-10-21T08:59:45.2226408Z /home/runner/work/neo-go/neo-go/pkg/rpcclient/wsclient_test.go:167 +0x404
2022-10-21T08:59:45.2226539Z testing.tRunner()
2022-10-21T08:59:45.2226900Z /opt/hostedtoolcache/go/1.18.7/x64/src/testing/testing.go:1439 +0x213
2022-10-21T08:59:45.2227042Z testing.(*T).Run.func1()
2022-10-21T08:59:45.2227398Z /opt/hostedtoolcache/go/1.18.7/x64/src/testing/testing.go:1486 +0x47
2022-10-21T08:59:45.2227406Z
2022-10-21T08:59:45.2227552Z Goroutine 37 (finished) created at:
2022-10-21T08:59:45.2227851Z github.com/nspcc-dev/neo-go/pkg/rpcclient.NewWS()
2022-10-21T08:59:45.2228327Z /home/runner/work/neo-go/neo-go/pkg/rpcclient/wsclient.go:149 +0x6fb
2022-10-21T08:59:45.2228843Z github.com/nspcc-dev/neo-go/pkg/rpcclient.TestWSClientEvents.func2()
2022-10-21T08:59:45.2229434Z /home/runner/work/neo-go/neo-go/pkg/rpcclient/wsclient_test.go:168 +0x131
2022-10-21T08:59:45.2229569Z testing.tRunner()
2022-10-21T08:59:45.2229930Z /opt/hostedtoolcache/go/1.18.7/x64/src/testing/testing.go:1439 +0x213
2022-10-21T08:59:45.2230069Z testing.(*T).Run.func1()
2022-10-21T08:59:45.2230424Z /opt/hostedtoolcache/go/1.18.7/x64/src/testing/testing.go:1486 +0x47
2022-10-21T08:59:45.2230526Z ==================
2022-10-21T08:59:45.2230703Z wsclient_test.go:186:
2022-10-21T08:59:45.2230988Z Error Trace: wsclient_test.go:186
2022-10-21T08:59:45.2231209Z Error: Should be true
2022-10-21T08:59:45.2231536Z Test: TestWSClientEvents/default_ntf_channel
2022-10-21T08:59:45.2231812Z testing.go:1312: race detected during execution of test
```
2022-10-24 06:09:36 +03:00
Anna Shaleva
d2a9e9120d
rpc: extend Waiter interface to wait for several txs with context
2022-10-24 06:09:36 +03:00
Anna Shaleva
6b216050f3
rpc: add compat tests for RPC* interfaces and Client implementations
2022-10-24 06:09:36 +03:00
Anna Shaleva
00d44235c1
rpc: add tests for RPC waiters
2022-10-24 06:09:36 +03:00
Anna Shaleva
388112dcaa
rpc: mark old WSClient's SubscribeFor* methods as deprecated
2022-10-24 06:09:36 +03:00
Anna Shaleva
5b81cb065f
rpc: refactor waiter-related actor code
2022-10-24 06:09:36 +03:00
Anna Shaleva
8e84bb51d5
rpc: add "till" filter to WS block events
2022-10-24 06:09:36 +03:00
Anna Shaleva
345d48d051
rpc: improve WS-based transaction awaiting
...
Subscribe only for required aers.
2022-10-24 06:09:36 +03:00
Anna Shaleva
d7c1f3eac7
rpc: add "container" filter to WS execution notifications
2022-10-24 06:09:36 +03:00
Anna Shaleva
71069b0ed0
rpc: improve WS-enabled transaction awaiting
...
Fetch blocks since VUB+1, if block received and we haven't returned the
result yet, then transaction wasn't accepted at all.
2022-10-24 06:09:36 +03:00
Anna Shaleva
673a495527
rpc: add "since" filter to WS block events
2022-10-24 06:09:36 +03:00
Anna Shaleva
10a0716217
rpc: implement transaction awaiting functionality
...
Close #2704 .
2022-10-24 06:09:36 +03:00
Anna Shaleva
6d38e75149
rpc: support multiple WSClient notification receivers
2022-10-24 06:09:36 +03:00
Anna Shaleva
4ce6bc6a66
rpc: adjust comment to Notification value cast
...
And explicitly specify field names on Notification creation.
2022-10-24 06:09:36 +03:00
Roman Khimov
317dd42513
*: use uint*Size and SignatureLen constants where appropriate
2022-10-05 10:45:52 +03:00
Roman Khimov
d40eb79975
rpcclient: simplify historic API
...
util.Uint256 is util.Uint256 and it's same RPC behind the scenes, so we can
make it a bit easier to digest. See #2545 also.
2022-09-09 13:41:45 +03:00
Roman Khimov
541d4b49e1
context: define a constant for transaction context type
2022-09-08 14:33:04 +03:00
Roman Khimov
6be9367f03
rpcclient/notary: add OnNEP17PaymentData and an example
...
Update documentation as well to mention it and not mention outdated APIs. We
can't link them yet, this will be done after the release.
2022-09-08 14:33:04 +03:00
Roman Khimov
3c02177d3c
rpcclient: improve comments for some methods
2022-09-08 14:33:04 +03:00
Roman Khimov
3e8e6857e5
rpcclient; deprecate more methods
...
They make little sense now.
2022-09-08 14:33:04 +03:00
Roman Khimov
c4ddf80742
rpcclient: correct Init requirement in documentation
2022-09-08 14:33:04 +03:00
Roman Khimov
ee55e95c28
rpcclient: add examples for nep11/nep17/neo
...
GAS doesn't need any, so just mention nep17 package there.
2022-09-08 14:33:04 +03:00
Roman Khimov
a1c9871d95
nns: it's NEP-11, so make NEP-11 methods available too
2022-09-08 14:33:04 +03:00
Roman Khimov
186e5c19b6
rpcclient: update documentation, mention subpackages
...
Drop TODOs (we have relevant GitHub issues), drop verbosity comment (we have
*Verbose APIs for that).
2022-09-08 14:33:04 +03:00
Roman Khimov
cb1a1f8532
actor: extend documentation, add example
2022-09-08 14:33:04 +03:00
Roman Khimov
e1fe76137e
rpcclient: use separate reader/writer structs in nep11 and nep17
...
Which greatly simplifies reuse of these packages (and they're expected to be
reused since real tokens implement standards and also add something of their
own) and allows to avoid effects like
doc_test.go:68:28: ambiguous selector neoContract.BalanceOf
when neo.Contract is used. Avoids duplication in NEP-11 implementation as
well.
2022-09-08 14:33:03 +03:00
Roman Khimov
00a9376311
invoker: update documentation, add example
2022-09-08 14:33:03 +03:00
Roman Khimov
aca8ce0d28
unwrap: provide ErrNoSessionID, add some explanations
2022-09-07 22:40:25 +03:00
Roman Khimov
c703ac6805
golangci: enable contextcheck linter, fix WSClient
...
pkg/rpcclient/wsclient.go:93:30 contextcheck Function `Dial` should pass the context parameter
2022-09-02 18:35:54 +03:00
Roman Khimov
3c009271f8
golangci: enable bodyclose checker and fix related code
...
It has found an issue in the oracle code, so I think it's worth doing.
2022-09-02 18:35:54 +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
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
673c8954cc
Merge pull request #2665 from nspcc-dev/notary-rpcclient
...
Notary RPC client
2022-08-30 12:43:13 +03:00
Roman Khimov
07f3023e84
rpcclient: add notary.Actor for seamless notary experience
2022-08-30 11:47:56 +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
a95984febf
actor: allow providing default attributes/hooks to be used
...
Which expands Actor use cases greatly.
2022-08-29 15:08:37 +03:00
Roman Khimov
a3f32bf306
neptoken: move BalanceOf implementation to Base from nep11/nep17
...
It's the same, even though standards define parameter name in a bit different
way.
2022-08-26 21:52:19 +03:00
Roman Khimov
0d9158bd79
rpcclient: add enough of NNS into nns to deprecate NNS methods
2022-08-26 19:45:37 +03:00
Roman Khimov
2f8896f7a1
rpcclient: add notary subpackage with the notary contract wrapper
2022-08-26 18:21:58 +03:00
Roman Khimov
a2c4a7f611
rpcsrv: adjust for paid attritbutes in calculatenetworkfee
...
calculatenetworkfee MUST calculate complete proper network fee, if we have
some extensions enabled and some attributes should be paid for that they're a
part of the equation too.
2022-08-23 15:34:18 +03:00
Roman Khimov
f3d83c90b1
rpcsrv: allow invalid contract signatures in calculatenetworkfee
...
See #2805 , it allows to cover more cases like Notary contract that can use
CalculateNetworkFee now instead of AddNetworkFee RPC client API.
2022-08-22 14:55:45 +03:00
Roman Khimov
b2524a3ba9
actor: add Sender helper method
2022-08-19 21:52:43 +03:00
Roman Khimov
c034f94a94
nep17: provide out of the box multitransfer capability
...
It can't replicate the old multitransfer methods in ability to transfer
multiple tokens, but it at the same time can do multiple senders.
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
d0702c2cf9
unwrap: provide ArrayOfUint160
...
It's a popular type as well.
2022-08-19 10:36:44 +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
79051f21c1
invoker: expand the interface with iterator wrappers
...
We need them for iterator-based interfaces. Invoker hides the difference
between different (session/expanded) iterators here.
2022-08-17 16:38:03 +03:00
Roman Khimov
689331b960
unwrap: perform consistency check in SessionIterator
...
C# servers with SessionEnabled=false will return iterator IDs and no session
IDs which can be reported as an error immediately because the iterator can't
be traversed.
2022-08-17 15:08:24 +03:00
Roman Khimov
37619743ad
unwrap: add ArrayOfPublicKeys()
...
This type of result is also popular in the NEO contract.
2022-08-17 12:45:46 +03:00
Roman Khimov
0dbe8b6ce2
rpcclient: add oracle package for OracleContract
2022-08-17 11:42:20 +03:00
Roman Khimov
5c8f3a99dc
rpcclient: add management wrapper for ContractManagement
2022-08-17 11:42:20 +03:00
Roman Khimov
5d5455312a
rpcclient: add policy package for the PolicyContract contract
...
And test it with the RPC server.
Notice that getters still return int64 instead of *big.Int, that's because
these values are very limited and technically could even fit into an int (but
that seems to be too dangerous to use for long-term compatibility).
2022-08-16 12:43:25 +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
ee84a4ab32
rpcclient: add rolemgmt pkg for RoleManagement contract
...
And test it with RPC server.
2022-08-16 12:43:25 +03:00
Roman Khimov
c967005216
rpcclient: add deprecation notices
...
And fix test code using old APIs to pass linter checks.
2022-08-12 18:21:02 +03:00
Roman Khimov
be74cc6b55
cli: use nep17 wrapper to implement commands
2022-08-12 18:21:02 +03:00
Roman Khimov
309358c85b
rpcclient: add new NEP-17 wrapper
2022-08-12 18:21:02 +03:00
Roman Khimov
f155a7f161
rpcclient: move result processing code into unwrap package
...
Which will be reused by upper-layer packages. It can be extended with more
types in future.
2022-08-09 17:38:47 +03:00
Roman Khimov
593fa4cac8
Merge pull request #2632 from nspcc-dev/rpcclient-actor
...
RPC client Actor interface
2022-08-09 17:21:24 +03:00