Commit graph

753 commits

Author SHA1 Message Date
Anna Shaleva
2fb083bd37 rpc: add NEP11TokenInfo method 2021-04-30 11:38:11 +03:00
Roman Khimov
438eb0c43a rpc: rename magic to network in JSON
Follow neo-modules/neo-core changes. We don't rename structure fields though
to stay compatible with current code (and we do have netmode.Magic to justify
that also).
2021-04-28 23:41:31 +03:00
Evgeniy Stratonikov
da360be5b1 rpc/request: allow to provide bool parameters, fix #1919 2021-04-28 16:44:19 +03:00
Anna Shaleva
127d0ad2ba rpc: allow to provide cosigners for NEP11-transfer-related commands 2021-04-23 10:45:11 +03:00
Anna Shaleva
49c35dec20 rpc: allow to provide cosigners for NEP17-transfer-related commands 2021-04-23 10:29:40 +03:00
Anna Shaleva
1d6ba389c9 rpc: split SignAndPushInvocationTx in two parts
There are several places where constructed transaction need to be
signed and sent. Thus, we definitely need a separate method for signing
and sending constructed transaction to avoid code duplication.
2021-04-23 10:27:47 +03:00
Anna Shaleva
48ae1cc486 rpc: refactor SignAndPushInvocationTx
We have a set of accounts provided via `cosigners` argument, so we
should fill all transaction witnesses in (not only sender's witness).
If we can't properly construct witnesses for all of the signers then an
error should be returned.
2021-04-21 18:52:32 +03:00
Roman Khimov
881ed3065e
Merge pull request #1909 from nspcc-dev/cli/default-cosigner-scope
cli, rpc: use CalledByEntry as a default cosigner's scope
2021-04-19 14:43:31 +03:00
Anna Shaleva
8f4257639e rpc: use CalledByEntry as default cosigner's scope 2021-04-19 12:06:13 +03:00
Anna Shaleva
ae36523a61 rpc, internal: fix CodeQL int conversions warnings
```
Incorrect conversion of an integer with architecture-dependent bit
size from to a lower bit size type int32 without an upper bound
check.
```
2021-04-19 11:30:28 +03:00
Anna Shaleva
1d3a297a6b rpc: add Data field to NEP17 TransferTarget
It's a part of transfer, thus it should be passed along with the other
transfer parameters.
2021-04-16 13:54:23 +03:00
Roman Khimov
13619a0e77 rpc/server: improve submitblock and submitnotaryrequest also 2021-04-10 22:47:24 +03:00
Roman Khimov
274f2c0408 rpc/server: be more specific in some sendrawtransaction error cases
Refs. #1894.
2021-04-10 00:31:42 +03:00
Roman Khimov
973ed8c1f6 rpc/server: fix ineffassign warning 2021-04-08 15:52:57 +03:00
Roman Khimov
d3ea720afb result: gofmt -s 2021-04-08 15:49:14 +03:00
Anna Shaleva
7f038bd465 mpt: split HashNode in two types
First type is non-empty HashNode, and the second one is an Empty node.
2021-04-01 10:19:57 +03:00
Anna Shaleva
b9927c39ee mpt: refactor nodes serialisation
It should be serialised with type in case if it's a children node.
The type can be either HashT or EmptyT.
2021-04-01 10:19:57 +03:00
Anna Shaleva
1ba7338b07 rpc: fix mpt-related responses serialisation
MPT structures should be serialized in base64.
2021-04-01 10:17:03 +03:00
Roman Khimov
5b4f6d255f
Merge pull request #1857 from nspcc-dev/rpc/nep11
rpc: add NEP11 and NNS interfaces to RPC Client
2021-03-27 18:27:29 +03:00
Anna Shaleva
ffc2ad3cc3 rpc: check RPC client is initialised where appropriate
We don't need magic to create tx anymore, but we need it to sign tx.
2021-03-26 20:51:17 +03:00
Anna Shaleva
626ec8a82b rpc: add resolve and isAvailable NNS API to RPC client 2021-03-26 20:48:07 +03:00
Anna Shaleva
f955589370 rpc: add NEP11 API support to the RPC client 2021-03-26 20:48:01 +03:00
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
347f7ed576 rpc: move all top*FromStack client functions to a separate file
Some of them are shared between multiple RPC client APIs, so let's keep
them in a separate place for better maintainability.
2021-03-26 20:44:32 +03:00
Anna Shaleva
30e7d9a8b0 rpc: remove duplicated code from CreateNEP17MultiTransferTx 2021-03-26 20:44:32 +03:00
Anna Shaleva
bcc5c055de rpc: allow to calculatenetworkfee for verify with args
We can load invocation script for those contract-based witnesses which
requires arguments for `verify` methods.
2021-03-26 19:16:00 +03:00
Anna Shaleva
252e03bc34 rpc: add CalculateNetworkFee RPC method 2021-03-26 19:14:46 +03:00
Anna Shaleva
d2a81daf57 rpc: refactor TestCalculateNetworkFee
We need to ensure that we don't add extra network fee during
calculation.
2021-03-26 19:12:43 +03:00
Roman Khimov
6989769f2c rpc/server: fix getversion reply for staterootinheader extension
Proper network should have it set to `true` and client should know about it.
2021-03-26 18:38:46 +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
0248e2c0d2 state: add network to MPTRoot, change hashing
Fix RC1 incompatibility.
2021-03-25 22:37:30 +03:00
Anna Shaleva
10fb86c0b2 rpc: add (*Client).GetDesignatedByRole method 2021-03-23 13:56:39 +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
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
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
Anna Shaleva
ee76db9ff2 rpc: refactor (*Client).AddNetworkFee errors handling
core.ErrVerificationFailed is not very informative. Also removing it
from RPC client allows to get rid of `core` dependency in the `client`
package, which is needed for the next commit.
2021-03-22 13:28:22 +03:00
Roman Khimov
20144e6137 *: fix some misspellings spotted by GoReportCard 2021-03-22 12:13:08 +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
7990fa1b61 client: add gasperblock getter
It's an important chain parameter.
2021-03-16 23:04:41 +03:00
Roman Khimov
87d4939093 client: add NNS price getter 2021-03-16 22:59:04 +03:00
Roman Khimov
f308a9995d client: add GetOraclePrice for oracle price 2021-03-16 22:55:17 +03:00
Roman Khimov
42674e46ac client: add GetStoragePrice for native policy contract 2021-03-16 22:50:14 +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
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
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
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
cdaca7be3e core: use Neo.Crypto.CheckSig for standard signature verification 2021-03-10 21:45:58 +03:00
Evgeniy Stratonikov
100f2db3fb native: implement CryptoLib contract 2021-03-10 19:24:19 +03:00
Evgeniy Stratonikov
f83b376181 block: replace Base with Header 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
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
55009153a9 vm/emit: emit Boolean values correctly
We should convert both `true` and `false` values.
2021-03-09 13:34:22 +03:00
Evgeniy Stratonikov
3e54b46ffb rpc/tests: fix verification contract 2021-03-09 13:34:22 +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
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
Anna Shaleva
6c0faa4ea3 rpc: provide cosigners accounts to CreateTxFromScript
We need to define network fee for each of cosigners, and the only way to
do it is to access the cosigner's script.
2021-03-04 10:37:35 +03:00
Anna Shaleva
b1b9a8cf66 rpc: refactor CreateTxFromScript signature
Make cosigners non-variadic.
2021-03-03 13:42:15 +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
Anna Shaleva
2c81fc8b8e *: upgrade tests to use T.Cleanup() 2021-03-01 17:08:00 +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
Anna Shaleva
2fbbadeb56 rpc: detalize submit* RPC validation error
These changes do not break the compatibility with the C# node response.

It is useful for the end-user to be aware of the failed validation reason.
Also, the `cause` will be displayed at the running node log.
2021-02-25 19:18:57 +03:00
Anna Shaleva
94430ef3ca network: refactor RelayTx error handling
We don't need to wrap different core errors in server. Also it would be
good to provede more error info to the user.
2021-02-18 12:40:40 +03:00
Anna Shaleva
d9c85a432b rpc: add new rule to SignAndPushP2PNotaryRequest 2021-02-16 14:12:02 +03:00
Anna Shaleva
bcb82b457d config: move notary module config to ApplicationConfiguration 2021-02-16 13:58:25 +03:00
Roman Khimov
8cd37c781c client: allow transfer method to read states
Makes no sense disabling it with writes enabled. Fixes #1725.
2021-02-11 18:56:05 +03:00
Anna Shaleva
a237e34c1f rpc: add test for submitNotaryRequest 2021-02-11 17:15:59 +03:00
Anna Shaleva
af510b4e25 rpc: add submitnotaryrequest method to RPC client 2021-02-11 17:11:36 +03:00
Anna Shaleva
9d73802244 rpc: add getMaxNotValidBeforeDelta method to RPC client 2021-02-11 17:11:36 +03:00
Anna Shaleva
7896ef0640 rpc: allow client to send nep17 transfer with data 2021-02-11 17:11:36 +03:00
Anna Shaleva
afdfa9ce62 rpc: add submitnotaryrequest RPC call 2021-02-11 17:11:36 +03:00
Evgeniy Stratonikov
4f1bea0bcb rpc/client: implement GetNativeContracts 2021-02-11 12:37:03 +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
Evgeniy Stratonikov
18911caa3a Revert "rpc: marshal GAS in getunclaimedgas as decimal"
This reverts commit df801a8539.
2021-02-09 11:37:25 +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
Roman Khimov
1f98289f5d
Merge pull request #1717 from nspcc-dev/rpc-base64
RPC base64 changes
2021-02-08 10:42:26 +03:00
Roman Khimov
e0c7a3b77c rpc: add getblockheadercount call
See neo-project/neo-modules#504.
2021-02-07 23:18:09 +03:00
Roman Khimov
272bb03e3b rpc: use base64 for getstorage in/out
See neo-project/neo#484.
2021-02-07 22:07:30 +03:00
Anna Shaleva
a2715404d0 core: serialise manifest as stackitem 2021-02-05 19:10:15 +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
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
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
Evgeniy Stratonikov
719dceff77 nef: merge Compiler and Version fields 2021-01-19 11:19:28 +03:00
Evgeniy Stratonikov
0bbdee2ce1 nef: add Reserved bytes 2021-01-19 11:19:28 +03:00
Evgeniy Stratonikov
52843fc1bf nef: add Tokens field 2021-01-19 11:19:24 +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
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
dbe81f9b80 smartcontract: move flags to a separate package 2021-01-14 17:52:09 +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