Evgenii Stratonikov
2a86149c82
vm: leave single CHECKMULTISIG implementation
...
Remove sequential implementation and benchmarks.
They will be still present in commit history.
2020-02-05 17:17:22 +03:00
Roman Khimov
02a5e036fc
vm: deduplicate checkMultisigPar
...
Make its logic more clear.
2020-02-05 17:12:23 +03:00
Evgenii Stratonikov
d93d060010
vm: parallelize CHECKMULTISIG
2020-02-05 17:12:18 +03:00
Roman Khimov
f0bb886be3
mempool: make all methods pointer methods
...
Makes no sense copying the Pool around.
2020-02-04 17:36:11 +03:00
Roman Khimov
70c22ebc7b
Merge pull request #641 from nspcc-dev/consensus-update
...
Consensus update
2020-02-04 15:39:53 +03:00
Roman Khimov
9ceefe17e2
consensus: check current chain height before processing timer
...
The chain may already be more current than our dBFT state (like when the node
has commited something at view 0, but all the other nodes changed view and
accepted something at view 1), so in this case we should reinit dBFT on new
height.
2020-02-04 13:16:09 +03:00
Evgenii Stratonikov
e65b5c9914
consensus: fill preparation hash in recovery message
2020-02-04 13:16:05 +03:00
Evgenii Stratonikov
e441cb1414
consensus: add preparation hash to logger
2020-02-04 13:16:00 +03:00
Evgenii Stratonikov
42dfb52e98
consensus: add more logging in consensus service
2020-02-04 13:15:54 +03:00
Roman Khimov
553b2391a3
consensus: handle encoding errors in Hash()
2020-02-03 16:33:03 +03:00
Roman Khimov
388fed06e5
transaction: forbid serializing invalid transactions
...
Transaction that has no data is invalid and can't be serialized, so throw an
error if someone tries to.
2020-02-03 16:33:03 +03:00
Roman Khimov
9374c5e7c2
Merge pull request #639 from nspcc-dev/networking-improvements
...
Networking improvements
2020-02-03 16:26:04 +03:00
Evgenii Stratonikov
c3094123a1
compiler: do not store constants as variables
...
Because the constants are loaded directly via `emitLoadConst`, there is no need to store
them in an array of locals. It can have a big overhead, because it
is done at the beginning of every function.
2020-02-03 13:29:28 +03:00
Roman Khimov
e5d0125a3f
network: do async broadcast when processing P2P TX
...
It can lead to some goroutine explosion, but supposedly it's better than
stalling other processing and eventually all of these goroutines should finish
their sends. Note that this doesn't change the behavior for RPC-relayed
transactions that are still waiting for the broadcast to finish ensuring
proper transaction distribution before returning the result to the client.
2020-01-30 14:03:52 +03:00
Roman Khimov
0fcbc697ca
network: only tell consensus service about new valid transactions
...
Transactions can be bad and can duplicate each other, consensus service
shouldn't be bothered with that.
2020-01-30 14:03:52 +03:00
Roman Khimov
fdbaac7a30
network: prevent broadcast queue starving, share time with p2p
...
Blocked broadcast queue of one peer may affect broadcasting capabilities of
the server, so prevent total blocking of it by p2p queue.
2020-01-30 14:03:52 +03:00
Roman Khimov
b2c4587dad
network: fix PeerAddr() for not-yet-handshaked case
...
If we have already got Version message, we don't need the rest of handshake to
complete before being able to properly answer the PeerAddr() requests. Fixes
some duplicate connections between machines.
2020-01-30 14:03:52 +03:00
Roman Khimov
49bd7aada5
network: log peerCount on connection registration
...
Symmetrical to disconnects, make it easier to look through the logs.
2020-01-30 14:03:52 +03:00
Roman Khimov
32695b4f40
network: don't unregister connected peers
...
If we drop connection because we're already connected don't unregister this
connected address because it's connected anyway!
2020-01-30 14:03:52 +03:00
Roman Khimov
eb4ec61b8b
network: register connected addr in handleVersionCmd()
...
Prevent useless attempts to connect to this peer if the peer has already made
a connection to us.
2020-01-30 14:03:52 +03:00
Roman Khimov
9eafec0d1d
network: introduce peer-to-peer message queue
...
This one is designed to give more priority to direct nodes communication, that
is that their messaging would have more priority than generic broadcasts. It
should improve consensus process under TX pressure and allow to handle
pings in time (preventing disconnects).
2020-01-30 14:03:52 +03:00
Roman Khimov
72e4eb7172
network: fix wrong NewPing() parameters
...
They have the opposite order, height first and nonce second. It was done wrong
in 4e6ed902
and never fixed since. Fixes sending wrong peer state leading to
useless getheaders messages (and disconnects when the other side is lagging
behind).
2020-01-30 14:03:52 +03:00
Roman Khimov
da09fda575
network: add debug on message receival
2020-01-30 14:03:52 +03:00
Roman Khimov
1c28dd2567
network: add message type to disconnect error message
...
If it was caused by message processing, but only after the handshake to
preserve errIdenticalID and other handshaking errors.
2020-01-30 14:03:52 +03:00
Roman Khimov
b79abd1e27
network: detect duplicate connections before handshake completes
...
We can have more than one connection attempt in progress and not yet completed
the handshake, so if there is a Version already received we should look it.
2020-01-30 14:03:52 +03:00
Roman Khimov
b1b660c779
rpc: fix getaccountstate/getunspents for unknown addresses
...
Returning error string as a result (not an error) is utterly wrong, but C#
implementation just returns a zero balance for unknown addresses, so we should
follow that.
2020-01-29 19:01:00 +03:00
Roman Khimov
0ccc59628c
Merge pull request #631 from nspcc-dev/fix/return3
...
compiler: fix a bug with assignment to underscore
2020-01-29 18:32:43 +03:00
Evgenii Stratonikov
390bf58f97
consensus: use our implementations of Recovery* messages
...
While decoding payload, local implementations of Recovery*
messages were used, but when creating RecoveryMessage inside dBFT
library default NewRecoveryMessage was invoked. This lead to parsing
errors.
2020-01-29 17:56:26 +03:00
Evgenii Stratonikov
8b922c057c
compiler: fix a bug with assignment to underscore
...
When using underscore it does not appear in the list
of local variables, so it can't be assigned.
In this commit the value is dropped.
2020-01-29 17:07:55 +03:00
Evgenii Stratonikov
7053b3b2c0
compiler: optimize append argument processing
...
Append should leave it's result on top of the stack.
Thus we need to transform top of the stack:
(top) a . b --> (top) a . b . b
It can be done with just OVER + SWAP.
2020-01-29 12:28:38 +03:00
Evgenii Stratonikov
b6629fb6bd
compiler: refactor argument handling for builtins
...
It is more convenient to have all unusual logic in one place.
2020-01-29 12:28:38 +03:00
Evgenii Stratonikov
d2326a8b96
compiler: support panic
in source
...
In situations where VM's FAULT state needs to be reached,
panic function can be used. It compiles to THROW instruction.
2020-01-29 12:28:38 +03:00
Evgenii Stratonikov
e0f47decc7
compiler: replace ROLL(2) with equivalent ROT
2020-01-29 09:56:16 +03:00
Evgenii Stratonikov
28571bd3dc
compiler: implement switch statement support
2020-01-29 09:56:16 +03:00
Roman Khimov
0ce0ecb95e
Merge pull request #624 from nspcc-dev/feature/bigint
...
compiler: emit integers correctly
2020-01-28 18:04:32 +03:00
Roman Khimov
ab03aee2cf
Merge pull request #627 from nspcc-dev/fix-getdata-and-pings
...
Fix getdata and pings
2020-01-28 17:43:13 +03:00
Roman Khimov
06c3fbe455
network: rework ping sends, fix overpinging
...
Our node was too pingy because of wrong timer setups (that divided timeout
Duration by time.Second), it also was wrong in its time calculations (using
UTC time to calculate intervals). At the same time missing block is a
server-wide problem, so it's better solved with server-wide protocol loop.
2020-01-28 17:39:52 +03:00
Roman Khimov
39800aecb3
network: fix getdata
handling
...
It was broken by 0ba6b2a7
, the peer only responded with one message instead of
full requested set.
2020-01-28 17:39:52 +03:00
Evgenii Stratonikov
d190b3a2e0
compiler: emit integers correctly
...
A while ago VM serialization format for Integer items was changed
but compiler continued to emit Integers in old format.
This commit changes compiler behaviour to be compatible with VM.
2020-01-28 16:39:19 +03:00
Evgenii Stratonikov
f15ceff592
vm: make IntToBytes, BytesToInt public
...
VM serialization format should be able to be reused.
2020-01-28 16:39:19 +03:00
Evgenii Stratonikov
77f9a2ee26
compiler: convert AppCall parameter from string properly
2020-01-27 15:34:03 +03:00
Evgenii Stratonikov
d65d6ab08d
compiler: allow to convert string constants to []byte
...
Also load constant directly into stack, not by name.
2020-01-27 15:29:52 +03:00
Evgenii Stratonikov
097d35b9d5
compiler: fix a bug with FromAddress handling
...
Conversion of string to address with FromAddress is performed
at compile time so there is no need to push parameters on stack.
2020-01-27 13:14:40 +03:00
Evgenii Stratonikov
330db36168
compiler: implement engine.AppCall interop
2020-01-27 13:14:36 +03:00
Evgenii Stratonikov
4fd766fe09
compiler: allow usage of string literals in index expressions
2020-01-23 17:28:35 +03:00
Evgenii Stratonikov
058958729d
compiler: support map literals
2020-01-23 17:06:15 +03:00
Evgenii Stratonikov
def73db8e9
compiler: support variables in slice literals
2020-01-23 15:51:16 +03:00
Evgeniy Kulikov
eb59460032
Merge pull request #614 from nspcc-dev/configurable-mempool-size
...
config: add MemPoolSize configuration parameter
2020-01-23 13:25:27 +03:00
Roman Khimov
67fe99b0ba
Merge pull request #618 from nspcc-dev/feature/for
...
compiler: support for loops with no init/post condition
2020-01-23 13:19:55 +03:00
Roman Khimov
04db87c770
Merge pull request #617 from nspcc-dev/feature/checksig
...
compiler: implement ECDSA signature verification
2020-01-23 13:18:21 +03:00
Roman Khimov
9aa5d0cf1e
Merge pull request #615 from nspcc-dev/network-peer-updates
...
Network peer updates
2020-01-23 13:15:43 +03:00
Roman Khimov
d6784e8f45
config: add MemPoolSize configuration parameter
...
Allow tuning/experimenting with mempool.
2020-01-23 13:10:44 +03:00
Evgenii Stratonikov
328267ca6f
compiler: support for loops with no init/post condition
...
Make it possible to use `for` loop with a single condition.
2020-01-23 11:48:43 +03:00
Evgenii Stratonikov
bd37359393
compiler: implement ECDSA signature verification
...
Add VerifySignature interop for signature verification.
It is converted to VERIFY opcode.
2020-01-23 10:56:15 +03:00
Evgenii Stratonikov
303b82cc44
core: set free GAS limit via config
2020-01-22 14:32:21 +03:00
Evgenii Stratonikov
54e0b5a4a7
rpc: set MaxGasInvoke in config
...
Implement ability to restrict maximum amount of GAS
available for free RPC calls.
2020-01-22 14:31:57 +03:00
Evgenii Stratonikov
4718375db1
rpc: return amount of consumed GAS in invoke*
2020-01-22 14:31:57 +03:00
Evgenii Stratonikov
2f865480d3
util: add YAML marshaler to Fixed8
2020-01-22 14:31:57 +03:00
Evgenii Stratonikov
7a6d6f43ce
vm: get rid of recursive (*VM).execute calls
...
Recursive execute() calls can affect gas calculation.
This commit makes execute() be called only for real opcodes
and moves duplicate logic for CALL/JMP into a separate function.
2020-01-22 14:31:57 +03:00
Evgenii Stratonikov
4eae55143f
core: restrict GAS available for invocation transactions
...
There are 10 GAS available for free plus any amount of GAS
attached to a transaction.
2020-01-22 14:31:54 +03:00
Evgenii Stratonikov
d72d978a19
vm: abstract out GetInterop() function
2020-01-22 14:04:40 +03:00
Evgenii Stratonikov
c22d09adad
vm: set GAS limit
...
Make it possible to set maximum amount of GAS which can be spent
during execution.
2020-01-22 14:04:40 +03:00
Evgenii Stratonikov
0662a7e3c2
vm: calculate GAS spent during execution
...
If getPrice callback is provided, accumulate spent GAS.
2020-01-22 14:04:40 +03:00
Roman Khimov
99dfdc19e7
network: drop now useless addrReq queue from the server
...
Just broadcast a high-priority message to everyone.
2020-01-22 11:28:59 +03:00
Roman Khimov
ea3b76ded1
network: make NewServer return an error, fix #612
...
It can return nil in two cases, so we're better return an error and handle
it.
2020-01-22 11:17:51 +03:00
Roman Khimov
f2ffffddb7
network: rework broadcasting functions, tune priorities
...
This gives more priority to anything related to consensus.
2020-01-22 11:01:13 +03:00
Roman Khimov
34b863d645
network: introduce Server's MkMsg()
...
That wraps NewMessage() for a configured network.
2020-01-21 17:31:51 +03:00
Roman Khimov
1f672e0da7
network: move SendVersion() to the Peer
...
Only leave server-specific `getVersionMsg()` in the Server, all the other
logic is peer-related.
2020-01-21 17:26:08 +03:00
Roman Khimov
9befd8de99
Merge pull request #610 from nspcc-dev/ping-improvements
...
Ping improvements
2020-01-21 13:34:15 +03:00
Roman Khimov
760b39e324
consensus: close chain in tests
...
Avoid test failures like this one:
=== RUN TestService_OnPayload
==================
WARNING: DATA RACE
Read at 0x00c00015a843 by goroutine 112:
testing.(*common).logDepth()
/usr/local/go/src/testing/testing.go:665 +0xa1
testing.(*common).Logf()
/usr/local/go/src/testing/testing.go:658 +0x8f
testing.(*T).Logf()
<autogenerated>:1 +0x75
go.uber.org/zap/zaptest.testingWriter.Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zaptest/logger.go:130 +0x11f
go.uber.org/zap/zaptest.(*testingWriter).Write()
<autogenerated>:1 +0xa9
go.uber.org/zap/zapcore.(*ioCore).Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/core.go:90 +0x1c3
go.uber.org/zap/zapcore.(*CheckedEntry).Write()
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/entry.go:215 +0x1e7
go.uber.org/zap.(*Logger).Info()
/go/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:187 +0x95
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).persist()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:720 +0x6bb
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run.func2()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:228 +0x53
Previous write at 0x00c00015a843 by goroutine 98:
testing.tRunner.func1()
/usr/local/go/src/testing/testing.go:900 +0x353
testing.tRunner()
/usr/local/go/src/testing/testing.go:913 +0x1bb
Goroutine 112 (running) created at:
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:227 +0x264
Goroutine 98 (finished) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:960 +0x651
testing.runTests.func1()
/usr/local/go/src/testing/testing.go:1202 +0xa6
testing.tRunner()
/usr/local/go/src/testing/testing.go:909 +0x199
testing.runTests()
/usr/local/go/src/testing/testing.go:1200 +0x521
testing.(*M).Run()
/usr/local/go/src/testing/testing.go:1117 +0x2ff
main.main()
_testmain.go:162 +0x337
==================
--- FAIL: TestService_OnPayload (4.11s)
2020-01-20 19:40:52 +03:00
Roman Khimov
f56383e9c8
network: use p.LastBlockIndex() in requestBlocks()
...
Always compare to the best known block index, comparing to the StartHeight is
just plain wrong now.
2020-01-20 19:37:17 +03:00
Roman Khimov
2c4ace022e
network/config: redesign ping timeout handling a bit
...
1) Make timeout a timeout, don't do magic ping counts.
2) Drop additional timer from the main peer's protocol loop, create it
dynamically and make it disconnect the peer.
3) Don't expose the ping counter to the outside, handle more logic inside the
Peer.
Relates to #430 .
2020-01-20 19:37:17 +03:00
Roman Khimov
62092c703d
network: use local timestamp to decide when to ping
...
We don't and we won't have synchronized clocks in the network so the only
timestamp that we can compare our local time with is the one made
ourselves. What this ping mechanism is used for is to recover from missing the
block broadcast, thus it's appropriate for it to trigger after X seconds of
the local time since the last block received.
Relates to #430 .
2020-01-20 19:37:17 +03:00
Roman Khimov
a8252ecc05
network: remove wrong ping condition
...
In reality it will never be true exactly in the case where we want this ping
mechanism to work --- when the node failed to get a block from the net. It
won't get the header either and thus its block height will be equal to header
height. The only moment when this condition is met is when the node does
initial synchronization and this synchronization works just fine without any
pings.
Relates to #430 .
2020-01-20 19:37:17 +03:00
Roman Khimov
247cfa4165
network: either request blocks or ping a peer, but not both
...
It makes to sense to do both actions, pings are made for a different purpose.
Relates to #430 .
2020-01-20 19:37:17 +03:00
Roman Khimov
0ba6b2a754
network: introduce peer sending queues
...
Two queues for high-priority and ordinary messages. Fixes #590 . These queues
are deliberately made small to avoid buffer bloat problem, there is gonna be
another queueing layer above them to compensate for that. The queues are
designed to be synchronous in enqueueing, async capabilities are to be added
layer above later.
2020-01-20 17:23:26 +03:00
Roman Khimov
7f0882767c
network: remove useless Done() method from the peer
...
It's internal state of the peer that no one should care about.
2020-01-20 17:23:26 +03:00
Roman Khimov
f39d5d5a10
network: fix unregistration on peer Disconnect
...
It should always signal to the server, not duplicating this send and not
missing it like it happened in the Server.run().
2020-01-20 17:23:26 +03:00
Roman Khimov
907a236285
network: move per-peer goroutines into the TCPPeer
...
As they're directly tied to it.
2020-01-20 17:23:26 +03:00
Roman Khimov
32213b1454
Merge pull request #601 from nspcc-dev/refactoring/core
...
core: refactor out Block, BlockBase and Header, closes #597 .
2020-01-20 16:19:20 +03:00
Roman Khimov
f4aa088d04
Merge pull request #603 from nspcc-dev/feature/wallet
...
consensus: use wallets instead of WIF, closes #588 .
2020-01-20 16:16:10 +03:00
Roman Khimov
bb80ba9b9e
Merge pull request #456 from nspcc-dev/pingpong_430
...
add ping pong processing
2020-01-20 16:10:29 +03:00
Evgenii Stratonikov
f0083b94c5
vm: use new big.Int (de-)serialization routines
...
Also fix a test with CAT.
2020-01-17 17:37:50 +03:00
Evgenii Stratonikov
f26bdae2c5
vm: implement proper big.Int to []byte conversions
...
Big.Int Bytes()/SetBytes() methods are not symmetric.
Moreover we need to mimic C# node behavior:
- if a positive number has MSB set, 0x00 byte should be appended
to distinguish positive number from negatives
- negative numbers should serialize as two's-complement
2020-01-17 17:37:50 +03:00
Evgenii Stratonikov
55d98ab19a
consensus: update keys from wallet after every block
2020-01-17 17:30:45 +03:00
Evgenii Stratonikov
aaefcdecae
consensus: use wallet in service
2020-01-17 17:25:51 +03:00
Evgenii Stratonikov
36cfa5b1f4
wallet: add GetAccount() method to Wallet
...
It is useful to be able to get account specified by script hash.
2020-01-17 17:25:51 +03:00
Evgenii Stratonikov
a798e4e0fa
wallet: add ScriptHash() method to Contract
2020-01-17 17:25:51 +03:00
Evgenii Stratonikov
a871f75063
wallet: use a script instead a hash
...
NEO wallets (e.g. used in privnet setup) use hex-encoded
script inside the wallet, not a script hash.
2020-01-17 17:25:51 +03:00
Roman Khimov
46b82b4fb5
keys: don't return error from PrivateKey.Sign
...
As it can't ever happen.
2020-01-17 17:00:30 +03:00
Vsevolod Brekelov
4e6ed9021c
network: add ping pong processing
...
add pingInterval same as used in ref C# implementation with the same logic
add pingTimeout which is used to check whether pong received. If not -- drop the peer.
add pingLimit which is hardcoded to 4 in TCPPeer. It's limit for unsuccessful ping/pong calls (where pong wasn't received in pingTimeout interval)
2020-01-17 13:24:14 +03:00
Roman Khimov
e2fff3bb1d
keys: update to newer rfc6979 package
...
Fixes #592 .
2020-01-16 18:21:10 +03:00
Evgenii Stratonikov
28183b81d6
mempool: simplify names of exported types
...
With the move to a separate package, naming can be simplified:
MemPool -> Pool, PoolItem -> Item, PoolItems -> Items.
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
fed6fba9b6
core: refactor out MemPool
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
79bceb3e40
block: use require in tests
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
489b88afbb
block: rename BlockBase to Base
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
63c56cca5c
core: refactor out Block, BlockBase and Header structs
...
See #597 .
2020-01-16 10:16:24 +03:00
Roman Khimov
7d4d57351e
network: fix requestTx() behaviour for consensus service
...
It wasn't actually requesting transactions but rather sending an inventory
message telling everyone that we have them which is completely wrong and
easily leads to ChangeView that could be avoided.
2020-01-15 14:31:56 +03:00
Roman Khimov
0420d48e56
network: micro-optimize relayInventory
...
Do less allocations, we're sending the same message with the same payload.
2020-01-15 13:16:09 +03:00
Roman Khimov
9eb880a095
Merge pull request #568 from nspcc-dev/feature/compiler_clean_and_tests
...
compiler: clean and tests
2020-01-14 18:44:07 +03:00
Vsevolod Brekelov
7084925e4b
compiler: add test for compile and save
2020-01-14 17:33:04 +03:00
Evgenii Stratonikov
3d704a3a3a
consensus: try to use previous proposal after ChangeView
...
When system and network pressure is high it can be beneficial
to use transactions which and were already proposed.
The assumption is that they will be in other node's memory pool
with more probability.
2020-01-14 16:05:27 +03:00
Roman Khimov
7ba5267494
Merge pull request #596 from nspcc-dev/feature/single_node
...
network: allow single-node privnet setup. Closes #595 .
2020-01-14 13:17:04 +03:00
Evgenii Stratonikov
70b23076f8
network: allow single-node privnet setup
2020-01-13 18:01:20 +03:00
Evgenii Stratonikov
5f5d0097e2
network: use TimePerBlock from config
2020-01-13 17:58:12 +03:00
Roman Khimov
2192b6602a
network: fix logic and logging for sendVersion() errors
...
It doesn't make sense trying to read from a broken connection and the
disconnect is to be logger from the server on unregistration.
2020-01-13 17:33:29 +03:00
Roman Khimov
b5f234ddef
rpc: make rpc request logging at Debug level
...
Makes no sense polluting logs with Info. It also affects benchmarking.
2020-01-13 17:33:29 +03:00
Evgenii Stratonikov
f3921ea3bd
network: fix NPE in logging
2020-01-13 15:06:57 +03:00
Roman Khimov
565c1940e3
Merge pull request #587 from nspcc-dev/feature/zap
...
Closes #284 .
2020-01-10 14:50:09 +03:00
Evgenii Stratonikov
9dc5571327
core,rpc: close Blockchain in tests
...
If blockchain is not closed, logging in defer can occur
after test has finished, which will lead to a panic with
"Log in goroutine after Test* has completed".
2020-01-10 11:47:56 +03:00
Evgenii Stratonikov
dc65684708
consensus: replace SugaredLogger with Logger
...
SugaredLogger was used to make output look more similar to logrus.
This is no longer needed.
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
9b8b77c9ea
network: return error if header message is too big
...
Big messages can still be processed but only first
2000 headers will be used.
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
637c99eda7
core: simplify newInteropContext
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
45a4524054
rpc: remove EnableCORSWorkaround from Request
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
289cb1c1d9
rpc: use zap.Logger
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
aecdf470e7
cli,pkg: use zap.Logger
2020-01-10 11:14:27 +03:00
Roman Khimov
e96b4bc82e
wallet: fix TestNewAccount
...
It duplicated TestNewFromWif.
2020-01-09 18:40:30 +03:00
Roman Khimov
9bb68d7025
wallet: make DecryptAccount a method of Account
...
Otherwise it almost duplicates keys.NEP2Decrypt().
2020-01-09 18:40:30 +03:00
Roman Khimov
951ee383e9
keys: improve NEP2 testing
2020-01-09 18:06:03 +03:00
Roman Khimov
b5b05a969c
keys: make NEP2Decrypt return a PrivateKey rather than WIF
...
There is no point in encoding the output of this function in a WIF format,
most of the users actually want the real key and those who need a WIF can
easily get if from the key (and it's simpler than getting the key from the
WIF).
It also fixes a severe bug in NEP2Decrypt, base58 decoding errors were not
processed correctly.
2020-01-09 18:05:14 +03:00
Evgenii Stratonikov
9c79684516
storage: panic on error in boltdb.Seek
...
Error in Seek means something is terribly wrong (e.g. db was not opened) and
error drop is not the right thing to do, because caller
will continue working with the wrong view.
2020-01-09 15:17:35 +03:00
Evgenii Stratonikov
8d1f564411
consensus: add tests for getTx
2019-12-27 14:12:58 +03:00
Evgenii Stratonikov
d803dffca8
consensus: return nil interface from getTx
2019-12-27 13:54:11 +03:00
Roman Khimov
c306d2f07c
Merge pull request #581 from nspcc-dev/feat/storage_find
...
core: implement Neo.Storage.Find interop, closes #422 .
2019-12-26 15:46:46 +03:00
Evgenii Stratonikov
48cf4f4a84
core: implement Neo.Storage.Find interop
2019-12-26 15:21:41 +03:00
Evgenii Stratonikov
7b5c47e7f5
vm: add NewMapIterator()
2019-12-26 14:34:15 +03:00
Roman Khimov
f8887b63ba
Merge pull request #578 from nspcc-dev/fix/sign
...
consensus: verify payloads correctly, closes #555 .
2019-12-26 13:07:40 +03:00
Evgenii Stratonikov
64d24d8ddd
consensus: verify payloads correctly
2019-12-26 10:49:56 +03:00
Evgenii Stratonikov
714c466c2c
core: add ScriptFromWitness function
...
Extracting verification script from witness became a common task.
This commit adds such a possibility.
2019-12-26 10:49:56 +03:00
Roman Khimov
234d94d27e
network: implement getblocks command
...
Fixes #577 , tested with C# nodes connecting to neo-go privnet.
2019-12-25 19:46:57 +03:00
Roman Khimov
9145855d2c
Merge pull request #579 from nspcc-dev/refactor-crypto
...
This moves some functionality into micro-packages, improves testing,
unexports some code and fixes bugs along the way.
2019-12-25 18:12:50 +03:00
Roman Khimov
604b2c8240
keys: add a successful test for 04-encoded public key
2019-12-25 18:06:25 +03:00
Roman Khimov
fa0537758f
keys: add a test for X/Y > P decoding case
2019-12-25 18:01:54 +03:00
Roman Khimov
6c471ecd98
keys: move IsOnCurve decoding check, add a test for it
...
This check only makes sense for 04-encoded points, because 02 and 03 derive Y
from X and they're on the curve by definition.
2019-12-25 18:00:25 +03:00
Roman Khimov
5ac8cae221
keys: fix bad compressed public key decoding, add a test
...
The error was not propagated properly here.
2019-12-25 17:44:30 +03:00
Roman Khimov
b246653f62
address: rename functions as per #579 comments
...
Make them more clear to understand.
2019-12-25 17:34:18 +03:00
Roman Khimov
53e6fbbbf9
base58: add a test for a025b9c42d
...
As noted by @fyrchik in #579 comments.
2019-12-25 17:33:48 +03:00
Roman Khimov
e25133a385
keys: reuse address package for address generation
...
Deduplicates code and makes prefix overridable.
2019-12-25 16:03:39 +03:00
Roman Khimov
b7702f3a2e
address: improve testing, make it 100% covered
2019-12-25 15:55:39 +03:00
Roman Khimov
c5ceb9128a
address: check for prefix when decoding
2019-12-25 15:50:52 +03:00
Roman Khimov
89b6cbf795
address: make Prefix overridable
...
As it should be, it's specified in the configuration file (and it should be
treated as byte in the config)
2019-12-25 15:42:18 +03:00
Roman Khimov
e685e9bf9a
address: move into its own package
...
Doesn't really belong to the crypto.
2019-12-25 15:22:02 +03:00
Roman Khimov
a025b9c42d
base58: remove bogus code from CheckDecode
...
No other implementation does that and it looks weird, I see nothing meaninful
here.
2019-12-25 15:07:11 +03:00
Roman Khimov
369ac01a27
base58: move into its own package
...
It doesn't belong to crypto in any way other than it uses hash function
internally.
2019-12-25 15:05:54 +03:00
Roman Khimov
5dd8d29534
hash: improve merkle tree testing
...
Make it 100% covered.
2019-12-25 14:43:50 +03:00
Roman Khimov
ddad9ac9a3
hash: simplify merkle tree error handling
...
buildMerkleTree() is internal to the hash package and if anyone calls it with
`len(leaves) == 0` he deserves a panic. As it's the only error case in it, we
can remove error value return from this function and simplify NewMerkleTree().
2019-12-25 14:38:48 +03:00
Roman Khimov
ee28fb08f6
crypto: move merkle tree into the hash package
...
It's all about hashes, so it makes sense putting it there.
2019-12-25 11:28:59 +03:00
Roman Khimov
db5555bb15
crypto: internalize aes functions into the keys package
...
This is the only user of it and no one outside should care about these
details.
2019-12-25 11:25:05 +03:00
Roman Khimov
9cc0fca9d2
Merge pull request #574 from nspcc-dev/feature/multireturn
...
compiler: implement multiple return support, closes #562 .
2019-12-25 08:46:38 +03:00
Vsevolod Brekelov
606616618f
rpc: add ability to answer as C# with block as []byte
2019-12-25 01:44:37 +03:00