Commit graph

529 commits

Author SHA1 Message Date
dauTT
955bb373fc Implemented SHL, SHR opcode (#250) 2019-03-28 22:28:20 +00:00
decentralisedkev
cb21c66316
Syncmgr: Implement synchronisation manager (#249)
* [syncmgr]

- Add blockmode, normal mode, headermode
- Add config file
- Add test files
- removed RequestBlocks and RequestHeaders from peers, as we will use
the peermanager for this
- OnHeaders and OnBlock in syncmgr, now return errors
- refactored all tests to use a convenience method to return a syncmgr
and testHelper
2019-03-28 21:22:17 +00:00
dauTT
84b4b41288 Implemented DIV, MOD opcode (#237) 2019-03-28 20:32:32 +00:00
decentralisedkev
493d8f3d95
[chain] Refactor, add chaincfg and database initialisation (#243)
* [chain]

- Add basic chain cfg parameters

- Added logic to insert genesis block, if it is a fresh database

- changed SaveBlock to ProcessBlock
- changed SaveHeaders to ProcessHeaders

- Changed parameter from a wire message to the payload, for header and
block processing

- Added check in chain for when the block is in the future, i.e. not at
the tip of the chain

- Added custom error returns, to distinguish between a database error
and a validation error
2019-03-28 20:23:50 +00:00
dauTT
139b770712 Implemented NZ, MUL opcode (#235) 2019-03-28 19:47:47 +00:00
decentralisedkev
8afec1ea45
[Peer] Add peer manager (#241)
* [PeerMgr]

- Add basic peer manager
2019-03-28 19:46:31 +00:00
dauTT
afe670f178 VM: Implement, ABS, NOT opcode (#233)
* Implemented, ABS, NOT opcode
2019-03-28 19:26:55 +00:00
decentralisedkev
dc5de1fa6d
[Peer] Refactor (#240)
[Peer]

- Closes #239

- moved response handlers to their own functions

- removed DefaultConfig from LocalConfig file

- passed peer as a parameter to all response handlers

- added peer start height

- refactored NewPeer function to be more concise and clear

- removed empty lines at end of functions

- Added AddMessage/RemoveMessage for Detector in outgoing and ingoing
requests for Block and Headers
2019-03-28 19:09:55 +00:00
dauTT
14e0ab48dd VM: Implemented SIGN, NEGATE opcode (#232)
* Implemented SIGN, NEGATE opcode
2019-03-28 18:30:36 +00:00
dauTT
d8e399f67d VM: Implement INC, DEC opcode (#231)
[VM]

- Implemented INC, DEC opcode
2019-03-26 23:15:13 +00:00
dauTT
24cd21bd8c VM:Implement THROW opcode (#219)
[VM]

- Changed vmstate from HALT to FAULT in Sub opcode
- Implemented THROW opcode + tests
- Renamed TestSimpleRun test to TestThrowIfNot
2019-03-26 21:19:41 +00:00
dauTT
ce1fe72607 Finalized size calculation methodology (#215)
- Simplified Transactioner interface
-  Added size calculation test
- Added utility methods in the address pkg: FromUint160, Uint160Decode
2019-03-25 01:04:54 +00:00
dauTT
beab4d186f Fixed Txn Attribute econding/decoding (issue: #216) (#217) 2019-03-24 23:11:54 +00:00
decentralisedkev
7d84d44b08
[chain] (#209)
- Add basic skeleton for chain struct
2019-03-23 19:09:25 +00:00
decentralisedkev
30e5aa8f48
Add Chain saving functionality to Database (#206)
* [database]

- Add Prefix method to interface
- Convert leveldb error to `database error`
- Be explicit with prefixedKey in `Table` as slices can be pointers

* [protocol]
- Add stringer method to protocol

* [Chaindb]

- Added saveBlock() which will allow us to save a block into the
database. The block is broken up into transactions and Headers. The
headers are saved as is. The transactions are saved as is, then the
utxos in the transactions are collected to make the utxo db.

- Verification for blocks and transactions will reside in the same
package. Note that the save methods are all unexported, while the Get
methods are exported. Making it so that any can call a get method, but
only code in this package may save to the database. The other code which
will reside in this package will be code verification logic.

* [chaindb]

- Added saveHeader function which saveHeaders  uses

- Update the latest header, each time we save a header instead of after a batch. This is so that we can call saveHeader without saveHeaders. This functionality can be rolled back if the performance of updating the header after a batch is significant

- small refactor in test code
2019-03-23 16:57:05 +00:00
dauTT
6f496754fb 1) Fixed String method in Uint256 (#208)
2) Added ReverseString Method to Uint256
2019-03-23 16:52:36 +00:00
decentralisedkev
e12255dd73
[connmgr] Refactor Connmgr (#205)
* [connmgr]

- Refactor Connmgr
- Remove un-needed async code
- Add comment for Request
2019-03-21 23:18:02 +00:00
decentralisedkev
9a1ef38689
[Database] (#202)
Remove unnecesary methods
2019-03-21 21:28:03 +00:00
dauTT
095653af23 Implement rpc server method: sendrawtransaction (#174)
* Added new config attributes: 'SecondsPerBlock','LowPriorityThreshold'

* Added new files:

* Added new method: CompareTo

* Fixed empty Slice case

* Added new methods: LessThan, GreaterThan, Equal, CompareTo

* Added new method: InputIntersection

* Added MaxTransactionSize, GroupOutputByAssetID

* Added ned method: ScriptHash

* Added new method: IsDoubleSpend

* Refactor blockchainer, Added Feer interface, Verify and GetMemPool method

* 1) Added MemPool
2) Added new methods to satisfy the blockchainer interface: IsLowPriority, Verify, GetMemPool

* Added new methods: RelayTxn, RelayDirectly

* Fixed tests

* Implemented RPC server method sendrawtransaction

* Refactor getrawtransaction, sendrawtransaction in separate methods

* Moved 'secondsPerBlock' to config file

* Implemented Kim suggestions:
1) Fixed data race issues
2) refactor Verify method
3) Get rid of unused InputIntersection  method due to refactoring Verify method
4) Fixed bug in https://github.com/CityOfZion/neo-go/pull/174#discussion_r264108135
5) minor simplications of the code

* Fixed minor issues related to

1) space
2) getter methods do not need pointer on the receiver
3) error message
4) refactoring  CompareTo method in uint256.go

* Fixed small issues

* Use sync.RWMutex instead of sync.Mutex

* Refined (R)Lock/(R)Unlock

* return error instead of bool in Verify methods
2019-03-20 12:30:05 +00:00
BlockChainDev
bab5d370bb Interop 2019-03-18 21:58:51 +00:00
decentralisedkev
c1b6738bdb
VM: Add basic vm (#166)
* VM:Add abstract stack item

* VM: Add stackItems; Array, Boolean, Int and ByteArray

* VM: Add tests for stack item

* VM: first pass at Random Access Stack object

* VM: Add Sub, Mul, Mod LSH, RSH

* VM: moved test helper functions into separate file

* VM: removed helper functions from stack_test.go

* Add conversions for bytearray and Int stack items

* Add instructions file for vm

* - Add guide to stack readme
- Add testReadInt64

* Add Builder

* Refactor Int, Boolean, ByteArray conversion

* Add Context stack Item

* Add Invocation stack - convenience RAS

* rename testhelper to test_helper

* Move opcode file

* - Add `Add` OpCode
- Add Opcode Function map

* - Add test for math `Add` opcode
- basic opcode execution

* Add popTwoIntegers convenience func

* Add `SUB` Opcode

* Export Context Read methods
- Return errors where failable

* - Add `Op` to handleOP func signature
- Add PushNBytes OPcode

* remove error on NewBoolean
- Expose underlying with Getter on Boolean StackItem
- Add Equals method for ByteArray

* Make Next() method on Context failable, refactor peekContext and Peek

* Add ExecuteOp, Step and Run methods on the VM

* Add Equal Opcode

* Add THROWIFNOT Opcode

* Add RET Opcode

* Refactor PushNBytes Opcode

* refactor Add, Sub to return VMSTATE
add popTwoByteArrays helper function

* Add basic tests for vm

* clarify vm states

* Add astack

* [VM]

Pass ResultStack to the opcode handlers

* [VM]

refactor handlers to have rstack as argument

* [Stack]

- Change RemoveCurrentContext for PopCurrentContext
- Add CopTo method to stack

* [VM]

Add Result stack Len check in simple run test

* [VM] fix typo

* [Peer/Stall]

Change seconds to milliseconds in test
2019-03-18 21:40:21 +00:00
BlockChainDev
9951f04099 [Stall]
Change seconds to milliseconds in test
2019-03-18 21:33:07 +00:00
BlockChainDev
a2bdc076d2 [VM] fix typo 2019-03-18 21:17:43 +00:00
BlockChainDev
8809be183e [VM]
Add Result stack len check in simple run test
2019-03-18 21:15:40 +00:00
BlockChainDev
da27c2b3f0 [Stack]
- Change RemoveCurrentContext for PopCurrentContext
- Add CopTo method to stack
2019-03-18 21:15:09 +00:00
BlockChainDev
c177e5577e [VM]
refactor handlers to have rstack as argument
2019-03-18 21:14:03 +00:00
BlockChainDev
38ad4572c4 [VM]
Pass ResultStack to the opcode handlers
2019-03-18 21:13:08 +00:00
BlockChainDev
de3137197a remove extra base58 2019-03-17 23:02:34 +00:00
BlockChainDev
351f0acdfe Add astack 2019-03-17 22:57:36 +00:00
BlockChainDev
9e16bac7d8 clarify vm states 2019-03-17 20:21:48 +00:00
BlockChainDev
231aa29e5a Fix test 2019-03-17 18:38:52 +00:00
BlockChainDev
98096f6c20 golint 2019-03-17 18:31:58 +00:00
BlockChainDev
5e26b40b5e Merge branch 'dev' into vm 2019-03-17 18:30:48 +00:00
BlockChainDev
a7db1ceaa5 minor comment 2019-03-17 18:30:12 +00:00
decentralisedkev
f8979fe7af
Fix lint errors (#182)
* golint and minor changes to make code readable
2019-03-17 18:26:35 +00:00
BlockChainDev
ef364900bb Add basic tests for vm 2019-03-16 22:15:08 +00:00
BlockChainDev
17c53d1081 refactor Add, Sub to return VMSTATE
add popTwoByteArrays helper function
2019-03-16 22:09:34 +00:00
BlockChainDev
c7e32e7eb3 Refactor PushNBytes Opcode 2019-03-16 22:09:23 +00:00
BlockChainDev
7b519eba0d Add RET Opcode 2019-03-16 22:09:04 +00:00
BlockChainDev
79e92d5e14 Add THROWIFNOT Opcode 2019-03-16 22:08:35 +00:00
BlockChainDev
31511e55d0 Add Equal Opcode 2019-03-16 22:06:32 +00:00
BlockChainDev
329f8f388c Add ExecuteOp, Step and Run methods on the VM 2019-03-16 22:05:00 +00:00
BlockChainDev
a7e973030c Remove context_test
rename invocation to invocationstack
export vmstate
2019-03-16 21:52:05 +00:00
BlockChainDev
9eb11d2822 Make Next() method on Context failable
refactor peekContext and Peek
2019-03-16 21:45:48 +00:00
BlockChainDev
48413900ca remove error on NewBoolean
Expose underlying with Getter on Boolean StackItem
Add Equals method for ByteArray
2019-03-16 21:44:03 +00:00
BlockChainDev
80fd427517 - Add Op to handleOP func signature
- Add PushNBytes OPcode
2019-03-15 23:37:54 +00:00
BlockChainDev
9a59755745 Export Context Read methods
- Return errors where failable
2019-03-15 23:21:30 +00:00
BlockChainDev
280d526f41 Add SUB Opcode 2019-03-15 22:55:08 +00:00
BlockChainDev
abc3b46f1c Add popTwoIntegers convenience func 2019-03-15 22:54:52 +00:00
BlockChainDev
baf9d2b768 - Add test for math Add opcode
- basic opcode execution
2019-03-15 22:42:35 +00:00