Roman Khimov
65332f5e7f
Merge pull request #529 from nspcc-dev/peer-communication-fixes
...
A set of fixes to make neo-go privnet more usable.
2019-11-29 16:29:28 +03:00
Roman Khimov
b4d9935bda
network: deduplicate a part of RelayTxn()
...
We already have relayInventory() for this.
2019-11-29 16:26:44 +03:00
Roman Khimov
2c0ed62680
core: fix blockchain init with (2000*N + 1) header hashes in DB
...
Stored header count includes block number zero, so it's (height + 1).
2019-11-29 16:26:44 +03:00
Roman Khimov
cd858ea5e6
Merge pull request #528 from nspcc-dev/fix/tx
...
consensus: fix 2 bugs
2019-11-29 16:12:53 +03:00
Evgenii Stratonikov
60f1648778
consensus: fix a bug with index out of range
2019-11-29 16:05:00 +03:00
Roman Khimov
efdcacca81
Merge pull request #527 from nspcc-dev/invoke-tx
...
Invoke RPC
2019-11-29 15:43:26 +03:00
Evgenii Stratonikov
189a708988
consensus: fix a bug with nil tx channel
2019-11-29 15:40:11 +03:00
Roman Khimov
293615ea5f
network/consensus: add new block relaying
...
Tell everyone about our new shiny blocks.
2019-11-29 12:27:15 +03:00
Roman Khimov
4d286dcfeb
network: check height before requesting headers
...
Only request headers from the other peer if his height is bigger than
ours. Otherwise we routinely ask 0-height newcomers for some random headers
that they know nothing about.
2019-11-29 11:48:17 +03:00
Roman Khimov
a730529b0c
network: process incoming p2p transactions
...
It's the same relaying as for RPC, but we don't need to return any result for
it.
2019-11-29 11:09:54 +03:00
Roman Khimov
9f9cf4ae3f
network: add getheaders message processing
...
This one is essential for the consensus nodes as otherwise they won't give out
the blocks they generate making their generation almost useless. It also makes
our networking part more complete.
2019-11-29 11:08:22 +03:00
Roman Khimov
734338ad70
network: move Version sending to the tcp transport
...
We have a race between reader and writer goroutines for the same connection
that leads to handshake failures when reader is faster to read the incoming
version (and try to reply to it) than writer is to write our own Version:
WARN[0000] peer disconnected addr="172.200.0.4:20334" peerCount=5 reason="invalid handshake: tried to send VersionAck, but didn't send Version yet
Fix it by moving Version sending before the reader loop starts.
2019-11-29 11:05:42 +03:00
Evgenii Stratonikov
0a9a742019
crypto: add invalid testcase
2019-11-29 11:03:03 +03:00
Evgenii Stratonikov
4d82419776
crypto: add missing tests for hash pkg
2019-11-29 11:03:03 +03:00
Roman Khimov
127f8418c8
rpc: refactor out runScriptInVM() from invokers
2019-11-28 19:13:58 +03:00
Roman Khimov
e216139108
rpc: implement server-side 'invoke' method, fix #346
2019-11-28 19:08:31 +03:00
Roman Khimov
2d41450ac9
Merge pull request #507 from nspcc-dev/dbft
...
network: plug in dBFT library
2019-11-27 15:22:40 +03:00
Roman Khimov
1b5da8401a
Merge pull request #521 from nspcc-dev/invokefunction
...
Invokefunction
2019-11-27 15:14:29 +03:00
Roman Khimov
e63b25d5ad
smartcontract: add user-facing testinvokefunction command
...
With a very special syntax.
2019-11-27 15:12:15 +03:00
Roman Khimov
c5e2b3ce73
Merge pull request #523 from nspcc-dev/fix-interim-block-changes-store
...
Fix interim block changes store
2019-11-27 14:51:29 +03:00
Vsevolod
1a9e98caf3
Merge pull request #522 from nspcc-dev/fix-invalid-tx-type-handling
...
Fix invalid tx type handling
2019-11-27 13:40:52 +03:00
Roman Khimov
467c9c146d
core: restore intermediate block-level store
...
Commit c80ee952a1
removed temporary store used
to contain changes of the block being processed. It's wrong in that the block
changes should be applied to the database in a single transaction so that
there wouldn't be any intermediate state observed from the outside (which is
possible now). Also, this made changes commiting persist them to the
underlying store effectively making our persist loop a no-op (and not
producing `persist completed` log lines that we love so much).
2019-11-27 13:28:13 +03:00
Roman Khimov
bb765ccfa7
core: gofmt
2019-11-27 13:27:47 +03:00
Roman Khimov
65bf0d01d5
transaction: don't hide decoding error by logging
...
Unknown transaction types are wrong and should be treated as errors.
2019-11-27 13:12:04 +03:00
Roman Khimov
05f3329ec0
vm: add IterBack to the Stack to iterate bottom-to-top
...
And use it to build user-facing stack representation because that's the order
that C# VM uses.
2019-11-27 13:00:11 +03:00
Roman Khimov
f3ed91a1f7
vm: properly convert arrays to stackItems
...
They should be arrays of stackItems, not arrays of values.
2019-11-27 13:00:11 +03:00
Roman Khimov
d04bc0cbe3
rpc: add marshaler for StackParamType
...
Makes stack output look better, no one cares about numbers.
2019-11-27 13:00:11 +03:00
Roman Khimov
3843451ec4
rpc: fix potential getblock handling problem, add a test for it
...
It should only accept hex strings and numbers, anything else is wrong.
2019-11-27 13:00:11 +03:00
Roman Khimov
1c883cc819
rpc: add invokescript tests
2019-11-27 13:00:11 +03:00
Roman Khimov
cf39171485
rpc: implement invokefunction, fix #347
...
Param getters were redone to return errors because otherwise bad FuncParam
values could lead to panic. FuncParam itself might be not the most elegant
solution, but it works good enough for now.
2019-11-27 13:00:11 +03:00
Evgenii Stratonikov
b5fb43bac9
network: don't reconnect to peers with identical ID
2019-11-27 11:58:17 +03:00
Evgenii Stratonikov
fdd5276d3e
network: plug in dBFT library
2019-11-27 10:57:22 +03:00
Vsevolod
34a38ccce1
Merge pull request #518 from nspcc-dev/feat/noerrors
...
core: do not return error in block.getHashableData
2019-11-26 16:20:46 +03:00
Evgenii Stratonikov
af61571ba0
core: do not return error in block.getHashableData
2019-11-26 15:27:37 +03:00
Evgenii Stratonikov
ab922c1810
util: add missing tests for Uint256
2019-11-25 11:55:26 +03:00
Evgenii Stratonikov
d018dc4e56
util: add missing tests for Uint160
2019-11-25 11:55:26 +03:00
Evgenii Stratonikov
18075bc5c8
util: add missing tests for Fixed8
2019-11-25 11:54:59 +03:00
Evgenii Stratonikov
116d4c656e
util: make tests use require
2019-11-25 11:53:49 +03:00
Roman Khimov
ea9bc22510
Merge pull request #513 from nspcc-dev/feat/rpc_param
...
This PR does 3 things:
adds array parameter unmarshalling
extend Param with convenient methods
refactor tests into using tables to make it easier add new tests
(part of #347 solution)
2019-11-22 18:47:59 +03:00
Roman Khimov
eb84ae49da
Merge pull request #508 from nspcc-dev/feature/getvalidators_420
...
core: Implement getvalidators interop
2019-11-22 18:15:08 +03:00
Evgenii Stratonikov
c9d5f8b89c
rpc: cover stack_param with more tests
...
Use require/assert instead of builtin facilities.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 13:20:15 +03:00
Evgenii Stratonikov
0f9024d177
rpc: make client default values constants
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:10 +03:00
Evgenii Stratonikov
3afcd784f0
rpc: refactor tests
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:07 +03:00
Evgenii Stratonikov
d5fa31cecd
rpc: trim spaces in tests once
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:03 +03:00
Evgenii Stratonikov
c8987eda32
rpc: add array param type and tests
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:56:58 +03:00
Evgenii Stratonikov
7331127556
rpc: make parameter type an enum
...
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:56:49 +03:00
Vsevolod Brekelov
38088b648a
crypto: add unit tests for public key
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
c03de88b41
core: unit tests blockchain state
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
d28f2dce05
core: unit test validator state
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
419b031e96
core: add weighted function for validators
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
672f314be0
core: nit refactoring and add godoc
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
8ae88593dd
core: blockchain fmt
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
3c4b0e955d
core: create blockchain state that represents state of the bc
...
move some util methods to blockchain state
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
d4e8846ed0
!squash core/crypto
2019-11-21 15:41:49 +03:00
Vsevolod Brekelov
c80ee952a1
core/crypto: add validators and interop for validators
...
add processing of validators while block persist;
add validator structure with decoding/encoding;
add validator get from store;
add EnrollmentTX and StateTX processing;
add pubkey decode bytes, unique and contains functions;
2019-11-21 15:23:35 +03:00
Roman Khimov
aae3e217a8
rpc/cli: implement contract deployment, fix #474
...
It's used like this:
./bin/neo-go contract deploy -i 1-print.avm -c neo-go.yml -e http://localhost:20331 -w KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr -g 100
2019-11-20 16:12:40 +03:00
Roman Khimov
310104667d
rpc: refactor out reusable parts of CreateRawContractTransaction()
...
Signing and inputs/outputs management is common for different transactions, so
make separate functions for them.
2019-11-20 16:12:40 +03:00
Roman Khimov
7d89ccdb6f
rpc: implement YAML marshaling/unmarshaling for StackParamType
2019-11-20 16:12:40 +03:00
Roman Khimov
34e2122e58
core: only check tx against mempool if it's not in the block
...
Fixes failure to process transaction from the block when it was relayed
initially:
WARN[0788] blockQueue: failed adding block into the blockchain blockHeight=7270 error="transaction 35088916403e5cf2152e16c3bc6e0fba20c955fba38543b9fa5c50a3d3a4ace5 failed to verify: invalid transaction due to conflicts with the memory pool" nextIndex=7271
WARN[0790] blockQueue: failed adding block into the blockchain blockHeight=7270 error="transaction 35088916403e5cf2152e16c3bc6e0fba20c955fba38543b9fa5c50a3d3a4ace5 failed to verify: invalid transaction due to conflicts with the memory pool" nextIndex=7271
WARN[0790] blockQueue: failed adding block into the blockchain blockHeight=7270 error="transaction 35088916403e5cf2152e16c3bc6e0fba20c955fba38543b9fa5c50a3d3a4ace5 failed to verify: invalid transaction due to conflicts with the memory pool" nextIndex=7271
2019-11-20 16:12:40 +03:00
Roman Khimov
27a57e1a2d
transaction: allow system fee specification in NewInvocationTX
...
It's not possible to create any deployment TX without it.
2019-11-20 16:12:40 +03:00
Roman Khimov
d93499cc6f
rpc: implement CalculateInputs for RPC client
...
Using getunspents RPC call.
2019-11-20 16:12:40 +03:00
Roman Khimov
826a29cc98
rpc: implement client-side getunspents
2019-11-20 16:12:40 +03:00
Roman Khimov
29882b076c
rpc: remove duplicating definition of UTXO
...
Port sorting methods to core.
2019-11-19 17:35:04 +03:00
Roman Khimov
d2bdae99e4
Merge pull request #492 from nspcc-dev/feature/interop_neo_tests1
...
core: add unit tests for interops_neo
2019-11-18 19:39:05 +03:00
Vsevolod Brekelov
d57b6e1091
core: add unit tests for interops_neo
2019-11-18 19:31:27 +03:00
Roman Khimov
5076704019
Merge pull request #502 from nspcc-dev/docker-compose-environment-for-neo-go
...
Create docker-compose environment
2019-11-18 17:21:11 +03:00
Evgeniy Kulikov
2f8b11dabf
reformat code at pkg/network/metrics/metrics.go
2019-11-18 17:17:21 +03:00
Evgeniy Kulikov
0a56d3ddbc
network: generate randomized server id
...
math/rand might generate same id's on one environment, so.. use crypto/rand for generation id's
2019-11-18 17:17:21 +03:00
Roman Khimov
53f666bc13
Merge pull request #504 from nspcc-dev/getunspents
...
Implement getunspents RPC API
2019-11-18 13:45:33 +03:00
Roman Khimov
5841d3931e
rpc: implement getunspents method, fix #473
2019-11-18 11:30:09 +03:00
Evgenii Stratonikov
e3098ed0f8
network: write messages atomically
...
Right now message can be written in several Write's so
concurrent calls of writeMsg() can in theory interleave.
This commit fixes it.
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-18 09:31:00 +03:00
Evgenii Stratonikov
f65545023d
io: restrict ReadArray max array size
2019-11-15 22:39:21 +03:00
Roman Khimov
e4868cd429
core: implement EncodeBinary on value
...
Fixes panic:
panic: core.NotificationEvent does not have EncodeBinary(*BinWriter)
goroutine 97 [running]:
github.com/CityOfZion/neo-go/pkg/io.(*BinWriter).WriteArray(0xc004f7dda0, 0xabf820, 0xc004f7ddc0)
/home/rik/dev/neo-go/pkg/io/binaryWriter.go:45 +0x4b7
github.com/CityOfZion/neo-go/pkg/core.(*AppExecResult).EncodeBinary(0xc000635498, 0xc004f7dda0)
/home/rik/dev/neo-go/pkg/core/notification_event.go:73 +0x9c
github.com/CityOfZion/neo-go/pkg/core.putAppExecResultIntoStore(0xcf0020, 0xc001aafec0, 0xc000635498, 0xc004f81940, 0x40)
/home/rik/dev/neo-go/pkg/core/notification_event.go:33 +0xab
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).storeBlock(0xc000118000, 0xc006f89ea0, 0xc006f89ea0, 0x0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:534 +0x2539
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).AddBlock(0xc000118000, 0xc006f89ea0, 0xc004f368b0, 0x1)
/home/rik/dev/neo-go/pkg/core/blockchain.go:256 +0x91
github.com/CityOfZion/neo-go/pkg/network.(*blockQueue).run(0xc0048f4b80)
/home/rik/dev/neo-go/pkg/network/blockqueue.go:39 +0x14c
created by github.com/CityOfZion/neo-go/pkg/network.(*Server).Start
/home/rik/dev/neo-go/pkg/network/server.go:133 +0x272
2019-11-15 22:05:09 +03:00
Roman Khimov
1a5731e005
core: rework balance accounting
...
Store all unspents instead of balance values. Bump store version as this is an
incompatible change.
2019-11-15 22:05:09 +03:00
Roman Khimov
a16c2c3825
core: add NEP5 transfer tracking stub
...
See #498 .
2019-11-15 18:04:59 +03:00
Roman Khimov
01082a8988
core: fix nondeterministic txGetReferences() behavior
...
Ranging over map is nondeterministic and contracts may be unprepared for
that. Fixes #454 .
2019-11-15 18:04:59 +03:00
Roman Khimov
5e8122bfac
core: add contract hash into the error output for checkStorageContext()
...
Makes debugging things easier.
2019-11-15 18:04:59 +03:00
Roman Khimov
64e20508e0
vm: use hex for ByteArray JSON marshallization
...
It's way more convenient for different purposes.
2019-11-15 18:04:59 +03:00
Roman Khimov
5ce269c035
core: change notify implementation to save notifications
...
Fixes #453 and makes it possible to refer to these notifications later.
2019-11-15 18:04:59 +03:00
Evgenii Stratonikov
7080b78a6b
vm: fix a bug in collection serialize
...
When encountering already seen stack item we should fail
only if it is a collection. Duplicate Integers or ByteArrays are ok
because they can't lead to recursion.
2019-11-15 12:48:00 +03:00
Evgenii Stratonikov
1a08ad19aa
sc: implement io.Serializable for ParamType
2019-11-14 14:20:38 +03:00
Evgenii Stratonikov
2be18f91df
util: implement io.Serializable for Uint256
2019-11-14 14:20:38 +03:00
Evgenii Stratonikov
b16e56a47b
io: refactor BinReader.ReadArray()
...
Make it accept arbitrary slice pointer.
2019-11-14 14:19:58 +03:00
Evgenii Stratonikov
085ca7b770
network: implement Consensus payloads
2019-11-13 17:27:25 +03:00
Evgenii Stratonikov
ad9091d13d
io: implement generic array (de-)serialization
...
It is done through reflection and panics
in every unexpected situation.
2019-11-13 17:27:23 +03:00
Evgenii Stratonikov
61fdd5cde5
util: make Uint256Size public
2019-11-13 17:09:55 +03:00
Roman Khimov
394346fc26
core: add proper claim transactions processing
2019-11-11 15:35:57 +03:00
Roman Khimov
b05754deac
core: add Close() to blockchainer, implement it to properly close chain
...
Before it the deferred function in Run() was actually never able to properly
close the Store, so we weren't synching the latest state to the disk.
2019-11-08 12:19:54 +03:00
Evgenii Stratonikov
816d78b5ee
vm: redefine SHL/SHR limits based on integer size
2019-11-07 12:50:11 +03:00
Evgenii Stratonikov
439cd72294
vm: restrict BigInteger item size
2019-11-07 12:34:27 +03:00
Vsevolod
f686069f37
Merge pull request #481 from nspcc-dev/core-fix-init-corner-cases
...
Fix init corner cases
2019-11-06 18:36:40 +03:00
Vsevolod
11b372b45d
Merge pull request #480 from nspcc-dev/handshake-wait-for-version
...
network: wait for both Version messages before ACKing
2019-11-06 18:33:20 +03:00
Roman Khimov
c567307748
core: fix potential issue with header list init
...
If we're to receive some 500 headers (less than `headerBatchCount`) and quit
before receiving more of them we end up with clean `bc.headerList` that will
be inited going backwards to the `targetHash`, but code path doesn't add add
the `targetHash` itself which it should do in this particular case, otherwise
we end with no genesis block hash in the list.
2019-11-06 18:13:45 +03:00
Roman Khimov
d7f747fa9a
network: wait for both Version messages before ACKing
...
Otherwise the node might crash in `startProtocol` because of missing Version
field in the peer. And it also keeps the sequence correct, Version MUST be
sent first and ACKs can only follow it.
2019-11-06 18:05:50 +03:00
Roman Khimov
b5199625cd
core: init genesis block header if there are no other headers in DB
...
Fixes crash when restarted after the DB initialization and no blocks written
into the DB.
2019-11-06 17:58:19 +03:00
Roman Khimov
c16c2bf102
core: store current header reference on clean init
...
Missing it the following line could fail on subsequent restarts:
currHeaderHeight, currHeaderHash, err := storage.CurrentHeaderHeight(bc.store)
if the node was stopped before any headers had been received.
2019-11-06 17:56:06 +03:00
Roman Khimov
c062a8e288
Merge pull request #470 from nspcc-dev/config_updates_460
...
config: use logpath and address for server/rpc/monitoring, fix #460 .
2019-11-06 17:30:01 +03:00
Vsevolod Brekelov
d799c98cfe
io: move common function and add unit tests for it
2019-11-06 17:12:33 +03:00
Roman Khimov
aeef395c45
Merge pull request #476 from nspcc-dev/feature/neoUT
...
VM: Use JSON-based tests from neoVM
After the implementation of stack limits nothing is needed for us to pass reference JSON tests :)
The only thing that differs --- we do not compare stack in case of FAULT (which matches NEO 3 behavior).
Also two commits were reverted to match 2.x VM behavior.
2019-11-06 16:42:06 +03:00
Evgenii Stratonikov
6c002297cd
vm: implement json tests from neoVM
...
Add neo-vm submodule @master2.x .
Closes #196 .
2019-11-06 16:22:56 +03:00