Anna Shaleva
d1f92a585b
core: add NewTransactionFromBytes method to Transaction
...
Added `NewTransactionFromBytes(b []byte)` method to
transaction.Transaction in order to avoid code duplication.
2020-04-13 12:04:43 +03:00
Evgenii Stratonikov
30cc2c5783
core: move enumerator/iterator interops to a separate packages
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
7ffc6c0936
core: move interopContext to a separate package
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
90a08986d6
core: fix typo in function doc-comment
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
89d1f7ce75
core: remove unneeded comment
...
Serialization interops are already implemented.
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
a7c19d445b
core: move Blockchainer interface to a separate package
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
efddcf3bfe
core: remove interop methods from interopContext
...
If interops are defined as a separate functions
they can be implemented in a separate packages
which can help us to structure core.
2020-04-11 10:56:35 +03:00
Roman Khimov
5a22651e36
Merge pull request #784 from nspcc-dev/neo3/null
...
vm: support NULL stack item
2020-04-10 10:38:17 +03:00
Roman Khimov
bfaa025a34
Merge pull request #839 from nspcc-dev/feature/badgerdb_support
...
storage: add support of BadgerDB
2020-04-09 15:57:50 +03:00
Anna Shaleva
54cdfe4a23
storage: add support of BadgerDB
...
closes #820
2020-04-09 13:55:59 +03:00
Roman Khimov
54a95810a4
Merge pull request #833 from nspcc-dev/test/vm_calls
...
vm: missing tests for CALL* instructions
2020-04-09 12:12:41 +03:00
Anna Shaleva
9f0bc2aaf5
vm: add tests to CALL* instructions
...
closes #452
2020-04-09 11:20:39 +03:00
Evgenii Stratonikov
c71ad6a5db
cli: output contract after compiling only with --verbose flag
...
Also remove Debug from compiler option as it is used only in CLI.
2020-04-08 13:09:51 +03:00
Evgenii Stratonikov
ee0ba9b1b4
core: make SpawnVM a method of context
...
spawnVMWithInterops is rather long too type and
it doesn't use Blockchain in any way.
2020-04-08 08:38:45 +03:00
Evgenii Stratonikov
a71cd0961e
core/dao: remove unnecessary slice type
...
It is used only once, so a simple `sort.Slice`
invocation will suffice.
2020-04-08 08:38:45 +03:00
Evgenii Stratonikov
030b7754ad
core: move DAO to a separate package
2020-04-08 08:38:44 +03:00
Anna Shaleva
495c1b0565
vm: add tests for missing bit and numeric operations
...
Added tests for:
- bit operatoins: AND, OR, XOR
- numeric operations: BOOLOR, MIN, MAX, WITHIN, NEGATE
2020-04-07 18:10:31 +03:00
Roman Khimov
4e0c3fab0f
Merge pull request #811 from nspcc-dev/feature/debug
...
compiler: support neo-debugger
2020-04-06 19:18:13 +03:00
Evgenii Stratonikov
da826522f8
compiler: set variable index on first declaration
...
This way variables will have indices corresponding to their
order of appearance in a source file.
2020-04-06 15:30:07 +03:00
Evgenii Stratonikov
457e7e006a
compiler: support exporting method variables in debug info
2020-04-06 15:30:07 +03:00
Evgenii Stratonikov
5bdee683e6
cli,compiler: support emitting debug info in a file
2020-04-06 15:30:07 +03:00
Evgenii Stratonikov
5d3da26e1e
compiler: support sequence points in debug info
...
Sequence points is a way to map a specific instruction offset
from a compiled contract to a text span in a source file.
This commit implements mapping only for `return` statements.
Further improvements are straight-forward.
2020-04-06 15:30:07 +03:00
Evgenii Stratonikov
24fef35ead
compiler: split Compile info sub-functions
...
Also add tests for basic debug info.
2020-04-06 15:30:07 +03:00
Evgenii Stratonikov
00c40b58aa
compiler: record basic debug info
...
Save info about method's byte-code sections.
2020-04-06 15:30:06 +03:00
Roman Khimov
9997661998
Merge pull request #821 from nspcc-dev/fix-cache-propagation-to-invocations
...
core: wrap cached dao properly, don't miss cached data
2020-04-06 11:52:41 +03:00
Evgenii Stratonikov
96806262bf
vm: handle negative arguments in SHL/SHR
...
Do it as in reference implementation: a >> -b == a << b.
2020-04-06 10:46:35 +03:00
Roman Khimov
83a02f42f7
Merge pull request #825 from nspcc-dev/fix/compiler
...
compiler: accept varargs in `runtime.Notify`
2020-04-06 10:08:02 +03:00
Evgenii Stratonikov
1fcc019bf3
rpc: update test chain
...
Also provide info for getblockheader RPC while
generating test chain.
2020-04-06 09:31:09 +03:00
Evgenii Stratonikov
004023920e
rpc: use Notify with varargs in the test contract
2020-04-06 09:31:09 +03:00
Evgenii Stratonikov
efad66aee1
compiler: make Notify accept varargs
2020-04-06 09:31:09 +03:00
Evgenii Stratonikov
0023c4f1f6
vm: use truncated division in MOD
...
Mimic C#'s `%` behavior.
Related 4b44190
(#773 ).
2020-04-06 09:30:48 +03:00
Roman Khimov
5f09381cf4
core: wrap cached dao properly, don't miss cached data
...
Fixes #817 where invoked contract missed updated account information because
it got it one layer below cachedDao used to process the block.
2020-04-03 10:15:11 +03:00
Evgenii Stratonikov
f7f48d0048
vm: implement ISNULL opcode
2020-04-02 14:15:17 +03:00
Evgenii Stratonikov
3db030bbb6
vm: implement PUSHNULL opcode
2020-04-02 14:15:17 +03:00
Evgenii Stratonikov
e50b529631
vm: implement Null item
2020-04-02 14:15:17 +03:00
Evgenii Stratonikov
6b7a57a66f
smartcontract: add Any type for parameter
...
It is used as a wildcard for default return type of a contract and
for a Null stack item.
2020-04-02 14:15:17 +03:00
Roman Khimov
f64aa201c7
Merge pull request #819 from nspcc-dev/fix/util160_marshalling
...
smartcontract: fix uint160 marshalling in smartcontract.Parameter
2020-04-01 22:04:30 +03:00
Anna Shaleva
5a62eb923e
smartcontract: fix uint160 marshalling in smartcontract.Parameter
...
There's a bug after #785 : smartcontract.Parameter of type hash160 should
be marshalled in LE (as default marshaller for uint160 does) instead of
BE, so fixed.
2020-04-01 20:48:46 +03:00
Roman Khimov
2d0ad30fcf
vm: rework Map with internal slice representation
...
Which makes iterating over map stable which is important for serialization and
and even fixes occasional test failures. We use the same ordering here as
NEO 3.0 uses, but it should also be fine for NEO 2.0 because it has no
defined order.
2020-04-01 19:33:53 +03:00
Roman Khimov
25201d480d
smartcontract: simplify Array JSON marshalling
2020-04-01 19:21:00 +03:00
Roman Khimov
3dbe549a61
smartcontract: store MapType Parameter as a slice of KV pairs
...
Fixes #809 .
Basically, there are three alternative approaches to fixing it:
* allowing both []byte and string for ByteArrayType value
minimal invasion into existing code, but ugly as hell and will probably
backfire at some point
* storing string values in ByteArrayType
incurs quite a number of type conversions (and associated data copying),
though note that these values are not changed usually, so dynamic
properties of []byte are almost irrelevant here
* storing only []byte values in ByteArrayType
makes it impossible to use them as map keys which can be solved in several
ways:
- via an interface (Marshalable)
which is good, but makes testing and comparing values in general harder,
because of keys mismatch
- using serialized Parameter as a key (in a string)
which will need some additional marshaling/unmarshaling
- converting MapType from map to a slice of key-value pairs
not a bad idea as we don't use this map as a map really, the type
itself is all about input/output for real VM types and this approach is
also a bit closer to JSON representation of the Map
2020-04-01 19:21:00 +03:00
Evgenii Stratonikov
a43c9b9246
compiler: calculate stack size more precisely
...
When calculating number of local variables, only
defining assignments (i.e. via `:=`) must be taken into account.
2020-04-01 17:36:19 +03:00
Roman Khimov
9b5dab57e8
Merge pull request #810 from nspcc-dev/refactor/config
...
config: move config.go out of config
2020-04-01 10:29:57 +03:00
Anna Shaleva
5a984fdf88
config: move config.go out of config/
...
closes #423
2020-03-31 17:55:59 +03:00
Anna Shaleva
a8fa9c9244
vm: add tests to stack_item.go
...
closes #199
2020-03-31 17:18:13 +03:00
Roman Khimov
e41853d0a4
Merge pull request #789 from nspcc-dev/fix/tx_specific_data_marshalling
...
rpc: fix marshalling of type-specific tx data
2020-03-30 16:10:25 +03:00
Anna Shaleva
9c09ad9c89
rpc: fix marshalling of type-specific tx data
...
closes #585
2020-03-30 15:48:50 +03:00
Roman Khimov
6f13455cc9
Merge pull request #800 from nspcc-dev/fix/slice
...
compiler: declare compoud types with var keyword
2020-03-30 00:14:59 +03:00
Roman Khimov
92bafffcd8
Merge pull request #805 from nspcc-dev/fix-rpc-invocation-json
...
rpc: fix stack field name for invocation results
2020-03-29 13:41:46 +03:00
Roman Khimov
237de73dec
Merge pull request #807 from nspcc-dev/optimize-memcached-persist
...
storage: optimize (*MemCachedStore).Persist for memory-backed ps
2020-03-29 13:41:21 +03:00
Roman Khimov
0d482ceb7f
Merge pull request #808 from nspcc-dev/fix-map-serialization
...
vm: make map serialization more compatible with C#
2020-03-29 13:40:52 +03:00
Roman Khimov
665bf78d11
vm: make map serialization more compatible with C#
...
C# pushes value and key to the stack of non-serialized items, so key gets
serialized first followed by value. Fixes #806 .
Notice though that neither IDictionary in C#, nor map in Go have elements
ordered, so we can easily get a difference in KV pairs order and it would be
impossible to fix.
2020-03-28 17:25:42 +03:00
Roman Khimov
4758de71ec
storage: optimize (*MemCachedStore).Persist for memory-backed ps
...
Most of the time it's persisted into the MemoryStore or MemCachedStore, when
that's the case there is no real need to go through the Batch mechanism as it
incurs multiple copies of the data.
Importing 1.5M mainnet blocks with verification turned off, before:
real 12m39,484s
user 20m48,300s
sys 2m25,022s
After:
real 11m15,053s
user 18m2,755s
sys 2m4,162s
So it's around 10% improvement which looks good enough.
2020-03-28 17:21:50 +03:00
Roman Khimov
2316e2c4a7
rpc: fix stack field name for invocation results
...
Follow C# implementation:
https://docs.neo.org/docs/en-us/reference/rpc/latest-version/api/invokefunction.html
2020-03-28 13:59:42 +03:00
Anna Shaleva
0be237beb6
rpc: fix double-pointer bugs in RPC Client
...
Fixed double-pointer bug in following methods:
- GetRawTransactionVerbose
- GetBlockVerbose
- GetBlockHeader
- GetTxOut
- ValidateAddress
2020-03-27 16:04:11 +03:00
Evgenii Stratonikov
3cbd138b67
compiler: allow to declare variables of struct type
...
Previously, struct variables were initialize with VM's nil value
which is of primitive type. Thus SETITEM used for struct's field
updating wasn't working.
2020-03-27 13:50:09 +03:00
Evgenii Stratonikov
6baed7a010
compiler: allow to declare slices of compound types
...
Previously this declarations were ignored which resulted
in runtime errors, because VM's nil is an element of primitive type
and can't be converted to an array.
2020-03-27 13:50:09 +03:00
Roman Khimov
c738975b7b
Merge pull request #803 from nspcc-dev/feature/appcall
...
emit: implement AppCallWithOperationAndArgs
2020-03-27 13:30:48 +03:00
Evgenii Stratonikov
db2dccf7cb
emit: implement AppCallWithOperationAndArgs
...
It is nice to have a typical task of calling contract method
with specific arguments incapsulated inside some function.
2020-03-27 11:05:36 +03:00
Evgenii Stratonikov
0036b3e52b
random: make use or random package in tests
...
Also implement Bytes/Fill routines for generating byte slices.
2020-03-27 10:27:46 +03:00
Evgenii Stratonikov
9abda40171
testserdes: implement helpers for encode/decode routines
...
Frequently one needs to check if struct serializes/deserializes
properly. This commit implements helpers for such cases including:
1. JSON
2. io.Serializable interface
2020-03-27 10:27:46 +03:00
Anna Shaleva
37cb60a0b5
compiler/interop: add missing methods to interop.Iterator
...
Add Next() and Value() to interop.Iterator and corresponding syscalls to
compiler
2020-03-26 16:39:10 +03:00
Evgenii Stratonikov
f0b6f783aa
compiler: allow for loops with empty condition
2020-03-26 15:00:14 +03:00
Evgenii Stratonikov
4522eed1bb
vm: fix offset for CALLI opcode
...
It is different from other JMP* and +2 should be added to the parameter.
2020-03-26 13:09:55 +03:00
Roman Khimov
396c78c722
Merge pull request #793 from nspcc-dev/update/boltdb
...
go.mod: update boltdb to v1.3.4
Related to #771 .
2020-03-25 17:33:54 +03:00
Evgenii Stratonikov
4e92642dec
rpc: allow to unmarshal integer params from string
2020-03-25 17:23:13 +03:00
Evgenii Stratonikov
fcc4877f43
go.mod: update boltdb to v1.3.4
...
Also import lib as declared in it's go.mod:
via `go.etcd.io/bbolt`.
2020-03-25 17:07:54 +03:00
Evgenii Stratonikov
5f876aaeda
smartcontract: do not require pointer in MarshalYAML
...
It is a single byte anyway.
Now `contract init` works properly.
2020-03-25 16:26:39 +03:00
Evgenii Stratonikov
43495a49f4
rpc: reuse handlers map for prometheus metrics
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
57f37bc7a0
rpc: add metrics for invoke* RPCs
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
2ed417388b
rpc: unify RPC handlers
...
Move all of them to a map. This can make it easier
to add/remove RPC based on plugins and makes code less verbose.
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
8236217a01
rpc: make all handler have the same signature
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
6e801d33f0
rpc: make a separate handler for every RPC
...
Move getbestblockhash, getblockcount, getconnectioncount RPC.
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
969ed6e6e1
rpc: move getaccountstate/getunspents RPCs to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
2ec5b9f08a
rpc: move getblock RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
e442ebdb69
rpc: move getblockhash RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
90fdde4018
rpc: move getversion RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
99d02d5de0
rpc: move getpeers RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
dfb4171e3c
rpc: move getrawmempool RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
4e25c9121b
rpc: move validateaddress RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
70eb0b175a
rpc: move getassetstate RPC to a separate func
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
9e6785bed9
rpc: unify counter metrics update
2020-03-25 15:25:12 +03:00
Evgenii Stratonikov
c992d6c518
core: reuse buffer in (*cacheddao).Persist()
...
When serializing multiple accounts, cost of a buffer grow
can become significant. This commit tries to amortize it by
reusing the same buffer in a single `Persist()` call.
2020-03-25 13:13:54 +03:00
Anna Shaleva
6998c5044b
rpc: add testing infrastructure to RPC client package
...
closes #716
NOTE: RPC client tests contain `serverResponse` json data fetched from examples
published in official C# JSON-RPC API v2.10.3 reference
(see https://docs.neo.org/docs/en-us/reference/rpc/latest-version/api.html )
2020-03-24 16:02:08 +03:00
Anna Shaleva
8e05bfe99c
rpc/crypto: fix validator field marshalling in getvalidators RPC server
...
Problem: wrong `PublicKey` field json marshalling of result.Validator
Solution: add marshaller to publickey (crypto)
2020-03-24 15:52:51 +03:00
Anna Shaleva
ca12c75b12
rpc: fix name of json nep5balance field
...
Problem: wrong json field name of result.NEP5Balances.Balances
(see for details:
https://github.com/neo-project/neo-modules/blob/master-2.x/RpcNep5Tracker/RpcNep5Tracker.cs#L295 )
Solution: rename field from `balances` to `balance` to be consistent with C# client
2020-03-24 14:55:20 +03:00
Anna Shaleva
4911837949
rpc: fix wrong script marshalling in getcontractstate RPC server
...
problem: `script` field of result.ContractState is marshalled as []byte
solution: add marshaller for result.ContractState
2020-03-24 14:55:20 +03:00
Anna Shaleva
79f7862496
rpc: fix blockheader marshalling in getblockheader RPC server
...
Problem: wrong json marshalling of `nextconsensus` field of
result.Header
Solution: change field type from util.uint160 to address string
2020-03-24 14:55:20 +03:00
Roman Khimov
751e79d480
Merge pull request #785 from nspcc-dev/feature/uint160_marshalling
...
util: JSONify uint160 using LE instead of BE
2020-03-24 12:41:07 +03:00
Evgenii Stratonikov
dc8fb13021
vm: make NewBigInteger accept int64
...
It is more correct upconvert to int64 if needed,
so precision is never lost.
2020-03-24 11:10:56 +03:00
Roman Khimov
5148b98f43
Merge pull request #773 from nspcc-dev/fix/bigint
...
vm: use truncated division for Integers
2020-03-23 18:01:21 +03:00
Anna Shaleva
2187346158
rpc: fix json marshalling of result.AssetState
...
Modified result.AssetState:
- removed `FeeMode` and `FeeAddress` fields
- fixed json name of `ID` and `AssetType` fields
to be consistent with C# RPC server
2020-03-23 17:44:15 +03:00
Anna Shaleva
2001a40312
util: JSONify uint160 using LE instead of BE
...
closes #769
2020-03-23 17:38:58 +03:00
Evgenii Stratonikov
6ed2bd63b9
core: marshal AppExecResult.Stack as an array
...
Closes #782 .
2020-03-23 16:27:47 +03:00
Evgenii Stratonikov
6ac69d075e
smartcontract: implement io.Serializable for Parameter
2020-03-23 16:27:47 +03:00
Evgenii Stratonikov
0f17b9be1d
smartcontract: use int64 for Integer parameter value
2020-03-23 16:24:57 +03:00
Roman Khimov
b37c5939f8
Merge pull request #780 from nspcc-dev/fix/776
...
vm: allow to push integer-like items to stack
2020-03-18 13:27:31 +03:00
Evgenii Stratonikov
954e8cdcf1
vm: allow to push integer-like items to stack
...
Perform automatic conversion of non-standard integer types to
int64 if possible.
Closes #776 .
2020-03-18 12:58:31 +03:00
Evgenii Stratonikov
9666e99a17
smartcontract: marshal Integer values to JSON-strings
...
It is done so in C# implementation, we better be
as compatible as possible.
Closes #770 .
2020-03-18 11:58:17 +03:00
Evgenii Stratonikov
1e7b47ec05
smartcontract: always use int64 for integers
...
It is good when internal representation is unique.
2020-03-18 11:58:17 +03:00
Roman Khimov
8400f0add2
mempool: gofmt -s
2020-03-17 16:47:51 +03:00
Evgenii Stratonikov
4b44190485
vm: use truncated division for Integers
...
When divisor is negative, the result is truncated towards
zero.
2020-03-17 15:45:56 +03:00
Evgenii Stratonikov
dfbb84ef38
rpc: support https
...
Allow to start TLS RPC server on a separate port.
Closes #702 .
2020-03-17 12:44:23 +03:00
Roman Khimov
ec76a0bf15
mempool: disallow more than one issue tx at once
...
Technically they could conflict for available asset amount, but as they're
very rare (and even can be considered obsolete) we can simplify this check.
2020-03-17 11:40:01 +03:00
Roman Khimov
d5d0479671
core: verify results of issue transaction
...
It shouldn't try to issue more tokens than there is available.
2020-03-17 11:40:01 +03:00
Roman Khimov
10601cb375
core: add issuer hashes into the verification list for Issue TX
...
As it should be done.
2020-03-17 11:40:00 +03:00
Roman Khimov
dca637d2d0
core: add owner hash to verified list for Register TX
...
As it should be done.
2020-03-17 11:37:02 +03:00
Roman Khimov
77a799f7d0
core: add missing state tx verifications
2020-03-16 20:14:59 +03:00
Roman Khimov
6ede65610d
core: add appropriate hashes to check for State TX
...
These checks are important for proper transaction verification.
2020-03-16 19:52:28 +03:00
Roman Khimov
a5e862c351
rpc/client: add TransferNEP5 method to easily transfer tokens
...
We have TransferAsset for regular tokens, so it'd be nice to have TransferNEP5
for NEP5 ones. Relates to #599 .
2020-03-16 17:52:32 +03:00
Evgenii Stratonikov
9a41ffb9fb
wallet: support token removal
...
Also add tests for Add/RemoveToken
2020-03-16 15:12:50 +03:00
Evgenii Stratonikov
03d0a6519a
wallet: support account removal
2020-03-16 15:12:50 +03:00
Evgenii Stratonikov
b193e78def
core: remove duplication from IsDoubleClaim/IsDoubleSpend
2020-03-16 14:11:19 +03:00
Evgenii Stratonikov
cdf025bf89
transaction: implement AddVerificationHash() method
2020-03-16 14:11:19 +03:00
Roman Khimov
e9429374aa
Merge pull request #756 from nspcc-dev/feature/unclaimed
...
core/state: do not unmarshal Unclaimed balances in account
2020-03-16 13:21:23 +03:00
Roman Khimov
cff6e226dd
Merge pull request #760 from nspcc-dev/fix-contract-storage-migration
...
core: fix contract's state migration and don't swallow errors
2020-03-16 12:25:15 +03:00
Evgenii Stratonikov
e503d1001d
core/state: do not unmarshal Unclaimed balances in account
2020-03-16 12:19:32 +03:00
Roman Khimov
e6e8761d35
core: fix contract's state migration and don't swallow errors
...
Fixes difference in state changes at mainnet's block 2442790 because contract
migration in b4eb2dc35226e6520ee4e09a56197dff91547b50a7f57edc82930fc18c75dffc
doesn't actually transfer the storage state, it only deletes the old one.
And add an error check just in case.
2020-03-16 11:52:09 +03:00
Evgenii Stratonikov
66727ab8fa
rpc: marshal Asset hash in LE in getnep5balances RPC
2020-03-16 10:14:55 +03:00
Roman Khimov
ba1c3bfccb
Merge pull request #758 from nspcc-dev/rpc-fix-hash160
...
rpc: fix invocations of contracts using hash160
2020-03-13 16:50:31 +03:00
Roman Khimov
c8f4eee5f4
rpc: fix invocations of contracts using hash160
...
ERROR Error encountered with rpc request {"error": "expected string size of 40 got 42",...
2020-03-13 16:47:08 +03:00
Anna Shaleva
784bac0b38
rpc: bug with empty stack marshalling in getapplicationlog
...
Problem: cannot marshall empty raw message from appExecResult.Stack
Solution: add handler for case when appExecResult.Stack is an empty string
2020-03-13 12:50:51 +03:00
Roman Khimov
d9a83373ed
Merge pull request #748 from nspcc-dev/feature/splitnep5
...
core: store NEP5 balances separately from account
2020-03-12 18:31:25 +03:00
Evgenii Stratonikov
ac475940a0
core: cache NEP5Transfers in cached DAO
2020-03-12 17:16:11 +03:00
Evgenii Stratonikov
6fa2a998f4
core: cache NEP5Balances in cached DAO
2020-03-12 17:06:20 +03:00
Roman Khimov
734778c1f9
Merge pull request #747 from nspcc-dev/fix-contract-deploy-gas-parameter
...
Use wallet in smartcontract deploy/invoke commands and calculate GAS properly
2020-03-12 17:00:04 +03:00
Roman Khimov
25da5a30d8
cli: change deploy and invoke commands to use wallet
...
Passing WIF directly in the command line is not something we should be doing.
Also split netfee and sysfee in the RPC as they're different (and add a script
attribute for free transactions).
2020-03-12 16:19:12 +03:00
Anna Shaleva
307b3b162b
rpc: implement missing RPC client methods
...
Implemented following RPC client methods:
- getapplicationlog
- getassetstate
- getbestblockhash
- getblockcount
- getblockhash
- getblockheader
- getblocksysfee
- getconnectioncount
- getcontractstate
- getpeers
- getrawmempool
- getstorage
- gettransactionheight
- gettxout
- getunclaimed
- getvalidators
- getversion
- submitblock
- validateaddress
2020-03-12 15:56:59 +03:00
Evgenii Stratonikov
6e0a57075f
*: gofmt
2020-03-12 14:51:13 +03:00
Evgenii Stratonikov
32401a567e
core: store NEP5Transfers in batches
...
This is an append-only log which is read only during some RPCs.
It is rather slow to get it from base every time we need to append to
it. This commit stores all NEP5Transfers in batches, so that
only a last batch needs to be unmarshaled during block processing.
2020-03-12 14:51:12 +03:00
Evgenii Stratonikov
3c6d9653b0
core/state: add Size() method to NEP5TransferLog
2020-03-12 12:58:30 +03:00
Evgenii Stratonikov
df2598c8dc
core: store NEP5 balances separately
...
There is no need to take and unmarshal an account structure only
to get it's NEP5 balances.
2020-03-12 12:58:28 +03:00
Evgenii Stratonikov
d25dddc780
rpc: refactor getDecimals
...
Use existing functions to invoke smartcontract's
method instead of constructing ad-hoc script.
2020-03-12 12:19:31 +03:00
Evgenii Stratonikov
05544a1510
rpc: return empty arrays instead of null in getnep5* RPCs
2020-03-12 12:19:30 +03:00
Roman Khimov
1b5dd53e07
Merge pull request #746 from nspcc-dev/fix/equal
...
vm: implement EQUAL opcode properly
Fixes #745 , #749 .
2020-03-12 11:46:51 +03:00
Roman Khimov
bbd802681e
cli: make gas parameter to deployment add gas to the base price
...
That's how it was intended to behave originally. One thing questionable here
is contract price (policy thing, basically) being moved to smartcontract
package, but it's probably fine for NEO 2.0 (as it won't change) and we'll
make something better for NEO 3.0.
2020-03-11 20:34:36 +03:00
Roman Khimov
695c4dd6ae
Merge pull request #744 from nspcc-dev/feature/getunclaimed
...
rpc: implement getunclaimed
2020-03-11 19:18:36 +03:00
Anna Shaleva
c23a522d25
rpc: implement getunclaimed
...
closes #712
2020-03-11 18:33:15 +03:00
Roman Khimov
5f1868af28
Merge pull request #743 from nspcc-dev/optimize-some-db-accesses
...
Optimize some db accesses
2020-03-11 17:33:36 +03:00
Roman Khimov
abd7855890
Merge pull request #742 from nspcc-dev/add-dynamic-appcall
...
vm: add support for dynamic invocations in APPCALL
2020-03-11 17:27:05 +03:00
Evgenii Stratonikov
dfc59129c7
vm: implement EQUAL opcode properly
...
When comparing elements of different types, conversions
should be performed. This commit implement custom equality
predicate for each stack item type.
2020-03-11 17:19:10 +03:00
Evgenii Stratonikov
5da82e8cf0
vm: add TryBytes() to StackItem interface
...
Conversion should be done in a StackItem, not in an Element.
2020-03-11 16:33:46 +03:00
Roman Khimov
8c902a7223
core: cache UnspentCoins in cachedDao
...
1.5M block import time (VerifyBlocks disabled) on AMD Ryzen 5 1600/16GB/HDD,
before:
real 159m16.551s
user 69m58.279s
sys 7m34.334s
after:
real 139m41.836s
user 67m12.477s
sys 6m19.420s
12% which is even a bit more than could be expected from inputs analysis (that
has around 10% cache hits for a block-wide cache), worth doing.
2020-03-11 12:40:02 +03:00
Roman Khimov
23464401bc
core/state: merge spent and unspent coins state, use it to store more things
...
This change reduces pressure on DB by doing the following things:
* not storing additional KV pair for SpentCoin
* storing Output right in the UnspentCoin, thus eliminating the need to get a
full transaction from DB
At the same time it makes UnspentCoin more fat and hot, but it should probably
worth it.
Also drop `GetUnspentCoinStateOrNew` as it shouldn't ever existed, UTXOs
can't come out of nowhere.
1.5M block import time (VerifyBlocks disabled) on AMD Ryzen 5 1600/16GB/HDD,
before:
real 302m9.895s
user 96m17.200s
sys 13m37.084s
after:
real 159m16.551s
user 69m58.279s
sys 7m34.334s
So it's almost two-fold which is a great improvement.
2020-03-11 12:40:02 +03:00
Roman Khimov
e1f194ea7b
core: treat state.Coin as a bitfield
...
As it was intended to.
2020-03-11 12:22:57 +03:00
Roman Khimov
377fb382aa
core: move (un)SpentCoin structs into the state package
...
As they're all about the state.
2020-03-11 12:22:52 +03:00
Roman Khimov
aab7dd515f
Merge pull request #728 from nspcc-dev/feature/nep5cli
...
cli: implement NEP5-related commands
2020-03-10 18:10:00 +03:00
Roman Khimov
b7fa8dd40f
Merge pull request #741 from nspcc-dev/fix/network
...
network: fix possible deadlock in DefaultDiscovery
2020-03-10 17:29:45 +03:00
Roman Khimov
8318adac56
vm: add support for dynamic invocations in APPCALL
...
Fixes #740 .
2020-03-10 17:17:36 +03:00
Evgenii Stratonikov
b7dee156e2
network: fix a deadlock in DefaultDiscovery
...
Why a deadlock can occur:
1. (*DefaultDiscovery).run() has a for loop over requestCh channel.
2. (*DefaultDiscovery).RequestRemote() send to this channel while
holding a mutex.
3. (*DefaultDiscovery).RegisterBadAddr() tries to take mutex for write.
4. Second select-case can't take mutex for read because of (3).
2020-03-10 15:40:23 +03:00
Evgenii Stratonikov
2a1402f25d
compiler: clean up stack on branch statements
...
When `return` or `break` statement is encountered inside
a for/range/switch statement, top stack items can be auxilliary.
They need to be cleaned up before returning from the function.
2020-03-10 15:26:00 +03:00
Evgenii Stratonikov
22e99a5b3e
rpc: implement (*Client).NEP5TokenInfo()
...
It can be useful to receive all NEP5 token info at once.
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
564a8e429d
wallet: allow to add token contracts to the wallet
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
d447064515
util: implement FixedN from string
...
When working with NEP5 contracts we frequently need
to parse fixed-point decimals with arbitrary precision.
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
cdeba6d417
rpc: implement (*Client).NEP5* methods
2020-03-10 13:02:14 +03:00
Evgenii Stratonikov
ebf867b11d
state: add a test for NEP5Transfer size
...
It's size is used in NEP5TransferLog so we need to be
sure it reflects reality.
2020-03-10 13:02:14 +03:00
Roman Khimov
15a5c7f3d6
Merge pull request #738 from nspcc-dev/feature/fallthrough
...
compiler: implement fallthrough in switch
2020-03-10 12:44:35 +03:00
Evgenii Stratonikov
91301df161
compiler: implement fallthrough in switch
...
Closes #628 .
2020-03-10 12:34:07 +03:00
Roman Khimov
ee57b96566
Merge pull request #733 from nspcc-dev/fix-getreferences-interop-regression
...
Fix GetReferences interop regression
2020-03-10 10:27:36 +03:00
Roman Khimov
0e2bda4f21
core: drop txHash from SpentCoinState
...
It's a key for it, makes no sense storing it as data.
2020-03-09 16:58:21 +03:00
Roman Khimov
eb404ceae3
core: fix max contract description limit check
...
It differs from other parameters in C# code. Fixes #735 .
2020-03-09 14:18:51 +03:00
Roman Khimov
4587121c7f
core: fix error propagation in contract-related interops
...
Obvious bug that hides failed contract deployments.
2020-03-09 14:18:00 +03:00
Roman Khimov
4b83e9a5cd
Merge pull request #732 from nspcc-dev/feature/getvalidators
...
rpc: implement getvalidators
2020-03-07 21:43:38 +03:00
Anna Shaleva
456a2d55fd
rpc: implement getvalidators
...
closes #714
2020-03-07 18:05:40 +03:00
Roman Khimov
baeaa3dbe6
core: optimize tx verification, only get references and results once
...
Getting references requires DB access and that is expensive.
2020-03-06 20:15:01 +03:00
Evgeniy Kulikov
b34ac22434
[rpc/server] fix getblock verbose response
...
- Nonce should not trim leading zeros
- NextConsensus should returns address (uint160 -> base58)
2020-03-06 19:53:11 +03:00
Roman Khimov
fe4916f691
core: simplify GetTransactionResults() a bit
...
Make less movements.
2020-03-06 19:26:39 +03:00
Roman Khimov
ced5ddbb9e
core: fix wrong references ordering in interop function
...
Broken by 9f7018503a
. Almost the same problem as
in 01082a8988
(though it is deterministic now,
just not the way the contract expects).
2020-03-06 19:20:55 +03:00
Roman Khimov
0e8ff558d1
Merge pull request #727 from nspcc-dev/fix-wrong-endian-in-interop-hashes
...
core: fix wrong endian used in interop functions
2020-03-06 19:07:28 +03:00
Roman Khimov
f8eee778f4
Merge pull request #724 from nspcc-dev/feature/submitblock
...
rpc: implement submitblock
2020-03-06 12:08:45 +03:00
Anna Shaleva
2031d8d103
rpc: add custom errors to sendrawtransaction
...
In case of unsuccessful relyReason sendRawTransaction should return
errors with codes [-500, ..., -505] instead of error with code -32603
2020-03-06 12:04:51 +03:00
Roman Khimov
b4eb05c1c1
Merge pull request #730 from nspcc-dev/feature/optimize
...
core: get rid of unnecessary copies
2020-03-06 12:03:38 +03:00
Anna Shaleva
a746d8e6e6
rpc: implement submitblock RPC
...
closes #344
2020-03-06 12:03:08 +03:00
Evgenii Stratonikov
40188c5400
core: get rid of unnecessary copies
...
There is no need to keep Balances and Unclaimed slices
sorted, we need only to remove a single element.
2020-03-05 20:42:20 +03:00
Anna Shaleva
d3063c26e1
core: add custom error to blockhain.go
...
Add InvalidBlockIndex error to AddBlock func
2020-03-05 20:30:19 +03:00
Roman Khimov
a9abd3d841
core: fix wrong endian used in interop functions
...
C# uses ToArray() or UintXXX(bytes) here which interprets hashes as they
should be interpreted (BE, although they always convert to LE when converting
to String just for the fun of it). It leads to state difference for us at
block 2025204 where even though we have the same value for the key, the key
itself differs, ours:
dd2b538e2a0c1db1ae5061c15be14f916bd1e678e512ffcda6d9499d8e7fe97ee71fd6b8004583d9afe09cc4dadbd5deb63d01e061009b7cffdaa674beae0f930ebe6085af900093e5fe56b34a5c220ccdcf6efc336fc5000000000000000000000000000000000010
theirs:
dd2b538e2a0c1db1ae5061c15be14f916bd1e67861e0013db6ded5dbdac49ce0afd9834500b8d61fe77ee97f8e9d49d9a6cdff12e5009b7cffdaa674beae0f930ebe6085af900093e5fe56b34a5c220ccdcf6efc336fc5000000000000000000000000000000000010
In this key there is a tx hash encoded
(e512ffcda6d9499d8e7fe97ee71fd6b84583d9afe09cc4dadbd5deb63d01e061 in LE used
by all the tools like neoscan).
I love Neo.
2020-03-05 19:44:09 +03:00
Anna Shaleva
ccd88c3af8
rpc: implement gettransactionheight
...
closes #713
2020-03-05 19:34:11 +03:00
Anna Shaleva
5cfa1bc2a8
rpc: fixed getblockheader tests
2020-03-05 19:16:22 +03:00
Roman Khimov
fbdc60b731
Merge pull request #723 from nspcc-dev/feature/nep5
...
core,rpc: implement NEP5-related logic
2020-03-05 18:33:58 +03:00
Evgenii Stratonikov
c019ce565f
rpc: move test contract hash to constant
...
When changing test chain it can be rather annoying
to replace all of the occurences of the contract hash.
2020-03-05 18:26:55 +03:00
Evgenii Stratonikov
547bd3bde3
rpc: display for NEP5 token amount properly
...
Every NEP5 contract MUST have `decimals` method which
is used to properly display token amount.
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
95a8fa234f
rpc: implement getnep5transfers RPC
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
2757882d26
rpc: implement getnep5balances RPC
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
6d270c4550
core,rpc: add NEP5 contract to testdata
...
Also transfer tokens between accounts.
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
b945f4346a
smartcontract: marshal Arrays properly
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
f92fd3c948
core: track NEP5 transfers
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
e8c4179a9c
core: track NEP5 balances
2020-03-05 18:22:19 +03:00
Roman Khimov
b273f3126a
Merge pull request #722 from nspcc-dev/feature/getblockheader
...
rpc: implement getblockheader RPC
2020-03-05 17:18:54 +03:00
Roman Khimov
44c392450a
Merge pull request #721 from nspcc-dev/fix-panic-in-tcptransport-close
...
network: add a nil check in (*TCPTransport).Close, prevent panic
2020-03-05 16:02:15 +03:00
Evgenii Stratonikov
3a510b9dad
core: allow transfer amount to be bytes
...
VM can produce both big.Int and []byte because they
are converted to each other on demand.
2020-03-05 15:18:38 +03:00
Anna Shaleva
42e2aff381
rpc: implement getblockheader RPC
...
closes #711
2020-03-05 14:47:45 +03:00
Roman Khimov
d03b2ef4a1
Merge pull request #706 from nspcc-dev/feature/transfer
...
cli: implement transfer from multisig accounts
2020-03-05 12:28:01 +03:00
Roman Khimov
31948ee4a7
network: add a nil check in (*TCPTransport).Close, prevent panic
...
You have to try to trigger that, but in the event of server shutdown before it
actually started listening Close will easily panic like this:
2020-03-05T11:48:08.660+0300 INFO node started {"blockHeight": 6458, "headerHeight": 15605}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x9d5f0a]
goroutine 1 [running]:
github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Close(0xc000fd7050)
/home/rik/dev/neo-go/pkg/network/tcp_transport.go:78 +0x2a
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown(0xc000182280)
/home/rik/dev/neo-go/pkg/network/server.go:190 +0x189
github.com/nspcc-dev/neo-go/cli/server.startServer(0xc000200160, 0x0, 0x0)
/home/rik/dev/neo-go/cli/server/server.go:367 +0x79e
github.com/urfave/cli.HandleAction(0xb84860, 0xccf240, 0xc000200160, 0xc0001c4500, 0x0)
/home/rik/dev/neo-go/vendor/github.com/urfave/cli/app.go:490 +0xc8
github.com/urfave/cli.Command.Run(0xc9a160, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0xca407f, 0x10, 0x0, ...)
/home/rik/dev/neo-go/vendor/github.com/urfave/cli/command.go:210 +0x996
github.com/urfave/cli.(*App).Run(0xc0001d64e0, 0xc0000ca000, 0x3, 0x3, 0x0, 0x0)
/home/rik/dev/neo-go/vendor/github.com/urfave/cli/app.go:255 +0x6af
main.main()
/home/rik/dev/neo-go/cli/main.go:25 +0x505
2020-03-05 11:53:26 +03:00
Roman Khimov
5c781be08d
Merge pull request #718 from nspcc-dev/fix-invocation-tx-checks-and-fee
...
Fix Invocation TX checks and fee
2020-03-05 11:51:51 +03:00
Roman Khimov
2032dd8e9f
Merge pull request #720 from nspcc-dev/fix-keycache-concurrent-access
...
core: protect (*Blockchain).keyCache with a lock
2020-03-05 11:46:23 +03:00
Evgenii Stratonikov
85755a4628
smartcontract: implement (*ParameterContext).GetWitness()
...
After all signatures were accumulated it should be possible
to extract Witness for the verifiable item.
2020-03-05 09:45:33 +03:00
Evgenii Stratonikov
cd487e3ad4
smartcontract: implement (*ParameterContext).AddSignature()
2020-03-05 09:45:11 +03:00
Evgenii Stratonikov
44901ca867
wallet: export contractParam
...
It is needed to be able to create Contracts
from the outside.
2020-03-05 09:43:14 +03:00
Evgenii Stratonikov
0d419d3899
smartcontract: implement ParameterContext
2020-03-05 09:43:14 +03:00
Evgenii Stratonikov
8819d4f970
vm: implement ParseMultisigContract()
...
When creating witness for a multisig contract, it is
needed to extract the order of public keys from it.
2020-03-05 09:43:14 +03:00
Roman Khimov
9ac8001c7d
core: protect (*Blockchain).keyCache with a lock
...
Avoid failures like this:
fatal error: concurrent map writes
goroutine 103 [running]:
runtime.throw(0xca6fe3, 0x15)
/usr/lib64/go/1.12/src/runtime/panic.go:617 +0x72 fp=0xc000687988 sp=0xc000687958 pc=0x42d8d2
runtime.mapassign(0xb9d4a0, 0xc0000b1f80, 0xc000687a6c, 0x13bd940)
/usr/lib64/go/1.12/src/runtime/map.go:590 +0x5e3 fp=0xc000687a10 sp=0xc000687988 pc=0x40e2a3
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHashAgainstScript(0xc0000f8000, 0x1300d1f5a3d348be, 0x78607089e4fe9fab, 0xc0a21e4f71, 0xc000d16070, 0x1e2b8881f8178e92, 0xd589cfa965287bb8, 0x24a4e4f292ebc797, 0xb90d3120d878e619, 0xc0001d01e0, ...)
/home/rik/dev/neo-go/pkg/core/blockchain.go:1866 +0x371 fp=0xc000687ad8 sp=0xc000687a10 pc=0x984ed1
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeaderWitnesses(0xc0000f8000, 0xc000d16000, 0xc00042d950, 0x1, 0xc00008a6c0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:1914 +0x209 fp=0xc000687c90 sp=0xc000687ad8 pc=0x985999
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeader(0xc0000f8000, 0xc000d16000, 0xc00042d950, 0xf0ee0049d611101f, 0xf8967398a8f9351b)
/home/rik/dev/neo-go/pkg/core/blockchain.go:1254 +0x235 fp=0xc000687d70 sp=0xc000687c90 pc=0x97e4e5
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).addHeaders(0xc0000f8000, 0x1, 0xc000d12000, 0x7d0, 0x7d0, 0x0, 0x1)
/home/rik/dev/neo-go/pkg/core/blockchain.go:369 +0x266 fp=0xc000687e68 sp=0xc000687d70 pc=0x973f46
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddHeaders(0xc0000f8000, 0xc000d12000, 0x7d0, 0x7d0, 0x0, 0xc0003640c0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:338 +0x51 fp=0xc000687eb0 sp=0xc000687e68 pc=0x973cb1
github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleHeadersCmd(0xc00022c140, 0xdd0ca0, 0xc000374000, 0xc00000c020)
/home/rik/dev/neo-go/pkg/network/server.go:431 +0x74 fp=0xc000687fc0 sp=0xc000687eb0 pc=0x9ce5e4
runtime.goexit()
/usr/lib64/go/1.12/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc000687fc8 sp=0xc000687fc0 pc=0x45ca51
created by github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage
/home/rik/dev/neo-go/pkg/network/server.go:705 +0xa4a
...
2020-03-04 20:26:18 +03:00
Evgenii Stratonikov
acea3867b2
smartcontract: implement ContextItem
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
46db4e9d9d
smartcontract: rename param_context.go to parameter.go
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
924d920423
smartcontract: support JSON unmarshaling of Signature param
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
7eaeb18f18
transaction: marshal ContractTX even if Data is nil
...
It contains no information so it doesn't matter anyway.
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
634e9483d3
transaction: unmarshal Witness properly
...
Both verification and invocation scripts need to
be unmarshaled from hex.
Also fix failing RPC tests: block contains non-pointer
`transaction.Witness` field and (*Witness).MarshalJSON method
is not called.
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
33f99104e8
transaction: unmarshal Output properly
...
Address is marshaled in base58 and needs to be
decoded accordingly.
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
b4f8d66bd3
smartcontract: allow to marshal nil parameters
2020-03-04 19:55:04 +03:00
Evgenii Stratonikov
7cde58f731
smartcontract: adjust parameter value to type properly
2020-03-04 19:49:50 +03:00
Roman Khimov
81d89cd502
core: fix SystemFee calculation for Invocation TXes
...
They have it specified right in the transaction. Unfortunately, this little
change rendered invalid our RPC test chain, but I think it became even better
after it, especially given that chain generation is a nice test by itself, so
it should be running as a regular test.
2020-03-04 19:23:23 +03:00
Roman Khimov
ae6edf0601
core: add a check for fractional gas in invocation TXes
...
It's not allowed in C# code and that's reasonable as it's a sysfee essentially
that can only be integer.
2020-03-04 19:23:23 +03:00
Roman Khimov
823798514a
util: rename Int64Value to IntegralValue, add FractionalValue
...
Makes it's interface more clear and allows to easily access fractional part.
2020-03-04 19:23:23 +03:00
Roman Khimov
7cc847d655
transaction: add some missing InvocationTX decoding checks
...
Script must have something inside and GAS can't be negative.
2020-03-04 19:23:23 +03:00
Roman Khimov
a9d8c9e0d3
rpc/client: implement GetRawTransaction, fix #586
2020-03-03 20:43:57 +03:00
Roman Khimov
f01766131b
rpc/client: add a set of GetBlock methods
...
They differ in input and output types (and data), thus four methods are
added.
2020-03-03 20:26:56 +03:00
Roman Khimov
685e34d83c
rpc: update client documentation
...
Add missing methods, move example into something that can be compiled (and fix
it along the way).
2020-03-03 18:59:21 +03:00
Roman Khimov
f747b39bc6
docs: update RPC server documentation, add missing methods
...
And drop doc.go from server package as it duplicates docs/rpc.md and has no
value of its own (TODO list is managed with GitHub issues, really). Also, RPC
server is not really expected to be used by non-neo-go packages (contrary to
the client).
2020-03-03 18:18:56 +03:00
Roman Khimov
f5a1b928ce
pkg: fix gofmt issues
2020-03-03 17:22:15 +03:00
Roman Khimov
e41d434a49
*: move all packages from CityOfZion to nspcc-dev
2020-03-03 17:21:42 +03:00
Roman Khimov
59e6dac351
Merge pull request #708 from nspcc-dev/fix/trigger
...
core: convert trigger.Type to byte when pushing on stack
2020-03-03 16:17:01 +03:00
Evgenii Stratonikov
fe3bbbd78a
core: convert trigger.Type to byte when pushing on stack
2020-03-03 16:13:19 +03:00
Roman Khimov
032cb513a6
Merge pull request #707 from nspcc-dev/skip-outdated-headers-on-add
...
core: don't reverify stale headers in addHeader
2020-03-03 15:43:40 +03:00
Roman Khimov
4c8d327353
rpc: drop duplicating Invoke* structures
...
And use smartcontract.Parameter instead of vm.StackItem where
appropriate. Closes #689 .
2020-03-03 15:38:03 +03:00
Roman Khimov
56e37ad6ba
vm: drop duplicating stackItem structure, build JSON from Parameters
...
smartcontract.Parameter has everything needed now.
2020-03-03 15:38:03 +03:00
Roman Khimov
9b4fd99fbc
vm: break circular references when recursing into ToContractParameters
...
Reference types can have circular pointers to each other, thus we need to
control recursion.
2020-03-03 15:38:03 +03:00
Roman Khimov
c3e73c5b7d
core: don't reverify stale headers in addHeader
...
During networked synchronization we expect there to be a lot of duplicate
headers received and it makes no sense for us reverifying them.
2020-03-03 15:34:03 +03:00
Roman Khimov
3282c6ed41
Merge pull request #704 from nspcc-dev/feature/getrawmempool
...
rpc: implement getrawmempool RPC
2020-03-02 19:44:19 +03:00
Anna Shaleva
e1fe12a07f
rpc: implement getrawmempool RPC
...
closes #175
2020-03-02 19:35:51 +03:00
Evgenii Stratonikov
1264b629f1
smartcontract: parse Struct item type same way as Array
2020-03-02 18:05:26 +03:00
Evgenii Stratonikov
05a3625b7d
wallet: implement (*Account).SignTx
...
It is used in both CLI and RPC.
2020-03-02 18:03:56 +03:00
Evgenii Stratonikov
6541bd4d42
vm: use Boolean
in (*BoolItem).String()
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
6add4f3e50
transaction: disallow negative outputs
...
Otherwise it is possible to make outputs which will sum
to the expected value, but steal GAS from some other account.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
9e9d59b49a
core: set NetworkFee to 0 for Claim and Miner transactions
...
Claim tx have no GAS inputs and a positive output which
can lead to negative network fee.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
21ef2638c0
consensus: log error if GetValidators() failed
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
de5215a564
core: use GetAccountStateOrNew() in (*Blockchain).GetValidators()
...
Target of the transaction output may not yet exist in database.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
1b9968df67
core: optimize CalculateClaimable()
...
Because accumulated system fee is stored for every block,
it is easy to calculate sum with just to reads.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
258d8be1dd
core: store all accumulated SystemFee with every block
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
f69c8a763b
core: store system fee together with block
...
Recalculating system fee can be rather costly if done
frequently.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
972e0d8ad1
core: add one more Contract tx to the test chain
...
When testing CLI it is useful to have some spent coins
on an account with a known key.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
37c2bc4733
rpc: implement (*Client).GetClaimable()
...
This is needed to form correct Claim transaction.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
45b8669b42
core: verify Claim transactions
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
9d5841df38
rpc: make (*Client).SendRawTransaction public
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
44792ed5f7
core: make test chain format compatible with mainnet
...
Write uint32 length before every block.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
51c4868641
rpc: implement getclaimable RPC
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
0e2a1f40ba
core: add ContractTX to a testchain generator
...
Simple transfer from multisig account to the account
of one of the validators.
2020-03-02 18:00:00 +03:00
Evgenii Stratonikov
72d72296c3
core: implement (*Transaction).GetSignedPart()
...
Marshalling it and taking all but last byte violates incapsulation
and is just wrong in case transaction already contains any witnesses.
2020-03-02 18:00:00 +03:00
Evgenii Stratonikov
95d9f36c98
core: implement UnclaimedBalance tracking
...
To make it easy to get unclaimed coins for the
specified account they must be tracked together.
2020-03-02 18:00:00 +03:00
Evgenii Stratonikov
7095ec6c51
core: implement (*Blockchain).CalculateClaimable
...
Calculating amount of GAS that can be claimed is required
for getclaimable RPC.
2020-03-02 18:00:00 +03:00
Roman Khimov
252a9f2f31
Merge pull request #690 from nspcc-dev/feature/getapplicationlog
...
rpc: implement getapplicationlog RPC
2020-03-02 17:41:32 +03:00
Anna Shaleva
ff4384d7ff
rpc: implement getapplicationlog RPC
...
Closes #500
2020-03-02 17:25:27 +03:00
Anna Shaleva
7d46404e2d
smartcontract: turn trigger types into Type
...
1) Turn trigger types from byte constants into Type
2) Add auto-generated stringer for future purposes
2020-03-02 17:25:27 +03:00
Anna Shaleva
b3621d4a86
smartcontract: remove unused structures
...
Removed following unused structures:
-smartcontract.ContextItem
-smartcontract.Signature
-smartcontract.ParameterContext
2020-03-02 17:25:27 +03:00
Anna Shaleva
535f391550
smartcontract: add marshaller for Parameter
...
1) Add marshaller and tests for smartcontract.Parameter
2) Add unmarshaller and tests for missing types of smartcontract.Parameter:
- MapType
- BoolType
2020-03-02 17:25:27 +03:00
Anna Shaleva
648e0bb242
rpc/smartcontract: merge contract parameter types
...
Merged two types:
- smartcontract.ParamType
- rpc.StackParamType
into single one:
- smartcontract.ParamType
as they duplicated the functionality.
NOTE: type smartcontract.MapType was added (as in C# implementation).
From now, list of supported smartcontract parameter types:
UnknownType
SignatureType
BoolType
IntegerType
Hash160Type
Hash256Type
ByteArrayType
PublicKeyType
StringType
ArrayType
MapType
InteropInterfaceType
VoidType
2020-03-02 17:25:21 +03:00
Evgenii Stratonikov
a3dacd3b74
tests: replace t.Fatal with require where possible
...
This makes tests less verbose and unifies the style
they are written in.
2020-03-02 17:22:27 +03:00
Evgenii Stratonikov
66f96e3f32
core: shutdown Blockchain gracefully in tests
2020-03-02 17:22:27 +03:00
Evgenii Stratonikov
3a5224344e
core: verify headers in AddHeaders()
...
Headers can be malformed so public methods should verify them
before adding.
2020-03-02 17:22:26 +03:00
Evgenii Stratonikov
357bb4ce41
core: get rid of global variables in tests
...
It can lead to unnecessary race conditions and is just
a bad practice.
2020-03-02 17:04:08 +03:00
Evgenii Stratonikov
8ca94e23c8
core: replace makeBlocks() with addBlocks() in tests
...
This simplifies tests a bit.
2020-03-02 17:04:08 +03:00
Evgenii Stratonikov
cbf26bac83
mempool: do not allocate new slice for verified transactions
...
Because transactions a iterated in an increasing order,
we can filter slice in-place.
2020-03-02 10:38:27 +03:00
Evgenii Stratonikov
0ef7a76e84
network: batch transactions on broadcast
2020-03-02 10:37:27 +03:00
Roman Khimov
ff551d2015
Merge pull request #700 from nspcc-dev/fix/forloop
...
compiler: do not short-circuit in complex conditions
2020-02-28 20:14:26 +03:00
Roman Khimov
36197056b1
Merge pull request #691 from nspcc-dev/network-conn-overflow-and-shutdown
...
Network conn overflow and shutdown
2020-02-28 18:16:29 +03:00
Evgenii Stratonikov
b461a6ab63
compiler: do not short-circuit in complex conditions
...
Current implementation of short-circuting is just plain wrong
as it uses `last` or `before-last` labels which meaning depend
on context. It doesn't even handle simple assignements like
`a := x == 1 && y == 2`.
This commit makes all jumps in such conditions local
and adds tests.
Closes #699 , #700 .
2020-02-28 17:44:46 +03:00
Roman Khimov
e213e69a33
network: rework shutdown sequence of Server
...
Close transport and disconnect peers right in the Shutdown(), so that no new
connections would be accepted and so that all the peers would be disconnected
correctly (avoiding the same deadlock as in e2116e4c3f
).
2020-02-28 16:22:04 +03:00
Roman Khimov
77624a8847
network: add Close() to discoverer, shut it down on exit
2020-02-28 16:22:04 +03:00
Evgenii Stratonikov
624a14f730
rpc: rename (*Client).SendToAddress to TransferAsset
...
SendToAddress name is similar to the `sendtoaddress` RPC call,
this can cause confusion.
Closes #686 .
2020-02-28 14:16:39 +03:00
Roman Khimov
3e2b490025
mempool: rework inputs verification, check Claim txes
...
Use more efficient check for Input and also check Claims to avoid double
claiming.
2020-02-27 13:43:35 +03:00
Roman Khimov
f329de73e8
mempool: fix Remove bug (dropping wrong tx!)
...
Uncovered by TestMemPoolAddRemoveWithInputsAndClaims (to be added later)
2020-02-27 13:43:35 +03:00
Roman Khimov
7d59fa0066
Merge pull request #696 from nspcc-dev/tx-verification-fixes
...
Claim and enrollment TX verification fixes
2020-02-27 12:45:36 +03:00
Roman Khimov
00d199ed85
core: fix NetworkFee calculation
...
Add doesn't change the variable state. Thanks to GolangCI for catching this.
2020-02-27 12:32:56 +03:00
Roman Khimov
7bea6e043e
core: add double claim verification check
2020-02-27 12:32:56 +03:00
Roman Khimov
29586f2aa7
core: add duplicate Claim verification check
...
Refactor HaveInputsDuplicate() out of the core and Blockchain, it doesn't
depend on the Blockchain state. Make it more efficient.
2020-02-27 12:32:56 +03:00
Roman Khimov
9b1ad40273
core: drop GetScriptHashesForVerifyingClaim, fix Claim's ScriptHash getter
...
Claim transactions should _add_ claims scripthashes to the standard list, not
replace them. And this code is actually very reusable.
2020-02-27 12:32:56 +03:00
Roman Khimov
9f7018503a
core/transaction: use new transaction.InOut for References
...
We don't need a map here, use simpler structures.
2020-02-27 12:00:03 +03:00
Roman Khimov
80de208a68
transaction: unbind GroupInputsByPrevHash from Transaction
...
Which allows to use it for ClaimTX. Make it also a bit more efficient as maps
are expensive.
2020-02-27 12:00:03 +03:00
Roman Khimov
71a18b1727
Merge pull request #688 from nspcc-dev/fix/jmplabels
...
compiler: use uint16 for labels
2020-02-27 00:28:46 +03:00
Roman Khimov
b1b184f77f
Merge pull request #692 from nspcc-dev/persist-timer-fix
...
core: reschedule the next persist in a second from previous one
2020-02-26 10:34:40 +03:00
Roman Khimov
2f2a4afe21
Merge pull request #693 from nspcc-dev/memorystore-seek-lock
...
storage: add locking into (*MemoryStore).Seek
2020-02-26 10:15:40 +03:00
Roman Khimov
c258adb532
core: move spent coin management out of the inner storeBlock loop
...
prevHash == input.PrevHash, so make less DB accesses and more real work. Fix
some bugs along the way:
* spentCoins structure may already be present in the DB when persisting TX,
there is nothing wrong with that and we shouldn't overwrite it
* it's only used for NEO and only to check for claim validity. Thus, when
processing claim tx the corresponding spentCoins should always be present
in the DB
2020-02-25 17:21:09 +03:00
Roman Khimov
36c6b6af14
core: put unspents get/put one loop above in storeBlock
...
Everywhere in this code prevHash == input.PrevHash, thus we can easily move
some common code out of the loop saving on DB accesses and
serialization/deserialization.
2020-02-24 18:53:10 +03:00
Roman Khimov
5c9681508b
transaction: strip off a layer of redirection from ClaimTX.Claims
...
We don't need a pointer here and this change makes this field compatible with
Transaction.Inputs which is useful in many scenarios.
2020-02-24 18:22:27 +03:00
Roman Khimov
ed9e9e8590
storage: add locking into (*MemoryStore).Seek
...
It was missing there.
2020-02-24 17:51:50 +03:00
Roman Khimov
b49808b766
core: reschedule the next persist in a second from previous one
...
It makes little sense queueing up several persistence goroutines (or actually
even running them concurrently).
2020-02-24 17:17:25 +03:00
Roman Khimov
e2116e4c3f
network: don't deadlock on connection overflow
...
(*Peer).Disconnect send an unregister signal to this goroutine, so invoking it
from here is not a good idea, run it asynchronously.
2020-02-24 15:56:49 +03:00
Roman Khimov
d5e6028c13
core: add validator public key into the list of hashes to verify
...
That should be done for Enrollment transactions.
2020-02-21 20:04:16 +03:00
Anna Shaleva
76a0a6e7e8
rpc: implement getblocksysfee RPC
...
Closes #341
2020-02-21 18:45:52 +03:00
Evgenii Stratonikov
177b725dc1
compiler: make writeJumps return error for bad jumps
...
The script is invalid anyway so it is better to notify user.
2020-02-21 17:45:45 +03:00
Evgenii Stratonikov
5e229d84d4
compiler: use uint16 for label numbers
...
As noted in #687 this will make compiler a bit more predictable.
2020-02-21 17:45:45 +03:00
Roman Khimov
8da20055d6
rpc: drop duplicating structures used in tests
...
We have proper results now, so use those. The only left is Invoke, but that
depends on another issue at the moment.
2020-02-21 15:23:11 +03:00
Roman Khimov
6a3be6081c
smartcontract: support "ByteArray" string for ByteArrayType
...
We actually do emit it ourselves in String()
2020-02-21 15:23:11 +03:00
Roman Khimov
3fa9de764b
rpc/client: only return the Result from calls, handle Error internally
...
Adjust structures accordingly and throw away most of them, they're useless.
2020-02-21 15:23:11 +03:00
Roman Khimov
28a26d2cae
rpc/client: look into data first, then HTTP error code
...
In case of error our own server responds with an HTTP error and proper
JSON-RPC error in the body, so look there first as it has more specific data.
2020-02-21 15:12:04 +03:00
Roman Khimov
877b987ecf
rpc: omitempty some fields in TransactionOutputRaw
...
These might be undefined for mempool transactions, thus they should be defined
as omitempty.
2020-02-21 15:12:04 +03:00
Roman Khimov
bba8ac15ff
rpc: introduce proper type for sendrawtransaction, drop useless types
...
sendrawtransaction just returns a bool, sendtoaddress returns a proper
transaction and that should be the same as the one we have in
TransactionOutputRaw.
2020-02-21 15:12:04 +03:00
Roman Khimov
465476201c
rpc/response: drop duplicating AccountState structure
2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
b50704fd3b
rpc: move server-related code to a separate package
2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
d24c6d1d9e
rpc: move client-related code to a separate package
...
This includes Client struct with RPC methods and
BalanceGetter implementation with NeoSCAN.
2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
b6bc4e580a
rpc: move functions for Tx building in request package/
2020-02-21 15:12:04 +03:00
Evgenii Stratonikov
98a1e2170a
rpc: move ContractDetails to request/ package
2020-02-21 15:12:04 +03:00