Commit graph

1183 commits

Author SHA1 Message Date
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
Anna Shaleva
6d357c3793 core: return a special error from verifyHashAgainstScript
It will help us to distinguish proper `false` verification result from
various verification errors.
2020-12-10 18:17:31 +03:00
Anna Shaleva
2ab0e6c399 core: check stack length before returning false verification result
We must be sure that stack has no other items before returning `false`
verification result. It is an error in both cases, but by preserving the
order we know exactly that it was correct `false` on stack.
2020-12-10 18:17:31 +03:00
Evgenii Stratonikov
e63191d31f core: hangle CallingScriptHash correctly
When using native contracts, script hash of second-to-top context
on invocation stack does not always correspond to a real calling
contract.
2020-12-10 16:52:36 +03:00
Evgenii Stratonikov
e903e40085 core: call from native contracts synchronously
Follow neo-project/neo#2130.
2020-12-10 16:43:46 +03:00
Roman Khimov
02457d9f77
Merge pull request #1597 from nspcc-dev/fix/safemethods
manifest: add `Safe` flag to method descriptor
2020-12-09 16:32:19 +03:00
Evgenii Stratonikov
e4c3339c91 util: move Fixed8 to encoding/fixedn package 2020-12-09 11:18:18 +03:00
Evgenii Stratonikov
b7e86fa6a3 manifest: add Safe flag to method descriptor
`interop.Contex.AddMethod` sets `Safe` flag for native
contracts. This allows not to forget to change manifest
when changing call flags.
Also fixed invalid `Safe` flags for `Notary` and `Designate` contracts.
2020-12-08 13:27:43 +03:00
Anna Shaleva
74a143cee3 core: allow to change deposit's till for owner only 2020-12-08 10:39:20 +03:00
Evgenii Stratonikov
cd5219086a wallet: export NewAccountFromPrivateKey()
Don't perform back-and-forth conversion, don't handle error
which never occur.
2020-12-04 12:45:53 +03:00
Evgenii Stratonikov
6e749f4977 core: add tests for crypto interops
Also move related test from `core/`.
2020-12-03 14:14:35 +03:00
Evgenii Stratonikov
5bd8ca9597 core/tests: extend test suite 2020-12-03 14:02:58 +03:00
Evgenii Stratonikov
dcc58b7c44 core: validate manifest before incrementing ID in Contract.Create
Also add more tests.
2020-12-02 15:54:03 +03:00
Evgenii Stratonikov
b203c23515 core: cover enumerator/iterator interops 2020-12-02 15:54:03 +03:00
Evgenii Stratonikov
d136569ac8 core: move System.Binary.* interops to binary/ package
Also extend test suite.
2020-12-02 15:54:03 +03:00
Evgenii Stratonikov
2eb256014e core: move System.Runtime.* interops to runtime/ package
Also extend test suite.
2020-12-02 15:54:03 +03:00
Roman Khimov
9211cb636c
Merge pull request #1555 from nspcc-dev/constant-contract-hashes
Constant contract hashes
2020-12-01 14:12:26 +03:00
Evgenii Stratonikov
1db27c004e native: do not fail on missing request in Oracle.PostPersist() 2020-12-01 12:29:18 +03:00
Evgenii Stratonikov
cba117352c mempool: correctly handle tx with oracle response
If tx with the same oracle response ID is already in mempool,
replace it if network fee of added transaction is higher and
return error otherwise.
2020-12-01 12:29:18 +03:00
Evgenii Stratonikov
3085710e9b native: call onPayment only during transfer
OnPayment method should be called during GAS distribution
and NEO transfer.
2020-11-30 13:05:44 +03:00
Roman Khimov
d93aa745bb contract: avoid going to the DB for entry scripts
This optimizes out DB access for non-deployed contracts under the assumption
that deployed ones are always loaded via `LoadScriptWithHash` (and if they're
not --- it's a bug anyway with the new hashing model) which actually is a very
popular case (every entry script does that).
2020-11-27 21:47:08 +03:00
Roman Khimov
49f6b33eae core: fix contract-based verification script hash
When using contract-based verification it's important to load contract's hash
along with the script, otherwise it won't be valid.

Simplify things along the way.
2020-11-27 21:47:08 +03:00
Roman Khimov
1cf1fe5d74 *: introduce stable contract hashes
Follow neo-project/neo#2044.
2020-11-27 21:47:08 +03:00
Roman Khimov
7044e9be40
Merge pull request #1549 from nspcc-dev/core/fix_committee_update
core: update committee every [committee length] blocks
2020-11-27 11:04:40 +03:00
Roman Khimov
b92ea2a48a manifest/compiler: drop hashes from ABI and debug info
See neo-project/neo-devpack-dotnet#391 and neo-project/neo#2044.
2020-11-26 18:30:49 +03:00
Roman Khimov
586dedecad
Merge pull request #1567 from nspcc-dev/tests/stillrelevant
core: add tests for `Blockchain.isTxStillRelevant()`
2020-11-26 17:28:21 +03:00
Evgenii Stratonikov
9f26d7b249 core: add tests for Blockchain.isTxStillRelevant() 2020-11-26 16:04:43 +03:00
Roman Khimov
f8957f10d7
Merge pull request #1566 from nspcc-dev/contractjson
rpc: marshal fees and GAS as Fixed8 decimal
2020-11-26 15:12:35 +03:00
Evgenii Stratonikov
a79b12b4d4 rpc: marshal fees and GAS as Fixed8 decimal 2020-11-26 15:04:30 +03:00
Evgenii Stratonikov
3a986d8635 core: add test for RemoveUntraceableBlocks setting 2020-11-26 12:33:34 +03:00
Roman Khimov
882c214646
Merge pull request #1561 from nspcc-dev/removeold
core: remove old blocks and transactions
2020-11-25 19:14:32 +03:00
Anna Shaleva
9faa63453c core: refactore some tests
They have a lot of common code.
2020-11-25 18:37:29 +03:00
Anna Shaleva
17842dabd6 core: implement native Notary contract 2020-11-25 18:37:29 +03:00
Anna Shaleva
c013522296 core: remove native contracts' name method
We have `name` in contract manifest.
2020-11-25 18:37:29 +03:00
Anna Shaleva
0f68528095 core: add callback to VM context 2020-11-25 18:37:29 +03:00
Anna Shaleva
c9acc43023 core: invoke contract verification script with AllowStates flag
We should call contract's `verify` with AllowStates flag.
2020-11-25 18:37:29 +03:00
Anna Shaleva
eca27055b8 core: fix NEP17 Transfer event
`Transfer` event declaration was placed at the wrong part of
`newNEP17Native`, that's why it had incorrect parameters.

Fixed.
2020-11-25 18:37:29 +03:00
Anna Shaleva
2fee69f26f core: add missing onPersist and postPersist methods to natives
Although not every contract is persisted (see
https://github.com/neo-project/neo/blob/master/src/neo/Ledger/Blockchain.cs#L94)
we have to add `onPersist` and `postPersist` methods to every
native contract in order to display them in manifest for users and
follow C# behaviour. In C# there are `onPersist` and `postPersist`
methods in base native contract class, see
https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/NativeContract.cs#L141
and
https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/NativeContract.cs#L148
2020-11-25 18:37:29 +03:00
Anna Shaleva
97069a05d5 core: fix locking in storeBlock 2020-11-25 18:37:29 +03:00
Anna Shaleva
52cf328296 core: add NotaryAssisted transaction attribute 2020-11-25 18:37:29 +03:00
Anna Shaleva
fc9f0034c9 core: adjust verifyTxAttributes for HighPriority attributes
The fact that they have hight priority does not mean that cheks for other
attributes should be skipped.
2020-11-25 18:37:29 +03:00
Anna Shaleva
8cdf2d3464 core: unify verifyTxAttributes errors
We already have pretty ErrInvalidAttribute error, so I think that all
other `verifyTxAttributes` errors should be wrappers around ErrInvalidAttr.
2020-11-25 18:37:29 +03:00
Anna Shaleva
31aa66a4a4 core: check the length of NotValidBefore attr while decoding
DecodeBinary throws panic otherwise.
2020-11-25 18:37:29 +03:00
Anna Shaleva
8548786444 core: do not rewrite binreader error for bad Conflicts attr
We should keep the original BinReader error untouched in case if
it is exists.
2020-11-25 18:37:24 +03:00
Evgenii Stratonikov
28b4d4e2f8 core: remove old blocks and transactions
Remove blocks with `height <= current height - MaxTraceableBlocks`
together with transactions.
2020-11-25 16:38:20 +03:00
Evgenii Stratonikov
54b177cf40 dao: store blocks/txransactions by big-endian hash
There is no need for additional allocations.
2020-11-25 14:03:43 +03:00
Anna Shaleva
b00eb51c55 core: add P2PNotary designated role 2020-11-24 18:47:09 +03:00
Evgenii Stratonikov
67f26859a8 scripts: implement script for creating dumps
This is useful for creating dumps providing various load
to benchmark restore or check compatibility with C# nodes.

Related #1472.
2020-11-24 16:47:33 +03:00
Evgenii Stratonikov
6f7284906a blockchainer: allow to dump/restore chain 2020-11-24 16:43:11 +03:00
Evgenii Stratonikov
966b50f2ae core: save StateRootInHeader in genesis block 2020-11-24 16:39:56 +03:00
Evgenii Stratonikov
7d91a3a89e pkg: move internal/ package to the root directory
This way we can use it in scripts and cli.
2020-11-24 16:39:56 +03:00
Evgenii Stratonikov
31eca342eb *: replace all NEP5 occurences to NEP17 2020-11-24 13:08:24 +03:00
Evgenii Stratonikov
b97dfae8d8 native: replace NEP-5 with NEP-17 2020-11-24 13:08:23 +03:00
Evgenii Stratonikov
a5914f89fa core: allow to provide block in GetTestVM()
Sometimes amount of GAS consumed depends on block height.
2020-11-24 12:17:29 +03:00
Evgenii Stratonikov
42ae226f9e native: use proper stack for result
When native method calls other contract result should be put
on the stack of current context. With oracles this problem wasn't
noticed because of void return type.
2020-11-24 12:17:28 +03:00
Evgenii Stratonikov
c849176be7 manifest: include contract Name 2020-11-24 11:23:44 +03:00
Evgenii Stratonikov
e38e8aa48a rpc: implement getproof RPC 2020-11-20 18:06:22 +03:00
Evgenii Stratonikov
1869d6d460 core: allow to use state root in header 2020-11-20 17:16:32 +03:00
Evgenii Stratonikov
85f927d892 mpt: implement reference counting
Also postpone MPT initialization until `storeBlock`
because we need to read-and-check or save info about refcounting
depending on starting height.
2020-11-20 16:50:30 +03:00
Evgenii Stratonikov
1c559634aa mpt: fill cached fields when getting node from store
Node which has been got from store shouldn't be flushed again.
2020-11-19 12:25:43 +03:00
Evgenii Stratonikov
fd9ff4102a mpt: export func for decoding node with type
`NodeObject` can contain auxilliary fields and shouldn't be used from outside.
2020-11-19 12:25:43 +03:00
Roman Khimov
2f824c590a
Merge pull request #1556 from nspcc-dev/allow-null-oracle-filters
Allow null oracle filters
2020-11-19 10:30:22 +03:00
Roman Khimov
eef921b8e0 native: allow NULL filter in oracle requests
Follow neo-project/neo#2067
2020-11-18 23:59:13 +03:00
Anna Shaleva
ec8ebc292c core: restrict notification size for System.Runtime.Notify 2020-11-17 16:27:51 +03:00
Anna Shaleva
933bb4ca75 core: update committee every [committee length] blocks
Was changed in https://github.com/neo-project/neo/pull/1848. Affects
storage dumps.
2020-11-17 11:22:32 +03:00
Anna Shaleva
054e60c0cf core: remove NodeList from Oracle storage
The reference implementation does not store NodeList. This commit fixes
state difference for genesis block.
2020-11-16 19:09:34 +03:00
Roman Khimov
88cee80a58
Merge pull request #1543 from nspcc-dev/compatibility-fixes
rpc, cli: tiny compatibility fixes
2020-11-16 15:53:42 +03:00
Anna Shaleva
083879838c rpc: adjust getrawtransaction and gettransactionheight RPC call
We should return verbose transaction in case if it is in the mempool
from `getrawtransaction`. We also shouldn't return height from
`gettransactionheight` in case if transaction is in the mempool.
2020-11-16 13:25:42 +03:00
Roman Khimov
3cb945f022 manifest: simplify marshaling 2020-11-13 21:46:26 +03:00
Roman Khimov
286d9185f4 smartcontract: remove contract features
We're featureless now, all contracts have access to storage and payable status
is to be determined via new NEP. Follow neo-project/neo#2060.
2020-11-13 21:26:23 +03:00
Evgenii Stratonikov
adf403666f native: decode storage item in Seek 2020-11-13 17:33:00 +03:00
Roman Khimov
0f827ee6ba
Merge pull request #1531 from nspcc-dev/core/applicationlog_with_multiple_triggers
core, rpc: store multiple execution results for single hash
2020-11-12 19:05:22 +03:00
Anna Shaleva
d6992cb5c4 core: marshal block hash for AppExecResult [NotificationsSubsystem] 2020-11-12 17:43:20 +03:00
Anna Shaleva
7ca93e76ac core, rpc: allow to store several AppExecResult for a single hash
It is required for we have several executions per block.
2020-11-12 16:24:39 +03:00
Roman Khimov
9142906abe
Merge pull request #1539 from nspcc-dev/core/fix_mempool_test
core: fix failing mempool test
2020-11-12 15:48:28 +03:00
Roman Khimov
11a224057b
Merge pull request #1536 from nspcc-dev/feature/retransmit3
network: retransmit stale transactions (master)
2020-11-12 15:47:00 +03:00
Anna Shaleva
a84e4c1e89 core: make some checks in TestMempoolAddRemoveConflicts non-critical
It will help to investigate test failures.
2020-11-12 15:14:32 +03:00
Anna Shaleva
54e6bcad12 core: fix failing mempool test
There might be a case when identical nonces are generated for tx6, tx7 or
tx8 (they are not in mempool, so each of them pass mempool-presence
check). In this case test fails due to the lack of hashes into mp.conflicts
map (two of tx6, tx7 or tx8 have identical hashes) with the following
error:

```
=== RUN   TestMempoolAddRemoveConflicts
--- FAIL: TestMempoolAddRemoveConflicts (0.00s)
    mem_pool_test.go:376:
        	Error Trace:	mem_pool_test.go:376
        	Error:      	Not equal:
        	            	expected: 4
        	            	actual  : 3
        	Test:       	TestMempoolAddRemoveConflicts
```

Fixed by maling the nonce non-random.
2020-11-12 15:05:01 +03:00
Anna Shaleva
b51eb7f5ef core: update opcodes prices
Changes ported from https://github.com/neo-project/neo/pull/2020.
2020-11-12 14:20:26 +03:00
Evgenii Stratonikov
3e5b84348d network: retransmit stale transactions 2020-11-12 13:51:44 +03:00
Anna Shaleva
01296bda5f core: remove policy default values initialisation 2020-11-10 18:05:40 +03:00
Roman Khimov
62d6f3ba22
Merge pull request #1530 from nspcc-dev/syscall/atoi
core: implement `System.Binary.Atoi/Itoa` syscalls
2020-11-10 16:39:02 +03:00
Evgenii Stratonikov
e4bf531e3e core: implement System.Binary.Atoi/Itoa syscalls
They follow C# conversion rules, but differ from our `bigint` module
conversions:
1. String must be big-endian.
2. Sign extension is 4-bit in size (single hex character)
   and not 8-byte.
2020-11-10 16:15:10 +03:00
Evgenii Stratonikov
54992ad4f3 core: provide account in calculate claimable
`getunclaimedgas` RPC should return all GAS available to claim.
2020-11-10 16:08:21 +03:00
Evgenii Stratonikov
860c146260 native: increase committee GAS bounty
Follow neo-project/neo#2049 .
2020-11-10 15:30:31 +03:00
Evgenii Stratonikov
af583c14ea native: add GAS rewards for voters
Close #1348.
2020-11-10 15:30:30 +03:00
Evgenii Stratonikov
a3c7130ab2 native: cache committee together with votes 2020-11-10 15:23:06 +03:00
Roman Khimov
ede2b05f29
Merge pull request #1529 from nspcc-dev/fix/nextconsensus
consensus: update NextConsensus only when committee is recalculated
2020-11-10 10:24:35 +03:00