Commit graph

2740 commits

Author SHA1 Message Date
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
Roman Khimov
8065114da6
Merge pull request #1129 from nspcc-dev/fix/payload
consensus: take payload hash based on data
2020-06-29 16:05:02 +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
Roman Khimov
88b933672a
Merge pull request #1125 from nspcc-dev/fix/consensus
Copy validators when returning to the outside
2020-06-29 11:05:21 +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
Anna Shaleva
1c1818d97e vm: fix typoes in cli package 2020-06-29 09:15:29 +03:00
Anna Shaleva
b387deaa05 vm: switch from .avm to .nef 2020-06-29 09:15:29 +03:00
Anna Shaleva
c7746da023 cli, compiler: switch from .avm to .nef
We don't generate clear .avm instructions anymore. Instead, use .nef
files with additional metadata.
2020-06-29 09:15:29 +03:00
Anna Shaleva
6b8957243a *: move wallet config from wallet to config package
In order to avoid dependency cycle at the next commits:

	imports github.com/nspcc-dev/neo-go/pkg/config
	imports github.com/nspcc-dev/neo-go/pkg/wallet
	imports github.com/nspcc-dev/neo-go/pkg/vm
	imports github.com/nspcc-dev/neo-go/pkg/smartcontract/nef
	imports github.com/nspcc-dev/neo-go/pkg/config
2020-06-29 09:15:29 +03:00
Anna Shaleva
927127e5fb smartcontract: add nef file
It should match C# NEF3 specification in order to debug and deploy smart
contracts via NEO3 Blockchain Toolkit.
2020-06-29 09:15:25 +03:00
Roman Khimov
cab437284d core: fix TestGetClaimable occasional failures 2020-06-27 12:36:43 +03:00
Roman Khimov
a46c71f2de consensus: prevent synchronization stalls
When CN is not up to date with the network is synchonizes blocks first and
only then starts consensus process. But while synchronizing it receives
consensus payloads and tries to process them even though messages reader
routine is not started yet. This leads to lots of goroutines waiting to send
their messages:

Jun 25 23:55:53 nodoka neo-go[32733]: goroutine 1639919 [chan send, 4 minutes]:
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/consensus.(*service).OnPayload(0xc0000ecb40, 0xc005bd7680)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/consensus/consensus.go:329 +0x31b
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleConsensusCmd(...)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:687
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage(0xc0000ba160, 0x1053260, 0xc00507d170, 0xc005bdd560, 0x0, 0x0)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:806 +0xd58
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*TCPPeer).handleConn(0xc00507d170)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/tcp_peer.go:160 +0x294
Jun 25 23:55:53 nodoka neo-go[32733]: created by github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Dial
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/tcp_transport.go:38 +0x1ad
Jun 25 23:55:53 nodoka neo-go[32733]: goroutine 1639181 [chan send, 10 minutes]:
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/consensus.(*service).OnPayload(0xc0000ecb40, 0xc013bb6600)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/consensus/consensus.go:329 +0x31b
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleConsensusCmd(...)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:687
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage(0xc0000ba160, 0x1053260, 0xc01361ee10, 0xc01342c780, 0x0, 0x0)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:806 +0xd58
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*TCPPeer).handleConn(0xc01361ee10)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/tcp_peer.go:160 +0x294
Jun 25 23:55:53 nodoka neo-go[32733]: created by github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Dial
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/tcp_transport.go:38 +0x1ad
Jun 25 23:55:53 nodoka neo-go[32733]: goroutine 39454 [chan send, 32 minutes]:
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/consensus.(*service).OnPayload(0xc0000ecb40, 0xc014fea680)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/consensus/consensus.go:329 +0x31b
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleConsensusCmd(...)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:687
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage(0xc0000ba160, 0x1053260, 0xc0140b2ea0, 0xc014fe0ed0, 0x0, 0x0)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/server.go:806 +0xd58
Jun 25 23:55:53 nodoka neo-go[32733]: github.com/nspcc-dev/neo-go/pkg/network.(*TCPPeer).handleConn(0xc0140b2ea0)
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/tcp_peer.go:160 +0x294
Jun 25 23:55:53 nodoka neo-go[32733]: created by github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Dial
Jun 25 23:55:53 nodoka neo-go[32733]: #011/go/src/github.com/nspcc-dev/neo-go/pkg/network/tcp_transport.go:38 +0x1ad

Luckily it doesn't break synchronization completely as eventually connection
timers fire, the node breaks all connections, create new ones and these new
ones request blocks successfully until another consensus payload stalls them
too. In the end the node reaches synchronization, message processing loop
starts and releases all of these waiting goroutines, but it's better for us to
avoid this happening at all.

This also makes double-starting a no-op which is a nice property.
2020-06-27 12:29:41 +03:00
Evgenii Stratonikov
3a356aafef io: make maxArraySize public 2020-06-27 12:18:56 +03:00
Evgenii Stratonikov
dac94a692d consensus: restrict invocation script size 2020-06-27 12:18:12 +03:00
Evgenii Stratonikov
02d0874200 io: allow to restrict slice size in ReadVarBytes 2020-06-27 12:17:27 +03:00
Roman Khimov
7e2e5e1879 keys: add support for uncompressed serialization in PublicKey 2020-06-27 12:16:31 +03:00
Roman Khimov
6031c8a087 consensus: fix processing changeview payloads from recovery message
Using view number from the recovery message is just plain wrong, it's gonna be
higher than our current view and these messages will be treated as coming from
the future, even though they have their original view number included.
2020-06-27 12:15:44 +03:00
Evgenii Stratonikov
d550e539ba rpc: convert null value to a defaultT
Right now we convert it is unmarshaler into a float64(0)
so an error is supressed.
2020-06-27 12:15:29 +03:00
Evgenii Stratonikov
bed08d3f89 rpc/server: unify boolean flag handling
Implement (*Param).GetBoolean() for converting parameter to bool value.
It is used for verbosity flag and is false iff it is either zero number
or empty sting.
2020-06-27 12:13:06 +03:00
Evgenii Stratonikov
35f952e44f rpc/server: simplify errors handling during parameter parsing
Forward-ported from 2.x with some updates.
2020-06-27 12:11:21 +03:00
Roman Khimov
6ea0d87934 docker: remove default ACC value, protect var expansion
The default makes little sense after 9b19b08e06,
but the feature might still be useful.
2020-06-27 11:38:13 +03:00
alexvanin
fb6c00d539 docker: fix shell condition check in entrypoint script 2020-06-27 11:20:41 +03:00
Roman Khimov
b92a1e3480
Merge pull request #1123 from nspcc-dev/feature/variadic
compiler: support `...` variadic calls
2020-06-27 11:00:48 +03:00
Evgenii Stratonikov
057e1e2806 compiler: support ... variadic calls 2020-06-27 10:42:30 +03:00
Roman Khimov
b9171eda14
Merge pull request #1118 from nspcc-dev/feature/variadic
Support variadic functions in compiler
2020-06-26 23:14:54 +03:00
Evgenii Stratonikov
a88ac44147 compiler: support variadic function definitions
Pack variadic arguments into a slice. This currently doen't work with
byte slices though.
2020-06-26 20:05:10 +03:00
Evgenii Stratonikov
c57d4cfff2 compiler: count current amount of locals correctly 2020-06-26 20:05:10 +03:00
Roman Khimov
637f75d9ef
Merge pull request #1122 from nspcc-dev/fix/printops
Extend PrintOps for JMP* and INIT* instructions
2020-06-26 19:51:58 +03:00
Evgenii Stratonikov
bdaffe75cb vm: extend PrintOps() with INITSSLOT & INITSLOT 2020-06-26 19:35:03 +03:00
Evgenii Stratonikov
82417499d7 vm: beautify PrintOps() output for JMP* instructions 2020-06-26 19:34:58 +03:00
Evgenii Stratonikov
709f656bcf vm: remove unused parameter from getJumpOffset 2020-06-26 19:17:17 +03:00
Roman Khimov
57f944b17e
Merge pull request #1120 from nspcc-dev/rpc/native-contract-addr
cli: update hardcoded script hashes for neo and gas contracts
2020-06-26 19:01:40 +03:00
Roman Khimov
1f9ab7dfa2
Merge pull request #1121 from nspcc-dev/fix/consensus
consensus: add network magic to hash data
2020-06-26 18:46:23 +03:00
Evgenii Stratonikov
857ced8230 consensus: add network magic to hash data
Consensus payload's hash now depends on the network node is operating
in.
2020-06-26 18:41:04 +03:00
alexvanin
cfa0c6e0ad cli: update hardcoded script hashes for neo and gas contracts
Use LittleEndian as preferred way to encode script-hashes
2020-06-26 16:22:02 +03:00