Commit graph

2491 commits

Author SHA1 Message Date
Roman Khimov
2f8e7e4d33 native: fix getvalidators to match C# implementation
ValidatorsCount is not initialized at block 0 with C# node (the first voter
initializes it) and until that initialization happens the standby validators
list is being returned as is without sorting.

Fixes state mismatch for the key ffffffff0e00000000000000000000000000000001 in
the first blocks.

It also affects tests as now the first validator is different and it receives
the network fees.
2020-06-24 10:21:24 +03:00
Roman Khimov
66df805f3b cli/server: update value conversion for Neo 3
Version is no longer being stored for the value, so there is no need for '00'
byte.
2020-06-24 10:21:24 +03:00
Roman Khimov
fb18eda515 cli/server: update toNeoStorageKey key conversion for Neo 3
Follow #1037 changes with contract IDs and update padding, the number of
value bytes is being stored now as 17th byte instead of number of zeroes.
2020-06-24 10:21:24 +03:00
Roman Khimov
0fdeafb8f7
Merge pull request #1058 from nspcc-dev/neo3/smartcontract/policy
core: add native policy contract
2020-06-24 09:37:29 +03:00
Anna Shaleva
9f11a55bd6 core: add policy check to mempool
After block was stored it's possible to have new FeePerByte constraint,
so we should remove all transactions which do not meet this requirement.
Also caching of FeePerByte was added in order not to re-verify
transactions each time mempool needs to be updated.
2020-06-24 07:58:09 +03:00
Anna Shaleva
ce402a70d2 core: add policy check to (*Blockchain).verifyTx method
If any of transaction's script hashes for verifying are included into
Policy blocked accounts list, transaction is invalid.
2020-06-24 07:58:09 +03:00
Anna Shaleva
b88863948d rpc: add native policy API to RPC client
part of #904
2020-06-24 07:58:09 +03:00
Anna Shaleva
9097a1a23d smartcontract: update (Parameter).MarshalJSON method
MarshalJSON should be defined on structure (not pointer), as we use
structures to marshal parameters (e.g. in NotificationEvent and
Invoke of RPC result package) and never use pointers for that purpose.

Also added marshalling of nil array into `[]` instead of `null` to
follow C# implementation.
2020-06-24 07:58:09 +03:00
Anna Shaleva
8de0332107 *: use MaxTransactionsPerBlock from Policy native contract
part of #904

1. We now have MaxTransactionsPerBlock set in native Policy contract,
   so this value should be used in (dbft).GetVerified method instead
   of passing it as an argument.
2. Removed (dbft).WithTxPerBlock.
2. DBFT API has changed, so update it's version.
3. Removed MaxTransactionsPerBlock from node configuration, as we
   have it set in native Policy contract.
2020-06-24 07:58:05 +03:00
Anna Shaleva
c2735a4569 core: add cache to native Policy contract
We can cache maxBlockSize, maxTransactionsPerBlock and feePerByte
in order to reduce the number of storage requests.
2020-06-24 07:36:11 +03:00
Anna Shaleva
08cc04c3d5 core: add native policy contract
part of #904
2020-06-24 07:35:07 +03:00
Roman Khimov
9d675f6e56
Merge pull request #1091 from nspcc-dev/neo3/rpc/getstorage
rpc: add GetStorageByID RPC client method
2020-06-23 22:19:34 +03:00
Anna Shaleva
65c1ce4f6a rpc: add GetStorageByID RPC client method
Should be a part of #1077
2020-06-23 17:31:22 +03:00
Roman Khimov
293e5c3f5d
Merge pull request #1079 from nspcc-dev/fix/rangeloop
Implement for-range loop without iterators
2020-06-22 14:52:47 +03:00
Evgenii Stratonikov
e54149d547 compiler: do not load map key twice in for-range loop 2020-06-22 13:43:59 +03:00
Evgenii Stratonikov
1847c28b42 compiler: do not load values which will be dropped 2020-06-22 13:43:59 +03:00
Evgenii Stratonikov
72be5412f4 compiler: optimize argument reversing
Do not reverse arguments if there is no more than 1.
2020-06-22 13:43:59 +03:00
Evgenii Stratonikov
3729865860 compiler: reimplement for-range loops without syscalls
System.Enumerator.Next costs 1_000_000 gas which is rather big for a
single iteration. Reimplement this by saving current counters on stack.
This approach will use 2 PICKITEMS (270_000 gas) for maps, which is
still cheaper that *.Next syscall.
2020-06-22 13:43:58 +03:00
Roman Khimov
da2d96d42f
Merge pull request #1080 from nspcc-dev/fix-verack
message: fix Verack processsing
2020-06-20 10:52:18 +03:00
Roman Khimov
892812d539 message: fix Verack processsing
Recent 9f42108ef completely broke handshaking.
2020-06-20 00:28:51 +03:00
Roman Khimov
36a65e3847
Merge pull request #1077 from nspcc-dev/neo3/smartcontract/id
core: store smartcontract items by id
2020-06-20 00:12:07 +03:00
Roman Khimov
a2cd2264a8 core: fix HasStorage check in storageGetContext
It was returning nil which is wrong.
2020-06-20 00:04:28 +03:00
Anna Shaleva
f1cdcbc99c core: store smartcontract items by id
closes #1037
2020-06-19 20:48:45 +03:00
Anna Shaleva
c767ac2973 core: fix NEO native contract id
It should be set to -1 as in c# implementation.
2020-06-19 20:44:52 +03:00
Roman Khimov
75cc109837
Merge pull request #1072 from nspcc-dev/fix/payload
Allow NullPayload only for CMDGetAddr
2020-06-19 15:58:40 +03:00
Evgenii Stratonikov
505029152f payload: always dereference NullPayload
There is no need in extra indirection level.
2020-06-19 15:02:21 +03:00
Evgenii Stratonikov
9f42108ef2 network: allow NullPayload only for specific commands
CMDFilterClear, CMDGetAddr, CMDMempool all have empty payloads.
2020-06-19 15:01:30 +03:00
Roman Khimov
025bf9c235
Merge pull request #1076 from nspcc-dev/fix/gas
Fix interop gas prices
2020-06-19 13:41:43 +03:00
Evgenii Stratonikov
a584c5a6a4 native: fix NEP5 contract method prices
Closes #1073.
2020-06-19 12:58:33 +03:00
Evgenii Stratonikov
47f53e612e vm: fix Log and Notify default interop prices 2020-06-19 12:58:33 +03:00
Evgenii Stratonikov
4b31c18316 core: fix Neo.Native.Deploy price 2020-06-19 12:58:33 +03:00
Evgenii Stratonikov
540ac23ca8 core: calculate prices of Neo.Crypt.* opcodes correctly 2020-06-19 12:58:33 +03:00
Roman Khimov
ce6bacd51a
Merge pull request #1070 from nspcc-dev/fix/getapplicationlog
Update `getapplicationlog` RPC
2020-06-19 12:45:33 +03:00
Evgenii Stratonikov
05dad10e82 native: fix native contract onPersist script
C# implementation uses NEWARRAY for creating arguments.
Don't change our implementation in `emit`, because PACK is cheaper and
this script must not depend on the internal details of `emit` package anyway.
2020-06-19 11:58:38 +03:00
Evgenii Stratonikov
3787a8895e rpc: marshal GasConsumed getapplicationlog as string
Also there is no more decimal point.
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
6a2161207a smartcontract: rename ByteArray to ByteString in JSON for smartcontract parameters 2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
81adb7ce83 core: set price getter for native contract persist routine 2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
b9e260a704 smartcontract: omit empty value in JSON for Interop/Any parameters 2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
3a0be5ce28 rpc: allow to invoke getapplicationlog with block hash
Support retrieving native contract persist results by block hash.
All necessary support is already here, just add test.
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
a980cac0b3 stackitem: support Null item (de-)serialization
It's binary representation contains just type (AnyT).
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
c0e482fe6c rpc: restructure getapplicationlog response
Move VM-related fields to top-level.
2020-06-19 11:38:56 +03:00
Roman Khimov
93b0011988
Merge pull request #1069 from nspcc-dev/addr-locking-and-other-fixes
Addr, locking and other fixes
2020-06-18 23:29:19 +03:00
Roman Khimov
c281944c9b
Merge pull request #1068 from nspcc-dev/fix/free
Remove logic related to free transactions
2020-06-18 23:28:55 +03:00
Evgenii Stratonikov
e7d8bb92f6 core/tests: extend native contract test
Check if native contract's method price is taken into account.
2020-06-18 22:44:10 +03:00
Evgenii Stratonikov
5354352d63 core: remove transaction priority
There is no such thing as high/low priority transactions, as there are
no free transactions anymore and they are ordered by fees contained
in transaction itself.

Closes #1063.
2020-06-18 22:44:10 +03:00
Evgenii Stratonikov
2f724b792c core: remove config fields related to free transactions
In NEO3 every transaction must have some gas attached.

Closes #1064.
2020-06-18 22:44:08 +03:00
Roman Khimov
1081791c68 core: fix contract manifest unpacking in System.Contract.Create
It's just JSON, io.Serializable is only used for DB storage where the length
should be obtained from the stream. Fixes:

2020-06-18T22:14:10.571+0300    WARN    contract invocation failed      {"tx": "1ffd475a9c246495d6206cb80a9a78e9d14a433ded60cd37aa87d897655606e1", "block": 25893, "error": "error encountered at instruction 3696 (SYSCALL): failed to invoke syscall: invalid character ':' after top-level value"}
2020-06-18 22:38:34 +03:00
Evgenii Stratonikov
84387b2416 core: set gas limit to transaction.SystemFee for all transactions 2020-06-18 22:17:48 +03:00
Roman Khimov
90d3bcbdc3 state: initialize PublicKey before decoding into it, fix #1061
These are pointers and decoding into a nil pointer is a bad idea.
2020-06-18 21:59:58 +03:00
Roman Khimov
dd6895b103 native: optimize GAS onPersist for empty blocks
There is no need to get a list of validators when there are no transactions in
the block.
2020-06-18 21:51:29 +03:00