Commit graph

5573 commits

Author SHA1 Message Date
Roman Khimov
3d00a19383 unwrap: add ErrNull to handle Null returned, fix #2795
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-21 13:23:32 +03:00
Ekaterina Pavlova
b63c7aad73 rpcsrv: add NEP24 test
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-11-20 14:45:28 +03:00
Ekaterina Pavlova
8e99ff65e1 rpcsrv: update testdata/testblocks.acc
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-11-20 14:45:28 +03:00
Ekaterina Pavlova
b2bd8e4a0a manifest: support NEP-24
Close #3451

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-11-20 14:45:28 +03:00
Ekaterina Pavlova
54e3708566 manifest: add Required field to Standard
`Required` contains standards that are required for this standard.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-11-20 14:45:28 +03:00
Roman Khimov
aba781c2de waiter: remove compat code for block-based waiting
A part of #3454 for 0.107.0 release.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-19 22:23:00 +03:00
Roman Khimov
aeee733479 neorpc: remove deprecated error codes (as scheduled)
A part of #3454.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-19 21:47:27 +03:00
Roman Khimov
632092b2cd network: drop deprecated serv_node_version metric
A part of #3454.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-19 21:43:08 +03:00
Roman Khimov
125f757988 state: drop compatibility code for NEOBalance
A part of #3454.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-19 21:40:01 +03:00
Roman Khimov
7683f4366d result: drop obsolete unmarshaling code
A part of #3454.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-19 21:35:50 +03:00
Ekaterina Pavlova
9082c6ea1a vm: fix PACKMAP operation
Close #3613

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-11-19 13:49:53 +03:00
Anna Shaleva
176593b31f
Merge pull request #3687 from nspcc-dev/extend-smartcontract-conversions
Extend smartcontract type conversions
2024-11-18 17:21:22 +03:00
Roman Khimov
db2956f1af smartcontract: add support for maps in NewParameterFromValue
It's just not possible to use maps in invokers/actors without this. And maps
have too many combinations to try pushing them into a type switch, that's
where reflection kicks in and solves it easily.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-18 15:20:39 +03:00
Roman Khimov
22c6ab4de9 smartcontract: process slices via reflection in NewParameterFromValue
Pros:
 * less code
 * handles more types
Cons:
 * slow

This code is not likely to be on the hot path and it is exactly the one used
by actors for making calls of various kinds. Supporting more types is more
important here than raw speed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-18 15:20:39 +03:00
Roman Khimov
270f0d2d7a vm: fix incorrect refcounting in POPITEM
We're popping an item (array) off the stack, OK, it triggers refs.Remove() for
it. Then we're pushing an inner item to the stack, OK, it triggers refs.Add()
for this element. Why are we removing it afterwards? Looks like something went
wrong in 324107b31e (and https://github.com/nspcc-dev/neo-go/pull/1670)
since a simple test shows zero counter after POPITEM and -1 after popping the
only item left on the stack.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-16 18:03:25 +03:00
Roman Khimov
a123b75fd9 io: no need to do ValueOf() again, it's known
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-15 22:29:06 +03:00
Roman Khimov
895a0ae624
Merge pull request #3677 from ixje/expose-slots
vm: make slots public
2024-11-15 13:16:48 +03:00
ixje
7ec0c1155c vm: expose Context slots, hide Set/ClearRefs on Slot, deprecate Dump*Slot methods
Signed-off-by: ixje <erik@coz.io>
2024-11-15 11:05:42 +01:00
Roman Khimov
9cc16d73f2 core: a bit better field explanations for header/transaction
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-15 11:27:21 +03:00
Roman Khimov
933d522b82 block: explain protocol extensions better
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-15 11:27:21 +03:00
Roman Khimov
ccbb198a5b core: document trimmed transactions better
Eventually we can drop them, but they were present for a long long time.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-15 11:27:21 +03:00
Roman Khimov
bbec25de43 block: document hash caching better
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-15 11:27:21 +03:00
Roman Khimov
7af2ab92d2 transaction: specify hash/size behavior better
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-15 11:27:21 +03:00
Ekaterina Pavlova
71a89c230a *: remove range usage from smartcontracts
Reverting a part of 1b83dc2, because ranging over integers is not
supported by smart contract compiler, ref. #3525.

Close #3671

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-11-14 16:57:39 +03:00
Anna Shaleva
3ec06f316e
Merge pull request #3674 from ixje/remove-breakpoint
vm: add RemoveBreakPoint support
2024-11-14 12:42:57 +03:00
ixje
d8ea4103c7 cli: add delete and list break point commands
Close #3673

Signed-off-by: ixje <erik@coz.io>
2024-11-14 09:52:25 +01:00
Roman Khimov
8b12b3ac64 *: fix some dupword warnings
Duplicate words in comments.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-13 20:57:10 +03:00
Ekaterina Pavlova
0afd9ac0bb rpcsrv: align default error code with C# implementation
We had 400, 405 and 500 in getHTTPCodeForError, but none is explicitly
set in C#.

1. **405 code** (unknown method, `neorpc.MethodNotFoundCode`). The
resulting HTTP code returned by C# server is 200 OK:
```
anna@kiwi:~/Documents/GitProjects/bane-labs/go-ethereum$ curl -v -d '{
"jsonrpc": "2.0", "id": 1, "method": "unknown-method", "params": [] }'
http://seed1t5.neo.org:20332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time
  Current
                                 Dload  Upload   Total   Spent    Left
                                 Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--
       0*   Trying 34.133.235.69:20332...
* Connected to seed1t5.neo.org (34.133.235.69) port 20332 (#0)
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--
       0> POST / HTTP/1.1
> Host: seed1t5.neo.org:20332
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 71
> Content-Type: application/x-www-form-urlencoded
>
} [71 bytes data]
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Tue, 12 Nov 2024 13:45:51 GMT
< Server: Kestrel
< Transfer-Encoding: chunked
<
{ [461 bytes data]
100   520    0   449  100    71    729    115 --:--:-- --:--:-- --:--:--
   844
* Connection #0 to host seed1t5.neo.org left intact
{
   "error" : {
      "code" : -32601,
      "data" : "   at Neo.Plugins.Result.True_Or(Boolean result,
      RpcError err)\n   at Neo.Plugins.RpcServer.ProcessRequestAsync
      (HttpContext context, JObject request)",
      "message" : "Method not found - The method 'unknown-method'
      doesn't exists. -    at Neo.Plugins.Result.True_Or(Boolean result,
       RpcError err)\n   at Neo.Plugins.RpcServer.ProcessRequestAsync
       (HttpContext context, JObject request)"
   },
   "id" : 1,
   "jsonrpc" : "2.0"
}
```
2. **400 code** (malformed request, `neorpc.BadRequestCode`). The
resulting HTTP code returned by C# server is 200 OK:
```
anna@kiwi:~/Documents/GitProjects/bane-labs/go-ethereum$ curl -v -d '{
"jsonrpc": "2.0", "id": 1, "method": "getapplicationlog", "params": ["]
}' http://seed1t5.neo.org:20332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time
  Current
                                 Dload  Upload   Total   Spent    Left
                                 Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--
       0*   Trying 34.133.235.69:20332...
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--
       0* Connected to seed1t5.neo.org (34.133.235.69) port 20332 (#0)
> POST / HTTP/1.1
> Host: seed1t5.neo.org:20332
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 75
> Content-Type: application/x-www-form-urlencoded
>
} [75 bytes data]
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Tue, 12 Nov 2024 13:50:12 GMT
< Server: Kestrel
< Transfer-Encoding: chunked
<
{ [86 bytes data]
100   150    0    75  100    75     84     84 --:--:-- --:--:-- --:--:--
   169
* Connection #0 to host seed1t5.neo.org left intact
{
   "error" : {
      "code" : -32700,
      "message" : "Bad request"
   },
   "id" : null,
   "jsonrpc" : "2.0"
}
```
3. **500 code** (internal server error, `neorpc
.InternalServerErrorCode`). It's difficult to reproduce this error on
real network for C# server, but the resulting code is expected to be the
 same, 200 OK.

Close #3586

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-11-12 17:08:01 +03:00
Roman Khimov
9cca702ac2 emit: add some package doc
People use it more often than they should, discourage that a bit, it's rarely
really needed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-07 18:44:55 +03:00
Roman Khimov
24577d320d rpcclient: improve GetNEPXXTransfers docs
No one cares about NeoGo 0.7X.smth, but timestamps are a bit unobvious here.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-07 18:02:53 +03:00
Anna Shaleva
1a540d5883
Merge pull request #3663 from nspcc-dev/io-improve-bytes-doc
io: specify Bytes() behavior a bit better for BufBinWriter
2024-11-06 11:15:52 +03:00
Roman Khimov
23f9c5a43b io: specify Bytes() behavior a bit better for BufBinWriter
It's not immediately obvious.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-11-05 16:58:33 +03:00
Alexey Savchuk
df9247c00b services/rpcsrv: Return a new server by pointer
Before, a new server was returned by value which could cause
a panic `unlock of unlocked mutex` on SIGHUP handling. It's
because the new server overwrites a locked mutex of the already
existing server.

oct‚ 22 13:51:15 node1 neo-go[1183338]: fatal error: sync: Unlock of unlocked RWMutex
oct‚ 22 13:51:15 node1 neo-go[1183338]: goroutine 538 [running]:
oct‚ 22 13:51:15 node1 neo-go[1183338]: sync.fatal({0xf83d64?, 0xc001085880?})
oct‚ 22 13:51:15 node1 neo-go[1183338]:         runtime/panic.go:1007 +0x18
oct‚ 22 13:51:15 node1 neo-go[1183338]: sync.(*RWMutex).Unlock(0xc00019a4c8)
oct‚ 22 13:51:15 node1 neo-go[1183338]:         sync/rwmutex.go:208 +0x45
oct‚ 22 13:51:15 node1 neo-go[1183338]: github.com/nspcc-dev/neo-go/pkg/services/rpcsrv.(*Server).dropSubscriber(0xc00019a2c8, 0xc000a77740)
oct‚ 22 13:51:15 node1 neo-go[1183338]:         github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/server.go:825 +0xce
oct‚ 22 13:51:15 node1 neo-go[1183338]: github.com/nspcc-dev/neo-go/pkg/services/rpcsrv.(*Server).handleWsReads(0xc00019a2c8, 0xc0034478c0, 0xc000af5f80, 0xc000a7
7740)
oct‚ 22 13:51:15 node1 neo-go[1183338]:         github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/server.go:810 +0x266
oct‚ 22 13:51:15 node1 neo-go[1183338]: github.com/nspcc-dev/neo-go/pkg/services/rpcsrv.(*Server).handleHTTPRequest(0xc00019a2c8, {0x11c3900, 0xc003437dc0}, 0xc00
31945a0)
oct‚ 22 13:51:15 node1 neo-go[1183338]:         github.com/nspcc-dev/neo-go/pkg/services/rpcsrv/server.go:582 +0x54a
oct‚ 22 13:51:15 node1 neo-go[1183338]: net/http.HandlerFunc.ServeHTTP(0x471779?, {0x11c3900?, 0xc003437dc0?}, 0xc000943b68?)
oct‚ 22 13:51:15 node1 neo-go[1183338]:         net/http/server.go:2171 +0x29
oct‚ 22 13:51:15 node1 neo-go[1183338]: net/http.serverHandler.ServeHTTP({0xc000a77680?}, {0x11c3900?, 0xc003437dc0?}, 0x6?)
oct‚ 22 13:51:15 node1 neo-go[1183338]:         net/http/server.go:3142 +0x8e
oct‚ 22 13:51:15 node1 neo-go[1183338]: net/http.(*conn).serve(0xc0032030e0, {0x11c5220, 0xc000a76960})
oct‚ 22 13:51:15 node1 neo-go[1183338]:         net/http/server.go:2044 +0x5e8
oct‚ 22 13:51:15 node1 neo-go[1183338]: created by net/http.(*Server).Serve in goroutine 534
oct‚ 22 13:51:15 node1 neo-go[1183338]:         net/http/server.go:3290 +0x4b4

Signed-off-by: Alexey Savchuk <alexey.a.savchuk@yandex.com>
2024-11-05 15:05:25 +03:00
Anna Shaleva
a4633ce2c7
Merge pull request #3649 from nspcc-dev/vm-modpow
vm: fix MODPOW operation
2024-10-31 17:50:40 +03:00
Ekaterina Pavlova
cccbe843be vm: fix MODPOW operation
Close #3612

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-10-31 17:49:02 +03:00
Anna Shaleva
a0d2f95e42 stackitem: extend ToJSON test
Inspired by https://github.com/neo-project/neo/pull/3558, although this
PR fixes different implementation of stackitem serializatior that is
used outside of VM.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-29 12:07:04 +03:00
Ekaterina Pavlova
8a154d9189 blockfetcher: add more details to errors
Close #3629

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-10-22 14:11:27 +03:00
Anna Shaleva
7b09812069 core: refactor TestEngineLimits
Replace repetative hand-written code with generated one.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-18 19:10:47 +03:00
Anna Shaleva
b5b89881b7 core: prove contract notifications count is not restricted
A part of #3490.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-18 19:10:34 +03:00
Ekaterina Pavlova
59fab5d654 blockfetcher: adjust index file numeration from 0
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-10-16 19:23:56 +03:00
Ekaterina Pavlova
2435484dc4 neofs: add ObjectSearchInitter
With ObjectSearchInitter ObjectSearch can can be done by both NeoFS SDK
client and pool.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-10-16 19:23:56 +03:00
Anna Shaleva
d8e945978a neotest: sort coverage blocks within a test scope
Make the behaviour similar to the `go test` output. It's not a problem
for the `go cover` tool, but the sorted file is easier to debug and analize.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-16 16:03:46 +03:00
Anna Shaleva
c747bb8ff7 neotest: preallocate coverage blocks list
And always use pointers for coverage block processing, dereference is
excessive in this context.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-15 15:44:54 +03:00
Anna Shaleva
49f2e1dc64 neotest: gracefully report about coverage setup error
Don't use panic when we can use t.Fatal.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-15 15:44:54 +03:00
Anna Shaleva
2dc588ea95 neotest: distinguish coverage modes
Use calls frequency calculated by executor in the final coverage
profile for `atomic` cover mode. Support only `set` cover mode for now
due to #3587.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-15 15:44:53 +03:00
Anna Shaleva
c5c64f5f07 interop: fix linter issues
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-11 12:41:06 +03:00
Roman Khimov
ad41d0f9c7 neotest: add a warning to CompileSource, it's bad for coverage
$ go tool cover -html=coverage.txt -o coverage.html
cover: can't read "/home/rik/dev/neo-go/examples/nft-nd-nns/contract.go": open /home/rik/dev/neo-go/examples/nft-nd-nns/contract.go: no such file or directory

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-10-09 15:53:01 +03:00
Anna Shaleva
7fac3bcd6f neotest: don't collect coverage for contracts with empty DI
Users are allowed to provide any contract to neotest, including those
contracts that don't have DebugInfo filled in. Neotest should filter
them out, otherwise panic may occur on attempt to write coverage profile:
```
--- FAIL: TestDeploys (0.01s)
panic: runtime error: invalid memory address or nil pointer dereference
	panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xc6f5b5]

goroutine 1735 [running]:
testing.tRunner.func1.2({0xd7aa80, 0x1723f60})
	/usr/local/go/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/usr/local/go/src/testing/testing.go:1634 +0x377
panic({0xd7aa80?, 0x1723f60?})
	/usr/local/go/src/runtime/panic.go:770 +0x132
github.com/nspcc-dev/neo-go/pkg/neotest.processCover()
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:143 +0xd5
github.com/nspcc-dev/neo-go/pkg/neotest.writeCoverageReport({0x10c6260, 0xc00033a378})
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:123 +0x4b
github.com/nspcc-dev/neo-go/pkg/neotest.reportCoverage({0x10db278, 0xc00021a000})
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/coverage.go:118 +0x165
github.com/nspcc-dev/neo-go/pkg/neotest.(*Executor).trackCoverage.func1()
	/home/anna/go/pkg/mod/github.com/nspcc-dev/neo-go@v0.106.4-0.20241007094345-11151938b9bd/pkg/neotest/basic.go:182 +0x1b
testing.(*common).Cleanup.func1()
	/usr/local/go/src/testing/testing.go:1175 +0x10f
testing.(*common).runCleanup(0xc00021a000, 0x58d7c0?)
	/usr/local/go/src/testing/testing.go:1353 +0xdb
testing.(*common).runCleanup.func2()
	/usr/local/go/src/testing/testing.go:1337 +0x47
panic({0xd7aa80?, 0x1723f60?})
```

An example of such partially-filled contract is:
a8d5e001a2/tests/deploys_test.go (L13)
a8d5e001a2/contracts/contracts.go (L96)

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-10-07 17:51:19 +03:00
Anna Shaleva
11151938b9
Merge pull request #3599 from Slava0135/fix-modmul
vm: fix modmul operation
2024-10-07 12:43:45 +03:00
slava0135
9aca090644 vm: fix modmul operation
Signed-off-by: Slava0135 <super.novalskiy_0135@inbox.ru>
2024-10-07 11:02:01 +03:00