Commit graph

625 commits

Author SHA1 Message Date
Yeastplume
c63aa70a0b
Integrated bulletproofs into Grin with optional build parameter (enabled by default) (#711) 2018-02-16 20:34:54 +00:00
Antioch Peverell
5572fa075e
tx pool lookup for kernel short ids (compact block hydration) (#710)
* wip - basic tx pool lookup for kernel short ids (compact block hydration)

* use the nonce in the compact_block to correctly generate short_ids for lookup

* query the tx pool based on kernel short_ids

* tests passing

* cleanup some logging

* cleanup logging
2018-02-16 10:42:27 -05:00
Ignotus Peverell
b82fa0ea1d
Block deletion, to be used for pruning 2018-02-14 23:25:12 +00:00
Antioch Peverell
8bdf0be73e
compact block needs a random nonce in it (used to generate short_ids) (#709) 2018-02-14 09:19:24 -05:00
Antioch Peverell
6fb139670e archive_mode is optional in grin.toml (#707)
default to None in grin.toml (which defaults to false)
add example config in grin.toml
2018-02-13 18:08:21 +00:00
Antioch Peverell
ebd801f14e
Transaction contain kernels. Transactions and blocks maintain a kernel offset (split key). (#681)
* WIP - split the key in final tx step
store "offset" on transaction itself

* rebase

* commit

* tx with offset

* got a test tx validating successfully using a sig from a split key and the appropriate offset

* sum up the offset for the block_header

* fix size tests for blocks and compact blocks (header now includes offset)

* use txs with offsets in most of the core tests
some tests now failing

* build kernel from k1G (k2 stored on tx, sum stored on header)

* commit

* tx now has vec of kernels
rework tx and kernel validation

* add test for tx cut_through

* wip - working on splitting in aggsig

* split the key when creating the initial sender aggsig context

* cleanup

* cleanup

* code needs claning up but split keys working for sender/receiver aggsig flow

* cleanup debug logging

* fix tests

* fix merge and basic cleanup

* fix keychain tests to use new tx_id
2018-02-13 10:35:30 -05:00
Ignotus Peverell
76796738c1
Clean server shutdown, generalizes usage of Weak (#700)
* Clean server shutdown, generalizes usage of `Weak`. Introduces 2 main changes:

  * A shared `AtomicBool` that signals server shutdown. All server
threads regularly check it to break out of their main loops when
it changes to `true`.
  * Breaking of circular `Arc` references, which can never be
destroyed, by downgrading to `Weak` instead. Only the main server
keeps the `Arc` while all other components get the `Weak` variant.

Both of these are required for all long-living structs to be
cleanly destroyed. Note that in Rust this is fairly important as
most resource-freeing logic is associated with `drop`,
which is only called when said struct is free of scope or `Arc`
references.

Should address most of #536 (only need the stop hook to call
`Server` shutdown).

* Test for fast sync, followed by restart, followed by re-fast-sync

* P2P test fix

* Double sync taking too long for Travis, commenting out for now
2018-02-13 00:38:52 +00:00
yeastplume
7dcbb8824d clarify transaction weight on diagram 2018-02-12 13:22:59 +00:00
yeastplume
2639f13710 error fix 2018-02-12 13:02:05 +00:00
yeastplume
f22f9d83be adding transaction workflow diagram, for reference 2018-02-12 12:55:08 +00:00
Ignotus Peverell
22c521eec8
[WIP] Abridged sync (#440)
* Util to zip and unzip directories
* First pass at sumtree request/response. Add message types, implement the exchange in the protocol, zip up the sumtree directory and stream the file over, with necessary adapter hooks.
* Implement the sumtree archive receive logicGets the sumtree archive data stream from the network and write it to a file. Unzip the file, place it at the right spot and reconstruct the sumtree data structure, rewinding where to the right spot.
* Sumtree hash structure validation
* Simplify sumtree backend buffering logic. The backend for a sumtree has to implement some in-memory buffering logic to provide a commit/rollback interface. The backend itself is an aggregate of 3 underlying storages (an append only file, a remove log and a skip list). The buffering was previously implemented both by the backend and some of the underlying storages. Now pushing back all buffering logic to the storages to keep the backend simpler.
* Add kernel append only store file to sumtrees. The chain sumtrees structure now also saves all kernels to a dedicated file. As that storage is implemented by the append only file wrapper, it's also rewind-aware.
* Full state validation. Checks that:
    - MMRs are sane (hash and sum each node)
    - Tree roots match the corresponding header
    - Kernel signatures are valid
    - Sum of all kernel excesses equals the sum of UTXO commitments
minus the supply
* Fast sync handoff to body sync. Once the fast-sync state is fully setup, get bacj in body sync
mode to get the full bodies of the last blocks we're missing.
* First fully working fast sync
* Facility in p2p conn to deal with attachments (raw binary after message).
* Re-introduced sumtree send and receive message handling using the above.
* Fixed test and finished updating all required db state after sumtree validation.
* Massaged a little bit the pipeline orphan check to still work after the new sumtrees have been setup.
* Various cleanup. Consolidated fast sync and full sync into a single function as they're very similar. Proper conditions to trigger a sumtree request and some checks on receiving it.
2018-02-09 22:32:16 +00:00
yeastplume
75f721039e attempt to make CUDA gcc detection a bit more robust and handle more cases 2018-02-09 11:18:14 +00:00
Quentin Le Sceller
06bd78faed Sender pays the fee. Fix #274 (#694) 2018-02-09 05:33:24 +00:00
yeastplume
623bdb696b update cuda mining defaults and trompcode 2018-02-07 21:00:58 +00:00
Antioch Peverell
ad594b53de
Revert "add block validation consensus rule for block coinbase output" (#691)
also fix tests for size of blocks etc.

This reverts commit ecda870d70.
2018-02-07 12:23:48 -05:00
Antioch Peverell
78a6447a09
fix bad merge - missing support for header msg type (#690) 2018-02-07 11:26:52 -05:00
Starmute
e485c158f3 fix grammar issue (go the extra step --> go the extra mile) (#688) 2018-02-07 10:00:42 +00:00
Yeastplume
92a23ec26d
Allow multiple Aggsig contexts (#685)
* update mean cuda miner to latest trompcode, and added tweakable parameters to grin configuration file

* Added UUID for transactions, and store aggsig contexts indexed by transaction ID

* updating test framework to allow checking of wallet contents during test
2018-02-06 11:42:26 +00:00
Ignotus Peverell
eb0ebab2d3
Add forgotten ping loop, fix TCP send interlacing 2018-02-05 23:09:57 +00:00
Ignotus Peverell
a9f4f36117
P2p ping and partial header reads fixes (#684)
* Re-introduce peer regular ping/pong
* Fix partial header reads. Turns out that on async tcp streams, even a small chunk like a
header can be read partially. So header read needs to rely on our
fixed-up `read_exact`, with an additional boolean to allow yield
when no bytes were read.
2018-02-05 19:52:11 +00:00
Quentin Le Sceller
fb46fad0ac Remove unused import and uniformize crates (#686)
* Removed unused crates
* Add listconnectedpeers in grin client
* Removed unused import and uniformize crates
2018-02-05 19:46:56 +00:00
Quentin Le Sceller
8a7eb94759 Update bitflags to ^0.1 (#682)
* Removed unused crates
* Add listconnectedpeers in grin client
* Update bitflags to ^0.1 globally
2018-02-05 19:43:54 +00:00
yeastplume
1f7dd4eb73 updating latest cuda miner 2018-02-04 20:45:06 +00:00
Quentin Le Sceller
53c85de43a List connected peers (#680)
* Removed unused crates
* Add listconnectedpeers in grin client
2018-02-03 00:37:35 +00:00
Antioch Peverell
62e44fa936
[WIP] Kernel investigation (#679)
* add some tests around building a tx_kernel from a tx
and adding secret keys together (and checking commitments)

* key addition tests
2018-02-02 09:51:55 -05:00
yeastplume
5f89d8abe9 bump cuckoo-miner tag 2018-02-02 11:33:35 +00:00
Ignotus Peverell
c7418cfe04
[WIP] Rewrite peer-to-peer logic to replace tokio with simple threading (#664) 2018-02-02 02:03:12 +00:00
Quentin Le Sceller
1ad6505130 Fix api_test panic (#678) 2018-02-01 23:29:14 +00:00
Antioch Peverell
5fe06e3e3b
we can now hydrate empty compact blocks and process them (#675)
* we can now hydrate empty compact blocks and process them

* add some tests to verify size of
various serialized blocks and compact blocks

* add_test_hydrate_empty_block

* fix broken test
2018-02-01 16:40:55 -05:00
Quentin Le Sceller
1e50d56c7e Add unit tests for API Endpoint (#653)
* First tests for API handlers

* Test chain UTXO handler

* Add test sumtrees handlers

* Fix typo

* Removed unused logger

* Update bitflags to ^1.0

* Missing test for bitflags update

* Moved test to grin directory

* Remove tests dependencies

* Add API P2P tests

* Fix hex string commitment

* Fix conflicting port

* Fix directory conflict and server port

* Wait for at least one block is mined on Travis
2018-02-01 13:14:32 -05:00
Yeastplume
c59e0e788d
update mean cuda miner to latest trompcode (#677)
* update mean cuda miner to latest trompcode, and added tweakable parameters to grin configuration file
2018-02-01 17:29:35 +00:00
Antioch Peverell
e86de901fb block.merge() is unused (and misleading) (#674) 2018-01-31 21:58:41 +00:00
Antioch Peverell
3f15f7f2f9
Request compact blocks (#667)
* first pass at allow/deny lists for hard-coded peers (not just seeds)

* commit

* add peers_allow and peers_deny examples and comments to grin.toml

* always ask for compact block
always fail to hydrate
always fallback to requesting full block

* decide to send full (empty) block over compact (empty) block

* add some randomness to the decision around broadcasting an empty block
as a block or as a compact block (so we can exercise more code paths easily)
2018-01-31 15:39:55 -05:00
Quentin Le Sceller
33cb0902bd Fix 672 (#673) 2018-01-31 13:29:45 -05:00
Antioch Peverell
c75026153c
only include kern_ids in compact block (we can safely omit input and outputs ids) (#670) 2018-01-31 10:23:42 -05:00
Yeastplume
f288a18b0c
minor test fix (#669) 2018-01-31 10:56:41 +00:00
Antioch Peverell
5fd47fb875
peers_allow/peers_deny in grin.toml (#665)
* first pass at allow/deny lists for hard-coded peers (not just seeds)

* commit

* add peers_allow and peers_deny examples and comments to grin.toml

* fix build issue with simulnet tests

* fix p2p tests
2018-01-30 16:44:13 -05:00
Dean Ancajas
94bba20488 Added INFO when reconnecting to wallet (#662) 2018-01-30 19:44:08 +00:00
Antioch Peverell
6647823177
header first propagation (#654)
* [wip] header first propagation
successfully propagating headers (unless we mined the block itself)
not yet asking for the block if we receive a header

* call request_block after successful processing header

* cleanup and skip asking for block if header is an orphan

* comments around error handling in receive_header
2018-01-30 09:42:04 -05:00
Simon B
765996a630 rustfmt install instruction gotcha (#663)
* rustfmt install instruction gotcha

rustfmt stopped working for me. It turns out people started having trouble with this last year already https://github.com/rust-lang-nursery/rustfmt/issues/2304

* rustfmt on a single file now works! Secrets inside

After `rustup component add rustfmt-preview` I get rustfmt as a command in my terminal.

`rustfmt --help` reveals --write-mode [replace|overwrite|display|plain|diff|coverage|checkstyle] and we've been using the default which is either `overwrite` or `replace` (depending on rustfmt version) and this was changing a bunch of files and a messed up workflow.

* Newcomer-friendly explanation how to use `rustfmt`
2018-01-30 08:36:18 -05:00
Antioch Peverell
5dce526f90
fix bug - p2p store was ignoring port numbers (#657) 2018-01-29 09:45:01 -05:00
Matthew Slipper
d754b8d1e4 Fix #566: serialize commit to hex (#574)
* Fix #566: Use serdes to serialize commit to hex

* Add printable UTXO
2018-01-29 09:36:09 -05:00
Simon B
86ff4e5bd0 Fix 658 and compiler complaints (#661)
* Tried but failed to fix `cargo build` complaint about unused #[macro use]. See also 7a803a8dc1
* Compiler complaints be-gone
* Give sumtree tests method-tagged folder names so they don't overwrite each others' files
Fixes #658
2018-01-28 06:12:33 +00:00
Yeastplume
783e4c250d
[WIP] Difficulty Adjustment Updates (#651)
* large updates for mining, fix async mode, will list changes in PR

* reset config and build defaults

* change to difficulty calculations

* tweaking mining params and tests

* tweaking to tests

* including pre-genesis data for difficulty adjustments, adding adjustment scenario tests

* further clarifying next_difficulty function

* moving tests out of consensus.rs

* pow test fix

* changing pre-genesis generation
2018-01-27 07:48:53 +00:00
Antioch Peverell
84128964fa Add test to cover case where a block has no coinbase outputs or kernels (#656) 2018-01-26 22:35:58 +00:00
Antioch Peverell
5a7d22977e
refactor/rework key derivation (#652)
seed -> ext_key -> many child_keys
2018-01-25 15:19:32 -05:00
Yeastplume
2def215553 Master port #605 (#606)
* port of stack overflow fix from testnet to master
* update process_block to encapsulate orphan check workflow
2018-01-24 18:20:34 +00:00
Morten Brøns-Pedersen
8710d52797 print default --key_derivations only once (#650)
Since the default value is also embedded in the help string it appears twice in the output from `grin wallet help`.  This PR just removes the default from the help string.
2018-01-23 18:37:56 +00:00
AntiochP
4be259e0de
hashed switch commitments - BLAKE2(bJ, r) (#648)
* wip

* derive switch commit hash key from extended key in wallet

* fix failing pool test
2018-01-23 07:14:06 -05:00
AntiochP
92d0fc3c08 Add block validation consensus rule for block coinbase output (#647)
and kernel counts
2018-01-22 20:55:27 +00:00