Evgenii Stratonikov
ff4880249d
compiler: enforce Hash160
and Hash256
size in literals
...
Can be useful to prevent small typos.
2020-12-10 14:11:28 +03:00
Evgenii Stratonikov
37a8550215
compiler: add contract.CallEx
interop
2020-12-10 13:45:10 +03:00
Evgenii Stratonikov
ec58bec803
compiler: fix global constant traversal
...
There can be no global variables, but some global constants.
Introduced in 0b44a430
.
2020-12-10 13:45:10 +03:00
Evgenii Stratonikov
b807fd9e7f
compiler: rename engine.AppCall()
to contract.Call()
2020-12-10 13:45:10 +03:00
Evgenii Stratonikov
c7ce9cd4f6
compiler: defer dir removal right after creation
2020-12-10 13:40:29 +03:00
Evgenii Stratonikov
76a6ddc3a4
vmcli/test: run shell after providing input
...
In some cases, `Run()` can read from input before we have written
anything to it.
2020-12-10 13:35:52 +03:00
Roman Khimov
d828096cbf
Merge pull request #1599 from nspcc-dev/compiler/debuginfo
...
compiler: save both VM and smartcontract types
2020-12-09 23:30:59 +03:00
Evgenii Stratonikov
cbf26f315c
compiler: save both VM and smartcontract types
...
VM types are used in debugger, while smartcontract ones are used in
manifest. We can't save only one of them, because conversion in either
side is lossy:
1. VM has `Array` and `Struct` but smartcontract only has `Array`.
2. Smartcontract has `Hash160` etc, which are all `ByteString` or
`Buffer` in VM.
And to spice things a bit more, return type in debugger can be `Void`,
which corresponds to no real stackitem type (as it must exist).
2020-12-09 22:35:22 +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
Roman Khimov
3d0ed6eac3
Merge pull request #1595 from nspcc-dev/tests/network
...
network: add tests for most of the commands
2020-12-09 15:31:57 +03:00
Evgenii Stratonikov
27624946d9
network/test: add tests for server commands
2020-12-09 15:23:49 +03:00
Evgenii Stratonikov
bd81b19a7a
network: fix requestTx()
...
2 bugs were here:
1. If amount of tx is small, no messages were sent.
2. Correctly cut byte slice if last message is small.
2020-12-09 12:04:10 +03:00
Evgenii Stratonikov
074ba5f394
network: fix GetBlocks command
...
Return exactly requested amount of hashes.
2020-12-09 12:04:10 +03:00
Evgenii Stratonikov
df801a8539
rpc: marshal GAS in getunclaimedgas
as decimal
2020-12-09 11:19:25 +03:00
Evgenii Stratonikov
56b23b718d
fixedn: allow to parse big decimals
2020-12-09 11:19:25 +03:00
Evgenii Stratonikov
e4c3339c91
util: move Fixed8
to encoding/fixedn package
2020-12-09 11:18:18 +03:00
Roman Khimov
8ed1d4dfba
Merge pull request #1593 from nspcc-dev/notary_contract_fix
...
core: allow to change deposit's `till` for owner only
2020-12-08 17:37:44 +03:00
Evgenii Stratonikov
ea4d14d20d
manifest/standard: check Safe
flag in Comply()
2020-12-08 13:47:05 +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
Roman Khimov
fb13acab94
Merge pull request #1592 from nspcc-dev/dont-reconnect-if-pool-is-connected
...
network: drop requests to discovery pool when it can't be handled
2020-12-07 10:43:51 +03:00
Roman Khimov
c6dbdddba9
Merge pull request #1591 from nspcc-dev/tests/network
...
network: add tests for `Message` serialization
2020-12-04 22:40:15 +03:00
Roman Khimov
1526772663
network: drop requests to discovery pool when it can't be handled
...
It happens from time to time in a four-node private network where there are
seeds (aka CNs) and not a lot of other nodes to connect to.
I don't know how to test for an infinite loop that has no side-effects, so no
test added here.
2020-12-04 21:39:50 +03:00
Evgenii Stratonikov
fc6cb2aa7b
network/payload: add missing tests for InventoryType
2020-12-04 15:26:14 +03:00
Evgenii Stratonikov
19a8ccbdb8
network/payload: add missing tests for AddressAndTime
2020-12-04 15:25:55 +03:00
Evgenii Stratonikov
6451a4bed3
network/test: add tests for Message
serialization
2020-12-04 15:16:29 +03:00
Evgenii Stratonikov
2dcd366ef9
network: remove extra error check from Message.Encode()
...
Buffer write error is returned from `Encode()`.
2020-12-04 15:00:35 +03:00
Evgenii Stratonikov
63aebfeae3
network: fix MerkleBlock
serialization
...
1. It contains `block.Base` thus needs network magic.
2. TxCount should match number of hashes.
2020-12-04 14:59:13 +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
573d1d10c0
cli: add tests for contract
command
2020-12-04 11:05:48 +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
d5b4553bb3
keys: allow to create keys on arbitrary curve
2020-12-03 14:06: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
e4ee7cd407
vm: improve coverage for default 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
972b0f176d
Merge pull request #1584 from nspcc-dev/tests/vmcli
...
Add tests for `vmcli`
2020-12-02 13:33:44 +03:00
Evgenii Stratonikov
4aa1a37f3f
network: fetch blocks in parallel
...
Blockcache size is 2000, while max request size is 500.
Try to fetch blocks in chunks starting from current height.
Lower height has priority.
2020-12-02 10:50:35 +03:00
Evgenii Stratonikov
33f13ab1c0
vmcli: add tests
2020-12-02 10:49:37 +03:00
Evgenii Stratonikov
f8728e4f44
vmcli: unify error messages
2020-12-02 10:49:37 +03:00
Evgenii Stratonikov
bea5125d42
vmcli: return after error in break
2020-12-02 10:49:37 +03:00
Evgenii Stratonikov
d7ffa89811
vmcli: set breakpoint before the instruction
...
Breakpoint should occur before actual instruction execution.
2020-12-02 10:49:37 +03:00
Evgenii Stratonikov
2f39701d76
vm: provide writer in PrintOps()
...
Make it more flexible and testable. Fallback to using
stdout if no writer is provided.
2020-12-02 10:49:37 +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
1672887123
nef: increase version field to 32 bytes
...
Follow recent C# changes.
2020-11-30 11:26:29 +03:00
Roman Khimov
470e1592d9
request: make CreateDeploymentScript work with NEFs
...
And use it in testing code.
2020-11-27 21:53:39 +03:00
Roman Khimov
4d0eaef510
nef: treat Version as string
...
Following changes in C# code and simpilifying things a lot.
2020-11-27 21:47:08 +03:00
Roman Khimov
e12c52f588
nef: change checksum calculation scheme
...
It's now being calculated for whole file, not just header.
2020-11-27 21:47:08 +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
0c7e727859
nef: drop scripthash
...
It's no longer a part of the file.
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
c5e39dfabf
nef: forbid NEFs with zero-length scripts
2020-11-26 18:30:53 +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
34d2eaf00e
manifest: update maximum possible length
...
As per neo-project/neo#2002 .
2020-11-26 18:07:20 +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
Roman Khimov
eca8b02c25
Merge pull request #1564 from nspcc-dev/tests/removeold
...
core: add test for `RemoveUntraceableBlocks` setting
2020-11-26 14:46:28 +03:00
Evgenii Stratonikov
75a9a42403
compiler: check emitted event names
...
Check that all `Notify` invocations in source correspond to some event
in manifest.
Helpful for typos such as `transfer` instead of `Transfer`.
2020-11-26 13:49:58 +03:00
Evgenii Stratonikov
25f1db6de0
compiler: check supported standards
...
Check that emitted manifest complies with supported standards.
This can be made a separate flag.
2020-11-26 12:51:39 +03:00
Evgenii Stratonikov
279b769fa3
manifest: support interface checking
...
There are some standards (NEP5, etc.) which impose
some restrictions on what methods and events a contract
must contain and their signatures. This commit supports
checking if arbitrary manifest complies with the standard.
2020-11-26 12:50:29 +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
Roman Khimov
ef15139179
Merge pull request #1557 from nspcc-dev/signature_collection/notary_contract
...
core: implement Notary contract
2020-11-25 19:14:02 +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
Roman Khimov
2ce3c8b75f
network: treat unsolicited addr commands as errors
...
See neo-project/neo#2097 .
2020-11-25 13:34:38 +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
4de233b339
emit: allow to emit nested arrays
2020-11-24 11:23:44 +03:00
Evgenii Stratonikov
c849176be7
manifest: include contract Name
2020-11-24 11:23:44 +03:00
Evgenii Stratonikov
8e60a65b55
rpc: implement verifyproof RPC
...
Test getproof and verifyproof together.
2020-11-20 18:06:22 +03:00