Commit graph

5429 commits

Author SHA1 Message Date
Anna Shaleva
c207b9b194
Merge pull request #3514 from nspcc-dev/microoptimize-chaindump
chaindump: microoptimize memory management
2024-07-16 16:54:41 +03:00
Roman Khimov
f60d5ee1b3
Merge pull request #3500 from nspcc-dev/optimize-ext-computations 2024-07-16 15:32:07 +03:00
Roman Khimov
1aefd7d16a chaindump: microoptimize memory management
Reuse buffers.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-16 15:03:17 +03: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
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
Anna Shaleva
17de1bf7fe core: avoid extra call to GetNextBlockValidatorsInternal
It should be sufficient to retrieve next block validators once per
updateExtensibleWhitelist call and then reuse this value. `nextVals`
copy intentionally omitted since the only change that
smartcontract.CreateDefaultMultiSigRedeemScript performs over the
`nextVals` list is sorting.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-07-03 13:03:10 +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
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
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
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
Anna Shaleva
e5a6e9ca32 core: introduce D hardfork
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-05 19:20:04 +03:00
Anna Shaleva
cf4d4a2611
Merge pull request #3469 from nspcc-dev/warn
logs: distinguish WARN and INFO for `peer disconnected`
2024-06-05 15:39:52 +03:00
Ekaterina Pavlova
4d6333866d network: extend errInvalidInvType error
Add type to the errInvalidInvType.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-05 15:32:43 +03:00
Ekaterina Pavlova
4a5e8f8592 logs: distinguish WARN and INFO for peer disconnected
Peer disconnections are not warnings in some cases.

Close #3182

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-05 15:32:42 +03:00
Ekaterina Pavlova
b4fdf8c3c9 wallet: do not store deployed contract script inside Contract account
`Contract` account field should not contain deployed contract script.

Close #3348

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-05 15:27:20 +03:00
Ekaterina Pavlova
41109f442a oracle: add length check o.MainCfg.NeoFS.Nodes
Prevent the risk of a division by zero error when accessing the
`o.MainCfg.NeoFS.Nodes[index]` array.

Close #3419

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-05 11:53:52 +03:00
Ekaterina Pavlova
5c408f7fe4 core: adjust prevHeader nil check
prevHeader is never nil.

Refs #3419

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-05 11:53:52 +03:00
Anna Shaleva
4945145b09 interop: use executing contract state for permissions checks
Do not use the updated contract state from native Management to perform
permissions checks. We need to use the currently executing state
instead got from the currently executing VM context until context is
unloaded.

Close #3471.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-06-03 12:32:10 +03:00
Anna Shaleva
7868578571 core: move P2PNotary node role out of P2PSigExtensions
Port https://github.com/neo-project/neo/pull/3172.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-21 12:10:47 +03:00
Roman Khimov
6a5833759c
Merge pull request #3448 from nspcc-dev/migrate-to-hf
Bind 0.106.0 protocol chages to Cockatrice hardfork
2024-05-20 15:51:26 +03:00
Roman Khimov
6be757af3e
Merge pull request #3444 from nspcc-dev/fix-native-init
native: perform initialisation for the set of hardforks
2024-05-17 16:34:00 +03:00
Anna Shaleva
c90f6785b9 native: perform initialisation for the set of hardforks
Close #3433.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-17 15:58:02 +03:00
Anna Shaleva
c30e7ec8d7 native: bind CryptoLib's verifyWithECDsa changes to Cockatrice
A part of #3440.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-17 15:52:00 +03:00
Anna Shaleva
ce442a1942 rpcsrv: remove test for Koblitz-based witness verification
It will be built properly in #3447.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-17 15:45:04 +03:00
Anna Shaleva
e92606a7ae native: bind Neo's CommitteeChanged event to Cockatrice
A part of #3440.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-17 15:22:29 +03:00
Anna Shaleva
df1ed68d98 native: support native method/event removal
Port a part of https://github.com/neo-project/neo/issues/3210.
A part of #3440.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-17 15:22:26 +03:00
Anna Shaleva
82a7c1bd9c native: adjust test helper behaviour
Supply the account with expected balance.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-17 12:33:59 +03:00
Anna Shaleva
c43cfae24c native: fix Policy's IsBlocked behaviour
Account is blocked when it's in the Policy's storage, not when it's
missing from the Policy storage. Introduced in
bbbc6805a8.

This bug leads to the fact that during native Neo cache initialization
at the last block in the dBFT epoch, all candidates accounts are
"blocked", and thus, stand-by committee and validators are used in the
subsequent new epoch. Close #3424.

This bug may lead to the consequences described in #3273, but it needs
to be confirmed.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-05-17 12:33:51 +03:00
Anna Shaleva
2d4993a837
Merge pull request #3438 from nspcc-dev/unwrap-fault-exception
unwrap: implement Exception type for better exception handling
2024-05-17 10:24:26 +03:00
Anna Shaleva
647b8c7fb1
Merge pull request #3439 from nspcc-dev/getnativecontracts
state: drop NativeContract, fix #3430
2024-05-17 10:23:45 +03:00
Roman Khimov
0b69901d1e
Merge pull request #3441 from nspcc-dev/boltdb-clone 2024-05-16 19:49:11 +03:00
Roman Khimov
502f024e7c storage: bytes.Clone(nil) == nil
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-05-16 19:29:11 +03:00