Commit graph

7734 commits

Author SHA1 Message Date
Anna Shaleva
4eadc2c1b0 core: move Notary contract under Domovoi hardfork
Close #3464. Adjust tests, enable all hardforks for RPC server tests
starting from genesis.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-15 13:53:28 +03:00
Anna Shaleva
b2ac71e578 core: fix bug in (bc *Blockchain).isHardforkEnabled
This code was never invoked since we had no native contract enabled
starting from some hardfork, Notary is the first one. And luckily, we
have plenty of tests that fail due to this bug.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-15 13:53:28 +03:00
Anna Shaleva
cc960d5a95 native: fix native deploy process
It doesn't work for contracts enabled starting from non-nil hardfork:
```
--- FAIL: TestStateroot_GetLatestStateHeight (0.00s)
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	initial gas supply is not set or wrong, setting default value	{"InitialGASSupply": "52000000"}
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	mempool size is not set or wrong, setting default value	{"MemPoolSize": 50000}
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	P2PNotaryRequestPayloadPool size is not set or wrong, setting default value	{"P2PNotaryRequestPayloadPoolSize": 1000}
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	MaxBlockSize is not set or wrong, setting default value	{"MaxBlockSize": 262144}
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	MaxBlockSystemFee is not set or wrong, setting default value	{"MaxBlockSystemFee": 900000000000}
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	MaxTransactionsPerBlock is not set or wrong, using default value	{"MaxTransactionsPerBlock": 512}
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	MaxValidUntilBlockIncrement is not set or wrong, using default value	{"MaxValidUntilBlockIncrement": 86400}
    logger.go:146: 2024-06-04T17:08:35.263+0300	INFO	Hardforks are not set, using default value
    logger.go:146: 2024-06-04T17:08:35.266+0300	INFO	no storage version found! creating genesis block
    chain.go:227:
        	Error Trace:	/home/anna/Documents/GitProjects/nspcc-dev/neo-go/pkg/neotest/chain/chain.go:227
        	            				/home/anna/Documents/GitProjects/nspcc-dev/neo-go/pkg/neotest/chain/chain.go:217
        	            				/home/anna/Documents/GitProjects/nspcc-dev/neo-go/pkg/services/stateroot/service_test.go:319
        	Error:      	Received unexpected error:
        	            	onPersist failed: VM has failed: at instruction 0 (SYSCALL): native contract descriptor cache is not initialized: contract c1e14f19c3e60d0b9244d06dd7ba9b113135ec3b, hardfork Default
        	Test:       	TestStateroot_GetLatestStateHeight
FAIL
coverage: 28.6% of statements

```

It happens because ActiveIn hardfork wasn't taken into account during
`latestHF` computation. This commit also removes the reusage of
`activeIn` variable in deploy procedure, it's misleading and not
necessary startign from #3444.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-15 13:53:28 +03:00
Anna Shaleva
99fc248520 interop: improve error message on native cache initialization error
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-15 13:53:28 +03:00
Anna Shaleva
03c29e068e native: fix error message on native cache initialization
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-15 13:53:28 +03:00
Anna Shaleva
6dee57893e core: introduce Echidna hardfork
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-15 13:53:27 +03:00
Anna Shaleva
c65d9f40e3
Merge pull request #3495 from nspcc-dev/cli
cli: upgrade urfave lib to v2
2024-07-12 12:49:50 +03:00
Ekaterina Pavlova
d4a3c912fb cli: fix errors format
Error string should not be capitalized or end with punctuation mark.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 12:35:10 +03:00
Ekaterina Pavlova
fc2798f9d1 cli: fix canceltx usage text
We do not have `--account` flag.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 12:16:24 +03:00
Ekaterina Pavlova
7b199af3b7 cli: change StringFlag to AddressFlag
For passing address or hash AddressFlag is more suitable.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Ekaterina Pavlova
39559b90e2 cli: add Required field for flags
Close #2861

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Ekaterina Pavlova
acde7bd0de cli: upgrade urfave lib to v2
Close #3097

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Ekaterina Pavlova
b32e568d21 cli: don't panic when handling error
Close #2886

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Ekaterina Pavlova
2f5c26f14b cli: use capital letter for Usage
To unified cli help only capital letter is used in Usage field.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-12 11:58:12 +03:00
Anna Shaleva
25dddc33cd
Merge pull request #3511 from nspcc-dev/lint-config
Upgrade `.golangci.yml` config
2024-07-12 11:30:35 +03:00
Anna Shaleva
aff66a23dc
Merge pull request #3508 from nspcc-dev/witness-check-hint
rpcsrv: improve witness verification error
2024-07-12 11:29:22 +03:00
Leonard Lyubich
d03fd02f79 lint: Drop no-op govet config
According to https://golangci-lint.run/usage/linters/#govet,
`check-shadowing` no longer exists. Now it should be
```yaml
govet:
  disable: [shadow]
```
but `shadow` is disabled by default. Thus, whole `govet` section is not
needed anymore.

```
$ golangci-lint --version
golangci-lint has version 1.59.1 built with go1.22.3 from 1a55854a on 2024-06-09T18:08:33Z
```

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
2024-07-11 21:22:10 +04:00
Leonard Lyubich
f37fa6f98c lint: Refresh deprecated config
This fixes
```
$ golangci-lint --version
golangci-lint has version 1.59.1 built with go1.22.3 from 1a55854a on 2024-06-09T18:08:33Z
$ golangci-lint run ./...
WARN [config_reader] The configuration option `output.format` is deprecated, please use `output.formats`
```

The configuration file is updated according to
https://golangci-lint.run/usage/configuration/.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
2024-07-11 21:21:21 +04:00
Anna Shaleva
434f94800a rpcsrv: improve witness verification error
It's needed to give user a hint about what's wrong with the witness
during `calculatenetworkfee` RPC request processing.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-11 12:03:34 +03:00
Anna Shaleva
7304b2c7fb
Merge pull request #3505 from nspcc-dev/array-cp
*: Convert slices to arrays instead of `copy` where possible
2024-07-08 11:00:31 +03:00
Anna Shaleva
da40f2de14
Merge pull request #3504 from nspcc-dev/fix-loadcfg
config: get back default node configuration values
2024-07-05 19:49:27 +03:00
Leonard Lyubich
c975d728e8 *: Convert slices to arrays instead of copy where possible
Became possible with Go 1.20.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
2024-07-05 20:36:22 +04:00
Anna Shaleva
ed9817d35b config: get back default node configuration values
This code was accidentally removed by
https://github.com/nspcc-dev/neo-go/pull/3477, it's important to have
these fields set by default.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-05 13:31:25 +03:00
Anna Shaleva
5566e354d4
Merge pull request #3501 from NeoGoBros/add-max-array-size-test
Add a missing `mptdata` test
2024-07-03 19:34:14 +03:00
Furetur
3456d92220 mptdata: add test for MaxArraySize
This commit adds a single test that covers the
previously uncovered branch in the mptdata
decoding algorithm.

Signed-off-by: Furetur <furetur@gmail.com>
2024-07-03 13:36:53 +03:00
Anna Shaleva
6f77195ce3
Merge pull request #3460 from NeoGoBros/add-onexec-hook
Implement OnExecHook VM API
2024-07-03 13:21:46 +03:00
Furetur
f5794e91a2 vm: implement OnExecHook
Refs #3415

This commit introduces a small new change
that implements the Hooks API and more
specifically the OnExecHook. This feature
can be used to implement test coverage
collection, tracing, breakpoints, and etc.

To be more specific, this commit:

1. adds a new `hooks` field to the `VM`
   (this field contains the OnExecHook
    function)

2. sets the default value of this hook
   to be a NOP function

3. adds the `VM.SetOnExecHook` method

Signed-off-by: Furetur <furetur@gmail.com>
2024-07-03 12:49:09 +03:00
Anna Shaleva
0f2229d6a5
Merge pull request #3477 from nspcc-dev/vm-default-config
cli: add embedded node config
2024-07-01 11:14:43 +03:00
Ekaterina Pavlova
a9abd84cc4 cli: add embedded node config
If `config-path` is not passed, default configs are used according to
the set network. In VM CLI the default privnet config with InMemory db
is used.

Close #3450
Close #3459

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-07-01 10:59:11 +03:00
Anna Shaleva
ce1edda3f2
Merge pull request #3481 from EdgeDLT/getPeerHeights
Extend getpeers RPC method to provide useragent and last known height
2024-06-28 11:07:09 +03:00
edgedlt
ba4ebbd107 rpcclient: fix getpeers test
Signed-off-by: edgedlt <edgedlt@protonmail.com>
2024-06-27 14:00:08 +01:00
edgedlt
aab2620548 neorpc: extend getpeers method
Signed-off-by: edgedlt <edgedlt@protonmail.com>
2024-06-27 10:41:59 +01:00
Anna Shaleva
d9d9d00775
Merge pull request #3492 from nspcc-dev/actor-signers
invoker: add Signers() API
2024-06-21 23:30:45 +03:00
Anna Shaleva
3889224c3e
Merge pull request #3491 from nspcc-dev/wait-success
actor: add a new WaitSuccess API
2024-06-21 23:29:00 +03:00
Roman Khimov
cc3f528eb6 actor: add SignerAccounts() API
Allow to retrieve the list easily.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-06-21 18:45:15 +03:00
Roman Khimov
8336b1b518 invoker: add Signers() API
Signers are very important for notary checks and keeping/passing an additional
copy of them is very inconvenient. Exposing them from invoker makes them
available in actors too.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-06-21 18:45:15 +03:00
Roman Khimov
a327a82085 actor: add a new WaitSuccess API
Most of the time people are interested in successful executions. Unfortunately,
unwrap package can't help here because of a different result structure (some
interface abstract can help, but it's still mostly stack-oriented and sessions
can be a problem), so this additional interface is needed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-06-21 18:39:02 +03:00
Roman Khimov
4ff2063539
Merge pull request #3489 from nspcc-dev/rel-0.106.2 2024-06-13 14:39:36 +03:00
Anna Shaleva
0acdb44c14 CHANGELOG: release 0.106.2
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-13 14:34:32 +03:00
Roman Khimov
05d602b0d8
Merge pull request #3487 from nspcc-dev/domovoi-schedule
config: port Domovoi schedule
2024-06-13 11:14:56 +03:00
Anna Shaleva
8c2c75d92d config: port Domovoi schedule
Ref. https://github.com/neo-project/neo/pull/3330.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 20:40:56 +03:00
Roman Khimov
fc82feb982
Merge pull request #3486 from nspcc-dev/extend-domovoi 2024-06-11 19:42:35 +03:00
Anna Shaleva
8f70d05f85 docs: add a note about System.Runtime.GetNotifications refcounting
Add a note about System.Runtime.GetNotifications refcounting to Domovoi
hardfork. Ref. https://github.com/neo-project/neo/pull/3301 and
https://github.com/nspcc-dev/neo-go/pull/3485.

Although NeoGo doesn't have anything to be updated, there's a
behaviour difference between C# and Go nodes before Domovoi hardfork, it
deserves a comment.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 19:26:11 +03:00
Roman Khimov
21aaadc4b7
Merge pull request #3473 from nspcc-dev/fix-call-check 2024-06-11 19:21:44 +03:00
Anna Shaleva
a7aceca74a interop: use currently executing contract state for permissions check
It's not correct to use an updated contract state got from Management to
check for the allowed method call. We need to use manifest from the
currently executing context for that. It may be critical for cases when
executing contract is being updated firstly, and after that calls
another contract. So we need an old (executing) contract manifest for
this check.

This change likely does not affect the mainnet's state since it's hard
to meet the trigger criteria, but I'd put it under the hardfork anyway.

Ref. https://github.com/neo-project/neo/pull/3290.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 19:13:17 +03:00
Roman Khimov
02627e948f
Merge pull request #3485 from nspcc-dev/test-maxstacksize 2024-06-11 19:04:26 +03:00
Roman Khimov
cffef71be7
Merge pull request #3476 from nspcc-dev/D-hardfork 2024-06-11 19:01:40 +03:00
Anna Shaleva
d156cea24d vm: improve stack size related errors
No functional changes, just add more details to the error.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 18:34:22 +03:00
Anna Shaleva
effba1fa47 core: ensure System.Runtime.GetNotifications can't break MaxStackSize
This test ensures that NeoGo node doesn't have the DeepCopy problem
described in https://github.com/neo-project/neo/issues/3300 and fixed in
https://github.com/neo-project/neo/pull/3301. This problem leads to the
fact that Notifications items are not being properly refcounted by C#
node which leads to possibility to build an enormously large object on
stack. Go node doesn't have this problem.

The reason (at least, as I understand it) is in the fact that C# node
performs objects refcounting inside the DeepCopy even if the object
itself is not yet on stack. I.e. System.Runtime.Notify handler
immediately adds references to the notification argumetns inside
DeepCopy:
b1d27f0189/src/Neo.VM/Types/Array.cs (L108)
b1d27f0189/src/Neo.VM/Types/Array.cs (L75)

Whereas Go node just performs the honest DeepCopy without references counting:
b66cea5ccc/pkg/vm/stackitem/item.go (L1223)

Going further, C# node clears refs for notification arguments (for array
and underlying array items). System.Runtime.GetNotifications pushes the
notificaiton args array back on stack and increments counter only for
the external array, not for its arguments. Which results in negative
refcounter once notificaiton is removed from the stack. The fix itself
(f471c0542d/src/Neo/SmartContract/NotifyEventArgs.cs (L84))
doesn't need to be ported to NeoGo because Go node adds object to the
refcounter only at the moment when it's being pushed to stack by
System.Runtime.GetNotifications handler. This object is treated as new
object since it was deepcopied earlier by System.Runtime.Notify handler:
b66cea5ccc/pkg/vm/stack.go (L178).

Thus, no functoinal changes from the NeoGo side. And we won't
intentionally break our node to follow C# pre-Domovoi invalid behaviour.

Close #3484, close #3482.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 17:51:41 +03:00
Anna Shaleva
55fa12355e stackitem: extend Make() with []string
Allow []string to be converted to stackitem.Item.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-11 17:50:53 +03:00