Commit graph

5694 commits

Author SHA1 Message Date
Anna Shaleva
ee56f73606 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>
2025-03-12 13:29:10 +03:00
Anna Shaleva
210059fff8 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>
2025-03-12 13:29:10 +03:00
Anna Shaleva
4a510637be interop: improve error message on native cache initialization error
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-03-12 13:29:09 +03:00
Anna Shaleva
2fd51cf6b1 native: fix error message on native cache initialization
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-03-12 13:27:22 +03:00
Anna Shaleva
7d72b6538a
Merge pull request #3828 from fyfyrchik/update-feeds
rpcsrv: allow to configure subscription limit
2025-03-07 16:42:35 +03:00
Evgenii Stratonikov
70b4d005e3
rpcsrv: allow to configure subscription limit
Close #3823

Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
2025-03-07 14:34:40 +03:00
Anna Shaleva
2881961421
Merge pull request #3808 from nspcc-dev/upload-state
cli: add `upload-state ` command
2025-03-07 14:05:23 +03:00
Ekaterina Pavlova
5f80a142b0 cli: add upload-state command
Close #3782

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-03-07 18:13:54 +08:00
Roman Khimov
d411337648
Merge pull request #3640 from nspcc-dev/fix-ntf
core: restrict the number of allowed SC notifications
2025-03-07 12:40:13 +03:00
Anna Shaleva
2c8bd056fa core: restrict the number of allowed SC notifications
Close #3490.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-03-07 12:28:25 +03:00
Ekaterina Pavlova
9c0274850a cli: refactor NeoFS related flags and functions
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-03-07 06:43:43 +08:00
Roman Khimov
94660f6333
Merge pull request #3832 from nspcc-dev/extend-billet-doc 2025-03-06 17:07:45 +03:00
Anna Shaleva
c3916ef2c3 mpt: introduce DummySTTempStoragePrefix
Use this constant as a dummy contract storage item prefix for those
situations when Billet is used as an MPT search wrapper. Otherwise it's
confusing to see `0` passed as a storage prefix to the billet
constructor and then panic inside the Billet's code if this prefix is
`0`.

Ref. https://github.com/nspcc-dev/neo-go/pull/2201.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-03-06 16:01:14 +03:00
Anna Shaleva
22a5bbcef3 mpt: extend Billet constructor documentation
Billet's mode must match the DB's MPT mode, otherwise Billet-level nodes
decoding won't work properly startign from 86cb4ed8.

Ref.
https://github.com/nspcc-dev/neo-go/pull/3808#issuecomment-2703668032
and 49945e9ae9.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-03-06 15:56:14 +03:00
Anna Shaleva
13b75c9d1a notary: warn if no space left in completed transaction queue
No functional changes, just add a warning to the node's logs.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-03-06 12:18:37 +03:00
Anna Shaleva
3ec14d2e8f *: extend NotaryRequest verification errors
This change is compatible with the old protocol.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-03-05 19:14:28 +03:00
Anna Shaleva
68d7e8e01c
Merge pull request #3820 from nspcc-dev/getblocknotifications
rpcclient: fix getblocknotifications filter handling
2025-02-27 14:46:56 +03:00
Ekaterina Pavlova
a227572d01 rpcclient: fix getblocknotifications no filter case handling
`error meta/blocks.go:96 block handling failed {"service": "meta data",
"error": "fetching
781475e13a407826b9147328f30a6a3635cf19238dc45b8c23fa9cd989672aba block:
Invalid params (-32602) - invalid filter: json: cannot unmarshal array
into Go value of type neorpc.NotificationFilter"}`

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-27 19:24:48 +08:00
Ekaterina Pavlova
a7c66dcb0b blockfetcher: add genesis header size to the headerSizeMap
Close #3807

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-26 11:46:41 +08:00
Ekaterina Pavlova
ff8ea5d4e8 block: fix GetExpectedHeaderSize for genesis block case
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-26 11:45:46 +08:00
Roman Khimov
d0e47c739a transaction: fix MaxConditionNesting
Rework 75d12081bf to follow https://github.com/neo-project/neo/pull/3761,
let's have a real depth value in this constant.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-17 15:25:42 +03:00
Ekaterina Pavlova
75d12081bf core: fix too many nesting levels bug
The C# implementation only decrements the nesting depth once in the
parent composite condition (And, Or, or Not) and then passes that
already‐decremented value onto its subconditions without further
decrementing inside the loop.

Close #3809

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-13 16:48:03 +03:00
Roman Khimov
30b3318503 vm: drop Dump*Slot methods from Context
As scheduled for the 0.108.0 release.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-11 16:38:21 +03:00
Roman Khimov
25e2d80363 neorpc: rename BlockNotifications fields to follow triggers exactly
Be more consistent.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-11 16:06:15 +03:00
Roman Khimov
93be186685 rpcsrv: check args first, get data from DB then
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-11 15:55:24 +03:00
Roman Khimov
d1926e4fb0 rpcsrv: handle block aer errors in getblocknotifications
Ignoring them is not correct. Notice that block-level aers are always present
and if filtering returns nothing the value of the resulting slice still remains
nil, so the behavior is the same.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-11 15:54:46 +03:00
Roman Khimov
cb4aba497e rpcsrv: filter out invalid getblocknotifications requests
Unknown fields are not allowed.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-11 15:52:34 +03:00
Ricardo Prado
bd170fb849 rpc: implement getblocknotifications API
Add new RPC method to retrieve block notifications organized by trigger type.

Signed-off-by: Ricardo Prado <ricardo.prado@simpli.com.br>
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-11 15:40:15 +03:00
Roman Khimov
8d728b4ec1
Merge pull request #3789 from nspcc-dev/headers
Headers fetching via NeoFS BlockFetcher service
2025-02-06 17:05:20 +03:00
Ekaterina Pavlova
1ad62ef5f5 blockfetcher: add headerSizeMap to GetRange headers accordingly
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-06 16:13:01 +03:00
Ekaterina Pavlova
91b60ea7d3 network: integrate state sync module with blockfetcher
Close #3574

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-06 16:12:55 +03:00
Roman Khimov
3fa02d062b
Merge pull request #3804 from nspcc-dev/toscparameter
rpcbinding: expand struct generator with ToSCParameter
2025-02-04 17:52:41 +03:00
Ekaterina Pavlova
de50d0be49 bqueue: make queue generic
The queue can operate with any item that implements proper interface.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-04 16:48:03 +03:00
Roman Khimov
e70b1063a6 rpcbinding: expand struct generator with ToSCParameter
Follow-up to 00e22b9751, while
stackitem.Convertible is good for vm/emit we still need
smartcontract.Convertible for invokers.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-02-04 12:10:26 +03:00
Ekaterina Pavlova
267d7dca78 zkpbinding: update interop
This place was not updated with update_deps.sh.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-03 22:00:37 +03:00
Ekaterina Pavlova
83a02fc0c0 zkpbinding: remove range usage from smartcontract
Reverting a part of 1b83dc2, because ranging over integers is not
supported by smart contract compiler, ref. #3525.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-03 21:56:54 +03:00
Ekaterina Pavlova
d02e2b629d *: neo-vm submodule update dependency
Close #3204

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2025-02-03 12:09:02 +03:00
Roman Khimov
8ba2bbf87c rpcbindings: fix missing return item
... not enough return values
        have (error)
        want (stackitem.Item, error)

An omission of 00e22b9751.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-26 23:47:36 +03:00
Anna Shaleva
7ba8048530
Merge pull request #3569 from ixje/applog-invocations
*: add invocations to applicationlog
2025-01-24 18:42:53 +03:00
ixje
4b2ee9a424
state, rpc: add invocations to applicationlog
Add setting to include smart contract invocations data to the applicationlog.
Original issue at https://github.com/neo-project/neo/issues/3386

Signed-off-by: ixje <erik@coz.io>
2025-01-24 15:44:10 +01:00
Roman Khimov
00e22b9751 rpcbindings: produce ToStackItem companion method
We need it for structs to be usable as function parameters, otherwise
they're not implementing stackitam.Convertible and they fail at transaction
script creation phase:

    2025/01/22 20:31:26 bootstrap error: could not invoke method (addNode): test invocation failed: unsupported operation: *netmap.NetmapNode2 type

Related to https://github.com/nspcc-dev/neofs-node/pull/3088.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-24 17:07:20 +03:00
Roman Khimov
4da753f822 stackitem: split TryMake and Make
Sometimes we may need something that doesn't panic.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-24 17:07:20 +03:00
Anna Shaleva
257fa7c6c9 native: add NEP-27 to Notary's supported standards
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-01-21 19:41:45 +03:00
Anna Shaleva
b2322a804a native: add NEP-27 to Neo's supported standards
Port https://github.com/neo-project/neo/pull/3643.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-01-21 19:41:43 +03:00
Anna Shaleva
fcd83e9fd7 smartcontract: support NEP-26 and NEP-27
A replacement of NEP11Payable and NEP17Payable. The essence is the same,
but these standards have official name since
https://github.com/neo-project/proposals/pull/169.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2025-01-21 18:14:55 +03:00
Roman Khimov
9513780c45 core: adjust in-memory processed set dynamically
Instead of tick-tocking with sync/async and having an unpredictable data
set we can just try to check for the real amount of keys that be processed
by the underlying DB. Can't be perfect, but still this adds some hard
limit to the amount of in-memory data. It's also adaptive, slower machines
will keep less and faster machines will keep more.

This gives almost perfect 4s cycles for mainnet BoltDB with no tail cutting,
it makes zero sense to process more blocks since we're clearly DB-bound:

2025-01-15T11:35:00.567+0300    INFO    persisted to disk       {"blocks": 1469, "keys": 40579, "headerHeight": 5438141, "blockHeight": 5438140, "velocity": 9912, "took": "4.378939648s"}
2025-01-15T11:35:04.699+0300    INFO    persisted to disk       {"blocks": 1060, "keys": 39976, "headerHeight": 5439201, "blockHeight": 5439200, "velocity": 9888, "took": "4.131985438s"}
2025-01-15T11:35:08.752+0300    INFO    persisted to disk       {"blocks": 1508, "keys": 39658, "headerHeight": 5440709, "blockHeight": 5440708, "velocity": 9877, "took": "4.052347569s"}
2025-01-15T11:35:12.807+0300    INFO    persisted to disk       {"blocks": 1645, "keys": 39565, "headerHeight": 5442354, "blockHeight": 5442353, "velocity": 9864, "took": "4.05547743s"}
2025-01-15T11:35:17.011+0300    INFO    persisted to disk       {"blocks": 1472, "keys": 39519, "headerHeight": 5443826, "blockHeight": 5443825, "velocity": 9817, "took": "4.203258142s"}
2025-01-15T11:35:21.089+0300    INFO    persisted to disk       {"blocks": 1345, "keys": 39529, "headerHeight": 5445171, "blockHeight": 5445170, "velocity": 9804, "took": "4.078297579s"}
2025-01-15T11:35:25.090+0300    INFO    persisted to disk       {"blocks": 1054, "keys": 39326, "headerHeight": 5446225, "blockHeight": 5446224, "velocity": 9806, "took": "4.000524899s"}
2025-01-15T11:35:30.372+0300    INFO    persisted to disk       {"blocks": 1239, "keys": 39349, "headerHeight": 5447464, "blockHeight": 5447463, "velocity": 9744, "took": "4.281444939s"}

2× can be considered, but this calculation isn't perfect for low number of
keys, so somewhat bigger tolerance is preferable for now. Overall it's not
degrading performance, my mainnet/bolt run was even 8% better with this.

Fixes #3249, we don't need any option this way.

Fixes #3783 as well, it no longer OOMs in that scenario. It however can OOM in
case of big GarbageCollectionPeriod (like 400K), but this can't be solved easily.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-15 22:08:08 +03:00
Roman Khimov
c14492e8c8 core: raise severity of persistence failure message
It is very critical in fact.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-14 12:46:01 +03:00
Roman Khimov
70aaeb06ad core: fix old transfer data deletion in RUB-only configuration
RemoveUntraceableBlocks without RemoveUntraceableHeaders is still a valid
configuration and removeOldTransfers() only checks for gcBlockTimes now
for timestamps, so they should always be added. This fixes

    2025-01-13T23:28:57.340+0300    ERROR   failed to get block timestamp transfer GC       {"time": "1.162µs", "index": 20000}

for RemoveUntraceableBlocks-only configurations.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-14 12:43:15 +03:00
Roman Khimov
ba0ca6a4ab core: perform synchronized persist if GC took some time
The intention here is to reduce the amount of in-flight changes and prevent
OOM. It doesn't matter what we're doing, persisting or collecting garbage,
what matters is that we're behind the schedule of regular persist cycle.

Refs. #3783.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-13 23:39:48 +03:00
Roman Khimov
1f83f472c7 core: swap transfer and MPT GC
It doesn't change anything logically, but transfer GC needs to have current
block timestamp for its logic and if we're delaying it with MPT GC it can
more often fail to obtain it:

    2025-01-13T16:15:18.311+0300    ERROR   failed to get block timestamp transfer GC       {"time": "1.022µs", "index": 20000}

It's not critical, this garbage can still be collected on the next run, but
we better avoid this anyway.

Refs. #3783.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2025-01-13 23:37:21 +03:00