Commit graph

1570 commits

Author SHA1 Message Date
Anna Shaleva
ad9ede455e rpc: add NNS-connected transactions to the test chain
It is needed for RPC client integration tests.
2021-03-26 20:44:32 +03:00
Anna Shaleva
a2a9d7ff05 core: move NNS record types to a separate package
We need this to avoid `native` dependency in RPC client.
2021-03-26 20:44:32 +03:00
Anna Shaleva
252e03bc34 rpc: add CalculateNetworkFee RPC method 2021-03-26 19:14:46 +03:00
Roman Khimov
5f7ec6e784 state: fix MPTRoot JSONization
Match C# implementation. It's easier to do this by changing the structure
itself.
2021-03-26 13:45:18 +03:00
Roman Khimov
b3f9cd1541 dao: drop network from DAO
Not used any more.
2021-03-26 13:45:18 +03:00
Roman Khimov
c789431402 payload: drop Network from P2PNotaryRequest
It's not needed now.
2021-03-26 13:45:18 +03:00
Roman Khimov
8c110a6147 state: drop Network from MPTRoot structure
It's only needed to verify/sign.
2021-03-26 13:45:18 +03:00
Roman Khimov
95c279325a block: drop Network from the Header
It's not network-tied any more, network is only needed to
sign/verify. Unfortunately we still have to keep network in consensus data
structures because of dbft library interface.
2021-03-26 13:45:18 +03:00
Roman Khimov
d314f82db3 transaction: drop Network from Transaction
We only need it when signing/verifying.
2021-03-26 13:45:18 +03:00
Roman Khimov
df12adaa9e crypto: remove crypto.Verifiable interface
We can now verify any hash.Hashable thing.
2021-03-26 13:45:18 +03:00
Roman Khimov
0248e2c0d2 state: add network to MPTRoot, change hashing
Fix RC1 incompatibility.
2021-03-25 22:37:30 +03:00
Anna Shaleva
1e649bc9a0 core: move NotaryVerificationPrice to a separate package
It is needed to avoid `native` dependency in RPC client.
2021-03-23 13:56:39 +03:00
Anna Shaleva
681bd89cc7 core: move native node roles to a separate pkg
We need this to avoid `native` dependency in the RPC client.
2021-03-23 13:56:34 +03:00
Roman Khimov
28da00f057
Merge pull request #1852 from nspcc-dev/tests/fix-rubles-contract
rpc: refactor Rubl test contract
2021-03-22 15:55:51 +03:00
Anna Shaleva
6b36590181 core: ensure all transactions are HALT while creating test chain 2021-03-22 15:35:22 +03:00
Anna Shaleva
0a5072a1da core: allow to compile test contracts with yaml config
And refactored Rubl test contract (it should support NEP-17 and
onNEP17Payment).
2021-03-22 15:32:26 +03:00
Roman Khimov
20144e6137 *: fix some misspellings spotted by GoReportCard 2021-03-22 12:13:08 +03:00
Anna Shaleva
96e198de97 core: fix Management.GetContract 2021-03-19 20:44:21 +03:00
Roman Khimov
57d4990fe6
Merge pull request #1850 from nspcc-dev/fex-storage-price
core: fix storage.Put price
2021-03-19 19:10:22 +03:00
Anna Shaleva
7118eae467 core: remove useless code from putWithContext 2021-03-19 18:57:29 +03:00
Anna Shaleva
5b18f5974f core: fix storage.Delete price 2021-03-19 18:57:00 +03:00
Anna Shaleva
0bca63b907 core: fix storage.Put price 2021-03-19 18:41:33 +03:00
Roman Khimov
b56e028733 *: add more package-specific documentation
For the most important packages at least.
2021-03-19 16:18:45 +03:00
Anna Shaleva
e5cdecfa9f core: fix transaction hashes 2021-03-18 17:57:54 +03:00
Roman Khimov
42465dd002
Merge pull request #1825 from nspcc-dev/fix-invokecontractverify
rpc: refactor invokecontractverify
2021-03-17 18:08:23 +03:00
Roman Khimov
0de72f1dc9 core: fix call flags for Native(On|Post)Persist
See neo-project/neo#2339.
2021-03-16 22:49:14 +03:00
Roman Khimov
d1251b8daf core: don't limit on/postPersist methods
They read/write/call/notify, so they need everything.
2021-03-16 22:48:32 +03:00
Roman Khimov
304b9ad3d4 contract: disable notifications for safe methods
See neo-project/neo#2339.
2021-03-16 22:47:49 +03:00
Roman Khimov
025330f132
Merge pull request #1832 from nspcc-dev/consensus/microfixes
consensus: add MaxBlockSize and MaxBlockSysFee settings
2021-03-16 18:11:33 +03:00
Anna Shaleva
0d9266d407 core: remove System.Contract.IsStandard 2021-03-16 16:59:23 +03:00
Roman Khimov
a18fbc7bb1
Merge pull request #1827 from nspcc-dev/native/update_history
config: add NativeUpdateHistory
2021-03-16 12:47:22 +03:00
Anna Shaleva
20b70ee9fe config: add MaxBlockSystemFee setting 2021-03-16 12:09:11 +03:00
Anna Shaleva
8f06bf21d7 config: add MaxBlockSize setting 2021-03-16 12:08:47 +03:00
Anna Shaleva
9377751e65 config: add NativeUpdateHistory 2021-03-15 12:35:14 +03:00
Anna Shaleva
edfca68a17 rpc: refactor invokecontractverify
In `(c *Client) AddNetworkFee` we define network fee for contract
witness verification via `invokecontractverify` RPC call, and that's the
initial purpose of this RPC method. But it was not implemented
correctly. It used `System.Contract.Call` instead of beheiving like
`initVerificationVM`.

During real contract witness verification the whole contract's script is
loaded into VM, and then we jump to the `verify` method. Thus, to define
exact contract verification price, we should act like this (and not just
perform `System.Contract.Call` of `verify` method).

Tests are added.

This bug is the reason of adding extra GAS (c.notary.extraVerifyFee) to
pre-calculated value in
https://github.com/nspcc-dev/neofs-node/pull/404/files#diff-639db437ca2578db46c9e8cbf18f9aa01f8ca5aee30e0fa7e70ba0354822d7b3R237
2021-03-12 18:59:20 +03:00
Anna Shaleva
1261dd5306 core: refactor initVerificationVM
It needs only VM and function to get contract state. Also exposed this
method and extended Blockchainer. These changes are needed for the
next commit.
2021-03-12 18:55:27 +03:00
Roman Khimov
f7d74190f5
Merge pull request #1829 from nspcc-dev/change-hashing-scheme
Change hashing scheme
2021-03-12 15:20:23 +03:00
Anna Shaleva
85a8644517 core: add nativenames.IsValid 2021-03-12 13:05:37 +03:00
Roman Khimov
6326094264 native: change getCommittee/getNextBlockValidators price
See neo-project/neo#2392, neo-project/neo#2391.
2021-03-12 11:32:27 +03:00
Roman Khimov
4462a6a6b7 change block/tx/extensible signing process, fix #1741
Sign [magic, hash], see neo-project/neo#2314.
2021-03-12 11:27:50 +03:00
Roman Khimov
096f48caf0
Merge pull request #1820 from nspcc-dev/fix/nativetypes
native: use proper types in manifest
2021-03-11 17:02:34 +03:00
Evgeniy Stratonikov
de04411488 core/fee: alter opcode prices
Follow neo-project/neo#2384.
2021-03-11 15:44:09 +03:00
Evgeniy Stratonikov
1cb25d3190 native: use proper types in manifest 2021-03-11 11:48:38 +03:00
Evgeniy Stratonikov
9cb38a4b1b native: support StorageFee 2021-03-11 10:12:30 +03:00
Evgeniy Stratonikov
256cd09228 native: allow to set oracle request price 2021-03-11 10:12:30 +03:00
Evgeniy Stratonikov
27fc28bd69 native: allow to set candidate register price 2021-03-11 10:12:30 +03:00
Evgeniy Stratonikov
d9e62de454 native: fix prefixGASPerBlock doc comment 2021-03-11 10:12:30 +03:00
Evgeniy Stratonikov
3278d23852 native: rename Price to CPUFee
Method price is now multiplied by `BaseExecFee`.
2021-03-11 10:12:30 +03:00
Anna Shaleva
9015e50847 core: refactor Neo.Crypto.CheckMultisigWithECDsaSecpr1
Rename it to Neo.Crypto.CheckMultisig and remove `message` parameter.
2021-03-10 21:46:05 +03:00
Anna Shaleva
7126637f73 core: remove Neo.Crypto.CheckMultisigWithECDsaSecp256k1
Koblitz RIP.
2021-03-10 21:46:05 +03:00
Anna Shaleva
cdaca7be3e core: use Neo.Crypto.CheckSig for standard signature verification 2021-03-10 21:45:58 +03:00
Anna Shaleva
4e6c1092b8 core: add Neo.Crypto.CheckSig interop 2021-03-10 19:24:19 +03:00
Anna Shaleva
14ade42101 core: remove System.Binary.[Serialize, Deserialize] syscalls
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
5c9c168ee5 core: remove System.Binary.[Base64*, Base58*] syscalls
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
4d2ad4b9e2 core: remove System.Json.[Serialize, Deserialize] interops
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
f65485b735 core: remove System.Binary.Itoa and System.Binary.Atoi syscalls
And move their tests to native StdLib.
2021-03-10 19:24:19 +03:00
Anna Shaleva
2b90d4455f native: implement StdLib contract 2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
100f2db3fb native: implement CryptoLib contract 2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
ac95510402 core: do not return block if only header is present 2021-03-10 13:38:44 +03:00
Evgeniy Stratonikov
f83b376181 block: replace Base with Header 2021-03-10 13:38:44 +03:00
Evgeniy Stratonikov
4df8a2ad36 block: remove MaxContentsPerBlock 2021-03-10 13:38:44 +03:00
Evgeniy Stratonikov
2f490a3403 block: remove ConsensusData field 2021-03-10 13:38:44 +03:00
Roman Khimov
e66d36900c
Merge pull request #1701 from nspcc-dev/statemsg
Update state-root handling
2021-03-09 15:16:44 +03:00
Evgeniy Stratonikov
2f3abf95a2 stateroot: broadcast state on new blocks 2021-03-09 13:51:11 +03:00
Evgeniy Stratonikov
3c65ed1507 stateroot: allow to sign new roots 2021-03-09 13:51:11 +03:00
Evgeniy Stratonikov
ac227a80fe stateroot: use RoleStateValidator for verification 2021-03-09 13:51:10 +03:00
Evgeniy Stratonikov
bf20db09e0 stateroot: move state-root related logic to core/stateroot 2021-03-09 13:48:29 +03:00
Evgeniy Stratonikov
d06718e1cb core/tests: print hash of the genesis block 2021-03-09 13:34:22 +03:00
Evgeniy Stratonikov
a737d473fb native: use ToPreallocatedBytes where possible 2021-03-09 12:11:26 +03:00
Evgeniy Stratonikov
e551432b30 dao: serialize state.StorageItem as raw bytes 2021-03-09 12:11:26 +03:00
Evgeniy Stratonikov
55698d0426 dao: use raw state.StorageItem instead of pointer
It is now a slice, there is no need for additional indirection.
2021-03-09 12:11:25 +03:00
Evgeniy Stratonikov
fd4174ad31 core/state: remove IsConst from StorageItem 2021-03-09 11:59:08 +03:00
Evgeniy Stratonikov
4195603257 native: add NeoFSAlphabet node role 2021-03-05 13:13:31 +03:00
Evgeniy Stratonikov
47ef3b41fa core: fix System.Storage.Find parameter count 2021-03-05 10:17:35 +03:00
Evgeniy Stratonikov
ffd85dd51d native/policy: remove MaxBlockSize and MaxBlockSystemFee 2021-03-04 16:59:19 +03:00
Evgeniy Stratonikov
7b8533b67c native/policy: move MaxTransactionsPerBlock to config 2021-03-04 16:59:19 +03:00
Evgeniy Stratonikov
0a789af10d core: fix parameter count for CreateMultisigAccount 2021-03-04 12:55:31 +03:00
Roman Khimov
e6d3a60431
Merge pull request #1782 from nspcc-dev/optimize/nep17
dao: do not look up new NEP17 batch
2021-03-02 15:28:42 +03:00
Roman Khimov
c9212f29e6
Merge pull request #1744 from nspcc-dev/fix/nativecall
Update `CallNative` to post-preview5
2021-03-02 15:28:00 +03:00
Roman Khimov
10cc19b33c
Merge pull request #1791 from nspcc-dev/drop-go-1-13
*: drop go 1.13
2021-03-01 17:20:26 +03:00
Anna Shaleva
ffb2d78bbd core: update Notary test
Let's allow to wait a bit more. Hardware resources of the Github
workflow tests aren't so fluent.
2021-03-01 17:08:00 +03:00
Anna Shaleva
2c81fc8b8e *: upgrade tests to use T.Cleanup() 2021-03-01 17:08:00 +03:00
Evgeniy Stratonikov
d255c4a517 vm: implement SQRT opcode 2021-03-01 16:58:53 +03:00
Evgeniy Stratonikov
6496782736 vm: implement POW opcode 2021-03-01 16:58:53 +03:00
Evgeniy Stratonikov
d5cb95e685 dao: do not look up new NEP17 batch
It will fail anyway.
2021-02-26 14:08:51 +03:00
Evgeniy Stratonikov
61ce4a7f79 core: set native script and hash in SetOracle 2021-02-26 10:59:09 +03:00
Evgeniy Stratonikov
f9f1fe03b2 core: refactor native call
1. `System.Contract.CallNative` expects version on stack.
2. Actual method is determined based on current
   instruction pointer.
3. Native hashes don't longer depend on NEF checksum.
2021-02-26 10:59:09 +03:00
Roman Khimov
f264996f74
Merge pull request #1777 from nspcc-dev/fix/vote
core: fix native method call flags
2021-02-25 18:55:10 +03:00
Evgeniy Stratonikov
663afbe4df core: check call flags in LoadToken
Follow neo-project/neo#2292.
2021-02-25 18:14:52 +03:00
Evgeniy Stratonikov
4db5ef05f8 core: fix call flags for System.Contract.Call
Follow neo-project/neo#2292.
2021-02-25 18:12:38 +03:00
Evgeniy Stratonikov
cbda20aca3 core: fix native method call flags
Replace `WriteStates` with `States`.

Follow neo-project/neo#2339.
Close #1775.
Related #1725.
2021-02-25 18:07:33 +03:00
Anna Shaleva
81ea4bbfcf core: update oracle test
It is failing from time to time.
2021-02-25 11:20:28 +03:00
Anna Shaleva
988dfcc7fe services: update Notary transaction size after completion
Close #1766
2021-02-24 12:38:32 +03:00
Roman Khimov
abee3b5b05
Merge pull request #1722 from nspcc-dev/fix/nep11
smartcontract: add NEP-11 standard check
2021-02-22 22:27:09 +03:00
Anna Shaleva
5a37201319 core: add System.Contract.CreateMultisigAccount interop 2021-02-19 17:31:50 +03:00
Evgeniy Stratonikov
ae30e30321 native: add NEP-11 check for name service 2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
9c0bbd0bfd smartcontract: add NEP-11 standard check
The only method missing is name, because it is
provided in manifest.
2021-02-19 17:06:07 +03:00
Roman Khimov
608df7fb21
Merge pull request #1747 from nspcc-dev/default-notary-config
notary: usability improvements
2021-02-17 14:21:47 +03:00
Roman Khimov
69458a9945
Merge pull request #1751 from nspcc-dev/microfixes
core: microfixes
2021-02-17 14:20:01 +03:00
Anna Shaleva
0cd02e2de8 core: update protocols regexps 2021-02-17 13:51:08 +03:00
Anna Shaleva
15d90925b8 core: refactor (*NameService).checkName method
It does not require native contract.
2021-02-17 13:29:18 +03:00
Anna Shaleva
a4d84ee3b0 core: enable test, disabled in ac52765 2021-02-17 13:19:26 +03:00
Anna Shaleva
1e108f20a7 core: remove description from NFT state 2021-02-17 13:19:26 +03:00
Anna Shaleva
a6d4a266b9 core: check transaction's scripts length during decoding 2021-02-17 13:19:23 +03:00
Evgeniy Stratonikov
0cb6ec7345 mpt: allow to remove non-existent keys in batch
This bug was here before batch were intoduced.
`Delete` is allowed to be called on missing keys with
HALT result, MPT needs to take this into account.
2021-02-17 12:37:44 +03:00
Anna Shaleva
bcb82b457d config: move notary module config to ApplicationConfiguration 2021-02-16 13:58:25 +03:00
Anna Shaleva
46dfd36a1f core: fix native designateAsRole method
It shouldn't return anything.
2021-02-15 18:13:00 +03:00
Anna Shaleva
664a2a88eb core: allow call in verification 2021-02-15 15:03:32 +03:00
Anna Shaleva
4893faa374 core: remove NEP17BalanceState if balance is null [addTokens]
Affects states.
2021-02-12 23:48:30 +03:00
Anna Shaleva
0f1473897b core: temp manifest.Extra marshalling fix
Manifest.Extra still serialized as JSON message with undefined  order
of items, so it affects contract states dumps.
2021-02-12 23:48:30 +03:00
Anna Shaleva
e1384cb795 core: fix native NameService methods return types
Affects dumps.
2021-02-12 18:58:31 +03:00
Anna Shaleva
49b1b4bb27 core: fix native Neo parameter name
Affects dumps.
2021-02-12 18:58:31 +03:00
Anna Shaleva
99f58d9cd5 core: fix native Ladger parameter type
Affects dumps.
2021-02-12 18:58:31 +03:00
Anna Shaleva
7021c76042 core: fix native Management's parameters names
Affects dumps.
2021-02-12 18:58:31 +03:00
Anna Shaleva
a237e34c1f rpc: add test for submitNotaryRequest 2021-02-11 17:15:59 +03:00
Anna Shaleva
2bb8537151 core: use declared constant for Notary's verification price
This constant is used from the outside, it should be synced with the
real verification price.
2021-02-11 17:11:36 +03:00
Anna Shaleva
9bd2cae08e core: refactor (*Notary).verify
There could be only one Notary signer.
2021-02-11 17:11:36 +03:00
Anna Shaleva
8444f3d816 network: refactor notary service's PostBlock
There was a deadlock while trying to finalize transaction during
PostBlock:
	1) (*Notary).PostBlock is called under the blockchain lock
	2) (*Notary).onTransaction is called inside the PostBlock
	3) (*Notary).onTransaction needs to RLock the blockchain to add
completed transaction to the memory pool (and the blockchain is Lock'ed
by this moment)

The problem is fixed by using notifications subsistem, because it's not
required to call (*Notary).PostBlock under the blockchain lock.
2021-02-11 17:11:36 +03:00
Evgeniy Stratonikov
560aff6155 compiler: adjust init/_deploy method offsets during optimization
Because `_initialize` and `_deploy` methods encompass multiple
Go functions, their offsets are stored differently and need
special treatment.
2021-02-11 15:59:02 +03:00
Evgeniy Stratonikov
02ca3d3dfd interop: reuse state.Native in ContractMD 2021-02-11 12:32:10 +03:00
Evgeniy Stratonikov
6ca7b4b966 interop: rename ContractID to ID
Helps further refactoring, see next commit.
2021-02-11 12:27:43 +03:00
Evgeniy Stratonikov
f0d8652bcd rpc: implement getnativecontracts RPC 2021-02-11 12:27:43 +03:00
Evgeniy Stratonikov
e1d2a5b5b7 state: split ContractBase and UpdateCounter
Latter doesn't make sense for native contracts.
2021-02-11 12:24:09 +03:00
Roman Khimov
29b1581ea8
Merge pull request #1723 from nspcc-dev/fix/rpcnumber
Marshal fees and GAS as integers.
2021-02-11 00:35:46 +03:00
Roman Khimov
7c419cebdc
Merge pull request #1729 from nspcc-dev/manifest-and-script-checks
Manifest and script checks
2021-02-10 20:58:52 +03:00
Roman Khimov
dd05cae506 core: check all transaction scripts
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
158f0d9d9c native/vm: add script check for deployed contracts
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
62ef5a8dc7 native: enforce contract manifest UTF-8 validity
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
e9ea89b4e3 manifest: add group signature length check
Refs. #1699.
2021-02-09 22:31:24 +03:00
Evgeniy Stratonikov
b0fbd897ad Revert "rpc: marshal fees and GAS as Fixed8 decimal"
This reverts commit a79b12b4d4.
2021-02-09 11:16:52 +03:00
Evgeniy Stratonikov
468dc5aad6 core/tests: fix NameService test
We should look for the timestamp of the block with `register`.
2021-02-08 17:56:10 +03:00
Roman Khimov
1a4958b1d5 manifest: add ABI validity check
Some methods must be defined in a valid ABI. Refs. neo-project/neo#2263.
2021-02-08 13:27:39 +03:00
Evgeniy Stratonikov
2f6345f2d9 compiler: add Hash compatibility test 2021-02-08 13:09:41 +03:00
Roman Khimov
5ba074b4cf manifest: return an error from IsValid
Be more specific.
2021-02-08 12:04:57 +03:00
Roman Khimov
e4b5b59663
Merge pull request #1704 from nspcc-dev/binary_manifest
core: serialise manifest as stackitem
2021-02-05 23:58:07 +03:00
Roman Khimov
aad2b3adad
Merge pull request #1712 from nspcc-dev/nep17-nep11-onpayments
NEP17/NEP11 onPayments
2021-02-05 21:04:35 +03:00
Roman Khimov
cd9b34416e native: call onNEP11Transfer for NEP-11 transfers
See neo-project/neo#2287.
2021-02-05 20:48:45 +03:00
Anna Shaleva
a2715404d0 core: serialise manifest as stackitem 2021-02-05 19:10:15 +03:00
Anna Shaleva
840104461b config: update testnet netmode to preview5 magic 2021-02-05 18:57:54 +03:00
Roman Khimov
a442e1530d native: rename onPayment into onNEP17Payment
Follow neo-project/neo#2287.
2021-02-05 16:09:51 +03:00
Roman Khimov
cdfc7fc8fa
Merge pull request #1703 from nspcc-dev/initials_for_natives
core: store native contracts' initial values in the DB
2021-02-05 15:32:05 +03:00
Evgeniy Stratonikov
d7f68d3650 native: fix getCommittee name
`C` was in russian.
2021-02-05 13:34:05 +03:00
Anna Shaleva
2b06601646 core: change Oracle request ID endianness 2021-02-05 11:37:12 +03:00
Anna Shaleva
12f7111ca8 core: mark blocked accounts with empty byte array 2021-02-05 11:37:12 +03:00
Anna Shaleva
6a4e312eac core: move GetPrice from core to interop
We have additional logic for getting BaseExecFee policy value. This
logic should be moved to interop context instead of being in Policer,
because Policer is just an interface over Policy contract.

After moving this logic to interop context, we need to use it to define
BaseExecFee instead of (Policer).BaseExecFee. Thus, moving
(*Blockchain).GetPrice to (*Context).GetPrice is necessary.
2021-02-05 11:36:32 +03:00
Anna Shaleva
260bcd373c core: store initial native values into DAO 2021-02-05 10:43:17 +03:00
Roman Khimov
ed3cef81cc core: allow to read states for non-contract verifications
C# does it this way now:
  callFlags = !witness.VerificationScript.IsStandardContract() ? CallFlags.ReadStates : CallFlags.None

So non-standard scripts _always_ have access to state and standards ones just
don't care (their code is known and it doesn't touch state).
2021-02-04 13:12:11 +03:00
Roman Khimov
ac527650eb native: add Ledger contract, fix #1696
But don't change the way we process/store transactions and blocks. Effectively
it's just an interface for smart contracts that replaces old syscalls.

Transaction definition is moved temporarily to runtime package and Block
definition is removed (till we solve #1691 properly).
2021-02-04 13:12:11 +03:00
Roman Khimov
641896b2fb
Merge pull request #1658 from nspcc-dev/signature_collection/module
core, network: add Notary module
2021-02-02 22:24:14 +03:00
Anna Shaleva
df26ca1c7f core: add Notary module test 2021-02-02 22:01:32 +03:00
Anna Shaleva
bfbd096fed core: introduce mempool notifications 2021-02-02 22:01:32 +03:00
Anna Shaleva
19fa0daaa6 core, network: add Notary module 2021-02-02 22:01:20 +03:00
Roman Khimov
f7cb00b82d
Merge pull request #1678 from nspcc-dev/nameservice
Implement NameService
2021-02-01 22:52:59 +03:00
Evgeniy Stratonikov
e4ff8326b5 native: add NameService 2021-02-01 21:40:21 +03:00
Evgeniy Stratonikov
ec6317d643 core: allow to sign with arbitrary signer
Related #1677.
2021-02-01 10:16:16 +03:00
Evgeniy Stratonikov
c8a07be58d native: sort methods in manifest 2021-01-29 12:19:08 +03:00
Evgeniy Stratonikov
2336415f42 naitve: disallow contract name modification 2021-01-29 12:19:08 +03:00
Evgeniy Stratonikov
c1cc7e6f9d native: add additional parameters to deploy
1. Management contract has 2 overloads of `deploy` method.
2. Normal contracts should have `_deploy` with 2 parameters.
2021-01-29 12:19:08 +03:00
Evgeniy Stratonikov
849385a533 native: allow to overload native methods 2021-01-29 12:19:08 +03:00
Roman Khimov
818d5988f5
Merge pull request #1695 from nspcc-dev/committeechecks
native: unify committee checks
2021-01-29 11:58:33 +03:00
Evgeniy Stratonikov
690b787fe3 native: unify committee checks
Fail execution if tx is not signed by committee.
2021-01-29 10:50:17 +03:00
Evgeniy Stratonikov
9592f3e052 network: implement pool for Extensible payloads 2021-01-28 17:09:06 +03:00
Evgeniy Stratonikov
153678160e native: use majority hash only for oracles 2021-01-28 17:09:06 +03:00
Evgeniy Stratonikov
db4e7558e0 native: cache all roles in Designate 2021-01-28 17:09:05 +03:00
Evgeniy Stratonikov
c420014cb5 oracle: implement filters 2021-01-28 13:00:59 +03:00
Evgenii Stratonikov
e4528e59dc oracle: reprocess request on fail 2021-01-28 13:00:59 +03:00
Evgenii Stratonikov
aa852aaaac oracle: submit responses concurrently 2021-01-28 13:00:59 +03:00
Evgenii Stratonikov
43e4d3af88 oracle: integrate module in core and RPC
1. Initialization is performed via `Blockchain` methods.
2. Native Oracle contract updates list of oracle nodes
  and in-fly requests in `PostPersist`.
3. RPC uses Oracle module directly.
2021-01-28 13:00:58 +03:00
Evgenii Stratonikov
7e16bea126 network: implement Oracle module 2021-01-28 12:43:20 +03:00
Evgeniy Stratonikov
c146540ce8 core: fix native contract verification 2021-01-28 12:35:02 +03:00
Evgeniy Stratonikov
dd1e2cefe4 core,cli: disallow verify methods with non-bool returns 2021-01-27 12:51:47 +03:00
Evgeniy Stratonikov
73f888f02e core: allow to overload contract methods
Multiple methods with different parameter count can co-exist.
2021-01-27 12:51:07 +03:00
Roman Khimov
3d79c7644e
Merge pull request #1687 from nspcc-dev/fix-transaction-fee-marshalling
Fix transaction fee marshalling
2021-01-23 15:11:14 +03:00
Roman Khimov
120ae4841f transactions: fix JSON unmarshalling of fees
Fixed8 is already marshalled as a string and stripping quotes from it just
leads to interpreting it as a float with all regular float problems (like
test transaction failing with `txid doesn't match transaction hash`).
2021-01-22 18:22:09 +03:00
Roman Khimov
054ca27e9c state: use checksums and names to calculate contract hashes
It allows to deploy the same NEF using one sender and get different contract
hashes. See neo-project/neo#2240.
2021-01-22 12:22:48 +03:00
Roman Khimov
6b9b37f170 native: don't call CreateNativeContractHash() in oracle contract
Move oracleScript from global context to Oracle itself. We have the hash
already computed by NewContractMD, there is no need to repeat this
calculation.
2021-01-22 11:28:13 +03:00
Roman Khimov
6bc2512767
Merge pull request #1684 from nspcc-dev/candidate-registration-price
native: make registering as a candidate cost more
2021-01-22 10:04:53 +03:00
Evgeniy Stratonikov
49de8161ef core: implement LoadToken handler 2021-01-22 09:04:37 +03:00
Roman Khimov
476cbbebdc native: make registering as a candidate cost more
Follow neo-project/neo#2252.
2021-01-21 23:02:59 +03:00
Evgeniy Stratonikov
c6894f3f55 native: check for committee in setters 2021-01-21 15:20:34 +03:00
Evgeniy Stratonikov
24d9a31476 testchain: support signing tx by committee 2021-01-21 14:51:15 +03:00
Evgeniy Stratonikov
719dceff77 nef: merge Compiler and Version fields 2021-01-19 11:19:28 +03:00
Evgeniy Stratonikov
52843fc1bf nef: add Tokens field 2021-01-19 11:19:24 +03:00
Evgeniy Stratonikov
324107b31e vm: implement POPITEM opcode 2021-01-19 09:46:01 +03:00
Roman Khimov
6ecc6f0422 native: call native contracts by ID instead of name
Fix #1666.
2021-01-18 00:38:23 +03:00
Roman Khimov
f39ede9869 opcode: add CALLT opcode, move ABORT/ASSERT
Refs. #1644. Hash compatibility test temporarily disabled, to be enabled when
it's up to date with current C# master.
2021-01-18 00:14:52 +03:00
Roman Khimov
db122de197 storage: fix linter warnings
pkg/core/interop/storage/find.go:19:6: exported type Iterator should have comment or be unexported
pkg/core/interop/storage/find.go:25:1: exported function NewIterator should have comment or be unexported
pkg/core/interop/storage/find.go:33:1: exported method Iterator.Next should have comment or be unexported
pkg/core/interop/storage/find.go:35:3: should replace s.index += 1 with s.index++
pkg/core/interop/storage/find.go:40:1: exported method Iterator.Value should have comment or be unexported
2021-01-15 21:12:10 +03:00
Evgeniy Stratonikov
9b1a7021ba core: add PickN flags to Storage.Find
Allow to pick items by index from serialized struct or array.
2021-01-15 21:12:10 +03:00
Evgeniy Stratonikov
44af99fd07 core: add Deserialize flag to Storage.Find
Allow to deserialize values being iterated over.
2021-01-15 21:12:10 +03:00
Evgeniy Stratonikov
7fc0c04dba core: add flags to Storage.Find
It can be iterated over keys, values or both.
Prefix can be stripped.
2021-01-15 21:12:08 +03:00
Evgeniy Stratonikov
2130e17f0c core,vm: remove System.Enumerator.* interops
Map iterator now returns key-value pair, while array/byte-array
iterators work like old enumerators.
Follow neo-project/neo#2190.
2021-01-15 21:11:32 +03:00
Evgeniy Stratonikov
d04b000748 vm: remove iterator/enumerator Concat API
Follow neo-project/neo#2170.
2021-01-15 21:08:59 +03:00
Roman Khimov
e36e71ffbd
Merge pull request #1647 from nspcc-dev/contractcall
Update `System.Contract.Call`
2021-01-15 21:02:01 +03:00
Anna Shaleva
09f0f03775 core: fix mempool.Add
Unlucky transaction could also have OracleResponce attribute.
2021-01-15 16:43:21 +03:00
Evgenii Stratonikov
1c0c331e25 core: update System.Contract.Call syscall
1. Remove `System.Contract.CallEx`.
2. Extend number of parameters.
3. Add return value count to `VM.Context`.
2021-01-14 18:23:36 +03:00
Evgenii Stratonikov
86b0e76bf0 core: remove callback interops
Follow neo-project/neo#2168 .
2021-01-14 17:53:46 +03:00
Evgenii Stratonikov
dbe81f9b80 smartcontract: move flags to a separate package 2021-01-14 17:52:09 +03:00
Roman Khimov
36b5751262
Merge pull request #1665 from nspcc-dev/nefstate
Store NEF in contract state
2021-01-14 10:14:38 +03:00
Evgeniy Stratonikov
0b26b46234 state: store NEF instead of script for contract
NEFs for native contracts are set statically, thus
field values are taken from the reference implementation.
2021-01-13 15:34:10 +03:00
Roman Khimov
f912ee60df
Merge pull request #1660 from nspcc-dev/initialize-role-management-before-oracles
native: swap oracle and role management init
2021-01-13 13:03:27 +03:00
Evgenii Stratonikov
fb88d4f3a0 mpt: support put in batches 2021-01-13 12:25:27 +03:00
Roman Khimov
524bf9aaa0 native: swap oracle and role management init
Role management doesn't need oracles, but oracles do need role management. See
neo-project/neo#2187.
2021-01-12 21:27:42 +03:00
Roman Khimov
ca86b78536
Merge pull request #1622 from nspcc-dev/nativenames
native: update contract names
2021-01-12 20:59:10 +03:00
Roman Khimov
4fa1476c03 native: use Hash160 method parameters where appropriate
Partially reverts 33386065bc, see
neo-project/neo#2183.
2021-01-12 18:08:12 +03:00
Evgenii Stratonikov
33b926586a native: update contract names
Follow https://github.com/neo-project/neo/pull/2152 .
2021-01-12 17:58:05 +03:00
Roman Khimov
a0c4deb20f
Merge pull request #1630 from nspcc-dev/oracle_response
core: add ProtocolNotSupported oracle response code
2020-12-30 17:29:48 +03:00
Roman Khimov
811f38eaed *: gofmt -s 2020-12-28 17:23:30 +03:00
Roman Khimov
197b98f40b
Merge pull request #1640 from nspcc-dev/fix/mpt
Hotfixes for testnet
2020-12-26 09:04:18 +03:00
Evgenii Stratonikov
c2f70a179b Revert "mpt: do not allocate new buffer when updating dirty node"
This reverts commit 168ba7960c.

It seems, there are some problems with it:
`2020-12-25T18:13:07.476+0300    WARN    blockQueue: failed adding block into the blockchain     {"error": "error while trying to apply MPT changes: unexpected EOF", "blockHeight": 9729, "nextIndex": 9730}`
2020-12-25 18:42:47 +03:00
Anna Shaleva
c13382e27d core: fix (*NEO).getCandidates
Don't need to pay attention to key prefix while sorting.
2020-12-25 17:03:05 +03:00
Evgenii Stratonikov
30423f3306 mpt: update MPT after the block processing 2020-12-25 14:40:23 +03:00
Evgenii Stratonikov
168ba7960c mpt: do not allocate new buffer when updating dirty node
Running time becomes faster under high load while staying the same in
the average case.
Memory allocation done in `Trie` goes down by about ~10% (even more,
actually).
2020-12-25 11:33:49 +03:00
Anna Shaleva
bc3f8a3b48 core: fix (*NEO).computeCommitteeMembers
In (*NEO).computeCommitteeMembers we return standbyCommittee in case
if there's not enought candidates. But there can be standby committee
members among candidates, so we need to fill in known votes.
2020-12-24 12:47:42 +03:00
Anna Shaleva
33386065bc core: adjust parameters of native methods
This commit is mostly about Hash160 -> ByteArray for native contracts'
methods. Manifest is included into states, so we need to be compatible.
2020-12-23 11:18:44 +03:00
Anna Shaleva
e40f3610ed core: store MinimumDeploymentFee as uint32 2020-12-22 16:09:16 +03:00
Roman Khimov
df6cb11017
Merge pull request #1631 from nspcc-dev/fix/appexec
vm: allow to serialize interop items
2020-12-22 13:20:30 +03:00
Roman Khimov
dee97d8542
Merge pull request #1524 from nspcc-dev/rpc/invoke_verify
rpc: add `invokecontractverify` RPC-method
2020-12-21 10:36:54 +03:00
Anna Shaleva
b1324db847 core: add notifications to ManagmentContract 2020-12-18 16:52:51 +03:00
Anna Shaleva
d34353aec2 core: add MinimumDeploymentFee 2020-12-18 16:48:05 +03:00
Anna Shaleva
a65544aab1 core: fix Managment destroy price
Too expensive.
2020-12-18 16:46:09 +03:00
Evgenii Stratonikov
3397f2c9be native: cache contract in Management contract 2020-12-18 13:11:17 +03:00
Evgenii Stratonikov
8c22d27acc state: allow to encode AppExecResult with recursive items
1. Encode them to a special type, decode to `nil`.
2. `Interop` can be encoded in JSON, this info should also be preserved.
2020-12-18 13:04:31 +03:00
Anna Shaleva
e0d76d873e core: add ProtocolNotSupported oracle response code 2020-12-18 13:01:45 +03:00
Anna Shaleva
31b06907c9 core: restrict allowed Oracle callbacks 2020-12-17 11:41:28 +03:00
Roman Khimov
4dcd06ef44
Merge pull request #1615 from nspcc-dev/opcodes
core: redefine opcode prices
2020-12-16 16:54:19 +03:00
Anna Shaleva
93a5c37696 core: fix bug with mempool.verifiedMap
Transaction is added to verifiedMap before OOM check, so we may have a
case when OOM occurs during tx1 pooling, but mp.containsKey(tx1)
returns `true` after this. Fixed.
2020-12-16 14:08:05 +03:00
Evgenii Stratonikov
65d147c890 core/test: simplify tests for policy contract
Most of the methods are just get/set with some boundaries.
This simplifies writing tests for new methods.
Also add missing test regarding cache behaviour for current methods
when value is set and read in the same block.
2020-12-16 13:55:40 +03:00
Evgenii Stratonikov
62da365302 native: allow to modify StoragePrice in the policy contract 2020-12-16 13:55:40 +03:00
Evgenii Stratonikov
4946556830 native: allow to modify ExecFeeFactor in the policy contract 2020-12-16 13:55:40 +03:00
Evgenii Stratonikov
1840c1c80d core: redefine opcode prices
Prices are defined in as a coefficients to `BaseExecFee` which
is defined by Policy contract (TBD later).
Native method prices are defined without need to multiply.
2020-12-16 13:55:39 +03:00
Anna Shaleva
f3279bd9f3 core: add missing RequiredFlags to System.Contract.Native*Persist 2020-12-15 16:21:00 +03:00
Anna Shaleva
da5eb67e85 rpc: implement invokecontractverify RPC method 2020-12-15 15:53:36 +03:00
Evgenii Stratonikov
dda4ba8d4d native: add compatibility test for hashes 2020-12-15 12:58:04 +03:00
Evgenii Stratonikov
1ffa1f9ade native: fix contract hashes 2020-12-15 12:58:04 +03:00
Evgenii Stratonikov
5310c7f3ce native: fix NEP17.Transfer cost
It was increased with the introducion of `postTransfer`.
2020-12-15 12:04:10 +03:00
Roman Khimov
7ba1b16854 state: drop unused UTXO remnant 2020-12-14 15:24:15 +03:00
Roman Khimov
cb5ecaefe7 native: drop OnPersistEnd
Now that PostPersist is being run for every native contract we can do our
dirty caching tricks right there instead of OnPersistEnd.
2020-12-14 15:24:15 +03:00
Roman Khimov
938be298f0 core: don't allow calls in verification context
Follow neo-project/neo#2144. System.Contract.CallNative already has "None"
flag, so tests work fine.
2020-12-14 15:24:15 +03:00
Roman Khimov
cf8cf93e7a native: change contract names, move them to separate package
Follow neo-project/neo#2138 and make RPC client's GetNativeContractHash
case-sensitive.
2020-12-14 15:24:15 +03:00
Roman Khimov
aff1469482 native: uppercase token symbols
Follow neo-project/neo#2136.
2020-12-14 15:24:15 +03:00
Roman Khimov
1e9253f1f0 interop: rename Neo.Native.Call to System.Contract.CallNative 2020-12-14 15:24:13 +03:00
Roman Khimov
e97cd9c032 core: fail TestCreateBasicChain when saving the chain
When regenerating RPC server test chain I usually need metadata this test
outputs and the easiest way to get it is make it fail.
2020-12-14 15:23:49 +03:00
Roman Khimov
ab12eee346 native: move contract deployment to management contract
See neo-project/neo#2119.
2020-12-14 15:23:46 +03:00
Roman Khimov
ad3547783d native: drop Neo.Native.Deploy, move contract init to management contract
The contract is almost a stub at the moment, though it does deploy other
contracts.
2020-12-14 13:33:41 +03:00
Roman Khimov
090bee8624 native: change OnPersist/PostPersist handling
Every contract now has these and they're always invoked. See
neo-project/neo#1913 and neo-project/neo#2119.
2020-12-13 21:36:06 +03:00
Anna Shaleva
2290b91b83 core: fix verification call flag
Previous commit sets AllowCall flag as required for Neo.Native.Call, but
invocation script was loaded with ReadStates flag => native contracts
verification failed.

Other contracts can also make use of AllowCall call flag.
2020-12-11 17:45:12 +03:00
Anna Shaleva
53e45d793b core: adjust call flags 2020-12-11 11:38:14 +03:00
Anna Shaleva
fadbae8997 core: rename call flags
Also new States flag is added and ReadOnly flag is adjusted.
2020-12-11 10:34:01 +03:00
Anna Shaleva
0b5cf78468 network: add notary request payload 2020-12-10 18:17:31 +03:00
Anna Shaleva
501c0c93c6 core: take into account NotaryAssisted attributes during verification
It's a bug, we have to reserve proper amount of GAS from verification
gas limit for NotaryAssisted attributes.
2020-12-10 18:17:31 +03:00