Commit graph

264 commits

Author SHA1 Message Date
Yeastplume
63c65605bb
[SYNC PERFORMANCE] Adjust DifficultyIterator to no longer deserialize PoW proof nonces (#3671)
* replace bitvec with more efficient bitpack algorithm

* optimise proof_unpack_len

* move proof pack length calculation

* small refactor

* first pass attempt at not deserializing proof nonces in difficulty iter

* another 10 seconds gained by not deserialising the proof from the difficulty iterator

* add new deser parameters to tests where needed

* add skip_proof variants to store

* remove hash from difficulty iterator struct, rename HeaderInfo to HeaderDifficultyInfo

* replace bitvec with more efficient bitpack algorithm

* optimise proof_unpack_len

* move proof pack length calculation

* small refactor

* first pass attempt at not deserializing proof nonces in difficulty iter

* another 10 seconds gained by not deserialising the proof from the difficulty iterator

* add new deser parameters to tests where needed

* add skip_proof variants to store

* remove hash from difficulty iterator struct, rename HeaderInfo to HeaderDifficultyInfo
2021-12-10 11:39:39 +00:00
John Tromp
53414ae105
Fixmmr part2 (#3666)
* use 0-based positions in  methods pmmr_leaf_to_insertion_index and bintree_postorder_height; add round_up_to_leaf_pos method

* use 0-based positions in method insertion_to_pmmr_index

* use 0-based positions in method is_leaf

* use 0-based positions in method family()

* use 0-based positions in method is_left_sibling

* use 0-based positions in method family_branch

* use 0-based positions in methods bintree_{left,right}most

* use 0-based positions in method bintree_pos_iter

* use 0-based positions in method bintree_range

* use 0-based positions in method bintree_leaf_pos_iter

* rename last_pos in MMR related structs to size

* use 0-based positions in method prune

* use 0-based positions in method push and apply_output return value

* use 0-based position argument of method merkle_proof

* use 0-based outputs in method pmmr::peaks

* fix peaks() code comments

* refix peaks() code comments

* use 0-based positions in method get_peak_from_file

* use 0-based positions in methods get_data_from_file

* use 0-based positions in methods get_from_file

* use 0-based positions in methods get_data

* use 0-based positions in methods get_hash

* use 0-based positions in method peak_path

* use 0-based positions in method bag_the_rhs

* use 0-based positions in method Backend::remove

* use 0-based positions in method leaf_pos_iter

* use 0-based positions in method self.LeafSet::includes

* use 0-based positions in methods self.LeafSet::{add,remove}

* use 0-based positions in methods is_pruned,is_pruned_root,is_compacted

* use 0-based positions in methods PruneList::append

* use 0-based positions in methods append_pruned_subtree

* use 0-based positions in method calculate_next_leaf_shift

* use 0-based positions in method append_single

* use 0-based positions in method calculate_next_shift

* use 0-based positions in method segment_pos_range

* use 0-based positions in method reconstruct_root

* use 0-based positions in method validate_with

* use 0-based positions in method validate

* rename size (formerly last_pos) to mmr_size

* use 0-based positions in Segment's hash_pos and leaf_pos

* minimize use of saturating_sub(1) and rename some pos/idx to size

* use 0-based positions in methods get_output_pos

* use 0-based positions in method get_unspent_output_at

* use 0-based positions in method get_header_hash

* use 0-based positions in methods MerkleProof::verify{,_consume}

* use 0-based positions in method cleanup_subtree

* don't allow 0 in prunelist bitmap

* use 0-based positions in methods get_{,leaf_}shift

* rename some 1-based pos to pos1; identify TODO

* Address yeastplume's PR review comments
2021-11-26 11:25:10 +00:00
Yeastplume
3f4f165e0b
PMMR Backend Support for append_pruned_root (Continued) (#3659)
* refactor prune_list with aim of allowing pruned subtree appending

* add test coverage around pmmr::is_leaf() and pmmr::bintree_leaf_pos_iter()

* comments

* cleanup

* implement append pruned subtree for prune_list

* commit

* we can now append to prune_list

* fix our prune_list corruption...

* rework how we rewrite the prune list during compaction

* test coverage for improved prune list api

* continuing to merge

* finish merge, tests passing again

* add function pmmr_leaf_to_insertion_index, and modify bintree_lef_pos_iter to use it. Note there's still an unwrap that needs to be dealt with sanely

* change pmmr_leaf_to_insertion_index to simpler version + handle conversion between 1 and 0 based in bintree_leaf_pos_iter

Co-authored-by: antiochp <30642645+antiochp@users.noreply.github.com>
2021-11-09 15:34:10 +00:00
Quentin Le Sceller
2e2149859f
bump to 5.2.0-alpha.1 on master (#3652) 2021-08-19 09:06:52 +02:00
Quentin Le Sceller
11e5efc089
Tagging v5.1.1 release (#3651) 2021-08-17 20:57:13 +02:00
Antioch Peverell
a9f1dd7bcd
bump to 5.2.0-alpha.1 on master (#3640) 2021-05-06 13:46:03 +01:00
Antioch Peverell
72a6eb81e8
bump to 5.1.0 to prep for release (#3639) 2021-05-06 13:02:01 +01:00
Antioch Peverell
87729a2227
bump crate version to 5.1.0-beta.2 to prep for release (#3636) 2021-04-29 13:05:28 +01:00
trevyn
431e4b97b7
Defork croaring (#3596)
* Defork croaring

* Attempt to fix Windows CI

* Fix windows-release.yml too

* Use ROARING_ARCH=x86-64-v2
2021-03-22 13:31:43 -04:00
Quentin Le Sceller
0259ed23ea
Update copyright year to 2021 (#3592)
* Update copyright year to 2021
2021-03-10 10:14:48 -05:00
Quentin Le Sceller
725622da7a
Remove imports and cleanups (#3590)
* Remove unused import and if else chain
2021-03-08 11:09:41 -05:00
Antioch Peverell
3583028781
Prune list iterators (#3574)
* wip

* use range beneath subtree for efficient is_pruned check

* various iterators over the prune list

* improved prune list iter and subtree handling

* use take_while so unpruned iterators are not infinite
2021-02-24 17:02:03 +00:00
Antioch Peverell
adddff9155
optimization for reading peak hashes from backend file (#3575) 2021-02-24 16:17:28 +00:00
Antioch Peverell
7487ffd75b
replace subtree with pruned root (#3576)
no need to remove sibling explicitly
2021-02-24 15:04:18 +00:00
Antioch Peverell
57f4592499
Retire pruned cache (#3573)
* use range beneath subtree for efficient is_pruned check
2021-02-23 19:34:32 +00:00
Antioch Peverell
9c44a4d08f
Refactor prune file replace (#3571)
* split prune file rewrite into two steps
only one needs a mut ref to self

* write both tmp files then replace
2021-02-23 11:40:26 +00:00
Antioch Peverell
4de2d92433
Revert "rework prune rewrite with iterators (#3568)" (#3569)
This reverts commit 5092652b0c.
2021-02-22 14:18:23 +00:00
Antioch Peverell
5092652b0c
rework prune rewrite with iterators (#3568)
* rework prune rewrite with iterators

* fix
2021-02-19 11:59:40 +00:00
jaspervdm
35ebdea967
Bump master version to 5.1.0-alpha.1 (#3510) 2021-01-04 15:29:50 +00:00
Antioch Peverell
f48a23655d
bump 5.0.0-beta.2 after fixing windows release script (#3508) 2020-11-26 21:35:10 +00:00
jaspervdm
64c8e0cf0a
Bump version to 5.0.0-beta.1 (#3505) 2020-11-26 18:48:16 +01:00
Antioch Peverell
2125c05020
use extend_from_slice when appending multiple hashes to hash file (#3497)
* use extend_from_slice when appending multiple hashes to hash file

* bump
2020-11-24 14:24:19 +00:00
Antioch Peverell
cba3137338
add segmenter for generating segments from txhashset with consistent rewind (#3482)
* add segmenter for generating segments from txhashset with consistent rewind

* rework segmenter to take a txhashset wrapped in rwlock
rework our rewindable pmmr so we can convert to readonly easily

* placeholder code for rewinding readonly txhashset extension to build a rangeproof segment

* segment creation for outputs/rangeproofs/kernels/bitmaps

* placeholder segment impl

* commit

* rework segmenter to use a cached bitmap (rewind is expensive)

* cache segmenter instance based on current archive header

* integrate the real segment and segment identifier with our segmenter

* exercise the segmenter code on chain init

* wrap accumulator in an arc, no need to clone each time
2020-11-23 19:07:07 +00:00
jaspervdm
8faba4ef83
PMMR segment creation and validation (#3453)
* Chunk generation and validation

* Rename chunk -> segment

* Missed a few

* Generate and validate merkle proof

* Fix bugs in generation and validation

* Add test for unprunable MMR of various sizes

* Add missing docs

* Remove unused functions

* Remove segment error variant on chain error type

* Simplify calculation by using a Vec instead of HashMap

* Use vectors in segment definition

* Compare subtree root during tests

* Add test of segments for a prunable mmr

* Remove assertion

* Only send intermediary hashes for prunable MMRs

* Get hash from file directly

* Require both leaves if one of them is not pruned

* More pruning tests

* Add segment (de)serialization

* Require sorted vectors in segment deser

* Store pos and data separately in segment

* Rename log_size -> height

* Fix bitmap index in root calculation

* Add validation function for output (bitmap) MMRs

* Remove left over debug statements

* Fix test

* Edge case: final segment with uneven number of leaves

* Use last_pos instead of segment_last_pos

* Simplify pruning in test

* Add leaf and hash iterators

* Support fully pruned segments

* Drop backend before deleting dir in pruned_segment test

* Simplify output of first_unpruned_parent
2020-11-17 19:38:44 +01:00
Antioch Peverell
e7bbda81a0
migrate blocks in batches (rework db iterator impl) (#3450)
* rework db iterator
more robust block migration based on low level iterator

* cleanup

* cleanup

* fixup
2020-10-07 11:47:25 +01:00
jaspervdm
0aec8b533b
Refactor PMMR read methods into trait (#3454) 2020-09-29 15:57:33 +02:00
Antioch Peverell
4944679fb2
add test coverage around existing behavior for exists() and iter() (#3452) 2020-09-25 13:49:48 +01:00
Antioch Peverell
62783997df
refactor get_ser to use get_with internally (#3451)
less code duplication and a cleaner code path
batch.exists() now aware of current write tx
2020-09-25 12:47:04 +01:00
Antioch Peverell
a22d98e9d5
bump working version on master to 4.2.0-alpha.1 (#3443)
we now have a current/4.1.x branch for 4.1.0 release
2020-09-15 17:26:44 +01:00
Antioch Peverell
7dc94576bd
Introduce CommitOnly variant of Inputs (#3419)
* Introduce CommitOnly variant of Inputs.
Introduce CommitWrapper so we can sort commit only inputs correctly.

* rememebr to resort if converting

* write inputs based on variant and protocol version

* read and write protocol version specific inputs

* store full blocks in local db in v3
convert to v2 when relaying to v2 peers

* add debug version_str for inputs

* no assumptions about spent index sort order

* add additional version debug logs

* fix ser/deser tests for proto v3

* cleanup coinbase maturity

* rework pool to better handle v2 conversion robustly

* cleanup txpool add_to_pool

* fix nrd kernel test

* move init conversion earlier

* cleanup

* cleanup based on PR feedback
2020-09-07 16:58:41 +01:00
Antioch Peverell
78e3ec3df0
sync_all() on leaf_set and prune_list when using temp file (#3354) 2020-08-19 09:37:22 +01:00
Antioch Peverell
824c51a346
bump version to 4.1.0 on master (4.0.1 on 4.0.x branch) (#3390) 2020-07-13 12:16:43 +01:00
Antioch Peverell
30db9c410e
bump master to 4.0.1-alpha.1 to differentiate from 4.0.0 official tagged build (#3374) 2020-07-02 15:51:11 +01:00
Yeastplume
7abe9fcb39
Versioning for 4.0.0 release (#3373) 2020-07-02 10:29:10 +01:00
Yeastplume
098d25e569
Version bump for 4.0.0-rc.1 (#3366) 2020-06-26 13:10:42 +01:00
Nym Seddon
39ca5d1c11
Store: error handling for file errors (#3364)
Use existing error handling plumbing for Store file creation errors

Co-authored-by: Nym Seddon <unseddd@shh.xyz>
2020-06-25 10:20:26 +01:00
Antioch Peverell
55a929e214
cleanup old unused code (#3355) 2020-06-15 15:05:47 +01:00
Antioch Peverell
dd88d28a7a
bump version to 4.0.0-beta.2 (#3351) 2020-06-12 14:08:12 +01:00
Antioch Peverell
20e5c1910b
NRD rules and "recent" kernel pos index (#3302)
* variants for output_pos linked list entries (head/tail/middle/unique)
next and prev and Vec<u8> lmdb keys

* get_pos on enum

* break list and list entries out into separate enums

* track output features in the new output_pos index, so we can determine coinbase maturity

* push entry impl for none and unique

* some test coverage for output_pos_list

* commit

* wip - FooListEntry

* use instance of the index

* linked list of output_pos and commit_pos both now supported

* linked_list

* cleanup and rename

* rename

* peek_pos

* push some, peek some, pop some

* cleanup

* commit pos
cleanup

* split list and entry out into separate db prefixes

* cleanup and add placeholder for pop_back

* pop_pos_back (for popping off the back of the linked list)
test coverage for pop_pos_back

* wip

* placeholder for prune via a trait
pos must always increase in the index

* rewind kernel_pos_idx when calling rewind_single_block

* RewindableListIndex with rewind support.

* test coverage for rewindable list index

* test coverage for rewind back to 0

* rewind past end of list

* add tests for kernel_pos_idx with multiple commits

* commit

* cleanup

* hook NRD relative lock height validation into block processing and tx validation

* cleanup

* set local chain type for kernel_idx tests

* add test coverage for NRD rules in block processing

* NRD test coverage and cleanup

* NRD relative height 1 test

* test coverage for NRD kernels in block processing

* cleanup

* start of test coverage for txpool NRD kernel rules

* wip

* rework pool tests to use real chain (was mock chain) to better reflect reality (tx/block validation rules etc.)

* cleanup

* cleanup pruneable trait for kernel pos index

* add clear() to kernel_pos idx and test coverage

* hook kernel_pos rebuild into node startup, compaction and fast sync

* verify full NRD history on fast sync

* return early if nrd disabled

* fix header sync issue
2020-06-10 16:38:29 +01:00
Quentin Le Sceller
093c500fed
Cargo Update (#3338) 2020-06-08 17:15:32 -04:00
Yeastplume
c7c9a32b9b
4.0.0-beta.1 Version Bump (#3339) 2020-06-04 14:52:26 +01:00
hashmap
26b411e79e
Reduce memory allocations in PMMR (#3328)
We have a pattern in the code - return Vec, turn it into an iterator, filter and collect to another Vec. The idea was to return iterator where possible to avoid allocating intermediate vecs.
2020-05-24 16:50:27 +01:00
Antioch Peverell
6faa0e8d75
thread local chain type vs global chain type (#3327)
* Introduce GLOBAL_CHAIN_TYPE and make CHAIN_TYPE thread_local.
This makes testing more explicit and significantly more robust.

* set_local_chain_type() in tests

* cleanup - weird

* get pool tests working with explicit local chain_type config

* core tests working with explicit local chain_type

* p2p tests working with explicit local chain_type

* store tests working

* cleanup, feedback
2020-05-22 12:51:58 +01:00
hashmap
2c62111561
Remove some unwraps in LMDB client (#3313) 2020-05-13 16:18:55 +02:00
hashmap
2397407dc4
Always return a typed structure from lmdb store (#3312)
We have a method get which returns a Vec, it's used in cases when we can't implement FromLmdbBytes or Readable on a desired type, eg when both traits and type are external for the current crate. This approach requires an extra allocation of a Vec, this PR introduces a method which accepts desirialzer as closure, which allows to desrialize in place without an intermidiate heap allocation.

It's still possible to get a Vec if needed, just pass a Vec constructor to get_with.
2020-05-05 11:00:23 +02:00
hashmap
8a22fb516a
Reduce number of allocations in to_key calls (#3311)
We have to make an extra allocation per db get request because key generation function to_key takes Vec. Taking byte slice (AsRef<[u8]> to be precise) also simplifes the code a bit.
2020-04-30 17:47:44 +02:00
hashmap
a82041d0ed
Refactor Readable trait (#3309)
Currently Writable accepts trait Write as a type parameter but Readable
takes Read as a trait object, which is not symmetrical and also less performant. This PR changes Readable trait and all places where it's used
2020-04-30 17:42:19 +02:00
jaspervdm
2fe0869321
Use croaring-mw with 'compat' feature (#3274) 2020-03-23 21:12:58 +01:00
Yeastplume
ee5fe1ac63
Use smaller LMDB Allocation Size in non-production modes (#3264)
* add option to override lmdb allocation size in testing

* simplify to use global::is_production_mode
2020-03-10 09:30:12 +00:00
Yeastplume
31bd2d923a
Add better LMDB error output (#3263) 2020-03-09 14:04:06 +01:00