Commit graph

2609 commits

Author SHA1 Message Date
Roman Khimov
21cb7d5701
Merge pull request #1078 from nspcc-dev/feature/mempool
network: implement CMDMempool command
2020-06-24 10:49:42 +03:00
Roman Khimov
5d51ceaeac
Merge pull request #1093 from nspcc-dev/fix-some-inconsistencies-wrt-sharp
Fix some inconsistencies wrt sharp
2020-06-24 10:47:16 +03:00
Evgenii Stratonikov
57bb2f73de network: implement CMDMempool command
CMDMempool returns hashes of transactions in mempool in chunks.
2020-06-24 10:46:26 +03:00
Roman Khimov
5251607fb7 transaction: s/txid/hash/ for JSON to match C# implementation
It uses `hash` for transactions now, but `txid` for application logs.
2020-06-24 10:43:58 +03:00
Roman Khimov
d81d826bfc core: fix Storage.Get to return Null when there is no value
Match C# implementation and fix state inconsistency at block 249920 of
preview2 testnet. Make our Go Storage.Get return nil and adapt
examples/tests.
2020-06-24 10:43:58 +03:00
Roman Khimov
954c8ff8d6 compiler: support nil checks 2020-06-24 10:43:58 +03:00
Roman Khimov
6f5a42facf smartcontract: correctly encode/decode AnyType
It might get emitted with notifications.
2020-06-24 10:22:21 +03:00
Roman Khimov
7987cdadc0 native: update storage item value after gas distribution
Even if the value is zero, the GAS distribution updates the balance height, so
storage item must be updated too. Fixes the followin on preview2 testnet:
block 74227: value mismatch for key ffffffff1454a6cb279fbcedc66162ad4ad5d1d910202b92743e000000000000000000000005: 1041032104809fd5002103f3210128010000 vs 1041032104809fd50021033f110128010000
2020-06-24 10:22:21 +03:00
Roman Khimov
48fac6f87d native: unify some transfer code 2020-06-24 10:22:21 +03:00
Roman Khimov
fccad11716 native: drop accounts with zero balance
They make no sense. Fixes preview2 testnet state problem:

file BlockStorage_100000/dump-block-70000.json: block 69935: state mismatch for key ffffffff1454a6cb279fbcedc66162ad4ad5d1d910202b92743e000000000000000000000005: Deleted vs Added
2020-06-24 10:22:21 +03:00
Roman Khimov
a77357227a vm: fix caller's script hash returned from VM
Regular CALLs don't update it, only Contract.Call does. Fixes the following
mismatch on preview2 testnet:

file BlockStorage_100000/dump-block-49000.json: block 48644, changes number mismatch: 6 vs 4
2020-06-24 10:22:21 +03:00
Roman Khimov
d5c9449a43 dao: combine GetNextContractID and PutNextContractID
And fix contract create to really update the ID, eliminating this difference
in the storage (preview2 testnet):
file BlockStorage_100000/dump-block-39000.json: block 38043: key mismatch: 0c000000617373657464df4ebe92334d1fc7e64b10f1d1e33942d9905e510000000000000009 vs 00000000617373657464df4ebe92334d1fc7e64b10f1d1e33942d9905e510000000000000009
2020-06-24 10:22:21 +03:00
Roman Khimov
5e56c9db29 native: fix voting accounting in transfers processing
We should modify votes count exactly by the amount of NEO balance change, it
might be negative here.
2020-06-24 10:22:21 +03:00
Roman Khimov
37d44b94e1 native: fix netfee gas redistribution
Preview2 testnet:
file BlockStorage_100000/dump-block-12000.json: block 11562: key mismatch: feffffff1454a6cb279fbcedc66162ad4ad5d1d910202b92743e000000000000000000000005 vs feffffff1431b7e7aea5131f74721e002c6a56b610885813f79e000000000000000000000005

Originally this code was written to run after transactions processing, but
after 0fa4c49735 it works in different manner.
2020-06-24 10:22:21 +03:00
Roman Khimov
d0331bf21b native: simplify votes saving in NEO contract
Follow C# behavior and fix state mismatch at block 11561 of preview2 testnet.
2020-06-24 10:22:21 +03:00
Roman Khimov
e5f05790d5 core: cache standby validators in the Blockchain
They never change, so it makes no sense parsing the keys over and over
again. It also simplifies the interface a little.
2020-06-24 10:22:17 +03:00
Roman Khimov
cd2dca0259 state: fix the way NEO balance is being serialized
Actually, our format is way better, but for preview2 compatibility we need to
use this one.
2020-06-24 10:21:24 +03:00
Roman Khimov
c124d2bcdf core: fix gas generation coefficients to match Neo 3
Follow neo-project/neo#911. Fixes state differences at block 4528 of preview2
testnet compared to C# node.
2020-06-24 10:21:24 +03:00
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