Commit graph

6509 commits

Author SHA1 Message Date
Roman Khimov
145ebad90e binding: drop the only error condition from TemplateFromManifest
Simplify the interface, we do IsValid() check anyway in the CLI and it covers
this condition as well.
2022-11-09 18:13:45 +03:00
Roman Khimov
be02eea7b1 binding: precompile template, remove useless error condition 2022-11-09 18:13:45 +03:00
Roman Khimov
a7f86dcb7f rpcbinding: generate Expanded methods for iterators
Refs. #2768.
2022-11-09 18:13:45 +03:00
Roman Khimov
d569fe01e6 rpcbinding: initial support for iterators, see #2768
Already better than stackitem.Item.
2022-11-09 18:13:45 +03:00
Roman Khimov
57ec67b375
Merge pull request #2782 from nspcc-dev/websocket-origin
rpcsrv: allow any Origin in WS connections if EnableCORSWorkaround
2022-11-09 13:38:28 +07:00
Roman Khimov
3247aa40a7 rpcsrv: allow any Origin in WS connections if EnableCORSWorkaround
Break origin checks even more. Alternative to #2772.
2022-11-09 09:28:09 +03:00
Roman Khimov
e3c503cee9
Merge pull request #2781 from nspcc-dev/btcd-update
Update 256k1 dependency
2022-11-08 23:50:19 +07:00
Roman Khimov
1e07cacc79 rpcsrv: fix test
client_test.go:1935:
                Error Trace:    /home/rik/dev/neo-go/pkg/services/rpcsrv/client_test.go:1935
                Error:          Should NOT be empty, but was 00000000-0000-0000-0000-000000000000
                Test:           TestClient_Iterator_SessionConfigVariations/sessions_disabled

It's obviously empty, since we have sessions disabled, but it was not
considered to be empty in testify 1.7.0, now it is, see 840cb80149
2022-11-08 18:31:25 +03:00
Roman Khimov
40f1056d43 nft-nd-nns: update neo-go dependency to drop btcec 2022-11-08 18:10:01 +03:00
Roman Khimov
8746d9877e keys: move from btcd/btcec to decred/secp256k1 package
There is a security issue found in github.com/btcsuite/btcd that we don't care
about (we're only using 256k1 implementation), but GitHub complains about
it. We could update to github.com/btcsuite/btcd/btcec/v2, but it's now just a
thin wrapper over github.com/decred/dcrd/dcrec/secp256k1/v4, so we better use
it directly.
2022-11-08 17:59:59 +03:00
Roman Khimov
695f00cfeb
Merge pull request #2778 from nspcc-dev/rpc-wrapper-writer
State-changing methods in RPC wrappers
2022-11-08 21:35:18 +07:00
Roman Khimov
69d8905ad9 rpcbinding: exclude onNEPXXPayment methods from wrappers
They make no sense there.
2022-11-08 17:01:36 +03:00
Roman Khimov
130608ac67 rpcbinding: support writer-only wrappers
"verify" contract doesn't have any safe methods.
2022-11-08 17:01:36 +03:00
Roman Khimov
df29008a50 rpcbinding: add GAS testcase, fix methodless wrappers
* strip NEP-XX methods before going into generator to avoid unused imports
 * nepXX.Invoker types already include Call
 * always import util, it's used for Hash
2022-11-08 17:01:36 +03:00
Roman Khimov
aeb61fb61d rpcbinding: generate ASSERT for bool-returning methods
It's a common pattern.
2022-11-08 17:01:36 +03:00
Roman Khimov
2a4a5ab479 rpcbinding: support simple wrappers for writer methods
Fixes #2769.
2022-11-08 17:01:36 +03:00
Roman Khimov
eb0494764c
Merge pull request #2776 from nspcc-dev/move-neofs-mainnet-fork
config: move NeoFS mainnet Aspidochelone fork again
2022-11-07 16:09:28 +07: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
9882718372 config: move NeoFS mainnet Aspidochelone fork again
We're still 0.98.5 on this network.
2022-11-07 10:40:30 +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
02ce59cfd5 binding: avoid name conflicts with Go keywords
And clashing one name on another after rename.
2022-10-27 22:57:49 +03:00
Roman Khimov
3b635164b7 docs: initial RPC wrapper generator doc 2022-10-27 22:57:49 +03:00
Roman Khimov
3fba1dd8cf docs: add generate-wrapper explainer 2022-10-27 22:57:49 +03:00
Roman Khimov
617c31093f smartcontract: initial rpcbinding implementation, fix #2705
It can do some unwrapping and reuse nepXX packages. It only uses manifest data
at the moment, see #2767, #2768, #2769.
2022-10-27 22:57:49 +03: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
Roman Khimov
e0eff94094 standard: correct Comply* comments 2022-10-27 18:32:00 +03:00
Roman Khimov
64b603b056 standard: export standard definitions
Make Comply* functions useful and expose standard definitions for some reuse.
2022-10-27 18:32:00 +03:00
Roman Khimov
b95c135856
Merge pull request #2764 from nspcc-dev/subs-refactoring
rpc: refactor WSClient subscriptions API
2022-10-26 19:48:45 +07: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
f5441f6085 docs: fix doc for transaction_executed WS notification
It returns *state.AppExecResult.
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
2a53db42af neorpc: adjust and extend event filters documentation 2022-10-26 15:32:54 +03:00
Anna Shaleva
0d39602a50 docs: adjust docmentation for execution results notifications 2022-10-26 15:32:54 +03:00
Roman Khimov
ea48982b35
Merge pull request #2765 from nspcc-dev/fix-query-test
cli: fix race in TestQueryTx
2022-10-26 18:50:56 +07:00
Anna Shaleva
499adccbcb cli: fix race in TestQueryTx
Problem - failing TestQueryTx test:
```
=== RUN   TestQueryTx/verbose/FAULT
=== CONT  TestQueryTx
    logger.go:130: 2022-10-26T10:47:51.414Z	DEBUG	processing rpc request	{"method": "getversion", "params": "[]"}
    logger.go:130: 2022-10-26T10:47:51.415Z	DEBUG	processing rpc request	{"method": "getnativecontracts", "params": "[]"}
    logger.go:130: 2022-10-26T10:47:51.612Z	DEBUG	processing rpc request	{"method": "getversion", "params": "[]"}
    logger.go:130: 2022-10-26T10:47:51.615Z	DEBUG	processing rpc request	{"method": "invokefunction", "params": "[11fdb7bc30a306a60dac874711a2b37b7da402c4 randomMethod  ]"}
    logger.go:130: 2022-10-26T10:47:51.617Z	DEBUG	processing rpc request	{"method": "getblockcount", "params": "[]"}
    logger.go:130: 2022-10-26T10:47:51.617Z	INFO	persisted to disk	{"blocks": 2, "keys": 154, "headerHeight": 2, "blockHeight": 2, "took": "260.704µs"}
    logger.go:130: 2022-10-26T10:47:51.618Z	DEBUG	processing rpc request	{"method": "calculatenetworkfee", "params": "[AIpp7dreAw8AAAAAAAAAAAAAAAAABQAAAAHYzFqQTVJvyabKtVugLJpv54nJVgAAK8IfDAxyYW5kb21NZXRob2QMFMQCpH17s6IRR4esDaYGozC8t/0RQWJ9W1IBACoRDCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcIRQZ7Q3Do=]"}
    logger.go:130: 2022-10-26T10:47:51.712Z	DEBUG	processing rpc request	{"method": "sendrawtransaction", "params": "[AIpp7dreAw8AAAAAABQbEgAAAAAABQAAAAHYzFqQTVJvyabKtVugLJpv54nJVgAAK8IfDAxyYW5kb21NZXRob2QMFMQCpH17s6IRR4esDaYGozC8t/0RQWJ9W1IBQgxAO2nxSMSRNFqBD5lOA37E9Px+nYDGMy6IqZromHXFtVTYD1c1hdUK4vTccoOr2AksdGwDsdQ8qIGJhXdEDxv8NSoRDCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcIRQZ7Q3Do=]"}
    logger.go:130: 2022-10-26T10:47:51.713Z	DEBUG	done processing headers	{"headerIndex": 3, "blockHeight": 2, "took": "228.756µs"}
    logger.go:130: 2022-10-26T10:47:51.813Z	DEBUG	processing rpc request	{"method": "getversion", "params": "[]"}
    logger.go:130: 2022-10-26T10:47:51.815Z	DEBUG	processing rpc request	{"method": "getnativecontracts", "params": "[]"}
    logger.go:130: 2022-10-26T10:47:51.923Z	DEBUG	processing rpc request	{"method": "getrawtransaction", "params": "[22bbb08d3f4b9e601a05c1bb1f7ac456d44bfad013287599bf3f843a75b30076 1]"}
=== CONT  TestQueryTx/verbose/FAULT
    executor.go:238:
        	Error Trace:	executor.go:238
        	            				executor.go:234
        	            				query_test.go:119
        	            				query_test.go:97
        	Error:      	Expect "OnChain:		false" to match "OnChain:\s+true"
        	Test:       	TestQueryTx/verbose/FAULT
```

chain.GetTransaction is looking into mempool also, so we need to check for the
AER instead of transaction.
2022-10-26 14:24:56 +03:00
Roman Khimov
396f56f792 binding: drop unused lowerFirst 2022-10-26 12:47:39 +03:00
Roman Khimov
4191b18728 binding: make TemplateFromManifest more reusable
Other template generators can make use of it.
2022-10-26 12:43:48 +03:00
Roman Khimov
d6d4f07280 binding: always import some packages and do it outside
If the contract has no methods, it's probably a broken one.
2022-10-26 12:40:59 +03:00
Roman Khimov
6af71755c1
Merge pull request #2762 from nspcc-dev/optimize-emit-bool
emit: optimize Bool GAS cost
2022-10-26 15:06:05 +07:00
Roman Khimov
4e58bd7411 compiler: use shorter and cheaper sequence to convert to Boolean 2022-10-25 18:20:55 +03:00
Roman Khimov
e9b752cbbb
Merge pull request #2763 from nspcc-dev/wallet-config-doc
docs: clarify wallet-config format
2022-10-25 20:38:13 +07:00
Roman Khimov
265221f65a docs: clarify wallet-config format 2022-10-25 13:30:39 +03:00
Roman Khimov
5d43367082 emit: optimize Bool GAS cost
NOT is 1 byte shorter and 2048 times cheaper than CONVERT. Inspired by
neo-project/neo-vm#493.
2022-10-25 13:08:33 +03:00
Roman Khimov
e19d867d4e
Merge pull request #2761 from nspcc-dev/fancy-getaddr
Fancy getaddr
2022-10-25 16:51:38 +07:00
Roman Khimov
4313b7f0c7
Merge pull request #2760 from nspcc-dev/net42
network: it is 42
2022-10-24 21:23:01 +07:00
Roman Khimov
28f54d352a network: do getaddr requests periodically, fix #2745
Every 1000 blocks seems to be OK for big networks (that only had done some
initial requests previously and then effectively never requested addresses
again because there was a sufficient number of addresses), won't hurt smaller
ones as well (that effectively keep doing this on every connect/disconnect,
peer changes are very rare there, but when they happen we want to have some
quick reaction to these changes).
2022-10-24 15:10:51 +03:00
Roman Khimov
9efc110058 network: it is 42
32 is a very good number, but we all know 42 is a better one. And it can even
be proven by tests with higher peaking TPS values.

You may wonder why is it so good? Because we're using packet-switching
networks mostly and a packet is a packet almost irrespectively of how bit it
is. Yet a packet has some maximum possible size (hi, MTU) and this size most
of the time is 1500 (or a little less than that, hi VPN). Subtract IP header
(20 for IPv4 or 40 for IPv6 not counting options), TCP header (another 20) and
Neo message/payload headers (~8 for this case) and we have just a little more
than 1400 bytes for our dear hashes. Which means that in a single packet most
of the time we can have 42-44 of them, maybe 45. Choosing between these
numbers is not hard then.
2022-10-24 14:44:19 +03:00
Roman Khimov
9d6b18adec network: drop minPoolCount magic constant
We have AttemptConnPeers that is closely related, the more we have there the
bigger the network supposedly is, so it's much better than magic minPoolCount.
2022-10-24 14:36:10 +03:00
Roman Khimov
af24051bf5 network: sleep a bit before retrying reconnects
If Dial() is to exit quickly we can end up in a retry loop eating CPU.
2022-10-24 14:34:48 +03:00