Commit graph

123 commits

Author SHA1 Message Date
Roman Khimov
9a30f2fbcc connmgr: correctly pass binding error to the server
And make the node fail gracefully if it's unable to bind. Before this commit:
-----
Server is starting up
Connection manager started
Error connecting to outbound  listen tcp 127.0.0.1:20332: bind: address already in use
We have connected successfully to:  127.0.0.1:20334
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x6bbfa2]

goroutine 12 [running]:
github.com/CityOfZion/neo-go/pkg/connmgr.New.func1.1(0x0, 0x0)
        /home/rik/dev/neo-go/pkg/connmgr/connmgr.go:47 +0x22
panic(0x718980, 0xa22f70)
        /usr/lib64/go/1.12/src/runtime/panic.go:522 +0x1b5
github.com/CityOfZion/neo-go/pkg/connmgr.New.func1(0xc000013430, 0xc000013450, 0xc000013440, 0xc0005265f0, 0xf, 0x0)
        /home/rik/dev/neo-go/pkg/connmgr/connmgr.go:52 +0x15e
created by github.com/CityOfZion/neo-go/pkg/connmgr.New
        /home/rik/dev/neo-go/pkg/connmgr/connmgr.go:38 +0xfe
exit status 2
-----

After this commit:
-----
listen tcp 127.0.0.1:20332: bind: address already in use
-----
2019-08-19 15:31:22 +03:00
Roman Khimov
2ddf1d15ab
Merge branch 'dev' into vm 2019-08-12 19:12:19 +03:00
Roman Khimov
f068f4c0ed pkg/vm/stack: drop unused (*RandomAccess).items()
GolangCI complains:
  U1000: func (*RandomAccess).items is unused

And it looks like everyone and their dog just use ras.vals without any
wrappers when there is a need to access it, so drop the wrapper.
2019-08-12 18:19:26 +03:00
Roman Khimov
bc87d3e8e6 pkg/vm: fix GolangCI's SA4009 in RET()
SA4009: argument ctx is overwritten before first use (from staticcheck)

It should be OK here.
2019-08-12 18:15:48 +03:00
Roman Khimov
9be53e5961 pkg/vm/stack: fix SA4006 GolangCI warning in TestStackPushPop()
SA4006: this value of stackElement is never used (from staticcheck)
2019-08-12 18:13:04 +03:00
Roman Khimov
f445103260 pkg/vm/stack: fix S1002 gosimple warnings in map.go
S1002: should omit comparison to bool constant, can be simplified to ok.Value() (from gosimple)
2019-08-12 18:08:39 +03:00
Roman Khimov
4e40467dc3 pkg/vm/stack: fix S1008 gosimple warning from GolangCI
S1008: should use 'return ' instead of 'if { return }; return ' (from gosimple)
2019-08-12 18:05:04 +03:00
Roman Khimov
bab187f4a8 pkg/vm: drop bogus err check in BoolAnd() and BoolOr()
GolangCI:
  nilness: impossible condition: nil != nil (from govet)
2019-08-12 18:00:54 +03:00
Roman Khimov
613bad36e0 pkg/vm/stack: fix unused binary.Read() result in testReadInt64()
GolangCI:
  Error return value of binary.Read is not checked (from errcheck)
2019-08-12 17:56:51 +03:00
Roman Khimov
d6c3f74e3c pkg/vm/stack: make some use of testReadInt64()
GolangCI complains:
  testReadInt64 is unused (from deadcode)

Fix it to always provide correctly-sized buffer for the binary.Read().
2019-08-12 17:53:19 +03:00
Roman Khimov
6be27ad4b0 pkg/vm/stack: s,testPeakInteger,testPeakInteger,
Fix obvious typo.
2019-08-12 17:16:47 +03:00
Roman Khimov
1fb66d6b73 pkg/vm/stack: improve Array testing code slightly
GolangCI complained:
  testArray is unused (from deadcode)

But this function was actually wrong being a copy-paste of testMakeStackMap(),
it also didn't conform to testMake... naming scheme, so this fixes it. To make
thing more uniform NewArray() was also changed to return error, map_test.go
code adjusted to this changes and finally array_test.go was added as a stub
for future Array testing.
2019-08-12 17:12:05 +03:00
Roman Khimov
3bc195659a pkg/vm: fix error handling in XDROP()
Found by GolangCI:
  Error return value of ctx.Estack.Remove is not checked (from errcheck)
  nilness: impossible condition: nil != nil (from govet)
2019-08-12 16:40:19 +03:00
Roman Khimov
06f9e1d123 pkg/(crypto|vm): fix GolangCI errcheck warnings
Like:
  Error return value of alg.Write is not checked (from errcheck)

Actually even though the hash.Hash implements an io.Writer interface (that
return meaningful things on .Write()) it has this comment in its
documentation:

// Write (via the embedded io.Writer interface) adds more data to the running hash.
// It never returns an error.

so it should be OK to ignore return results here.
2019-08-12 16:36:06 +03:00
Roman Khimov
a976c4d04f pkg/vm: go fmt
Some errors were introduced by github merges.
2019-08-12 16:29:42 +03:00
Roman Khimov
0258fa48f8 pkg/vm: fix all GolangCI warnings about v.executeOp errcheck
Fixes lots of warnings like this in the test code:
  Error return value of v.executeOp is not checked (from errcheck)
2019-08-12 16:25:16 +03:00
Roman Khimov
18d32a33a2
Merge branch 'vm' into dauTT/vm-ROLL-ROT-SWAP-TUCK-opcode 2019-08-12 15:37:58 +03:00
Roman Khimov
e9f4a0739f
Merge branch 'vm' into dauTT/vm-DUP-NIP-OVER-PICK-opcode 2019-08-12 13:35:08 +03:00
Roman Khimov
5167c37255
Merge branch 'vm' into dauTT/vm-XSWAP-XTUCK-DEPTH-DROP-opcode 2019-08-12 13:02:24 +03:00
Roman Khimov
c0a0749d80
Merge branch 'vm' into dauTT/vm-DUPFROMALTSTACK-TOALTSTACK-FROMALTSTACK-XDROP-opcode 2019-08-12 12:47:24 +03:00
Roman Khimov
3a7cfe26ac
Merge branch 'vm' into dauTT/vm-NOP-JMP-JMPIF-JMPIFNOT-opcodes 2019-08-12 12:42:21 +03:00
Roman Khimov
b46439d8d4
Merge branch 'vm' into dauTT/vm-crypto-opcode-194 2019-08-12 12:36:23 +03:00
Roman Khimov
03939bb8ba
Merge branch 'vm' into dauTT/vm-bitwise-opcodes-191 2019-08-12 12:21:52 +03:00
Roman Khimov
eeecbf96bf
Merge branch 'vm' into dauTT/vm-implement-Map-Struct-167 2019-08-12 12:11:29 +03:00
Roman Khimov
e52f78165e
Merge pull request #261 from dauTT/dauTT/vm-implement-MIN-MAX-WITHIN-opcodes-230
Implemented MIN, MAX WITHIN opcode
2019-08-12 12:06:24 +03:00
Roman Khimov
e99d916b04
Merge pull request #286 from nspcc-dev/interop-test-dummy
neo-vm test reusage sample, merging as per #283 discussion.
2019-08-12 12:05:36 +03:00
Roman Khimov
03629a31c7
Merge pull request #264 from nspcc-dev/blockPool
syncmgr : Add blockpool to syncmgr
2019-08-12 12:02:09 +03:00
dauTT
b9b118d3ea Add ReverseString, ToReverseScriptHash method (#281)
* Added
1) ReverseString method to the Uint160 type
2) ToReverseScriptHash method to convert a base58 address to a reverse script hash

* Simplified ToScriptHash method
2019-08-05 09:34:31 +02:00
DauTT
458e6f922b Clean up comments 2019-04-12 22:34:28 +02:00
DauTT
d36d8b456c Implemented following opcodes:
1) ROLL
2) ROT
3) SWAP
4) TUCK
2019-04-12 22:27:52 +02:00
DauTT
d43dcf03cb Implemented following opcodes:
1) DUP
2) NIP
3) OVER
4) PICK
2019-04-12 20:25:20 +02:00
DauTT
aa67e98726 Implemented following opcodes:
1) XSWAP
2) XTUCK
3) DEPTH
4) DROP
2019-04-12 00:38:57 +02:00
DauTT
7e20b604b4 Implemented following opcodes:
1) DUPFROMALTSTACK
2) TOALTSTACK
3) FROMALTSTACK
4) XDROP
2019-04-11 00:07:17 +02:00
DauTT
4dc11ee48f Implemented following control flow opcodes:
1) NOP
2) JMP
3) JMPIF
4) JMPIFNOT
2019-04-09 01:07:15 +02:00
DauTT
51f8351723 Used consistently assert.Nil for checking absence of error 2019-04-05 21:13:23 +02:00
DauTT
3c8448ed40 Simplied code by using help method PopByteArray 2019-04-05 20:34:02 +02:00
DauTT
2897c3cbc1 Implemented crypto opcodes:
1) SHA1
2) SHA256
3) HASH160
4) HASH256
2019-04-04 22:46:06 +02:00
DauTT
de1c4e01a1 Implemented bitwise opcodes:
1) AND
2) XOR
3) OR
4) INVERT
2019-04-04 00:34:21 +02:00
dauTT
6d2fb5d89f
Merge branch 'vm' into dauTT/vm-implement-MIN-MAX-WITHIN-opcodes-230 2019-04-03 20:36:54 +02:00
dauTT
045db09af2 Implemented LTE, GTE opcode (#260)
* Implemented LTE, GTE opcode
2019-04-02 23:43:52 +01:00
DauTT
c6cd0e0c21 Implemented Map Stack Item:
1) Added new file map.go, map_test.go
2) Added Map, Hash Method to Item interface
3) Implemented Hash Method for every stack items (Boolean, Array, Int, ...)
2019-04-02 22:38:41 +02:00
BlockChainDev
12149c9379 [server]
- remove extra call after adding a peer
- switched endian for headers endian switch
2019-03-31 00:24:10 +00:00
BlockChainDev
336fc02ad5 [syncmgr]
- Fix bug; accounts for a fresh database startup and we only have the genesis block
2019-03-30 22:42:07 +00:00
BlockChainDev
06e71d9b7e [syncmgr]
- update comment
2019-03-30 21:44:24 +00:00
BlockChainDev
68b0e2e3f2 [server]
- modified server to pass the syncmgr the lastBlock.Index+1 so that
syncmgr knows what blockIndex it should be looking for upon
initialisation
2019-03-30 21:39:39 +00:00
BlockChainDev
751d2711d4 [syncmgr]
- refactored OnBlockBlockMode to use blockPool
- syncmgr now checks for future blocks, instead of looking for a
FutureBlockErr from the Chain. This makes it so that syncmgr does not
depend on the Chain package.
- removed GetBestBlockHash function from config(unused)
- refactored all tests in the syncmgr package
2019-03-30 21:36:50 +00:00
BlockChainDev
c401247af9 [syncmgr]
- refactor syncmgr for blockpool
- add nextBlockIndex so that we can add blocks to the blockPool by
comparing their index
- add processBlock helper method,wraps around cfg.ProcessBlock and increments the nextBlockIndex
internally
2019-03-30 21:34:27 +00:00
BlockChainDev
5ed61ff389 [syncmgr]
- add blockpool plus test
2019-03-30 21:32:44 +00:00
decentralisedkev
abb4da9cbd
[PeerMgr] Add Caching and Re-processing system (#263)
[peermgr]

- Add request cache with tests
- Add requestCache to peermgr
- refactored peer manager tests
- Added blockInfo struct, to allow sorting on the blockIndex
- added helper methods for cache, pickItem, pickFirstItem, removeHash,
findHash and refactored tests
- renamed requestcache to blockcache
- refactored peer manager to use block cache for block requests *only*
- added blockCallPeer function to handle block requests only
- refactored onDisconnect to add back any pending peer requests that the
disconnected peer did not complete into the peer manager queue

[peermgr/server]

- Modify onBlock handler in server, to send peermgr a BlockInfo struct

[peermgr/syncmgr/server]

- Modified blockIndex in BlockInfo to be uint32 and not uint64
- RequestBlocks in syncmgr now takes an index along with the hash
- modified syncmgr code to pass index along with hash in all methods
2019-03-30 18:10:27 +00:00
dauTT
7bf4d691a9 Implemented NUMEQUAL, NUMNOTEQUAL opcode (#256) 2019-03-30 15:01:06 +00:00