Commit graph

808 commits

Author SHA1 Message Date
Yeastplume
4c34c9ab52
PMMR Block to File positions metadata storage (#739)
* adding file position index data accessable to the chain, and allowing for storage of such within db

* missing file

* restart files at last recorded position in stored file metadata

* just use tip to store last pmmr index information

* error handling

* test fix
2018-03-03 09:08:36 +00:00
Antioch Peverell
cc12798d7a
Merkle Proofs (#716)
* family_branch() to recursively call family() up the branch
todo
  - we hit a peak, then we need to get to the root somehow
  - actually get the hashes to build the proof

* wip

* some additional testing around merkle tree branches

* track left/right branch for each sibling as we build the merkle path up

* MerkleProof and basic (incomplete) verify fn

* I think a MerkleProof verifies correctly now
need to test on test case with multiple peaks

* basic pmmr merkle proof working

* MerkleProof now serializable/deserializable

* coinbase maturity via merkle proof basically working

* ser/deser merkle proof into hex in api and wallet.dat

* cleanup

* wip - temporarily saving merkle proofs to the commit index

* assert merkle proof in store matches the rewound version
there are cases where it does not...

* commit

* commit

* can successfully rewind the output PMMR and generate a Merkle proof
need to fix the tests up now
and cleanup the code
and add docs for functions etc.

* core tests passing

* fixup chain tests using merkle proofs

* pool tests working with merkle proofs

* api tests working with merkle proof

* fix the broken comapct block hashing behavior
made nonce for short_ids explicit to help with this

* cleanup and comment as necessary

* cleanup variety of TODOs
2018-03-02 15:47:27 -05:00
Quentin Le Sceller
f2d709cb01 Fix wrong images in Dandelion docs (#742) 2018-03-02 17:59:41 +00:00
Quentin Le Sceller
6d7125b336 Add Dandelion docs (#740)
* Add scenario
* Update dandelion aggregation explanation
2018-03-02 03:18:47 +00:00
Ignotus Peverell
b3104fe2f6
Typo fix 2018-03-01 19:15:38 +00:00
Antioch Peverell
a20ffc700b
fix the broken comapct block hashing behavior (#738)
made nonce for short_ids explicit to help with this
2018-03-01 13:25:33 -05:00
Ignotus Peverell
7f478d79f6
Proper error when trying to rewind to empty genesis 2018-03-01 03:09:10 +00:00
Ignotus Peverell
07df881a72
Initialize sumtree if genesis isn't empty 2018-03-01 03:08:35 +00:00
Ignotus Peverell
9fa344383c
Fix MMR compaction to take a horizon. Additional tests. 2018-02-28 21:20:54 +00:00
Alexey Miroshkin
9e11afe8a2 Error handling with failure (using Error and ErrorKind) (#713)
* Initial version

* store failure parameters inside ErrorKind variants

* continue failure transformation

* 4 errors left

* still two errors

* return old code back

* finally compiling

* Fix compilation and test errors after merge
2018-02-28 12:56:09 -05:00
Quentin Le Sceller
0d15e22f97 Update contracts.md (#737) 2018-02-28 12:46:25 -05:00
Yeastplume
5d1f1af892
Bulletproof messages (#730)
* beginning to add bullet proof messages

* Updated core transaction creation to embed the output's value and switch commit hash as part of the rangeproof message

* formatting issue

* more formatting issues

* Removing conditional feature compliation.. just bulletproofs from now on

* ensure MAX_PROOF_SIZE uses bulletproof sizing instead of earlier version

* updated with switch commit committed to in extra data

* accidentally commented out bullet-proof-size feature
2018-02-27 21:11:55 +00:00
Alexey Miroshkin
d116a434bf Log the reason of peer ban (#736)
This PR fixed #455 by adding a few debug log messages
2018-02-27 20:33:40 +00:00
Ignotus Peverell
6f675e18e3
Clarified current limitation for atomic swap 2018-02-27 19:42:09 +00:00
Ignotus Peverell
47cc921486
Really, no blake2 here 2018-02-27 18:00:51 +00:00
Quentin Le Sceller
a0d2fb0eab Add initial Dandelion doc (#732) 2018-02-26 22:43:08 +00:00
Ignotus Peverell
34e47749de
secp256k1 uses sha 256, not blake2 2018-02-26 19:31:54 +00:00
Ignotus Peverell
4f95fcef47
Minor header formatting fix 2018-02-26 19:15:39 +00:00
Ignotus Peverell
341a3c9f4d
Minor cleanup, range proof pmmr validation and tests 2018-02-24 23:40:13 +00:00
Ignotus Peverell
3ab616b8be
Fix range proof deser (length issue) 2018-02-24 23:40:12 +00:00
Quentin Le Sceller
ccf8eb9eeb Add Inbound/Outbound for connected peers (#725)
* Add Inbound/Outbound for connected peers

* Fix tests

* Undo removing trailing commas

* Revert "Fix tests"

This reverts commit 0d024188d4.
2018-02-24 16:00:38 -05:00
Ignotus Peverell
16d778a99b
Zip integration tests 2018-02-24 20:30:42 +00:00
Ignotus Peverell
787891bf9e
First pass at a more formal contracts doc 2018-02-24 20:24:41 +00:00
Antioch Peverell
29044b5a32 last output in a block is the last regular output, failing that the last coinbase output (#727)
apply_block() processes regular outputs last so we need to be consistent with this
2018-02-24 19:40:23 +00:00
John Tromp
bc9a1cfeed tweak intro (#728) 2018-02-24 13:59:21 +00:00
Alexey Miroshkin
452996a421 Attempt to recover from isolated orphaning (#724)
Due to occasional bad network conditions, a node can miss a block.
When the next one is received and detected orphaned, we should at least try a request for the
previous block, assuming it's not already an orphan in itself and we're not syncing already.

No additinal tests were implemented, test like `simulate_full_sync` test this functionality because
sync starts later. It seems to be an issue with sync test coverage. As fix I'd suggest to start sync
as soon as we get a peer connection.

[https://github.com/mimblewimble/grin/issues/705]
2018-02-24 02:48:02 +00:00
Yeastplume
05d1c6c817
Take the 'Sum' out of 'Sumtree' (#702)
* beginning to remove sum

* continuing to remove sumtree sums

* finished removing sums from pmmr core

* renamed sumtree files, and completed changes+test updates in core and store

* updating grin/chain to include removelogs

* integration of flatfile structure, changes to chain/sumtree to start using them

* tests on chain, core and store passing

* cleaning up api and tests

* formatting

* flatfiles stored as part of PMMR backend instead

* all compiling and tests running

* documentation

* added remove + pruning to flatfiles

* remove unneeded enum

* adding sumtree root struct
2018-02-22 13:45:13 +00:00
Antioch Peverell
c2ca6ad03f
diagram how Merkle proof and pruning interact (proposed) (#722) 2018-02-21 12:20:02 -05:00
Ignotus Peverell
3b51ffd83c
Fixup MMR position in n_leaves if invalid
Allows the client to not worry about what position is a valid
MMR size. Associated tests.
2018-02-20 21:48:24 +00:00
Quentin Le Sceller
755d0b7902 Typo broadcast/transaction (#718) 2018-02-20 21:27:18 +00:00
Brad Neuman
f081f75283 Fix small typo in intro.md (#717)
fee -> feel
2018-02-20 12:04:56 -05:00
Ignotus Peverell
866ec977da
Factoring in mmr leaf count function 2018-02-19 23:20:32 +00:00
Antioch Peverell
4022b82817
cleanup various build warnings (#714)
* cleanup various build warnings

* use serde_json in tests only
2018-02-17 12:56:22 -05:00
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