Commit graph

617 commits

Author SHA1 Message Date
Roman Khimov
4acd1688a1 subscriptions: move NotificationEvent to state
1. It's not good for pkg/core to import anything from pkg/neorpc.
2. The type is closely tied to the state package, even though it's not stored
   in the DB
2022-07-25 11:58:13 +03:00
Roman Khimov
1e0750e3cd rpc: merge response and request under pkg/neorpc
Move result there also.
2022-07-25 11:57:53 +03:00
Roman Khimov
8cd7b93208 limits: new package with storage limits
Packages like core/state or core/mpt shouldn't import whole core/storage just
to get some constant value, it's not a good dependency.
2022-07-08 23:30:30 +03:00
Roman Khimov
fab8dfb9f8 vm: move State type into a package of its own
It's used a lot in other places that need it, but don't need whole VM at the
same time.
2022-07-08 18:34:52 +03:00
Anna Shaleva
7c48edaccb core, rpc: fix height-related issue of historic call functionality
Specifying a certain stateroot R as `invoke*historic` RPC-call
parameter, we're willing to perform historic call based on the storage
state of root R. Thus, next block should be of the height h(R)+1. This
allows to use historic functionality for the current blockchain height.
2022-06-20 19:05:22 +03:00
Roman Khimov
0055b18a8a core: export CreateGenesisBlock
Nothing bad with it being public.
2022-06-08 18:20:34 +03:00
Roman Khimov
92c94f265c interop/vm: make VM reusable and use on VM for all in-block execs
Avoid allocating again and again. Increases TPS by about 3%.
2022-06-07 10:05:47 +03:00
Roman Khimov
bdc6624c9d interop: unify VM price getter setting 2022-06-06 22:00:16 +03:00
Roman Khimov
638b04b29a interop: wrap contract.LoadToken in context.LoadToken
Creating a closure in runtime is a relatively costly thing, but it can easily
be avoided.
2022-06-06 21:53:03 +03:00
Roman Khimov
799394192b state: create buffer/io writer once per TokenTransferLog
name                       old time/op    new time/op    delta
TokenTransferLog_Append-8   93.0µs ±170%   46.8µs ±152%     ~     (p=0.053 n=10+9)

name                       old alloc/op   new alloc/op   delta
TokenTransferLog_Append-8    53.8kB ± 4%    38.6kB ±39%  -28.26%  (p=0.004 n=8+10)

name                       old allocs/op  new allocs/op  delta
TokenTransferLog_Append-8       384 ± 0%       128 ± 0%  -66.67%  (p=0.000 n=10+10)
2022-06-04 00:11:11 +03:00
Roman Khimov
1e5825c4af core: don't allocate another int for notification handler
It'll be serialized anyway.
2022-06-03 23:39:46 +03:00
Roman Khimov
c3d989ebda stackitem: reusable serialization context
We serialize items a lot and this allows to avoid a number of allocations.
2022-06-02 15:38:39 +03:00
Anna Shaleva
08b68e9b82 vm, core: push Null return value only if no exception occurs
Close https://github.com/nspcc-dev/neo-go/issues/2509.
2022-05-26 09:26:31 +03:00
Anna Shaleva
e70bf7d12e core: allow to create hard-fork 2022-05-11 14:21:38 +03:00
Elizaveta Chichindaeva
28908aa3cf [#2442] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Anna Shaleva
473955c2d6 core: use proper current block height/hash for interop API 2022-04-29 18:00:46 +03:00
Anna Shaleva
11ab42d91c core: keep Designation cache always valid and up-to-date
Always use cache instead of DAO where possible. Update cache in-place
each time new designated node is chosen.
2022-04-29 16:10:04 +03:00
Anna Shaleva
aa886f67ce core: use dao-binded cache for native contracts
All native cached values are binded to DAO, so that it's possible
to properly handle historic calls.
2022-04-29 16:10:04 +03:00
Anna Shaleva
e63d6aeff7 core: move natives cache initialisation to a separate method 2022-04-29 16:10:04 +03:00
Anna Shaleva
63c26ca270 core, rpc: support [invokefunction, invokescript, invokecontractverify]historic 2022-04-29 16:10:04 +03:00
Anna Shaleva
1890e7cdc1 core: upgrade storage version 2022-04-22 18:38:05 +03:00
Anna Shaleva
51a54fa248 core: return default BaseExecFee if blockchain height is 0
For (bc *Blockchain).GetBaseExecFee().
2022-04-08 14:28:30 +03:00
Anna Shaleva
544f2c2cb2 core: use proper storage price within the whole interop context
We shouldn't use StoragePrice from Blockchain because its dao doesn't
contain the whole set of changes from previouse transactions in the
current block. Instead, we should use an updated storage price for
each transaction and retrieve the price from cached DAO.
2022-04-08 12:50:56 +03:00
Anna Shaleva
91a4bc5beb core: use proper DAO to get ExecFeeFactor
The usage of the Blockchain's one leads to the same ExecFeeFactor within
a single block. What we need is to update ExecFeeFactor after each
transaction invocation, thus, cached DAO should be used as it contains
all relevant changes.
2022-04-08 12:50:50 +03:00
Roman Khimov
4e375fd8f4
Merge pull request #2414 from nspcc-dev/eliminate-getstorageitems
Eliminate GetStorageItems
2022-04-01 09:16:42 +03:00
Roman Khimov
60375e9db3 core: drop GetStorageItems interface
It's not used and not useful.
2022-03-31 16:46:41 +03:00
Anna Shaleva
28e936eb95 core: export GetMaxNotValidBeforeDelta blockchain API
Mostly for tests, but it can also be useful as a separate API.
2022-03-30 11:46:44 +03:00
Roman Khimov
ff60571869
Merge pull request #2378 from nspcc-dev/notary-adjustments
*: several Notary subsystem adjustments, part 1
2022-03-02 11:58:36 +03:00
AnnaShaleva
92282c70cb *: support customisable NotaryServiceFeePerKey value
* Add corresponding methods to Notary contract.
* Extend RPC Client API.
* Adjust tests.
2022-03-01 19:08:16 +03:00
AnnaShaleva
8e3f2417f4 core: add check for native activations history
It should be consistent with storage states.
2022-02-28 18:49:18 +03:00
Anna Shaleva
032d9749c2 core: improve blockchain error messages 2022-02-28 18:49:18 +03:00
Anna Shaleva
8d6aa1782d core: fix StateRootInHeader error message for (*Blockchain).init() 2022-02-28 18:49:18 +03:00
Anna Shaleva
ad0c53c067 core: unify the format of error messages for (*Blockchain).init() 2022-02-28 18:49:12 +03:00
Roman Khimov
7d6f087337 storage: drop (KeyPrefix).Bytes() API
It allocates and most of the time we can avoid that.
2022-02-18 15:19:57 +03:00
Roman Khimov
7223caf369 dao: improve PutCurrentHeader logic
Move serialization out of the core.
2022-02-18 15:05:25 +03:00
Roman Khimov
d2db58d748 dao: move header hash store logic out of the core
Which allows for more efficient buffer use along the way.
2022-02-18 14:54:05 +03:00
Roman Khimov
de2579ec07 dao: put contract IDs into keys using big endianness
We don't have a need to iterate over them at the moment, but since we're
changing the DB format in the next release anyway let's add this ability also,
just in case.
2022-02-18 14:38:51 +03:00
Roman Khimov
600da6909c storage: put uint32 into keys using in big endianness
Which allows to iterate over the contents easily.
2022-02-18 14:35:17 +03:00
Roman Khimov
5402e654d1 core: don't create useless DAO layer in GetTestVM
We're already wrapping in interop.NewContext.
2022-02-18 14:12:44 +03:00
Roman Khimov
b60d4ff191 dao: deduplicate header->KV conversion 2022-02-18 14:12:44 +03:00
Roman Khimov
f80680187e storage: expose private storage map for more efficient MPT batch
It couldn't be done previously with two maps and mixed storage, but now all of
the storage changes are located in a single map, so it's trivial to do exact
slice allocations and avoid string->[]byte conversions.
2022-02-17 23:41:10 +03:00
Roman Khimov
7dc8fc443f dao: simplify buffer management for private DAO
Private DAO is only used in a single thread which means we can safely reuse
key/data buffers most of the time and handle it all in DAO.

Doesn't affect any benchmarks.
2022-02-17 22:27:39 +03:00
Roman Khimov
9bfb3357f2 storage: add "private" mode to MemCachedStore
Most of the time we don't need locking on the higher-level stores and we drop
them after Persist, so that's what private MemCachedStore is for.

It doesn't improve things in any noticeable way, some ~1% can be observed in
neo-bench under various loads and even less than that in chain processing. But
it seems to be a bit better anyway (less allocations, less locks).
2022-02-17 22:27:39 +03:00
Roman Khimov
aefb26255a dao: drop DAO interface
It's a remnant from the days when we had Simple and Cached DAO
implementations, now it makes zero sense.
2022-02-16 18:24:20 +03:00
Roman Khimov
9d2ef775cf storage: simplify (*MemCachedStore).Put/Delete interface
They never return errors, so their interface should reflect that. This allows
to remove quite a lot of useless and never tested code.

Notice that Get still does return an error. It can be made not to do that, but
usually we need to differentiate between successful/unsuccessful accesses
anyway, so this doesn't help much.
2022-02-16 18:24:20 +03:00
Roman Khimov
017795c9c1 storage: completely remove MemoryBatch
If you need something like that, just wrap another MemCachedStore layer around
it.
2022-02-16 16:13:12 +03:00
Roman Khimov
54bc603831 core: remove old storage items synchronously during jump
There won't be a lot of them and GC experience we have shows that iterating
over 1-2M of entries is not a huge problem for DBs we have.
2022-02-16 13:03:13 +03:00
Roman Khimov
805d81e441 core: drop old transfer data during state jump 2022-02-16 12:12:03 +03:00
Roman Khimov
3a2b800e5f core: remove stale transfer entries, fix #2096
Initially I thought of doing it in the next persist cycle, but testing shows
that it needs just ~2-5% of the time MPT GC does, so doing it in the same
cycle doesn't affect anything.
2022-02-15 15:51:03 +03:00
Roman Khimov
ccdda21718 stateroot: add and use DataMPTAux for auxiliary data
Use DataMPT for nodes only, otherwise with 1M blocks with have 1M
height-stateroot mapping entries that our GC has to iterate over for no
reason.
2022-02-14 17:29:21 +03:00