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
Vsevolod Brekelov
7f1844a39e
transaction: add unmarshaling for TXType
2019-12-25 01:44:37 +03:00
Evgenii Stratonikov
f4571ba8cf
compiler: implement multiple return support
2019-12-24 16:46:43 +03:00
Evgenii Stratonikov
5bc32b523a
vm: implement Neo.Iterator.* interops
2019-12-24 10:21:47 +03:00
Evgenii Stratonikov
3ff7fd5262
vm: implement Neo.Enumerator.* interops
2019-12-24 10:21:46 +03:00
Roman Khimov
bf84e1f2fb
core: cache top block
...
Turns out, our dApps use it a lot and we were going to the DB to get it which
is a useless waste of time. Technically we could also remove blockHeight here,
but not doing it at the moment as it's more involved.
It eliminates this time waste from the pprof graph, but doesn't change 1.4M ->
1.5M 100K mainnet block import test case in any noticeable way.
2019-12-23 19:18:12 +03:00
Roman Khimov
cc16dac0b4
vm: optimize script loading a bit
...
Preseed the scriptHash value when we already know it. Eliminates this time
waste from the pprof graph, but doesn't really change anything in the 1.4M ->
1.5M 100K mainnet blocks import test.
2019-12-23 18:02:39 +03:00
Roman Khimov
094c8474b7
compiler: move tests from vm/tests
...
These don't belong to VM as they compile some Go code and run it in a VM. One
may call them integration tests, but I prefer to attribute them to
compiler. Moving these tests into pkg/compiler also allows to properly count
the compiler coverage they add:
-ok github.com/CityOfZion/neo-go/pkg/compiler (cached) coverage: 69.7% of statements
+ok github.com/CityOfZion/neo-go/pkg/compiler (cached) coverage: 84.2% of statements
This change also fixes `contant` typo and removes fake packages exposed to the
public by moving foo/bar/foobar into the testdata directory.
2019-12-23 17:05:34 +03:00
Roman Khimov
deb76c5199
core: add negative non-interop test for all interops
...
Try to feed some garbage into these functions.
2019-12-23 16:14:43 +03:00
Roman Khimov
76d69ee5ee
core: restore proper interops ordering
2019-12-23 16:14:43 +03:00
Roman Khimov
c287a9e93c
core: implement Neo.Witness.GetVerificationScript interop
2019-12-23 16:14:43 +03:00
Roman Khimov
9d638d0fee
core: implement Neo.InvocationTransaction.GetScript
2019-12-23 16:14:43 +03:00
Roman Khimov
33958be45f
Merge pull request #559 from nspcc-dev/feature/stack_limits
...
vm: don't refcount simple items
Improves 1.4M to 1.5M 100K mainnet block import test by ~4%.
2019-12-23 12:44:01 +03:00
Vsevolod Brekelov
d576aa2753
compiler: remove not used functions
2019-12-20 13:05:47 +03:00
Roman Khimov
79323cc10b
Merge pull request #567 from nspcc-dev/feature/codegen_add_mod
...
compiler: Add Mod token, closes #563
2019-12-19 15:32:18 +03:00
Vsevolod Brekelov
1458116567
vm: add tests
2019-12-19 15:23:14 +03:00
Vsevolod Brekelov
b68e9591aa
compiler: add test for codegen
2019-12-19 15:23:14 +03:00
Vsevolod Brekelov
3c7ac7eb95
compiler: add mod
2019-12-19 15:23:14 +03:00
Roman Khimov
26ea4799c3
Merge pull request #565 from nspcc-dev/hashed-interop-callback
...
vm/core: add ID support for SYSCALL, redo interop registration
2019-12-19 15:02:53 +03:00
Roman Khimov
5f3a220b48
Merge pull request #566 from nspcc-dev/feature/varindex
...
compiler: implement assignment to a variable index
2019-12-19 13:40:32 +03:00