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
Roman Khimov
a7457d08a1
vm/core: add ID support for SYSCALL, redo interop registration
...
This solves two problems:
* adds support for shortened SYSCALL form that uses IDs (similar to #434 , but
for NEO 2.0, supporting both forms), which is important for compatibility
with C# node and mainnet chain that uses it from some height
* reworks interop plugging to use callbacks rather than appending to the map,
these map mangling functions are clearly visible in the VM profiling
statistics and we want spawning a VM to be fast, so it makes sense
optimizing it. This change moves most of the work to the init() phase
making VM setup cheaper.
Caveats:
* InteropNameToID accepts `[]byte` because that's the thing we have in
SYSCALL processing and that's the most often usecase for it, it leads to
some conversions in other places but that's acceptable because those are
either tests or init()
* three getInterop functions are: `getDefaultVMInterop`, `getSystemInterop`
and `getNeoInterop`
Our 100K (1.4M->1.5M) block import time improves by ~4% with this change.
2019-12-19 13:35:42 +03:00
Evgenii Stratonikov
891a878af1
compiler: implement assignment to a variable index
...
Fixes #564 .
2019-12-19 13:14:17 +03:00
Evgenii Stratonikov
f957af35d4
vm: do not store items of scalar types in map
...
As they do not contain any other items,
they can be only accounted via total size.
2019-12-18 11:12:19 +03:00
Roman Khimov
1a26548be8
Merge pull request #561 from nspcc-dev/fix-duping-and-and-tests
...
Fix duping and add tests.
C# node actually implements DUP in the same way we did, but it does create a
new element when accessing some particular value (like BigInt() or Bytes()) so
in the end this DUP implementation doesn't lead to any visible side-effects. In
our case I think it's more appropriate to fix the DUP (and its variants) itself
avoiding useless allocations in the VM.
2019-12-18 11:07:41 +03:00
Roman Khimov
10766fe813
vm: add tests for hashing instructions
...
These were cross-checked with the C# implementation.
2019-12-17 20:31:16 +03:00
Roman Khimov
21efcb012b
vm: fix non-dupped items in PICKITEM
...
TestPICKITEMDupMap and TestPICKITEMDupArray were failing.
2019-12-17 20:26:30 +03:00
Roman Khimov
a6d60e387a
vm: fix OVER and PICK to duplicate stack items
...
TestPICKDup and TestOVERDup failed without this.
2019-12-17 20:26:30 +03:00