Commit graph

245 commits

Author SHA1 Message Date
Yeastplume
48a60858ba Wallet output selection performance (#238)
* allow selecting a commit while providing a key index
* added static reference to libsecp that can be called throughout
* don't serialise rangeproof to json if it's not desired
2017-11-07 11:48:37 -05:00
AntiochP
ad07866275 iterate once over txs in a block (#233)
Split out verify_sig and build_kernel to make kernel explicit.
2017-11-03 14:17:09 -04:00
Ignotus Peverell
dbaba8aed5
Order block elements when block is built 2017-11-01 22:18:51 -04:00
Ignotus Peverell
5b462ee2fc
Allowing for dumping of larger sum trees on error 2017-11-01 19:32:49 -04:00
Ignotus Peverell
f7ddd6b3d3
Fix couple minor import errors after rebase 2017-10-31 20:00:39 -04:00
Ignotus Peverell
e4ebb7c7cb
Cleanup HTTP APIs, update ports to avoid gap, rustfmt
Moved the HTTP APIs away from the REST endpoint abstraction and
to simpler Hyper handlers. Re-established all routes as v1.
Changed wallet receiver port to 13415 to avoid a gap in port
numbers.

Finally, rustfmt seems to have ignored specific files arguments,
running on everything.
2017-10-31 19:42:56 -04:00
Yeastplume
05d22cb632
changing secp import to tag, and consolidating Cargo.toml import (#220) 2017-10-31 23:20:55 +00:00
Yeastplume
914810713d Add test for switch commit consistency (#219) 2017-10-31 17:20:11 -04:00
Yeastplume
7f8d307cc8 Sum tree and improved chain API Endpoints (#214)
* adding more useful handlers
* added method to return last n leaf nodes inserted into the sum tree
* endpoints in place for getting last n sumtree nodes
2017-10-27 21:57:04 +00:00
AntiochP
7178b400b8 refresh multiple wallet outputs in single api call (#205)
* mount v2 router for flexibility - wallet checker now refreshes multiple outputs via single api call
* fix the api router
2017-10-25 17:57:48 +00:00
Ignotus Peverell
f679a9e458
Consensus change: set reward and base grin unit 2017-10-22 10:56:55 +00:00
Ignotus Peverell
f1488f9529
Lots of chain sync and block validation fixes
* Fix for the chain pipeline partly relying on an outdated head,
leading to not properly recognizing a fork and inconsistent sum
tree state.
* Do not drop block requests during sync that don't get satisfied,
retry enough time to get them and avoid stall.
* Always validate header, even in sync where we may have validated
it already. We don't want a block coming from a peer that could
squeeze through with an invalid header.
* When syncing, do not mark blocks that were errored by the chain
as received (typical case: orphan). Keep retrying.
* Improved chain state dump for debugging.
* Do not add to orphans blocks too far in the future.
* Better error reporting on db errors.
* Related sync test fixes.

TODO figure out why syncing peers timeout so often, very useful
to test but not that great for a fast sync experience.
2017-10-22 07:11:45 +00:00
Yeastplume
8f76746e84 Switch commitments (#179)
* Adding switch commit to grin outputs
* logging output fix
* adding switch commitment hash to sum tree node
* added hash_with to Hashed trait, to allow for hashing to include another writeable element
* adding hash_with as method in hashed trait
2017-10-16 21:23:10 +00:00
AntiochP
9a230ca7f6 fail deserialization if inputs or outputs are not sorted for txs (#173)
* fail deserialization if input or outputs are not sorted for txs, fail deserialization if inputs or outputs or kernels are not sorted for blocks, make sure we sort them before serialization
* extract consensus rule into verify_sort_order on VerifySortOrder trait
* rework the sort and write into WriteableSorted trait
* fix wallet sending bug (fees related) so we can test
* refactored read_and_verify_ordered out into ser, used in transaction and block
2017-10-13 17:23:18 +00:00
AntiochP
86420d4bca Shorter identifiers and call them key_id (not pubkey) (#175)
* rename pubkey -> key_id, these are key identifiers, not public keys
* reduce identifier seize to 10 bytes, get rid of fingerprints (identifiers are now small enough to use as-is)
* IDENTIFIER_SIZE const
* add FeeDispute error for when sender and recipient disagre on fee calculation (should never happen)
* does not need to be mut
* cleaned up some warnings
2017-10-13 04:45:07 +00:00
Ignotus Peverell
b85006ebe5 Wallet operation to burn some coins (#172)
* Burn transaction for testing
* Burn bug fixes, embed burn key in keychain
* Better error logging in API, wallet fee calc fix
2017-10-12 03:35:40 +00:00
AntiochP
bf7c1fb44f add lock_height to Transaction and TxKernel (#167)
* add lock_height to Transaction and TxKernel, sign msg including both fee and lock_height in kernel
* make the order of the fields in tx and kernel more consistent
* rename to kernel_sig_msg
* add test to cover adding timelocked tx to pool, where tx is invalid based on current height of the blockchain
* add tests for adding timelocked txs to blocks (valid and otherwise)
2017-10-11 18:12:01 +00:00
Ignotus Peverell
9310151680
Block versions and hard fork schedule 2017-10-10 00:09:06 +00:00
AntiochP
3dd1dde00b Pass pubkey for coinbase (#159)
* store wallet output data in hashmap
* cleanup up commented out code
* pass pubkey/identifier and not derivation around to miner etc.
* fix failing tests
2017-10-07 17:38:41 +00:00
Ignotus Peverell
c7f1ce965e
Block size limit as a max weight 2017-10-06 03:35:06 +00:00
Ignotus Peverell
7012d37f5f
Half of fees get rewarded, half burnt. Minor cleanups
Update coinbase building and block summation to account for half of
the fees going to the coinbase. Forcing fees to be even as a
consequence. Now that we can't build the coinbase independently
from the block (because fees), had to update the miner to keep the
key derivation so a new derivation isn't made any time a new block
gets worked on.

Minor doc and warning cleanups.
2017-10-05 07:30:10 +00:00
AntiochP
e060b1953e rust-secp256k1-zkp breaking changes to support (#155)
Rewinding range proofs to recover transaction value from outputs
2017-10-05 21:40:46 +00:00
Yeastplume
e68a6a69bb Cuckoo miner fixes and configurable coinbase maturity (#154)
* cuckoo miner update+coinbase maturity
* set mining parameter mode on immature coinbase test
2017-10-04 17:44:22 +00:00
Ignotus Peverell
4e49b85b82
Cleanup for block validation errors 2017-10-03 22:27:26 +00:00
AntiochP
677d0a3a95 keychain crate (no more secretkeys in core) (#146)
* introduce grin_keychain, encapsulate derivation of secret_keys
* core compiles against keychain, tests don't run yet
* core tests are now passing against keychain
* wip - getting wallet working with keychain
* add util and keychain to travis test matrix
* basic test around key derivation
2017-10-03 00:02:31 +00:00
Ignotus Peverell
6b4f2a63da
Store test for sumtree rewind 2017-10-02 22:32:45 +00:00
Ignotus Peverell
8504efb796
Cargo fmt all the things 2017-09-29 18:44:25 +00:00
Ignotus Peverell
0a57258d42
Fix #144 with platform specific import. Add store crate to CI 2017-09-29 18:09:44 +00:00
Ignotus Peverell
36bcd3cc39 Integrate sum trees with the rest of the system (#116)
* Integrate PMMR and its persistent backend with the Chain
* Chain can set tree roots; PMMR backend discard
* Check spent and prune for each input in new block
* Handling of forks by rewinding the state
* More PMMR tests and fixes, mostly around rewind
* Rewrite get_unspent to use the sumtrees, fix remaining compilation issues
2017-09-27 23:46:32 +00:00
AntiochP
0b26a57ca6 Remove rust-crypto dependency (#141)
Use blake2b in wallet for key derivation and key identifiers
2017-09-26 22:51:45 +00:00
AntiochP
670aa11e5a expose "wallet info" on CLI (#132)
* expose "wallet info" on CLI
* add sleep and retry logic when obtaining wallet.lock
* fix pool test for immature coinbase
2017-09-24 04:40:31 +00:00
AntiochP
dbc4e10cec Wallet now supports coinbase maturity (#130) 2017-09-22 16:44:12 +00:00
AntiochP
7c5b7d23e7 Replace secp256k1 directory with repository dependency (#126)
* workaround the "commitment is not a public key" problem by using to_two_keys() from rust-secp256k1-zkp
* remove secp256k1zkp, update the various Cargo.toml to use rust-secp256k1-zkp from external git repo, update code to not rely on to_pubkey (and use verify_from_commit)
* secp256k1zkp from git
* cleanup secp256k1 dependencies
* gitignore node1 and node2 dirs
2017-09-21 00:07:40 +00:00
AntiochP
95a92eefc9 Cannot spend coinbase for N blocks (#111)
* use head_header in add_to_memory_pool
* add COINBASE_MATURITY const to consensus
* add coinbase maturity (wip) validaton rule to validate_block
* add coinbase maturity check to validate_block
* map errors in adapters - specific errors still wip
* reworked so adapter translates chain errors to pool errors (core errors not required)
* add test for spending immature coinbase in memory pool
* wip - add test to cover spending coinbase output in chain.process_block
* added test coverage around process_block - we have a problem with coinbase output commitments
* add a comment on the failing test
* process_block will now fail validation if we attempt to spend coinbase that has not yet matured
(remember to use a new reward_key for every block). test coverage in place to verify this
2017-09-12 17:24:24 +00:00
osaka-kun
6493468959 Checking rangeproof explanatory comment (#120) 2017-09-12 17:20:26 +00:00
AntiochP
4aea4d0548 fixes to allow benchmarks to be run for core (#122)
cargo +nightly bench -p grin_core
2017-09-12 17:20:01 +00:00
AntiochP
87cd0e5c58 added basic tests around range_proof (#121)
Pass nonce in to range_proof (we need it for rewind_range_proof, at least for testing)
2017-09-10 18:31:41 +00:00
Ignotus Peverell
405a4bc985 Prunable MMR storage (#112)
* Base MMR storage structures

Implementations of the MMR append-only file structure and its
remove log. The append-only file is backed by a mmap for read
access. The remove log is stored in memory for quick checking
and backed by a simple file to persist it.
* Add PMMR backend buffer, make PMMR Backend mutable
* The Backend trait now has &mut self methods, and an &mut
reference in PMMR. This simplifies the implementation of all
backends by not forcing them to be interior mutable. Slight
drawback is that a backend can't be used directly as long as it's
used by a PMMR instance.
* Introduced a buffer in the PMMR persistent backend to allow
reads before the underlying files are fully flushed. Implemented
with a temporary VecBackend.
* Implement a prune list to use with dense backends
The PruneList is useful when implementing compact backends for a PMMR (for
example a single large byte array or a file). As nodes get pruned and
removed from the backend to free space, the backend will get more compact
but positions of a node within the PMMR will not match positions in the
backend storage anymore. The PruneList accounts for that mismatch and does
the position translation.
* PMMR store compaction
Implement actual pruning of the underlying PMMR storage by
flushing the remove log. This triggers a rewrite of the PMMR nodes
data (hashes and sums), removing pruned nodes. The information of
what has been removed is kept in a prune list and the remove log
is truncated.
* PMMR store pruning tests and fixes
2017-09-05 05:50:25 +00:00
AntiochP
7b12746a1f Store block header hash by input and output commitment (#104)
* initial pass at indexing block header hashes by commitments
* check block height matches currently indexed block height
when getting block header for an output commit
* add some test coverage
* document get_block_header_by_output_commit
2017-08-29 16:32:45 +00:00
Yeastplume
b5e62c81c0 Switch commitments in libsecp fork (#109)
* first pass at switch committment generator
* create sage generator script
2017-08-29 16:27:01 +00:00
Seamus Finnigan
9c649edfbf Use UTC in timestamps and fix broken header test (#105)
* Fix block header timestamp UTC and fix test
* Always use UTC for timestamp as time::Tm
2017-08-26 16:31:27 +00:00
AntiochP
babb6110c4 unit tests for coinbase flags (output and tx kernel) (#99)
* add tests around flipping COINBASE_OUTPUT and COINBASE_KERNEL flags
* add serialize_deserialize test for a minimal block
2017-08-22 18:26:13 +00:00
Yeastplume
045f5bb4da POW refactor (#100)
* Adding output stats from plugin, when available
* adding grin config
* moving pow crate from core/pow to it's own crate
* moving POW/mining stuff into pow module, and removing mining dependency from chain
* refactored most of mining into pow module...miner.rs still in server
* update grin tests
* updating genesis block mining to use configured miner, if available
* chain tests back into chain, done with pow refactor
* use tag of cuckoo-miner for pr
2017-08-22 18:23:54 +00:00
Riccardo Casatta
6772d9f516 various typos in docs (#95)
* various typos in docs
* fix a number in comments
2017-08-21 16:56:26 +00:00
Yeastplume
2a275a2f87 POW Blake 2 changeover (#91)
* playing around with changing cuckoo sizes on the fly
* modifying tests to use global cuckoo parameters, and checking results
* check for pow size
* Changing global function names, and removing length from POW serialization
* changes to use blake2 for cuckoo seed generation
* updating tests to blake 2
2017-08-11 21:05:59 +00:00
AntiochP
3b4a48b2fd Cleanup build warnings (#87)
* minor cleanup - unused imports
* cleanup build warnings - unused vars
* make structs pub to get rid of the private_in_public lint warning
* missing docs on RangeProof
* add missing docs to store delete function
* cleaned up deprecation warning -
tokio_core -> tokio_io
complete() -> send()
2017-08-10 00:54:10 +00:00
Yeastplume
131ea2f799 Ci mode fixes (#86)
* playing around with changing cuckoo sizes on the fly
* modifying tests to use global cuckoo parameters, and checking results
* check for pow size
* Changing global function names, and removing length from POW serialization
2017-08-09 16:40:23 +00:00
Ignotus Peverell
d32ab967f0
Prunable and easy to store MMR impl 2017-08-05 09:32:41 +00:00
Ignotus Peverell
ae9a9c8938
Merge branch 'master' of github.com:ignopeverell/grin 2017-08-04 19:52:04 +00:00
Ignotus Peverell
95fe570187
Prunable and easy to store MMR impl 2017-08-04 19:50:32 +00:00
Yeastplume
cdf4203dd1 Cuckoo miner integration, Queue implementation (#84)
* Adding ability to serialise parts of the header, pre-nonce and post-nonce
* Some test integration of queueing functions in cuckoo-miner
* more cuckoo-miner async mode integration, now more or less working
* integrating async miner workflow
* rocksdb update
* u64 internal difficulty representation, and integration of latest Cuckoo-miner API
* change to cuckoo-miner notify function
* Issue in testing, and if use_async value is None in grin.toml
* making async mode explicit in tests - 2
* fiddle with port numbers for CI
* update tag to ensure cuckoo-miner build doesn't fail on windows
* change the order in which tests are run
2017-08-03 16:57:55 +00:00
Ignotus Peverell
a6047903d2
Sum tree: n_children -> n_leaves (more explicit) 2017-07-24 21:46:22 +00:00
Ignotus Peverell
22f3d42b94
Simple sum tree benchmark 2017-07-23 01:19:10 +00:00
Ignotus Peverell
2261415c27
Oops. Fix blake2 dependency issues. 2017-07-20 15:03:47 +00:00
Ignotus Peverell
eb11b14cab
Minor warning cleanup in core
Remove some unused import and add missing docs.
2017-07-20 14:22:40 +00:00
Ignotus Peverell
929943d8b1
Sum-tree only stores hashes
Couple improvements to the sum tree implementation. First change
is to not store the data but only its hashes, assuming a higher
level layer will take care of the data (KV store).

Second minor improvement is renaming Node into NodeData and vice
versa.
2017-07-20 14:07:57 +00:00
Ignotus Peverell
01b66de437
Replace SHA3 with BLAKE2b everywhere 2017-07-20 13:52:33 +00:00
Ignotus Peverell
9703cba92a
Formatting 2017-07-20 13:52:33 +00:00
Yeastplume
42376e68bc Cuckoo-miner better merged into Grin (#80)
* Adding cuckoo-miner into grin as a proper dependency now
* Defaulting to using cuckoo-miner
* Updates to tests to use cuckoo_miner by default, (using cuckoo16)
2017-07-18 20:57:09 +00:00
Merope Riddle
e2ebd854e1 [WIP] Implement Merkle-sum-tree (#40)
* core: partially implement sumtree; appending and pruning work
* core: add simple merkle-root-sum-calculating function. 
* core: implement replacement in sumtree
* core: implement de/serialization for sumtree
* core: make sumtree index use hashes rather than data
* core: prevent double-adds to sumtrees
* core: replace sumtree's separate sums with a Summable trait
* core: make SumTree::contains() return the index if an element exists
2017-07-12 18:59:18 +00:00
Yeastplume
12480e7310 Changes to allow for testing and playing with cuckoo-miner integration (#76)
* Refactoring to allow for different miner implementations. Added conditional support for compiling and loading the cuckoo-miner plugin project.
* Small changes to experimentally integrate with cuckoo-miner and compatibility with latest version of cuckoo-miner.
* Turning off inclusion of cuckoo_miner by default
* Disabling simulate_parallel_mining test for now
2017-07-11 17:11:03 +00:00
Yeastplume
97b7421ce0 Mining test debug output, fixes to diff. adjustment and start of POW documentation (#69)
* Beginning to add a POW description, and some minor changes to mining testing, addition of further debug information to mining output.
* Many additions to create first draft of POW documentation
* Fixes to difficult adjustments by adding a MINIMUM_DIFFICULTY consensus value. Otherwise never adjusted above 1 due to flooring.
2017-06-29 16:49:11 +02:00
Ignotus Peverell
75f19ecfab
Fix difficulty tests, forgot to rename method 2017-06-20 10:21:31 -07:00
Ignotus Peverell
e8a6b61100
Apply new difficulty algo, remove configurable cuckoo size
Integrate the new difficulty calculation into the block chain
validation, the miner and tests. As the difficulty calculation
doesn't use varying Cuckoo sizes anymore and we narrowed down
reasonable final Cuckoo Cycle parameters, removed all Cuckoo
Cycle sizes from block headers.

Formalized easier Cuckoo Cycle sizes for testing (and possibly
testnet) by introducing a test mode in configuration. Updated
all tests.
2017-06-19 08:59:56 -07:00
Ignotus Peverell
163b1133a7
Implemented new difficulty calculation algorithm.
See #62 for background. Still needs to be integrated with proof
of work and validation.
2017-06-17 20:22:20 -07:00
Ignotus Peverell
eb9cc7ef13
Integrate transaction pool with rest of the system
* Transactions coming from the network are now pushed to the pool
through the net adapter.
* New blocks accepted by the chain are sent to the pool for
eviction.
* The miner requests transactions from the pool to build its
blocks.
* The push API adds to the pool, removing the mock.
* Implementation of the adapter to the chain required by the pool
to get consistent UTXOs. Grossly unoptimized until we have the UTXO
MMR ready.
2017-06-10 12:51:33 -07:00
Ignotus Peverell
11c0d67805
Revert "Delegate Block Encoding to Store (#44)"
This reverts commit 8ffc0c6f8e.
2017-05-31 15:49:15 -07:00
Ignotus Peverell
40d23db6c1
Revert "[WIP] Partial Transition from Writeable/Readable to Codecs (#51)"
This reverts commit de4ebdde71.
2017-05-31 15:47:52 -07:00
Ignotus Peverell
996eab72ae
Formatting. 2017-05-31 14:44:44 -07:00
Ignotus Peverell
f79fb8ef95
Sending end of the wallet
Most of the logic to build a transaction that sends coin to
another party. Still requires more debugging and clean up.
Main changes and additions are:

* Update to serde 1.0
* API endpoint to retrieve an Output
* Output is now Serialize and Deserialize
* Wallet configuration
* Command line for the send operation
* Wallet data checker to update created outputs into confirmed
* Wallet-specific configuration
2017-05-28 20:21:29 -07:00
Ignotus Peverell
1ae2e905d8
Printing difficulty while mining 2017-05-25 17:42:29 -07:00
Ignotus Peverell
791d2355ee
Miner querying wallet receiver for coinbase output
With the coinbase receiver daemon in place, when starting a Grin
server in mining mode, the miner will now ask the receiver for a
coinbase output. The output is then used to insert in a block when
successfully mined.
2017-05-25 17:22:21 -07:00
Ignotus Peverell
ac553493f1
WIP: Wallet functionality to receive and send coins
Beginning of a first pass at simple wallet functionalities so
Grin can be used to author transactions. We introduce a
receiving server, to be at least able to build coinbase outputs
that can be used by the mining daemon.

Present:

* Coinbase receiving API.
* Command to start the receiving server.
* Beginning of a transaction sending command.
* Improvements to the REST API abstractions to support the above.

Still to do:

* Change to the miner daemon to use the receiving server.
* A command line sender.
* API to receive any transaction (not just coinbase).
* A command line receiver.

Beyond that, HD derivation and seed generation are very simple
so far and almost certainly insecure. Just for testing for now.
2017-05-24 16:09:39 -07:00
Jacob Payne
de4ebdde71 [WIP] Partial Transition from Writeable/Readable to Codecs (#51)
* Sample Signatures for put_enc and get_dec
* Implement put_enc and get_dec
* Implement ChainCodec in grin_chain
* Truncate src only on complete Blocks
* Truncate src only on complete Tip + Check Len
* Move BlockHeader Encoding to BlockHeaderCodec
* Define put_enc for store::Batch
* Replace BlockCodec and BlockHeaderCodec with generic BlockCodec<T>
* Implement Default for BlockCodec Manually
* Replace get_ser/put_ser with get_enc/get_dec for chain::ChainKVStore
* Remove Writeable/Readable for chain::Tip
* Add Tokio-io and Bytes to grin_p2p
* Additional Setup for Message enum + Msg{Encode,Decode} traits
* base msg ping pong encoding and test
* fill out msg-codec tests
* Implement Hand Encoding/Decoding
* msg-encode shake
* msg-encode getpeeraddr
* codec peer-addrs message, SockAddr struct wierdness
* header message codec
* msg encoding finished prelim
* Implement PeerCodec Encoding/Decoding
* Set PeerStore to use PeerCodec for Encoding/Decoding
* Add a DecIterator
* Prune PeerStore
* Replace Decoding and Encoding in handle_payload
* Prune Writeable/Readable methods in store::Store
* Remove Incomplete Frame Testing ( Not Nessesary right now )
* separate block and tx codec tests
* Refactor {Tx,Block}Codec Tests
2017-05-22 19:16:13 +02:00
MoaningMyrtle
23fd07be60 WIP: Tracking Transaction Pool Implementation (#48)
* Beginning work on pool design doc
* Refining data structures; adding connect capability
* Fleshing out the connectivity paths for the tx pool
* Bringing tx pool and orphan set add logic up into parent TransactionPool
* Use output's commitment as identifier in graph structures
* Breaking a bunch of stuff to start migration to output commitment as id instead of hash
* Wrapping up updates to pool using commitment keys, dummy blockchain. Contains lots of cleanup on the internal flow.
* Beginning work on new block reconciliation
* WIP: Replacing monolithic pool cleanup with mark-and-sweep, which greatly simplifies the logic.
* Laying the groundwork for pool tests; test tx generator
* WIP: More elaborate test helpers; starting work on more elaborate block acceptance test.
* Need DummyUtxoSet to actually apply blocks now
* Using search_for_best_output to validate output status in test_basic_pool_add
* Enable modification of chain while under shared pool ownership. Cleanup pending
* WIP: Begining to untangle the TransactionPool impl from Pool and Orphans data structures
* Finishing refactoring of pool block reconciliaition; getting tests working again
* Add metrics for graph sizes; prereq to pool size throttling
* Remove redundant search_for_available_output from pool graph container
* Minimum viable block builder: return all fully rooted txs
* Tests for block building procedure
* Delegate duplicate output checking to check_duplicate_outputs
* Delegate orphan reference resolution to resolve_orphan_refs
2017-05-19 17:22:08 +02:00
Jacob Payne
8ffc0c6f8e Delegate Block Encoding to Store (#44)
Builds codecs to encode and decode blocks, block headers, transactions, kernels, etc. Will be used by the store and peer-to-peer layer for serialization, but also to compute hashes. Separates out serialization from core.
2017-05-03 10:27:38 -07:00
Ignotus Peverell
e4ca924b47
Various comment and dead wood cleanup 2017-04-20 11:31:02 -07:00
Ignotus Peverell
e71ae27f77
Invert inputs and outputs commitment sums. Fixes #37. 2017-04-10 00:27:19 -07:00
Merope Riddle
39ddeb0a2a core: various cleanups, improvements, code comments (#38)
* core: cleanup slicing impls for Hash
* core: clean up Readable trait, implement Readable/Writeable for various integers
* core: change Hash debug output to hex
* core: correct warnings in all modules
2017-04-09 23:17:23 -07:00
Jacob Payne
9e82fb1774 Replace AsFixedBytes with Sized + AsRef<[u8]> (#35)
* Replace AsFixedBytes with Sized + AsRef<[u8]>
* Add AsRef<u8> to impl_array_newtype!
* Include AsFixedBytes as marker trait
* Related fixes
* Remove Deref
2017-04-06 22:54:54 -07:00
Ignotus Peverell
382754e54c
Add workspace support for all crates 2017-04-05 23:41:49 -07:00
Ignotus Peverell
afb219ce5c
Hashed impl only needed for empty arrays. 2017-04-03 18:10:55 -07:00
Ignotus Peverell
38d5d67e79
Add features bitmask to Block, Output, Kernel; coinbase validation
Block, Output and Kernel now have bitmasks to hold supported
features and eventually versioning. Will make adding features and
updates easier and open the possibility of soft forks.

First added feature for Output and Kernel is the marking of coinbase
related ones. Allows the validation of the coinbase part of a block.
2017-03-23 17:06:00 -07:00
Ignotus Peverell
b6b815f6c1
Reintroduce block tests with new tx building
The build module introduced some facilities to build transactions
that can now be leveraged when building blocks and in related
tests.
2017-03-20 14:32:11 -07:00
Ignotus Peverell
6bd3fc0d48
Cleanup of Transaction and Block data structures
Some renaming and cleanup of the Input, Output, Transaction and
Block structs. The main change is the removal of all the overt
structures which are now replaced by a specialized module to
build transactions easily. More specifically:

* Rename the TxProof to TxKernel in Block to reflect the current
naming consensus in MimbleWimble.
* Change Input and Output to be plain structs instead of enums
making their manipulation a lot easier. The building of
transactions is now handled by the build module.
* Input now directly includes the commitment of the Output it's
spending instead of going through an intermediate hash.
* The new build module encapsulates all the transaction building
logic, making it very straightforward by chaining combinators.
* Moves some tests to the core mod.rs as they required being able
to build a transaction to test it.
2017-03-20 14:07:00 -07:00
Ignotus Peverell
cb84f588fb
Small tweaks and addition to a Transaction to make 2-parts building easier. Unit test covering the standard exchange between 2 parties when building a transaction. 2017-03-11 13:48:33 -08:00
Ignotus Peverell
f64d20749f
Framework to define services as RESTful HTTP API services. Serde implementations for some core types. 2017-03-07 17:00:34 -08:00
Ignotus Peverell
45b134ab30
PoW only ever needs the block header, full block unnecessary. 2017-02-07 13:48:11 -08:00
Ignotus Peverell
dde54beb3f
Hash needs to be writeable for network serialization. 2017-02-06 12:08:35 -08:00
Ignotus Peverell
4a034018cb
Block inputs and ouputs Merkle tree validation. 2017-01-25 11:44:37 -08:00
Ignotus Peverell
dda223f25b
Chain logic to support multiple forks, select the most worked fork as the head. Significantly simplified from the original direction as it doesn't seem that explicitly materializing forks is necessary. Simple total difficulty accounting in block headers helping a lot there. 2017-01-09 15:16:44 -08:00
Ignotus Peverell
85e3255ee4
Removed need for a PowHeader. Directly checking serialization mode in block header serialization instead. 2017-01-09 12:07:38 -08:00
Ignotus Peverell
ce23dda6cb
Block headers maintain total difficulty up to previous. Changed all references of target to difficulty to stay consistent. Ported retargeting algo to use difficulty as well. 2016-12-26 15:39:31 -08:00
Ignotus Peverell
c1340223de
Minor API change to PoW verify, to use the size provided by the block header by default. 2016-12-20 17:32:19 -08:00
GarrickOllivander
2e6d3d9fdb Safer serialization of base types (#18)
* use MESSAGE_SIZE constant instead of 32
* use Hashed trait in genesis
* safer serialization of Hash
* Hashed of [u8] should send only data to hash function, not length + data
* Safer serialization of Proof
* Safer serialization of Commitment
* Safer serialization of RangeProof
* introduce read_limited_vec instead of potential panic in conversion
2016-12-17 13:44:14 -08:00
Ignotus Peverell
d395b3d128
Added another server implementation for when the client needs to stay in control of the event loop (i.e. multiple servers for tests). Test to spin up 5 servers and connect them all together. 2016-12-14 16:10:39 -08:00
Ignotus Peverell
8a255c0218
Formatting. 2016-12-13 19:21:49 -08:00
Ignotus Peverell
4b5c010b05
Rewrote most of p2p code to use futures-rs instead of mioco. Need some cleanup and support for a few more message types. 2016-12-10 19:11:49 -08:00
Ignotus Peverell
eb56d40807
Removed limit on number of inputs or outputs in blocks and transactions. For DoS protection only a total message size needs to be enforced by the p2p layer. 2016-12-07 18:54:28 -08:00
Ignotus Peverell
4d7bc2269b
Fixed retargeting tests for truncation. 2016-11-30 11:15:49 -08:00
Ignotus Peverell
ea1820cff7
Fixed usages of block constructor. 2016-11-30 11:15:23 -08:00
Ignotus Peverell
55f5771a2a
Avoid unecessary move of the previous block header to build a block. 2016-11-29 20:05:35 -08:00
Ignotus Peverell
2e52b13c35
Date format uses year since 1900. 2016-11-29 20:04:13 -08:00
Ignotus Peverell
1ab9001338
Target needs to be truncated after next target calculation, given that serialization in the block header does it anyway. 2016-11-29 20:03:43 -08:00
Ignotus Peverell
11b8a6222a
Any size pow accesible to tests. 2016-11-29 18:46:28 -08:00
Ignotus Peverell
d11c85dae1
Fixed missing previous in block header. 2016-11-29 18:42:43 -08:00
Ignotus Peverell
9795d9e452
Miner facility, using the current chain state to build on top of. 2016-11-27 12:31:15 -08:00
Ignotus Peverell
ca26f0c3f7
Block header needs its own deserialization. Fixed pow verify to use the block target. 2016-11-16 14:08:46 -08:00
Ignotus Peverell
3c5e2b2958
Block now uses the new Target type. Consensus next_target calculation adjusting every block based on deviation and increasing Cuckoo size gradually. Block time of a minute until we learn more from mining ecosystem, so enough PoW attempts can be made even on CPUs. 2016-11-15 14:41:16 -08:00
Ignotus Peverell
44545525f4
Target addition and subtraction. A little more doc. 2016-11-15 14:41:16 -08:00
Roman Zeyde
151a0150b9 Fix a small typo in documentation 2016-11-14 21:21:18 +02:00
Ignotus Peverell
f7b31dc5f3
Bitcoin-style target implementation. Large 32 byte number that can be compared and serializes truncated. 2016-11-13 21:04:01 -08:00
Garrick Ollivander
956dd6b816
fix file headers: Developer -> Grin Developer 2016-11-13 12:47:09 +01:00
Ignotus Peverell
2b8faf8709
A few more consensus values. 2016-11-10 17:19:03 -08:00
Ignotus Peverell
d710301833
Missing consensus file. 2016-11-10 16:02:47 -08:00
Ignotus Peverell
baeae7d1a5
Merged master. 2016-11-10 15:54:47 -08:00
Ignotus Peverell
4ade3ec1b8
Moved consensus related constants to their own core module. 2016-11-09 15:51:24 -08:00
Ignotus Peverell
6e2a232ca3
Cleaned up total fees from block header. Unnecessary now. 2016-11-09 13:25:40 -08:00
Ignotus Peverell
4e9aad639e
Formatting fixes. 2016-11-09 11:10:02 -08:00
Ignotus Peverell
8317854b70
Slight changes to transaction signature. The transaction fee gets signed (instead of the empty string) and the fee amount is attached to the transaction proof in blocks. This allows fee accounting and the tracking of fees within a block. 2016-11-09 11:05:44 -08:00
Ignotus Peverell
ea425dc614
Protocol cleanup. Tests cleanup. Additional test for transaction broadcast. 2016-11-05 16:31:45 -07:00
Ignotus Peverell
edc6c62577
Fixed message serialization following changes in core. Sending of block and transaction. 2016-11-01 10:42:33 -07:00
Merope Riddle
33ccfe3b65 core: remove several unused imports 2016-11-01 13:19:38 +00:00
Merope Riddle
ca89dae7e1 core: unify Hashed and Writeable to simplify things and remove allocations 2016-11-01 13:19:28 +00:00
Merope Riddle
245f0a8b56 core/ser: add default implementations for most methods of Writer 2016-11-01 13:14:26 +00:00
Merope Riddle
630c4eb6fb core/ser: replace write_vec with write_bytes, drop a bunch of clones 2016-11-01 02:14:52 +00:00
Merope Riddle
bc38016385 core/ser: change serialization trait to use Result<(), Error> in place of Option<Error> 2016-11-01 02:14:52 +00:00
Ignotus Peverell
2efa8ce706 Merge pull request #7 from GarrickOllivander/fix_merkle_tree_malleability
Fix Merkle tree malleability.
2016-10-30 18:18:40 -07:00
Ignotus Peverell
42769c373c
Re-implemented the whole interaction between server, peer and protocol to be more Rust-ish. Server maintains peer references and protocol is internally mutable. 2016-10-29 12:36:45 -07:00
Garrick Ollivander
4e11aab1ea
added comment to avoid this vulnarability sneaking back 2016-10-29 18:18:32 +02:00
Garrick Ollivander
ab3ffafdcd
fix merkle tree malleability 2016-10-29 17:55:47 +02:00
Ignotus Peverell
b1762cb5f4
p2p module getting close to first integration test allowing 2 peers to connect. Fleshed out handshake and protocol use. Fixed most errors, just need to make the borrow checker happy. 2016-10-25 22:06:13 -07:00
Ignotus Peverell
4657b09c4e
WIP: more p2p code, mostly interaction between peer, protocol and server as well as ser/deser for first message types. 2016-10-24 21:35:10 -07:00
Ignotus Peverell
9f780f6865
Converse of deser macro to make serialization of structs less verbose. 2016-10-24 20:41:28 -07:00
Ignotus Peverell
b50e1ab038
Simple macro to remove some of the verbosity in deserialization. 2016-10-24 17:43:14 -07:00
Merope Riddle
4b51610d9a core: move remaining contents of core/ser.rs into ser.rs 2016-10-23 19:50:58 +00:00
Merope Riddle
82adc54971 core: separate Transaction into its own module 2016-10-23 19:49:35 +00:00
Merope Riddle
2ea58d4478 core: move Block and BlockHeader into their own module 2016-10-23 13:53:29 +00:00
Merope Riddle
88b07791fa core: move Hash into its own module 2016-10-23 13:23:04 +00:00
Merope Riddle
7e2b271865 add doccomments for consensus comments 2016-10-23 13:23:04 +00:00
Merope Riddle
9644fb6a73 Add apache 2.0 license header to all source files 2016-10-23 13:20:39 +00:00
Ignotus Peverell
e5e908adde Merge pull request #1 from kanzure/trivial-typo-fixes
Fix some trivial typos
2016-10-22 00:47:20 -04:00
Ignotus Peverell
d3e4ecc100
Corrected spelling of Cuckoo Cycle here and there and updated easiness to 50% following @tromp feedback. 2016-10-21 18:02:20 -04:00
Bryan Bishop
2fff216491
fix some trivial typos 2016-10-21 10:17:33 -05:00
Ignotus Peverell
f73a308bf3
Initial import. 2016-10-20 20:06:12 -04:00