Roman Khimov
f5131491b7
Merge pull request #1271 from nspcc-dev/core/call_from_native
...
core: contractCall from native contracts
2020-08-07 21:24:50 +03:00
Anna Shaleva
c87e2262c3
core: remove ScriptHashGetter from interop context
...
We have VM inside the context, so don't need ScriptHashGetter anymore.
2020-08-07 20:31:20 +03:00
Anna Shaleva
42736095a1
core: add test to call contract from native
...
Closes #1200
2020-08-07 20:31:16 +03:00
Evgenii Stratonikov
412fc53cdd
rpc: provide timestamps in getnep5transfers
...
Set default value for the first timestamp to a week ago.
2020-08-07 18:42:34 +03:00
Evgenii Stratonikov
807338f97e
core: do not store NEP5 transfer log in memory
...
Traversing transfer log instead of accumulating and returning it
is faster and takes less memory.
2020-08-07 18:21:06 +03:00
Anna Shaleva
995053f2eb
core: add VM into interop context
2020-08-07 16:15:24 +03:00
Roman Khimov
c3c88a57cd
Merge pull request #1281 from nspcc-dev/drop-go-1.12-and-fix-some-things
...
Drop go 1.12 and fix some things
2020-08-07 13:34:54 +03:00
Roman Khimov
d5a9d80c12
core: refactor out policy check for transaction
...
We were checking blocked accounts twice which is obviously excessive. We also
have our accounts sorted, so we can rely on that in CheckPolicy(). It also
doesn't make much sense to check MaxBlockSystemFee in Blockchain code, policy
contract can handle that.
2020-08-07 12:21:52 +03:00
Roman Khimov
90180c6fb6
native: pass DAO to CheckPolicy(), it doesn't need interop context
...
Simplify things a bit.
2020-08-07 12:21:52 +03:00
Roman Khimov
791c983304
core: drop GetScriptHashesForVerifying
...
It no longer depends on blockchain state and there can't ever be an error, in
fact we can always iterate over signers, so copying these hashes doesn't make
much sense at all as well as sorting arrays in verifyTxWitnesses (witnesses
order must match signers order).
2020-08-07 12:21:52 +03:00
Roman Khimov
c19838ea67
core: use errors.Is in PoolTx
...
Just in case.
2020-08-07 12:21:52 +03:00
Roman Khimov
4c38fae54c
core: fix mempool error check in PoolTx
...
ErrAlreadyExists should be returned for ErrDup, not ErrConflict.
2020-08-07 12:21:52 +03:00
Roman Khimov
0e2784cd2c
always wrap errors when creating new ones with fmt.Errorf()
...
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.
Fix #350 .
2020-08-07 12:21:52 +03:00
Roman Khimov
205f52c563
core: use error wrapping to provide more details
2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae
remove github.com/pkg/errors from dependencies
...
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
Evgenii Stratonikov
bfda60c683
native: add missing witness checks to NEO.(Un)registerCandidate
2020-08-07 09:17:02 +03:00
Evgenii Stratonikov
8af3f05358
native: implement NEO.UnregisterCandidate
method
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
38a92323c9
native: fill votes when registering unregistered candidate
...
If a candidate was registered, then unregistered and then again
registered, it's votes must not be lost.
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
27169d140f
core: implement (*Blockchain).GetStandByCommitee()
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
05c24d9401
cli: support voting
...
Closes #1206 .
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
a3f419f8df
emit: allow to emit Null
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
e5d973d3a4
config: rename StandbyValidators to StandbyCommittee
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
b14b047c78
native: add tests for delegated voting
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
9bc731b3b1
native: implement delegated voting
...
Close #867 .
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
f0b62cdaa6
native: make *totalSupply accept DAO
...
There is no need to provide full interop context.
2020-08-06 14:26:24 +03:00
Evgenii Stratonikov
3e39f0f211
native: rename Validator to Candidate
2020-08-06 14:26:24 +03:00
Roman Khimov
e1d3223505
Merge pull request #1247 from nspcc-dev/feature/pointers
...
Support pointers in compiler
2020-08-06 13:53:08 +03:00
Roman Khimov
5e53aceb0f
Merge pull request #1277 from nspcc-dev/restrict-verification-call-flags
...
core: restrict verification scripts with CallFlags.None
2020-08-06 13:52:14 +03:00
Roman Khimov
57ee8b80e5
Merge pull request #1246 from nspcc-dev/protocol/getblockbyindex
...
protocol: request blocks by index
2020-08-05 23:21:07 +03:00
Roman Khimov
f5fbef165a
Merge pull request #1259 from nspcc-dev/fix/notifications
...
Disallow changing notifications
2020-08-05 19:50:45 +03:00
Roman Khimov
b7f89b0544
core: restrict verification scripts with CallFlags.None
...
Follow neo-project/neo#1776 . Looks very suspicious to me as it severely limits
verification scripts, but we have to be compatible at this point.
2020-08-05 19:17:48 +03:00
Roman Khimov
fced917b71
Merge pull request #1261 from nspcc-dev/feature/init
...
compiler: allow to use `init` function
2020-08-05 19:04:51 +03:00
Evgenii Stratonikov
f2107bfbc4
compiler: copy structs when passing as arguments
...
In Go structs must be copied when used as arguments.
To do so we must clone struct on VM level.
This is done by appending this struct to an intermediate array.
2020-08-05 13:14:38 +03:00
Evgenii Stratonikov
4488f61777
compiler: compile init
even if there are no globals
...
`init` can be useful even if no globals are present,
e.g. we can use some syscall inside.
2020-08-05 12:59:53 +03:00
Evgenii Stratonikov
194da64975
core: deepcopy notification in System.Runtime.Notify
...
Make it impossible to change already emitted notifications via
`System.Runtime.GetNotifications`.
2020-08-05 11:19:41 +03:00
Evgenii Stratonikov
b8cc33d0b2
stackitem: implement DeepCopy
2020-08-05 11:19:41 +03:00
Evgenii Stratonikov
439d9ff94d
compiler: initialize packages according to go spec
...
`init()` functions should be called during package initialization,
after global variables were processed.
2020-08-05 11:15:07 +03:00
Evgenii Stratonikov
6f2759be3a
compiler: process packages in deterministic order
2020-08-05 11:00:25 +03:00
Evgenii Stratonikov
b771d2d024
compiler: allow to use init
function
...
Process `init()` functions after global variables has been processed.
It's body is saved into the `_initialize` method where all
initialization is performed.
2020-08-05 11:00:25 +03:00
Roman Khimov
4bbe863904
Merge pull request #1266 from nspcc-dev/notifications/filter_by_name
...
rpc: filter subscriptions' notifications by name
2020-08-05 10:00:15 +03:00
Evgenii Stratonikov
7e3813a88f
cli: use TAB as delimiter in vm parse
...
Make it simpler to use result in pipes:
neo-go vm parse 123 | rg "Integer to Hex" | cut -f1- | sed -r 's/\t//g'
2020-08-05 09:40:50 +03:00
Evgenii Stratonikov
227c6a2caa
cli: allow to use vm parse
directly
2020-08-05 09:40:50 +03:00
Roman Khimov
ef53a45e7a
Merge pull request #1264 from nspcc-dev/smartcontract/manifest/supported_standards
...
smartcontract: add list of supported standards to manifest
2020-08-04 22:17:00 +03:00
Roman Khimov
49688de75c
Merge pull request #1260 from nspcc-dev/feature/sendmany
...
cli: allow to transfer multiple tokens in `multitransfer`
2020-08-04 19:35:03 +03:00
Anna Shaleva
6c8accf18c
core, network: request blocks instead of headers
...
Closes #1192
1. We now have CMDGetBlockByIndex, so there's no need to request headers
first when we can just ask for blocks.
2. We don't ask for headers (i.e. we don't send CMDGetHeaders),
consequently, we shouldn't react on CMDHeaders.
3. But we still keep on reacting on CMDGetHeaders command as
there could be a node which needs headers.
2020-08-04 17:52:34 +03:00
Anna Shaleva
f6f3863e0e
network: allow to GetHeaders by index
...
Use GetBlockByIndex payload for GetHeaders command instead of GetBlocks
payload.
2020-08-04 17:52:34 +03:00
Anna Shaleva
7b1c305000
network: fix handleGetBlockByIndexCmd method
...
It returned an error in case if block wasn't found (it might be when our
chain is lower). Fixed. It also should return all requested blocks, not
the first one.
2020-08-04 17:52:34 +03:00
Anna Shaleva
0b0591fc34
network: allow to use -1 to specify GetBlockByIndex.Count
2020-08-04 17:52:34 +03:00
Anna Shaleva
0b856033b0
network: use MaxHeadersAllowed to restrict GetBlockByIndex
2020-08-04 17:52:34 +03:00
Anna Shaleva
737ba700e9
network: rename GetBlockData command
...
GetBlockData -> GetBlockByIndex
2020-08-04 17:52:34 +03:00
Anna Shaleva
7c6cdcbcc9
core: fix bug with policy.MaxVerificationGas
...
In 121c9664b
we should take into account isValid flag of
NativePolicy contract while retrieving MaxVerificationGas native
policy value. Otherwise we won't be able to get MaxVerificationGas
after the node was restarted, because this value is not truly
stored along with the other native policy values.
This commit fixes bug with headers verification after the node
restarting with an existing storage:
```
2020-08-03T12:52:56.158+0300 WARN failed processing headers {"error": "vm failed to execute the script with error: error encountered at instruction 0 (PUSHDATA1): gas limit is exceeded", "errorVerbose": "vm failed to execute the script with error: error encountered at instruction 0 (PUSHDATA1): gas limit is exceeded\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHashAgainstScript\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1454\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeaderWitnesses\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1517\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeader\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1175\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).addHeaders\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:484\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddHeaders\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:453\ngithub.com/nspcc-dev/neo-go/pkg/network.(*Server).handleHeadersCmd\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/network/server.go:454\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1373"}
```
2020-08-04 17:52:34 +03:00
Anna Shaleva
ba08a9b6ad
core: move all transaction.Decode checks to separate method
...
We should perform the same checks during UnmarshalJSON.
2020-08-04 17:34:06 +03:00
Anna Shaleva
ead6bdb25e
core: remove unnecessary comment
2020-08-04 17:34:06 +03:00
Anna Shaleva
90825efa16
core: move transaction's sender to cosigners
...
Closes #1184
Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00
Anna Shaleva
66ceaa6b75
smartcontract: add list of supported standards to manifest
...
Closes #1204
2020-08-04 17:29:44 +03:00
Anna Shaleva
4ff3a9e9a7
rpc: filter subscriptions' notifications by name
...
Closes #1263
2020-08-04 16:29:13 +03:00
Anna Shaleva
8697582b23
core: add FeeOnly witness scope
2020-08-04 15:08:59 +03:00
Anna Shaleva
75f1c2d6f2
core: add scopes check to cosigners in DecodeBinary
2020-08-04 15:08:59 +03:00
Anna Shaleva
7865bc5925
core: fix native policy tests
...
That was a merge problem.
2020-08-04 15:05:31 +03:00
Roman Khimov
62f5aa8eb4
Merge pull request #1254 from nspcc-dev/native/policy/maxblocksystemfee
...
core, consensus: add maxBlockSystemFee to native Policy
2020-08-04 13:13:06 +03:00
Roman Khimov
fa5ff8dd95
Merge pull request #1242 from nspcc-dev/fix/json
...
Implement lossless stackitem to json conversion
2020-08-04 12:59:47 +03:00
Evgenii Stratonikov
d54c60ded3
compiler: support pointer dereferencing for structs
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-08-04 11:14:07 +03:00
Evgenii Stratonikov
eb047b12a7
compiler: support creating pointers to struct
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-08-04 11:14:07 +03:00
Anna Shaleva
db65ed04d9
consensus: apply policy during verifyBlock
...
To follow C# implementation we should also check proposed block on
policy matching.
2020-08-04 10:59:09 +03:00
Anna Shaleva
4a1c8464f9
core: use maxBlockSize to apply policy to tx set
...
We should also take into account maxBlockSize in
(bc *Blockchain).ApplyPolicyToTxSet
2020-08-04 10:59:09 +03:00
Anna Shaleva
c647f8e4ed
core: add maxBlockSystemFee to native Policy
...
Closes #1195
2020-08-04 10:59:00 +03:00
Evgenii Stratonikov
2dd6ef964e
cli: allow to transfer multiple tokens in multitransfer
...
Like this:
./neogo wallet nep5 multitransfer -w wallet1_solo.json
--from NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK -r http://127.0.0.1:30333
neo:NYqxsNMHxDg3T19APYP27mBZFfauC4zngR:2
neo:NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK:3
gas:NYqxsNMHxDg3T19APYP27mBZFfauC4zngR:2
2020-08-04 10:36:06 +03:00
Roman Khimov
3e192b11b2
Merge pull request #1255 from nspcc-dev/p2p-handle-decompression-length-mismatch
...
network: handle length mismatch in decompression routine
2020-08-04 10:24:57 +03:00
Roman Khimov
1f46f73d12
network: handle length mismatch in decompression routine
...
It's a protocol level error when uncompressed payload size doesn't match the
one specified in the header.
2020-08-03 22:38:55 +03:00
Roman Khimov
00671deb8f
Merge pull request #1241 from nspcc-dev/fix/string
...
Ensure strings are valid UTF-8 where appropriate
2020-08-03 18:10:27 +03:00
Anna Shaleva
13336f9dba
core: adjust calling flags of native Policy methods
2020-08-03 16:09:10 +03:00
Anna Shaleva
60f9abae40
core: chenge maxBlockSizeKey of native Policy
2020-08-03 16:00:15 +03:00
Anna Shaleva
b2aef6acbf
smartcontract: calculate double-SHA256 for .nef files
...
Closes #1203
2020-08-03 14:25:27 +03:00
Evgenii Stratonikov
54590062e6
vm: use raw stack items when printing stack
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
e5d538ed21
core: use raw stack items in application logs
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
9cba25616d
rpc: use raw stack items in invoke*
RPC
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
7b4acd5a7f
vm: allow to convert stack to a slice
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
805f746f15
rpc: change NotificationEvent format
...
Name is now a separate field.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
9d6ce4bdcc
stackitem: implement unmarshaling from JSON with types
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
ee5ff40b17
stackitem: allow to convert type from string
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
c16bb466a0
stackitem: implement marshaling to JSON with types
...
There are 2 kinds of JSON marshaling:
1. Lossy raw marshaling, when type information is lost and
map keys are expected to be valid utf-8 strings.
2. Almost lossless marshaling, which can handle any non-recursive item.
Interop value preserves only type.
This commit implements the second.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
b53f0257f5
stackitem: change ByteArray type to ByteString
...
Adjust only string representation.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
a781d299e0
compiler: use fully-qualified names for tracking functions
...
Function name now consists of 3 parts:
1) full package path
2) method receiver type (if any)
3) function name itself .
Fix #1150 .
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:07:06 +03:00
Evgenii Stratonikov
528c184f00
compiler: allow to use exported constants
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
6df019913d
compiler: allow to use exported variables
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
b8d7e93459
compiler: make ForEachFile
accept a package
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
ac040a6f22
compiler: remove unused resolveEntryPoint
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
Evgenii Stratonikov
7009417325
compiler: allow to declare global variables in multiple files
...
Traverse and count globals across all used files.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 12:06:42 +03:00
fyrchik
babd84ec10
Merge pull request #1243 from nspcc-dev/protocol/uncompressed_payload_size
...
network: add uncompressed payload size
2020-07-31 10:03:55 +03:00
fyrchik
e4fc655115
Merge pull request #1239 from nspcc-dev/store_nep5_with_id
...
core: store contract IDs instead of hashes for NEP5Balances and Transfers
2020-07-30 12:56:19 +03:00
Anna Shaleva
2574b65b74
network: add uncompressed payload size
...
Closes #1212
2020-07-30 12:47:42 +03:00
Roman Khimov
e21c65c59f
core: add state height to prometheus metrics
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
5ee3ecf381
core: update verified state root height
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
ab802cdd5f
state: implement JSON marshaling for MPT* items
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Roman Khimov
236438d799
core: do MPT compaction every once in a while
...
We need to compact our in-memory MPT from time to time, otherwise it quickly
fills up all available memory. This raises two obvious quesions --- when to do
that and to what level do that.
As for 'when', I think it's quite easy to use our regular persistence interval
as an anchor (and it also frees up some memory), but we can't do that in the
persistence routine itself because of synchronization issues (adding some
synchronization primitives would add some cost that I'd also like to avoid),
so do it indirectly by comparing persisted and current height in `storeBlock`.
Choosing proper level is another problem, but if we're to roughly estimate one
full branch node to use 1K of memory (usually it's way less than that) then we
can easily store 1K of these nodes and that gives us a depth of 10 for our
trie.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Roman Khimov
58b7e16e0e
core: fix PrevHash calculation for MPTRoot
...
This was differing from C# notion of PrevHash. It's not a previous root, but
rather a hash of the previous serialized MPTRoot structure (that is to be
signed by CNs).
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Roman Khimov
caea6d6ca8
mpt: fix extension node cache invalidation
...
It should always be invalidated if something changes in the `next` (below the
extension node).
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
0e29382035
core: update MPT during block processing
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Roman Khimov
2b53877dff
mpt: don't flush nodes already present in the DB
...
It's just a waste of time.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Roman Khimov
475bf2445a
mpt: restructure nodes a bit, implement serialization and hash cache
...
It drastically reduces the number of allocations and hash calculations.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
6ca22027d5
mpt: implement (*Trie).Collapse()
...
Because trie size is rather big, it can't be stored in memory.
Thus some form of caching should also be implemented. To avoid
marshaling/unmarshaling of items which are close to root and are used
very frequenly we can save them across the persists.
This commit implements pruning items at the specified depth,
replacing them by hash nodes.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
f0b85f8af7
mpt: implement JSON marshaling/unmarshaling
...
Because there is no distinct type field in JSONized nodes, distinction
is made via payload itself, thus all unmarshaling is done via
NodeObject.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
9b328240dd
mpt: implement MPT proof Get and Verify
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
dc6741bce7
mpt: implement MPT trie
...
MPT is a trie with a branching factor = 16, i.e. it consists of sequences in
16-element alphabet.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-30 12:42:15 +03:00
Evgenii Stratonikov
5500195d58
stackitem: ensure map keys are a valid UTF-8
2020-07-30 12:37:32 +03:00
Evgenii Stratonikov
3c99393bef
core: simplify System.Contract.Call*
parameter handling
2020-07-30 12:37:32 +03:00
Evgenii Stratonikov
f40aba4cd0
vm: convert items to UTF-8 strings
...
Add `stackitem.ToString` for seamless string conversion.
2020-07-30 12:37:31 +03:00
Anna Shaleva
167bd7d9df
rpc: store decimals by contract ID instead of hash
...
And we should also cache contract scripthash to fill Asset field.
2020-07-29 15:15:48 +03:00
Anna Shaleva
0dd1730632
core: store NEP5Transfer asset by ID instead of hash
...
To avoid problems with retrieving decimals for migrated contracts.
2020-07-29 15:15:48 +03:00
Anna Shaleva
b9bdab8ec8
core: store nep5balances using contract id
...
Closes #1194
2020-07-29 15:15:48 +03:00
Anna Shaleva
1f5794b316
rpc: make getDecimals
return a standard error
...
`getDecimals` is an internal method, wo there's no need to return
response.Error.
2020-07-29 15:14:24 +03:00
Anna Shaleva
dbd460d883
core: retrieve contract hash by ID
...
We'll need this ability further to retrieve contracts hashes for Nep5Balances.
2020-07-29 15:14:24 +03:00
Evgenii Stratonikov
9a992865b1
interop: add Secp2k to the list of crypto interops
...
Allow to use them during verification.
2020-07-29 13:43:33 +03:00
Evgenii Stratonikov
23a1430395
core: allow to restrict creating callbacks from syscalls
...
Specify DisallowCallback flag if syscall is not allowed to be used in a
callback.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
99b0397a61
core: implement System.Callback.CreateFromSyscall
interop
...
Allow to create callbacks from syscalls.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
c54b45e76d
core: implement System.Callback.CreateFromMethod
interop
...
Support creating callbacks from contract methods.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
f96c217aba
core/tests: refactor getting contract state
...
Get 2 contracts in pair which is useful everytime we need to test
syscall with one contract calling the other.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
e654d22991
core/tests: introduce loadScript helper
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
382a7f5b3e
core: implement System.Callback.*
interops
...
Support creating callbacks from pointers.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
c09ea04df3
core: add prices for TRY* opcodes
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
51ae12e4fd
*: move syscall handling out of VM
...
Remove interop-related structures from the `vm` package.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Anna Shaleva
4bf88ba6b0
core: decouple native contracts from interop service
...
Closes #1191 .
2020-07-29 10:33:18 +03:00
fyrchik
b187dfe3ce
Merge pull request #1236 from nspcc-dev/rpc/getrawmempool
...
rpc: update `getrawmempool` and `getrawtransaction` RPC-calls
2020-07-29 10:18:51 +03:00
Anna Shaleva
0c424a0ed2
rpc: update getrawtransaction
RPC call
...
Closes #1183 .
Added VMState to transaction output raw.
2020-07-29 10:14:08 +03:00
Anna Shaleva
70ef733ce7
core, vm: store VMState as byte instead of string
...
Part of #1183
2020-07-29 10:14:08 +03:00
Anna Shaleva
990db9f205
rpc: update getrawmempool
RPC-call result
...
Closes #1182
2020-07-29 10:14:01 +03:00
fyrchik
0d558ef95e
Merge pull request #1230 from nspcc-dev/feature/multitransfer
...
Generate multitransfer NEP5 transactions on client
2020-07-29 09:50:49 +03:00
fyrchik
5cf4481331
Merge pull request #1228 from nspcc-dev/fix/contractcall
...
Adjust `System.Contract.Call.*` interops
2020-07-28 13:18:24 +03:00
Evgenii Stratonikov
5fe8095cee
vmcli: implement parse command
...
Implement parse command for converting arbitrary values to other
formats. It supports Integer, String, Hex, Base64 and
Address representations.
2020-07-27 13:05:37 +03:00
Evgenii Stratonikov
b3e166aeff
vmcli: remove unused method
2020-07-27 13:04:52 +03:00
Evgenii Stratonikov
84c148575d
rpc: remove Main func from test contract
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
685d44dbc1
*: support _initialize
method in contracts
...
Invoke `_initialize` method on every call if present.
In NEO3 there is no entrypoint and methods are invoked by offset,
thus `Main` function is no longer required.
We still have special `Main` method in tests to simplify them.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
466af55dea
vm: isolate stack in LoadScript
...
When calling contract it must be provided with a new stack containing
only it's arguments. The result is then copied back on RET.
Fix #1220 .
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
13b9eda08d
vm: allow to call VM methods from outside
...
Abstract out (*VM).Call method and use in in CALL* opcodes.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
6ecd1ae437
vm: allow to initialize static slot in method
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
28e0661f82
interop: update AppCall comment
...
Do not require contract hash to be known at compile time.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
d2ddf7b7cb
*: support invoking methods by offset
...
Allow to invoke methods by offset:
1. Every invoked contract must have manifest.
2. Check arguments count on invocation.
3. Change AppCall to a regular syscall.
4. Add test suite for `System.Contract.Call`.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
e87eba51f9
compiler: emit bytecode for unused exported functions
...
Exported functions should always be present in byte-code.
This will be needed later when arbitrary method calls are allowed.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
54d7882acf
core: compiler contract on-the-fly in helper test
...
Generate proper manifest file too.
2020-07-27 13:00:34 +03:00
Evgenii Stratonikov
04bf357fa5
compiler: make DebugInfo.convertToManifest public
...
Allow to generate manifest when using compiler as a library.
2020-07-27 11:08:01 +03:00
Evgenii Stratonikov
7d8fead1fd
native: change onPersist return type to Void
2020-07-27 11:08:01 +03:00
Evgenii Stratonikov
a892e3ffa8
manifest: add Offset in method descriptor
2020-07-27 11:08:01 +03:00
Evgenii Stratonikov
e52c39ae7e
manifest: remove EntryPoint from manifest
2020-07-27 11:08:01 +03:00
Roman Khimov
d2c823daa6
Merge pull request #1233 from nspcc-dev/fix/gasverify
...
core: restrict maximum gas allow for verification
2020-07-26 22:40:13 +03:00
Roman Khimov
5983e6bd55
Merge pull request #1232 from nspcc-dev/fix/verifytest
...
crypto: fix failing Secp256r1 test
2020-07-26 09:09:55 +03:00
Evgenii Stratonikov
121c9664b4
core: restrict maximum gas allow for verification
...
Disallow costly verification methods. We put this limit in policy
contract as it may be a subject to change in future.
In fact this value also overrides gas limit for header verification.
Close #1202 .
2020-07-25 14:33:38 +03:00
Evgenii Stratonikov
8931c9a794
core/interop: increase coverate for crypto interops
2020-07-25 12:16:56 +03:00
Evgenii Stratonikov
83e53fab24
core/test: ensure public key is invalid in test
...
When providing public key as a subslice, it still can be
decoded as a valid key, thus interop will not return an error
but rather push `false` on stack. This test is about providing
invalid key, so ensure this via setting invalid prefix.
2020-07-25 12:01:16 +03:00
Evgenii Stratonikov
76fdbea331
keys: fix failing Secp256k1 test
...
Pad R and S when computing signature.
Fix #1223 .
2020-07-25 12:01:12 +03:00
Evgenii Stratonikov
e013477bc9
rpc,cli: support multitransfer transactions
...
Allow to transfer single asset to multiple recepients
in a single transaction. It is currently a separate command in CLI
and can be merged in future.
2020-07-24 17:01:30 +03:00
Evgenii Stratonikov
299491080a
vm: simplify interop id in json tests
2020-07-24 10:44:02 +03:00
Evgenii Stratonikov
68ad620af0
vm: update json tests to master
2020-07-24 10:44:02 +03:00
Evgenii Stratonikov
797324cb04
vm: support exceptions
...
Implement 3 new instructions: TRY,ENDTRY,ENDFINALLY.
1. TRY marks the start of the block where exceptions are catched.
It has 2 arguments which are relative offsets of exception handler
and the end of the whole try/catch construction.
2. ENDTRY denotes either end of try or catch block.
3. ENDFINALLY denotes end of finally block which is executed
irregardless of whether an exception has occured.
2020-07-24 10:41:41 +03:00
Evgenii Stratonikov
c0d7b9d234
vm: clear references on context unload
...
Remove argument and local references from the reference counter when
returning from function.
2020-07-24 10:41:40 +03:00
Evgenii Stratonikov
aec9111961
vm: replace jumpIf with jump
...
`jumpIf` is used only once with non-constant condition.
2020-07-24 10:36:51 +03:00
Roman Khimov
a45c160f10
Merge pull request #1225 from nspcc-dev/fix/equal
...
vm: make EQUAL type strict
2020-07-23 23:42:22 +03:00
Roman Khimov
2800179ce0
Merge pull request #1226 from nspcc-dev/fix/pusha
...
vm: make offset in PUSHA relative
2020-07-23 23:40:21 +03:00
Anna Shaleva
8fde41001e
core, vm: remove allowed triggers from syscalls
...
Closes #1205 .
2020-07-23 20:44:39 +03:00
Roman Khimov
d8a1c3de46
Merge pull request #1221 from nspcc-dev/neo3/interop/post-preview2_adjustment3
...
interop: post-preview2 adjustment, part 3
2020-07-23 20:35:53 +03:00
Evgenii Stratonikov
b8843a2dfa
vm: make offset in PUSHA relative
...
Follow neo-project/neo-vm#317 .
2020-07-23 13:07:30 +03:00
Evgenii Stratonikov
9252ef65bb
vm: make EQUAL type strict
...
Do not perform type conversions when comparing elements.
2020-07-23 13:01:43 +03:00
Roman Khimov
18dcc16553
Merge pull request #1222 from nspcc-dev/fix/rvcount
...
Remove return value count
2020-07-23 10:34:34 +03:00
Evgenii Stratonikov
58a594e3d4
vm: remove rvcount
...
It isn't used anymore.
2020-07-23 10:29:05 +03:00
Roman Khimov
06f70e6a0b
Merge pull request #1218 from nspcc-dev/neo3/interop/post-preview2_adjustment2
...
interop: post-preview2 adjustment, part 2
2020-07-23 09:35:34 +03:00
Anna Shaleva
ef8de3b2dc
core: adjust System.Runtime.GetNotifications interop
...
Part of #1055 .
Forgot to add this pretty interop to the list of system interops.
2020-07-23 07:54:51 +03:00
Anna Shaleva
120eff92f7
core: adjust System.Runtime.Notify interop
...
Part of #1198 .
Notification name should be UTF8-encoded.
2020-07-23 07:55:12 +03:00
Anna Shaleva
2c41b7b254
core: adjust System.Runtime.Log interop
...
Part of #1055 and #1198 .
It should check the message length and encoding.
2020-07-23 07:54:51 +03:00
Anna Shaleva
76acef18ad
core: adjust System.Runtime.Platform interop
...
Part of #1055 .
Added `Platform` method to compiler.
2020-07-23 07:51:24 +03:00
Anna Shaleva
88e003d219
core: adjust System.Runtime.GetTime interop
...
Part of #1055 .
It should have AllowStates flag.
2020-07-23 07:51:24 +03:00
Anna Shaleva
990ef5525c
core: adjust System.Runtime.GasLeft interop
...
Part of #1055 .
In test mode it should return -1.
2020-07-23 07:51:24 +03:00
Anna Shaleva
8fed383523
core: adjust System.Runtime.CheckWitness interop
...
Part of #1055 .
It should have `AllowStates` flag.
Also removed unreachable code: we can't have such situation when
script container is not a transaction in the scope of `CheckWitness`
method because:
1. Blocks have their own implementation of CheckWitness for
internal usage (it's (bc *Blockchain) verifyHeaderWitnesses method).
2. For the outside calls of System.Runtime.CheckWitness interop (e.g.
calls from smart-contract) script container is always a transaction.
2020-07-23 07:51:24 +03:00
Anna Shaleva
c9ef7425ac
core: adjust System.Iterator.Create interop
...
Closes #1201 .
It should be able to iterate over primitive byte-array-like types also.
2020-07-23 07:51:55 +03:00
Anna Shaleva
459ac34839
core: adjust System.Enumerator.Create interop
...
Part of #1201 .
It should be able to create enumerator from primitive byte-array-like
stack items too.
2020-07-23 07:51:24 +03:00
Roman Khimov
c4cde44543
Merge pull request #1216 from nspcc-dev/neo3/rpc/sendrawtransaction
...
rpc: adjust `sendrawtransaction` and `submitblock` RPC calls
2020-07-22 22:13:21 +03:00
Anna Shaleva
6e44499cec
core: adjust Neo.Native.Deploy interop
...
Part of #1055 .
It could be that context.Block is nill.
2020-07-22 16:58:32 +03:00
Anna Shaleva
2bbe218547
compiler: move SHA256 from builtins to syscalls
...
Now it can be processed as a normal syscall.
2020-07-22 16:58:32 +03:00
Anna Shaleva
b8d82b49ec
core: add Neo.Crypto.RIPEMD160 interop
...
Closes #1193 .
2020-07-22 16:58:32 +03:00
Anna Shaleva
84bf87df52
core: adjust System.Storage.PutEx interop
...
Part of #1055 .
Added System.Storage.PutEx to compiler. Added StorageFlag in order to
denote whether item is constant or not.
2020-07-22 16:58:23 +03:00
Evgenii Stratonikov
261ff3c655
vm: remove alt.stack
...
It is no longer present in NEO3.
2020-07-22 13:20:31 +03:00
Anna Shaleva
47eadcdf2a
core: adjust System.Storage.Put interop
...
Part of #1055 .
Maximum storage key len has been changed. Also added maximum storage
value len restriction.
2020-07-22 11:05:10 +03:00
Anna Shaleva
b5185d5d1a
core: refactor System.Storage.Get[ReadOnly]Context interops
...
Part of #1055 .
Split methods, as they have a lot of common code. This also fixex nil
error of storageGetReadOnlyContext in case when contract does not have
storage.
2020-07-22 10:51:47 +03:00
Anna Shaleva
889a5d7eb6
rpc: adjust submitblock
RPC-call
...
It should return block hash instead of boolean.
2020-07-22 08:37:53 +03:00
Anna Shaleva
c2534b1a0b
rpc: adjust sendrawtransaction
RPC-call
...
It should return tx has instead of boolean.
2020-07-22 08:37:46 +03:00
Evgenii Stratonikov
3d7fa9de93
*: make Notify interop accept event name
2020-07-20 13:33:32 +03:00
Roman Khimov
432cef59f4
network: copy peers for Shutdown iteration
...
We can't lock them (or there will be a deadlock), but we need to fix this:
fatal error: concurrent map iteration and map write
goroutine 1 [running]:
runtime.throw(0xdec086, 0x26)
/usr/lib64/go/1.12/src/runtime/panic.go:617 +0x72 fp=0xc02fec2bf8 sp=0xc02fec2bc8 pc=0x42d932
runtime.mapiternext(0xc02fec2d40)
/usr/lib64/go/1.12/src/runtime/map.go:860 +0x597 fp=0xc02fec2c80 sp=0xc02fec2bf8 pc=0x40efe7
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown(0xc0000fc160)
/home/rik/dev/neo-go2/pkg/network/server.go:194 +0x238 fp=0xc02fec2db0 sp=0xc02fec2c80 pc=0xa89da8
github.com/nspcc-dev/neo-go/cli/server.startServer(0xc0000fcc60, 0x0, 0x0)
/home/rik/dev/neo-go2/cli/server/server.go:399 +0x7a9 fp=0xc02fec3820 sp=0xc02fec2db0 pc=0xae2079
...
2020-07-17 19:03:12 +03:00
Roman Khimov
ae9658a108
dao: migrate nep5 balances with the contract
...
Fixes #1144 . It's quite simple approach, we just update balance info right
upon contract migration. It will slow down migration transactions, but it
takes about 1-2 seconds to Seek through balances at mainnet's 3.8M, so the
approach should still work good enough. The other idea was to make lazy
updates (maintaining contract migration map), but it's more complicated to
implement (and implies that a balance get might also do a write).
There also is a concern about memory usage, it can give a spike of some tens
of megabytes, but that also is considered to be acceptable.
2020-07-17 19:03:12 +03:00
Evgenii Stratonikov
a6fc5cfdf1
rpc: support raw address in getnep5transfers RPC
2020-07-17 18:51:13 +03:00
Evgenii Stratonikov
c4c2ce1465
rpc: support stringified address in getnep5balances RPC
2020-07-17 18:51:13 +03:00
Evgenii Stratonikov
62bb130ccb
rpc/request: add (*Param).GetUint160FromAddressOrHex()
...
Allow to get address from both representations.
2020-07-17 18:51:13 +03:00
Roman Khimov
3f2f0be2c2
Merge pull request #1187 from nspcc-dev/neo3/interop/post-preview2_adjustment
...
interop: post-preview2 adjustment
2020-07-17 13:33:29 +03:00
Anna Shaleva
74d2f437f4
core: add System.Binary.Base64Encode(Decode) interops
...
Part of #1055
2020-07-17 12:36:18 +03:00
Anna Shaleva
f31ce9289d
core: add System.Contract.GetCallFlags interop
...
Part of #1055 .
It returns calling flags of the current context.
2020-07-17 12:35:02 +03:00
Anna Shaleva
842feb2533
core: adjust System.Contract.Update interop
...
Part of #1055 .
We should check contract scripthash against the one provided in manifest
and manifest groups. We shouldn't put on stack anything after return.
And ofcourse, we mast not destroy the old contract at the end, as
`contractDestroy` removes all storage items associated with the
old contract ID (which equals to the new contract ID). We just remove
old contract state - it's enough.
2020-07-17 12:33:44 +03:00
Anna Shaleva
fddad0b475
core: adjust System.Contract.Create interop
...
Part of #1055 .
It should check given scripthash against manifest groups and return the
contract state as a struct (not interop interface).
2020-07-17 09:28:52 +03:00
Anna Shaleva
d2ec0fed3d
core: adjust System.Blockchain.GetContract interop
...
Part of #1055 .
It should put on stack an array instead of interop interface.
2020-07-17 09:28:52 +03:00
Anna Shaleva
1a5fb01e61
core: adjust System.Contract.IsStandard interop
...
Part of #1055 .
It should check not only stored contracts, but also interop context
script container in case if it's a transaction.
2020-07-17 08:19:43 +03:00
Anna Shaleva
d2f452c240
core: adjust System.Contract.CallEx interop
...
Part of #1055
2020-07-17 08:19:43 +03:00
Anna Shaleva
74ffde8367
core: adjust System.Blockchain.GetTransactionFromBlock interop
...
To match C# implementation, we should pick all arguments from stack first.
2020-07-17 08:19:43 +03:00
Anna Shaleva
a1f98f92fe
compiler: add ConvertResultToStruct flag
...
Part of #1055 .
There'll be a lot of interops which result with a struct on stack instead
of interop interface, and sometimes their names are the same, so it's
unrelyable to take into account interop name only and don't pay
attention to it's API (package).
Also sort syscalls by package and name.
2020-07-17 08:19:43 +03:00
Roman Khimov
38f0432f36
core: remove stale storeBlock comment, fix #365
...
After transaction unification and UTXO removal storeBlock became quite simple
and doesn't require any refactoring any more.
2020-07-16 23:06:17 +03:00
Roman Khimov
58f23422ac
Merge pull request #1161 from nspcc-dev/neo3/protocol/cmd_not_found
...
network: update CMDUncknown
2020-07-16 09:49:16 +03:00
Roman Khimov
acfded7f45
Merge pull request #1180 from nspcc-dev/fix-calling-scripthash-check-in-nep5
...
Add calling scripthash check to native nep5 transfers
2020-07-16 07:29:14 +03:00
Anna Shaleva
db5b42b601
network: update CMDUncknown
...
Closes #1135
2020-07-16 06:58:55 +03:00
Roman Khimov
59be6bcd24
native: add calling script hash to NEP5 transfer witness check
...
Fix transfers from contract's address.
2020-07-15 22:52:35 +03:00
Roman Khimov
d4c3a17883
interop/native: always use proper ScriptHashGetter, fix #924
...
All scripts are run in VM, so it's there to tell us about script hashes
involved and it must be used instead of nep5ScriptHash kludge.
2020-07-15 22:43:30 +03:00
Roman Khimov
f46ed798f0
Merge pull request #1169 from nspcc-dev/neo3/rpc/fields_names_adjustment
...
rpc: adjust RPC calls JSON fields
2020-07-15 18:24:54 +03:00
Anna Shaleva
e9f4693e18
wallet: adjust isDefault
field name
...
Part of #1130
2020-07-15 14:45:57 +03:00
Anna Shaleva
2ab23dc56a
rpc: adjust getunclaimedgas
RPC-call
...
Part of #1130
2020-07-15 14:45:51 +03:00
Anna Shaleva
3a3cd0353d
rpc: adjust invokefunction
RPC-call JSON fields names
...
Part of #1130
2020-07-15 14:44:22 +03:00
Anna Shaleva
48ccdb09d4
rpc: adjust getversion
RPC-call JSON fields names
...
Part of #1130
2020-07-15 14:44:22 +03:00
Anna Shaleva
538616e9f8
rpc: adjust getrawtransaction
RPC-call JSON fields names
...
Part of #1130
2020-07-15 14:44:13 +03:00
Roman Khimov
75dc62fa81
Merge pull request #1175 from nspcc-dev/neo3/crypto/ecdsa
...
crypto: add Secp256k1 support
2020-07-15 13:34:42 +03:00
Roman Khimov
5ba4f3ef08
rpc: set transaction's script for test invocation
...
GetScriptContainer() interop can try to get this transaction and this attempt
will lead to hash calculation with transaction serialization, but transaction
can't be successfully serialized if it doesn't have a script set, so this
makes test invocations fail.
2020-07-14 18:05:49 +03:00
Anna Shaleva
063a7f683c
compiler: add CheckMultisig interops
...
Part of #918
2020-07-14 16:21:38 +03:00
Anna Shaleva
a3e306ff78
core: implement Secp256k1 Verify and CheckMultisig interops
...
Closes #918 .
2020-07-14 16:21:34 +03:00
Anna Shaleva
5326fc587a
core: rename Neo.Crypto.CheckMultisig to Neo.Crypto.CheckMultisigWithECDsaSecp256r1
...
Part of #918
2020-07-14 16:19:12 +03:00
Anna Shaleva
17233e1d8e
core: rename Neo.Crypto.Verify to Neo.Crypto.VerifyWithECDsaSecp256r1
...
Part of #918
2020-07-14 16:19:12 +03:00
Anna Shaleva
8f17c7fb05
crypto: switch to standard ecdsa keys
...
Now we have not only Random EC curve, but also Koblitz curve, so
it will be useful to have information about the curve for each
particular EC point. ecdsa.PublicKey has this information.
2020-07-14 16:19:07 +03:00
Roman Khimov
4c23aa1d7c
Merge pull request #1174 from nspcc-dev/neo3/interop/getscriptcontainer
...
core, compiler: return tx from GetScriptContainer interop
2020-07-14 08:58:52 +03:00
Roman Khimov
dafb9eea4d
Merge pull request #1177 from nspcc-dev/no-free-vm-runs
...
No free VM runs
2020-07-14 08:42:13 +03:00
Roman Khimov
db027ad9c5
vm: zero GAS means no GAS, use fee data to properly limit execution
...
We were accepting transactions with zero system fee, but we shouldn't do
that. Also, transaction's verification execution has to be limited by network
fee.
2020-07-14 08:37:29 +03:00
Anna Shaleva
c4f7b06974
core, compiler: return struct from GetScriptContainer interop
...
Closes #1173
2020-07-14 06:04:48 +03:00
Roman Khimov
419d68329c
core: limit GAS available for block verification
2020-07-13 18:24:58 +03:00
Roman Khimov
395f4ea46d
consensus: limit the number of signatures used for test transactions
...
We only need 3 out of 4.
2020-07-13 18:08:23 +03:00
Roman Khimov
330e1670d6
consensus: limit payload verification time with GAS
...
Follow C# implementation.
2020-07-13 18:07:02 +03:00
Roman Khimov
3134e364b2
core: fix CalculateNetworkFee() for multisig contracts
...
We return m from the vm.ParseMultiSigContract and n is the length of pubs,
invocation script then pushes m signatures for n keys.
2020-07-13 18:05:46 +03:00
Roman Khimov
afc5ee1ded
core: fix ECDSA verifiation price, it's 1000000 and it's defined in crypto
2020-07-13 18:04:50 +03:00
Roman Khimov
a43e374ac6
consensus: replace magic 1000000 with something more meaningful
2020-07-11 19:54:50 +03:00
Roman Khimov
579630a3fa
native: don't expose internal slices to the outside world
...
They should be hidden.
2020-07-11 19:54:50 +03:00
Roman Khimov
7eef895061
consensus: use GetNextBlockValidators where appropriate
...
GetValidators without parameter is called upon DBFT initialization and it
should receive validators for the next block (that will create it),
parameterized GetValidators is used for NextConsensus calculation where we
need a list for the current state of the chain.
2020-07-11 19:54:50 +03:00
Roman Khimov
2278cd5700
consensus: drop NextConsensus from the prepareRequest
...
Follow neo-project/neo#744 to make our requests compatible with C# node.
2020-07-11 19:54:50 +03:00
Roman Khimov
ae497228f0
core: use native NEO GetValidators for bc.GetValidators
...
NextBlockValidators are updated before the new block persist, so we need to
use GetValidators to get the list corresponding to the current state of the
chain.
2020-07-11 19:54:50 +03:00
Roman Khimov
815c075112
consensus: update dbft, use millisecond-precision time, add CV reason
2020-07-11 19:54:50 +03:00
Roman Khimov
fedcc6b6fc
transaction: drop old attributes
...
They're not supported in Neo 3. Also change data encoding to base64 following
Neo 3 changes.
2020-07-10 20:40:27 +03:00
Roman Khimov
56a8f11ad6
Merge pull request #1115 from nspcc-dev/fix/convert
...
keys: support returning legacy verification script
2020-07-10 19:27:36 +03:00
Anna Shaleva
789ee2d3c1
core: do not update mempool while verifying tx
...
Closes #1168
2020-07-09 20:45:59 +03:00
Anna Shaleva
4be1009def
core: refactor checkBalanceAndUpdate
2020-07-09 18:27:20 +03:00
Anna Shaleva
72a6740717
rpc: adjust getcontractstate
RPC-call JSON fields names
...
Part of #1130
2020-07-09 17:34:53 +03:00
Anna Shaleva
15f7b78a8c
rpc: adjust getnep5transfers
RPC-call JSON fields names
...
Part of #1130
2020-07-09 17:34:53 +03:00
Anna Shaleva
dc273736be
rpc: adjust getnep5balances
RPC-call JSON fields names
...
Part of #1130
2020-07-09 17:34:53 +03:00
Anna Shaleva
e81ccb7deb
rpc: adjust getblock
RPC-call JSON fields names
...
Part of #1130
2020-07-09 17:34:53 +03:00
Anna Shaleva
51576f236d
rpc: adjust getapplicationlog
RPC-call JSON fields names
...
Part of #1130
2020-07-09 17:34:53 +03:00
Roman Khimov
1fa2d4bc6a
Merge pull request #1165 from nspcc-dev/neo3/state/nep5transfer
...
core: store NEP5 transfers and balances as big.Int
2020-07-09 16:55:51 +03:00
Roman Khimov
15c6cc932d
vm: drop checkedhash, it's an unused NeoVM 2 remnant
2020-07-09 15:05:14 +03:00
Roman Khimov
1bb26dcdc1
vm: fix INITSSLOT, it's context-wide, not VM-wide
...
It's tied to the current contract, not to VM.
2020-07-09 15:00:49 +03:00
Roman Khimov
bc1d6791b9
compiler: allow to append multiple elements
2020-07-09 13:59:43 +03:00
Anna Shaleva
abe3c94b95
core: use big.Int to store NEP5 balances
...
closes #1133
2020-07-09 13:26:39 +03:00
Anna Shaleva
43b28ffa06
core: get rid of NEP5TransferSize
...
Part of #1133
It will help us to use big.Int to store amount of NEP5 tokens. As far as
big.Int doesn't have constant size, we shouldn't use `NEP5TransferSize`
constant anymore.
2020-07-09 13:25:03 +03:00
Roman Khimov
76925fe3e0
compiler: slices must default to nil
2020-07-09 13:07:21 +03:00
Roman Khimov
eee8ac1655
compiler: fix initialization of struct fields, fix #1164
...
Make `s{}` initializers work. Deduplicate code a bit along the way. The test
added follows bf6aa02dcf
test.
2020-07-09 12:27:21 +03:00
Anna Shaleva
56a5c9db11
compiler: compile appcall with dynamic argument
...
Closes #1160
2020-07-08 19:49:14 +03:00
Roman Khimov
8532d76401
Merge pull request #1155 from nspcc-dev/interop-compiler-fixes-for-3.0
...
Interop and compiler fixes for 3.0
2020-07-08 09:40:06 +03:00
Roman Khimov
540a20c1c9
rpc/request: decode bytearray as base64, fix #1151
...
It's encoded in base64 now.
2020-07-07 22:35:03 +03:00
Roman Khimov
694963d607
compiler: fix binary.* syscalls compilation, fix #1152
...
They were attributed to a wrong package.
2020-07-07 21:57:51 +03:00
Roman Khimov
ebe37d1a46
compiler: check for NULL when calculating len(), fix #1153
2020-07-07 21:49:21 +03:00
Roman Khimov
b3e450477d
interop/runtime: synchronize trigger values with smartcontract/trigger
...
Neo 3.0 has new updated and improved constants. A better (non-function-based)
fix requires #1154 to be solved.
2020-07-07 20:25:52 +03:00
Anna Shaleva
2200f7ff71
compiler: lowercase the first letter of methods in manifest
...
In order to be compatable with NEP5 standards and C# node we have to
keep the first letter of each manifest method lowercased.
2020-07-07 13:44:47 +03:00
Anna Shaleva
f37831d173
compiler: convert to manifest only methods from main pkg
...
manifest.json should contain only methods from the package where `Main`
function located.
2020-07-07 13:42:15 +03:00
Anna Shaleva
c2dccb6314
compiler: add ability to emit package to debug info
...
Emit package information into MethodDebugInfo
2020-07-07 13:39:58 +03:00
Anna Shaleva
c3a0998cae
compiler: fix bug in codegen
...
Main function (as far as the others uncknown to codegen at the moment of
`convertFuncDecl`) didn't have package set. Fixed.
2020-07-07 13:28:38 +03:00
Anna Shaleva
7d8a3a7065
compiler: exclude unexported methods from manifest
...
We should be able to invoke exported methods only.
2020-07-07 13:23:01 +03:00
Anna Shaleva
1755ce10ac
rpc: make getapplicationlog
error more deterministic
2020-07-06 15:04:28 +03:00
Anna Shaleva
29f1e646ed
vm: fix stackitem serialisation
...
We're able to serialise Buffer stackitem, but can not deserealise it
which leads to errors. Fixed.
2020-07-06 15:04:19 +03:00
Anna Shaleva
7b90ad9337
rpc: fix cosigner scope in CreateNEP5TransferTx
...
It should be the same as transaction's cosigner scope.
2020-07-06 11:03:21 +03:00
Anna Shaleva
966ad8a0b1
rpc: fix adding extra network fee to tx
2020-07-06 11:02:57 +03:00
Anna Shaleva
1880e96844
cli: fix contract deploy&invoke
...
We should add cosigners to deplyment and invocation transactions.
2020-07-06 10:01:14 +03:00
Evgenii Stratonikov
5787d7775f
transaction: fail creating tx if there is additional data present
2020-07-03 18:03:57 +03:00
Evgenii Stratonikov
27b3054df4
transaction: set feePerByte on tx construction
2020-07-03 17:52:13 +03:00
Evgenii Stratonikov
3097dc60e5
transaction: cache feePerByte
2020-07-03 17:37:01 +03:00
Roman Khimov
2f09ec38fc
Merge pull request #1140 from nspcc-dev/feature/config
...
config: allow to specify config path directly
2020-07-03 12:28:30 +03:00
Evgenii Stratonikov
681e0e0a4d
config: allow to specify config path directly
...
It costs us nothing and makes API much more flexible.
2020-07-03 11:47:56 +03:00
Roman Khimov
08d304c838
Merge pull request #1138 from nspcc-dev/fix/nep6
...
wallet: marshal script in base64
2020-07-03 10:11:49 +03:00
Roman Khimov
4f8e4628dc
cli/rpc: hide parameter encoding details for Invoke* calls
...
The script is passed as a hex string, but no one should care. The hash is a
hex-encoded LE value, but no one should care either. Hex might change to
base64, LE to BE, no one outside these functions should care about that.
2020-07-02 16:41:34 +03:00
Roman Khimov
0819583413
cli/rpc: test-invoke deployment script to get the system fee value
...
Fix #1134 .
2020-07-02 16:41:31 +03:00
Roman Khimov
17ea6411a2
rpc/client: ensure compatibility with preview2 C# node for invoke*
...
It won't work with proper cosigners and the client must be compatible both
with neo-go and C# node. See neo/neo-modules#260 also.
2020-07-02 16:40:32 +03:00
Roman Khimov
cc95d559cc
rpc/client: unify invoke* functions
2020-07-02 16:40:32 +03:00
Evgenii Stratonikov
0b67d80bb1
wallet: marshal script in base64
...
Related #1015 .
2020-07-02 11:43:53 +03:00
Anna Shaleva
4dfb0eb438
compiler, cli: generate manifest.json and debug.json independently
...
We should be able to generate manifest.json without debug.json and vice
versa.
2020-06-30 14:33:19 +03:00
Roman Khimov
59d1013a8f
Merge pull request #1136 from nspcc-dev/neo3/consensus/fix
...
consensus: prevent `invalid message` panic
2020-06-30 13:10:43 +03:00
Anna Shaleva
995abcf0c3
consensus: prevent invalid message
panic
...
After 5c2f69bd2c
there's an `invalid
message` panic when trying to run 4-nodes private network:
```
=> Try to restore blocks before running node
2020-06-30T08:59:39.696Z INFO no storage version found! creating genesis block
2020-06-30T08:59:39.696Z INFO service is running {"service": "Prometheus", "endpoint": ":20001"}
2020-06-30T08:59:39.696Z INFO service hasn't started since it's disabled {"service": "Pprof"}
_ ____________ __________
/ | / / ____/ __ \ / ____/ __ \
/ |/ / __/ / / / /_____/ / __/ / / /
/ /| / /___/ /_/ /_____/ /_/ / /_/ /
/_/ |_/_____/\____/ \____/\____/
2020-06-30T08:59:39.696Z INFO starting rpc-server {"endpoint": ":30333"}
2020-06-30T08:59:39.696Z INFO node started {"blockHeight": 0, "headerHeight": 0}
/NEO-GO:/
2020-06-30T08:59:39.697Z INFO new peer connected {"addr": "172.200.0.1:20333", "peerCount": 1}
2020-06-30T08:59:39.697Z INFO new peer connected {"addr": "172.200.0.2:46692", "peerCount": 2}
2020-06-30T08:59:39.697Z INFO new peer connected {"addr": "172.200.0.1:54140", "peerCount": 3}
2020-06-30T08:59:39.697Z INFO new peer connected {"addr": "172.200.0.4:42890", "peerCount": 4}
2020-06-30T08:59:39.697Z INFO new peer connected {"addr": "172.200.0.4:20336", "peerCount": 5}
2020-06-30T08:59:39.697Z INFO new peer connected {"addr": "172.200.0.2:20334", "peerCount": 6}
2020-06-30T08:59:39.697Z INFO started protocol {"addr": "172.200.0.4:42890", "userAgent": "/NEO-GO:/", "startHeight": 0, "id": 3797159912}
2020-06-30T08:59:39.697Z WARN peer disconnected {"addr": "172.200.0.4:20336", "reason": "already connected", "peerCount": 5}
2020-06-30T08:59:39.697Z INFO started protocol {"addr": "172.200.0.2:20334", "userAgent": "/NEO-GO:/", "startHeight": 0, "id": 1116452361}
2020-06-30T08:59:39.697Z WARN peer disconnected {"addr": "172.200.0.2:46692", "reason": "already connected", "peerCount": 4}
2020-06-30T08:59:39.697Z WARN peer disconnected {"addr": "172.200.0.1:54140", "reason": "identical node id", "peerCount": 3}
2020-06-30T08:59:39.697Z WARN peer disconnected {"addr": "172.200.0.1:20333", "reason": "identical node id", "peerCount": 2}
2020-06-30T08:59:40.673Z INFO new peer connected {"addr": "172.200.0.3:44948", "peerCount": 3}
2020-06-30T08:59:40.673Z INFO new peer connected {"addr": "172.200.0.3:20335", "peerCount": 4}
2020-06-30T08:59:40.673Z WARN peer disconnected {"addr": "172.200.0.3:20335", "reason": "already connected", "peerCount": 3}
2020-06-30T08:59:40.673Z WARN peer disconnected {"addr": "172.200.0.3:44948", "reason": "unexpected empty payload", "peerCount": 2}
2020-06-30T08:59:40.673Z INFO new peer connected {"addr": "172.200.0.3:44950", "peerCount": 3}
2020-06-30T08:59:40.673Z INFO new peer connected {"addr": "172.200.0.3:20335", "peerCount": 4}
2020-06-30T08:59:40.677Z INFO node reached synchronized state, starting consensus
2020-06-30T08:59:40.677Z INFO started protocol {"addr": "172.200.0.3:44950", "userAgent": "/NEO-GO:/", "startHeight": 0, "id": 2658713129}
2020-06-30T08:59:40.689Z WARN peer disconnected {"addr": "172.200.0.3:20335", "reason": "already connected", "peerCount": 3}
2020-06-30T08:59:40.697Z INFO blockchain persist completed {"persistedBlocks": 0, "persistedKeys": 23, "headerHeight": 0, "blockHeight": 0, "took": "243.634µs"}
2020-06-30T08:59:41.057Z INFO initializing dbft {"height": 1, "view": 0, "index": 0, "role": "Backup"}
2020-06-30T08:59:41.057Z DPANIC invalid message
2020-06-30T08:59:41.058Z DPANIC invalid message
```
Reason: payload wasn't decoded as payload.message isn't null anymore.
Fixed.
2020-06-30 12:06:50 +03:00
Roman Khimov
ee0d869815
Merge pull request #1126 from nspcc-dev/fix/variable
...
compiler: support variable shadowing
2020-06-30 11:27:52 +03:00
Evgenii Stratonikov
4f64bf86e5
compiler: add test for argument shadowing
...
Thanks @roman-khimov.
2020-06-30 10:41:48 +03:00
Evgenii Stratonikov
26cfae7c9a
compiler: support shadowing via Block statements
2020-06-30 10:31:52 +03:00
Evgenii Stratonikov
40bacc6775
compiler: support variable shadowing
...
Closes #1131 .
2020-06-30 10:31:52 +03:00
Evgenii Stratonikov
1ee4acbdbc
compiler: manage variables in a separate varScope struct
...
Abstract var scope management from the funcScope.
2020-06-30 10:31:51 +03:00
Roman Khimov
08c516014f
Merge pull request #1132 from nspcc-dev/neo3/rpc/fixed8_marshalling
...
*: switch from Fixed8 to int64
2020-06-29 21:44:40 +03:00
Anna Shaleva
c421805141
core: fixed typo in method description
2020-06-29 21:40:59 +03:00
Anna Shaleva
0aaaf7f787
*: switch from fixed8 to int64 in (Blockchain).CalculateClaimable
2020-06-29 21:40:54 +03:00
Anna Shaleva
73b630db9b
*: switch from fixed8 to int64
...
Follow C# implementation, we have to marshall JSON Fixed8 fields without
taking into account decimals.
2020-06-29 21:39:27 +03:00
Roman Khimov
372dd71708
Merge pull request #1108 from nspcc-dev/neo3/compiler/nef
...
compiler: support *.nef and *.manifest.json generation
2020-06-29 20:55:47 +03:00
Anna Shaleva
dc5da4f37e
compiler: fix unhandled error
2020-06-29 20:44:03 +03:00
Anna Shaleva
66b6a27b09
compiler: fix DebugInfo JSON marshalling
...
MethodDebugInfo.Parameters should be marshalled as `params`
MethodDebugInfo.ReturnType --> `return`
EventDebugInfo.Parameters --> `params`
(see https://github.com/ngdseattle/design-notes/blob/master/NDX-DN11%20-%20NEO%20Debug%20Info%20Specification.md#v11-format )
2020-06-29 20:42:03 +03:00
Evgenii Stratonikov
5c2f69bd2c
consensus: take payload hash based on data
...
Fix 857ced82
.
2020-06-29 15:52:06 +03:00
Roman Khimov
8ad355b444
Merge pull request #1124 from nspcc-dev/forward-port-from-2.x
...
Forward port from 2.x
2020-06-29 11:52:45 +03:00
Evgenii Stratonikov
f007cca80b
native: hide native contract methods
...
Copy public keys when returning them to the outside and hide unused
`GetValidators` method.
2020-06-29 10:48:37 +03:00
Evgenii Stratonikov
8c18142e8a
keys: implement PublicKeys.Copy()
...
Implement convenient wrapper over explicit allocation and copying.
2020-06-29 10:44:35 +03:00
Evgenii Stratonikov
bbe02ac584
native: store typed nil
in validators cache
...
Fix `error encountered at instruction 0 (SYSCALL): sync/atomic: store of nil value into Value"`.
2020-06-29 10:37:52 +03:00
Evgenii Stratonikov
f67b8ce607
consensus: check if payload is present in cache before validation
...
Don't check signature correctness twice.
2020-06-29 10:37:26 +03:00
Anna Shaleva
45213dda49
compiler: remove unnecessary structures
2020-06-29 09:15:29 +03:00
Anna Shaleva
2f6065f541
compiler, cli: introduce *.manifest.json
...
Add ability to generate NEO3-compatable *.manifest.json into compiler.
This file represets contract manifest and includes ABI information, so
we don't need to create separate *.abi.json file. NEO3 debugger also
needs *.manifest.json only. So, switched from *.abi.json to
*.manifest.json file.
2020-06-29 09:15:29 +03:00