Evgenii Stratonikov
540ac23ca8
core: calculate prices of Neo.Crypt.*
opcodes correctly
2020-06-19 12:58:33 +03:00
Evgenii Stratonikov
05dad10e82
native: fix native contract onPersist
script
...
C# implementation uses NEWARRAY for creating arguments.
Don't change our implementation in `emit`, because PACK is cheaper and
this script must not depend on the internal details of `emit` package anyway.
2020-06-19 11:58:38 +03:00
Evgenii Stratonikov
3787a8895e
rpc: marshal GasConsumed getapplicationlog
as string
...
Also there is no more decimal point.
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
6a2161207a
smartcontract: rename ByteArray to ByteString in JSON for smartcontract parameters
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
81adb7ce83
core: set price getter for native contract persist routine
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
b9e260a704
smartcontract: omit empty value in JSON for Interop/Any parameters
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
3a0be5ce28
rpc: allow to invoke getapplicationlog
with block hash
...
Support retrieving native contract persist results by block hash.
All necessary support is already here, just add test.
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
a980cac0b3
stackitem: support Null item (de-)serialization
...
It's binary representation contains just type (AnyT).
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
c0e482fe6c
rpc: restructure getapplicationlog
response
...
Move VM-related fields to top-level.
2020-06-19 11:38:56 +03:00
Roman Khimov
93b0011988
Merge pull request #1069 from nspcc-dev/addr-locking-and-other-fixes
...
Addr, locking and other fixes
2020-06-18 23:29:19 +03:00
Evgenii Stratonikov
e7d8bb92f6
core/tests: extend native contract test
...
Check if native contract's method price is taken into account.
2020-06-18 22:44:10 +03:00
Evgenii Stratonikov
5354352d63
core: remove transaction priority
...
There is no such thing as high/low priority transactions, as there are
no free transactions anymore and they are ordered by fees contained
in transaction itself.
Closes #1063 .
2020-06-18 22:44:10 +03:00
Evgenii Stratonikov
2f724b792c
core: remove config fields related to free transactions
...
In NEO3 every transaction must have some gas attached.
Closes #1064 .
2020-06-18 22:44:08 +03:00
Roman Khimov
1081791c68
core: fix contract manifest unpacking in System.Contract.Create
...
It's just JSON, io.Serializable is only used for DB storage where the length
should be obtained from the stream. Fixes:
2020-06-18T22:14:10.571+0300 WARN contract invocation failed {"tx": "1ffd475a9c246495d6206cb80a9a78e9d14a433ded60cd37aa87d897655606e1", "block": 25893, "error": "error encountered at instruction 3696 (SYSCALL): failed to invoke syscall: invalid character ':' after top-level value"}
2020-06-18 22:38:34 +03:00
Evgenii Stratonikov
84387b2416
core: set gas limit to transaction.SystemFee for all transactions
2020-06-18 22:17:48 +03:00
Roman Khimov
90d3bcbdc3
state: initialize PublicKey before decoding into it, fix #1061
...
These are pointers and decoding into a nil pointer is a bad idea.
2020-06-18 21:59:58 +03:00
Roman Khimov
dd6895b103
native: optimize GAS onPersist for empty blocks
...
There is no need to get a list of validators when there are no transactions in
the block.
2020-06-18 21:51:29 +03:00
Roman Khimov
f0fbb2d8ff
core: prevent panic on forced exit
...
If we're to close the Blockchain while it's storing a block this might happen:
panic: assignment to entry in nil map
goroutine 63 [running]:
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).put(...)
/home/rik/dev/neo-go/pkg/core/storage/memory_store.go:53
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).Persist(0xc000673a40, 0x0, 0x0, 0x0)
/home/rik/dev/neo-go/pkg/core/storage/memcached_store.go:118 +0x245
github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).Persist(0xc003dbdcc0, 0xc003b18900, 0xc002505538, 0xc001c510e0)
/home/rik/dev/neo-go/pkg/core/dao/dao.go:543 +0x2e
github.com/nspcc-dev/neo-go/pkg/core/dao.(*Cached).Persist(0xc003b189c0, 0xc000240000, 0x0, 0x0)
/home/rik/dev/neo-go/pkg/core/dao/cacheddao.go:169 +0x756
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).storeBlock(0xc0001f4000, 0xc003611040, 0x0, 0x10)
/home/rik/dev/neo-go/pkg/core/blockchain.go:647 +0xfa2
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddBlock(0xc0001f4000, 0xc003611040, 0x0, 0x0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:447 +0xee
github.com/nspcc-dev/neo-go/pkg/network.(*blockQueue).run(0xc0006f4120)
/home/rik/dev/neo-go/pkg/network/blockqueue.go:48 +0x158
created by github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start
/home/rik/dev/neo-go/pkg/network/server.go:179 +0x2b5
2020-06-18 21:35:17 +03:00
Roman Khimov
bbe174ee4a
network: fix inverted logic of address addition to the pool
...
Fix #1066 .
2020-06-18 21:34:45 +03:00
Evgenii Stratonikov
8a0b2be285
core: process NEP5 transfers emitted by Native.onPersist
...
All GAS is minted/burnt during `onPersist` call.
2020-06-18 16:38:08 +03:00
Evgenii Stratonikov
c9df5d3aed
rpc: fix typo in getnep5transfers
rpc
...
Omit empty address for transfers in both directions.
2020-06-18 16:31:33 +03:00
Evgenii Stratonikov
3e76b9a9bf
native: fix Transfer event in burn
...
Tokens should subtract, but transfer amount is positive.
2020-06-18 16:19:09 +03:00
Evgenii Stratonikov
295d8fc70e
core: save application logs for native persist
2020-06-18 15:32:27 +03:00
Evgenii Stratonikov
3894b6db9f
native: take into account native contract method prices
...
Burn gas right before function invoke.
2020-06-18 15:32:27 +03:00
Evgenii Stratonikov
031fd93172
native: fix native contract prices
2020-06-18 15:32:27 +03:00
Evgenii Stratonikov
0fa4c49735
core,native: persist native contract via VM
...
After native contracts are deployed, single persist script is created
and executed at the start of every block persisting.
2020-06-18 15:32:27 +03:00
Roman Khimov
b483c38593
block/transaction: add network magic into the hash
...
We make it explicit in the appropriate Block/Transaction structures, not via a
singleton as C# node does. I think this approach has a bit more potential and
allows better packages reuse for different purposes.
2020-06-18 12:39:50 +03:00
Roman Khimov
8fda6a3407
block: fix ConsensusData hashing
...
It's DoubleSha256 as with the rest of the structures.
2020-06-18 12:22:49 +03:00
Roman Khimov
5fe8287fbb
rpc: use non-pointer Block and Transaction in results
...
Pointers can be nil and in some cases it's important to always have access to
Block or Transaction fields.
2020-06-18 12:13:35 +03:00
Roman Khimov
a7cce3f894
smartcontract: use new VerifiableDecodable for ParameterContext
...
And implement it for Transaction, the only user of ParameterContext for
now. Which make correct signing/verifying possible for cases when
serialization for general transmission and signing differ.
2020-06-18 12:12:56 +03:00
Roman Khimov
dde0763840
network: fix compression handling functions
...
Turns out, Neo uses block compression and not a streaming lz4 format. And it
doesn't contain uncompressed payload size which makes guessing it somewhat
suboptimal.
2020-06-18 12:12:43 +03:00
Roman Khimov
8388e509df
network: don't allocate memory for messages larger than PayloadMaxSize
2020-06-18 12:12:31 +03:00
Roman Khimov
39fd799992
network: fix Compress flag, it's the first bit (index 0)
2020-06-18 12:12:17 +03:00
Roman Khimov
0002b65238
block: it's not a padding, but a witness count in the base
...
At least that's the interpretation C# codebase has, so be a bit more correct
in error message.
2020-06-18 12:12:00 +03:00
Roman Khimov
b9a66c64e1
block: drop paddings from structures
...
It makes no sense at all storing them in a structure, they're just a part of
encoding/decoding process.
2020-06-18 12:11:41 +03:00
Roman Khimov
b6eef9d275
consensus: don't duplicate RebuildMerkleRoot in newBlockFromContext
2020-06-18 12:11:26 +03:00
Roman Khimov
d22286cbbc
client/cli: add network option to the RPC client
...
It doesn't affect anything yet, but it's going to be used in the future for
network-specific behavior. It also renames short '--timeout' form to '-s'
avoiding conlict with '-t' used for '--testnet'.
2020-06-18 12:11:13 +03:00
Roman Khimov
1c2318eed4
netmode: use non-zero unittest network
...
Using zero is a bit dangerous as it's the default type's value, so we can miss
some uninitialized variables when testing.
2020-06-18 12:10:12 +03:00
Roman Khimov
78ff11fe53
netmode: make default Magic String() more useful
2020-06-18 12:09:57 +03:00
Roman Khimov
26f11a52d9
config: move NetMode into its own micropackage
...
It's going to be used a bit more and pulling whole config just for one type is
a bit wrong.
2020-06-18 12:09:57 +03:00
Roman Khimov
6eb600de5a
config: sync network magic numbers
...
unit_testnet YAML was out of sync with Go code and Go code was out of sync
with YAML for mainnet and testnet after 308243f36e
.
2020-06-18 12:09:55 +03:00
Roman Khimov
5f276de003
Merge pull request #1057 from nspcc-dev/fix/newaddress
...
Update addresses to NEO3 format
2020-06-17 16:25:32 +03:00
Evgenii Stratonikov
7b4ca57e33
*: change address to the new format
...
NEO3 uses new prefix for address (53 = 0x35), thus string representations as
well as encrypted WIFs should be changed.
2020-06-17 15:58:21 +03:00
Evgenii Stratonikov
651976b2ca
config: remove AddressVersion from the configuration
...
It is never used and is the same constant for both mainnet, testnet and
privnet.
2020-06-17 15:55:22 +03:00
Evgenii Stratonikov
b3b1137030
cli: allow to convert wallet from NEO2 to NEO3 format
...
This command may be helpful to have during transition.
2020-06-17 15:49:34 +03:00
Evgenii Stratonikov
61cae8d8b1
compiler: implement missing System.Contract.*
interops
...
Support System.Contract.IsStandard/CreateStandardAccount syscall.
2020-06-17 11:38:34 +03:00
Evgenii Stratonikov
3762ebdd08
core: implement System.Runtime.GetInvocationCounter syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
75e597f880
core: implement System.Runtime.GetNotifications syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
afd8f3b87a
compiler: push Null item for nil
values
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
a4e4439967
core,vm: implement System.Runtime.GasLeft syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
a7d4fff897
vm: make (*VM).GasLimit public
...
VM is inherently single-threaded and replacing setter/getter methods
with public field simplifies code a bit.
2020-06-16 15:13:20 +03:00
Evgenii Stratonikov
1f97f3abd8
core: adjust prices and flags for System.Runtime.* interops
...
Related #1055 .
2020-06-16 12:30:55 +03:00
Evgenii Stratonikov
ad2a75a500
core: move System.ExecutionEngine.* interops to System.Runtime.*
2020-06-16 12:30:55 +03:00
Evgenii Stratonikov
52a27e9be4
core: implement System.Contract.CreateStandardAccount syscall
2020-06-16 12:12:29 +03:00
Evgenii Stratonikov
5b4f38d717
core: implement System.Contract.IsStandard syscall
2020-06-16 12:12:27 +03:00
Evgenii Stratonikov
b1d2d70c02
core: adjust prices for blockchain/contract syscalls
2020-06-16 12:04:57 +03:00
Evgenii Stratonikov
becb8a0f72
compiler: support System.Json.*
syscalls
2020-06-16 11:35:08 +03:00
Evgenii Stratonikov
6339efac11
core: implement System.Json.* interops
2020-06-16 11:35:06 +03:00
Evgenii Stratonikov
d836233352
stackitem: allow to (de-)serialize items to JSON
...
This commit implements behavior identical to that of C# `System.Json.*` interops.
2020-06-16 11:34:01 +03:00
Evgenii Stratonikov
f2f01a08c9
vm: move MaxArraySize and MaxItemSize to stackitem package
2020-06-16 11:32:16 +03:00
Evgenii Stratonikov
aae312d408
core,vm: adjust prices for iterator/enumerator syscalls
...
Closes #1027 .
2020-06-16 11:05:26 +03:00
Evgenii Stratonikov
18066143bd
core,vm: adjust binary (de-)serialization syscalls
...
Related #1027 .
1. Move System.Runtime.(De)serialize to System.Binary.*
2. Rename compiler stubs.
3. Adjust opcode prices.
2020-06-16 11:00:38 +03:00
Roman Khimov
b3507d490d
Merge pull request #1051 from nspcc-dev/neo3/rpc/scopes
...
core: add json marshaller for Cosigner's scopes
2020-06-15 16:13:48 +03:00
Anna Shaleva
3568ab3d6d
core: add json marshaller for Cosigner's scopes
...
Following C# implementation, we should marshal Scopes as a set of
strings instead of single byte.
2020-06-15 13:48:15 +03:00
Evgenii Stratonikov
2e996ea57d
core: adjust System.Storage.*
interop prices
2020-06-15 12:02:28 +03:00
Evgenii Stratonikov
61bba1a39c
core: store precise gas price in interop descriptions
...
In NEO3 sycalls can have prices less than 10^5, we need to store them
precisely. Adjusting actual prices is to be done in the following tasks.
2020-06-15 12:02:28 +03:00
Evgenii Stratonikov
fd2cd291e7
core: calculate opcode prices correctly
2020-06-15 12:02:22 +03:00
Evgenii Stratonikov
8f20a70969
core: calculate a price of System.Storage.Put
correctly
...
It also depends on the item already stored by key.
2020-06-15 12:02:21 +03:00
Roman Khimov
fe31c7ed2d
Merge pull request #1047 from nspcc-dev/neo3/rpc/invoke
...
rpc: update invoke* RPC-calls
2020-06-11 21:39:20 +03:00
Anna Shaleva
9e7fca013e
rpc: update CLI and RPC client invoke* calls
...
part of #1036
2020-06-11 20:32:05 +03:00
Anna Shaleva
d5355acfa9
rpc: update RPC server invoke* calls
...
part of #1036
2020-06-11 19:34:13 +03:00
Evgenii Stratonikov
971ab0646f
core: specify allowed triggers for interops
...
Related #1026 , #1027 , #1028 , #1031 .
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
4dfce07d11
vm: provide trigger upon VM creation
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
b12add5a78
smartcontract: rewrite trigger types for NEO3
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
a3b876d55c
native: specify call flags for native contract methods
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
0dd00a49f5
core: specify require call flags in interop description
...
Related #1026 , #1027 , #1028 , #1031 .
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
bda94c74c3
vm: check calling flags on syscall invocation
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
55ab7535be
core: optimize contractCallEx
...
Provide script hash upon script load.
2020-06-11 13:06:10 +03:00
Evgenii Stratonikov
61edc8705e
smartcontract: start flags with 1
...
`iota` keyword is equal to the index of the declaration in the
corresponding block, thus AllowStates was 2 in our case.
2020-06-11 13:03:55 +03:00
Evgenii Stratonikov
532262827d
smartcontract: add CallFlag.Has() helper
2020-06-11 13:03:55 +03:00
Evgenii Stratonikov
ebbf0321b2
smartcontract: add AllowStates call flag
2020-06-11 13:03:55 +03:00
Evgenii Stratonikov
a86e1910e1
core: remove unused interops
...
Missed in #1040 .
2020-06-11 10:51:19 +03:00
Evgenii Stratonikov
f8a11f61b6
core: update *.Contract.* interops
...
1. Remove GetScript, IsPayable, GetStorageContext.
2. Revert 82319538
related to GetStorageContext.
3. Rename Migrate to Update.
4. Move remaining to System.Contract.*.
Related #1031 .
2020-06-11 10:50:35 +03:00
Evgenii Stratonikov
c69f8a2fa3
core: check for permission in System.Contract.Call(Ex)
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
5514b3f52f
smartcontract,vm: remove DynamicInvoke feature
...
It doesn't exist in NEO3.
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
76a2f62fbd
cli: use manifest during contract deployment
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
a03af55732
core: provide monotonically increasing ID for contracts
...
ID is a contract identifier which doesn't change during migration.
It is also used as a part of storage context instead of contract hash.
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
20616cc97f
interop: perform contract checks in CheckWitness
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
7256efd1ed
vm: implement (*VM).AddGas
...
Calculating interop prices can be tricky. It is more convenitent to burn
gas inside interops where necessary parameters are popped.
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
df958caf93
core: add Manifest to state.Contract
2020-06-11 10:45:24 +03:00
Anna Shaleva
3549515fd7
rpc: fix typo in method description
2020-06-10 20:31:09 +03:00
Anna Shaleva
0af5b9339d
rpc, cli: remove invoke
RPC-call
...
part of #1036
2020-06-10 20:30:55 +03:00
Evgenii Stratonikov
425277098c
native: set ContractID for NEO & GAS contracts
2020-06-10 14:23:25 +03:00
Evgenii Stratonikov
38d020d1a2
core: move Neo.Storage.* interops to System.*
2020-06-10 12:13:35 +03:00
Evgenii Stratonikov
0472a0b0b1
core: move Neo.Runtime/Enumerator/Iterator.* interops to System.*
2020-06-10 12:13:35 +03:00
Evgenii Stratonikov
97c6ac7a73
core: move Neo.Blockchain.* syscalls to System.*
2020-06-10 12:13:18 +03:00
Evgenii Stratonikov
3d3fe9398e
core: remove Neo.Header/Witness/Account.* interops
...
They are not present in NEO3.
2020-06-10 12:13:18 +03:00
Roman Khimov
4264a758ac
Merge pull request #1039 from nspcc-dev/neo3/rpc/getversion
...
rpc: update `getversion` RPC-call
2020-06-10 11:08:45 +03:00
Anna Shaleva
3418e4f7f4
rpc: update getversion
RPC-call
...
closes #1035
2020-06-10 10:47:11 +03:00
Anna Shaleva
8b7abd36c9
core: remove Block.GetTransactions, Block.GetTransactionsCount interops
...
Updated System.Blockchain.GetBlock interop replaced the functionality of
the following interops:
System.Block.GetTransactions
System.Block.GetTransactionCount
Neo.Block.GetTransactions
Neo.Block.GetTransactionsCount
2020-06-09 23:24:11 +03:00