Commit graph

626 commits

Author SHA1 Message Date
ard'O'crat
059ae0390d
build: update croaring crate to fix bindgen errors for recent C compilers (#3770) 2023-09-28 11:58:11 +01:00
Yeastplume
94277bba9d
update versioning to 5.2.0-beta.3 (#3766)
* update versioning to 5.2.0-beta.3

* cargo lock
2023-08-02 10:22:25 +01:00
Yeastplume
b69f18d0a2
Update versioning for 5.2.0-beta.2 (#3760) 2023-06-28 10:46:28 +01:00
ard'O'crat
45ebc8ae50
pibd: save latest_block_height to request less data from db when checking progress (#3756) 2023-06-20 12:13:15 +01:00
Yeastplume
fd1410ebeb
version change to 5.2.0-beta.1 for tag (#3753) 2023-06-12 10:10:42 +01:00
Yeastplume
01370d74ff
Foreign API: Bulk block request (#3751)
* remove non-mainnet check for PIBD requests

* add first version of get blocks function

* .\api\src\foreign.rs

* add a max value to get_blocks, documentation

* typo

* updates based on feedback
2023-06-12 09:41:08 +01:00
Yeastplume
684f0a387a
updats to warnings, cargo.lock, version number (#3739) 2022-10-21 13:17:39 +01:00
Yeastplume
030bd0e1d9
[DNM] PIBD Task / Issue Tracker (#3695)
* [PIBD_IMPL] Introduce PIBD state into sync workflow (#3685)

* experimental addition of pibd download state for testnet only

* fixes to bitmap number of segments calculation + conversion of bitmap accumulator to bitmap

* attempt to call a test message

* add p2p methods for receiving bitmap segment and applying to desegmenter associated with chain

* fixes to state sync

* add pibd receive messages to network, and basic calls to desegmenter from each (#3686)

* [PIBD_IMPL] PIBD Desegmenter State (#3688)

* add functions to desegmenter to report next desired segments, begin to add state to determine which segments have been requested

* add segmentidentifier type to id requested segments uniquely

* make a call on where to keep track of which PIBD segments have been requested

* move segmenttype definition, add functions to manipulate peer segment list

* remove desegmenter state enum

* change chain desegmenter function to provide rwlock

* trace, warning cleanup

* udpate to test compliation

* [PIBD_IMPL] Bitmap accumulator reconstruction + TxHashset set reconstruction (#3689)

* application of received bitmap segments to local accumulator

* add all required elements to send/receive output segment requests and responses

* testing of output sync

* add special cases to pmmr segment request

* [PIBD_IMPL] PMMR Reassembly from Segments (#3690)

* update pibd copy test to use new desgmenter structure

* begin reconstruction of output pmmr

* clean up hash/leaf insertion logic

* push pruned subtree appears to be working, now also calculates left hand hashes correctly

* factor out ordering of segment/hash order array

* refactor for pmmr application code

* test of chain copy appears to be working

* add rangeproof functions to desegmenter

* add kernel functions, attempt refactor

* small test cleanup, reconstruction of live chain working in manual copy test

* [PIBD_IMPL] PIBD tree sync via network and kill/resume functionality (#3691)

* add functions to determing latest verifiable block height for the given pibd state

* attempting to allow for pibd to resume after killing process

* fix to ensure prune list is properly flushed during pibd sync

* removal of unneeded code

* ignore test for now (fix before full merge)

* [PIBD_IMPL] Finalize PIBD download and move state to chain validation (#3692)

* investigations as to why a slight rewind is needed on startup during PIBD

* move validation code into desegmenter validation thread (for now)

* ensure genesis entries in pmmrs are removed if they're removed in the first segment

* validation all working except for verifying kernel sums

* remove unneeded pmmr rollbacks on resume now root cause was found

* updates to remove unpruned leaves from leaf set when rebuilding pmmr

* remove + 1 to segment traversal iter length

* [PIBD_IMPL] PIBD Stats + Retry on validation errors (#3694)

* start to add stats and reset chain state after errors detected

* add functions to reset prune list when resetting chain pibd state

* debug statement

* remove test function

* [PIBD_IMPL] Update number of simultaneous peer requests for segments (#3696)

* cleanup of segment request list

* allow for more simultaneous requests during state sync

* up number of simultaneous peer requests for segments

* [PIBD_IMPL] Thread simplification + More TUI Updates + Stop State Propagation (#3698)

* change pibd stat display to show progress as a percentage of downloaded leaves

* attempt some inline rp validation

* propagate shutdown state through kernel validation

* change validation loop timing

* simplify validator threading

* add more detailed tracking of kernel history validation to tui, allow stop state during

* adding more stop state + tui progress indication

* remove progressive validate

* test fix

* revert to previous method of applying segments (#3699)

* fix for deadlock issue (#3700)

* update Cargo.lock for next release

* [PIBD_IMPL] Catch-Up functionality + Fixes based on testing (#3702)

* ensure desegmenter attempts to apply correct block after a resumte

* ensure txhashset's committed implementation takes into account output bitmap for summing purposes

* remove check to de-apply outputs during segment application

* return removal of spent outputs during pibd

* remove unneeded status

* remove uneeded change to rewind function

* documentation updates + todo fixes (#3703)

* add pibd abort timeout case (#3704)

* [PIBD_IMPL] BitmapAccumulator Serialization Fix (#3705)

* fix for writing / calculating incorrect length for negative indices

* update capabilities with new version of PIBD hist

* remove incorrect comment

* fix capabilities flag, trace output

* test fix

* Merge DNSSeed scope changes into pibd impl branch (#3708)

* update Cargo.lock for next release

* visibility scope tweaks to aid seed test utilities (#3707)

* move all PIBD-related constants into pibd_params modules (#3711)

* remove potential double read lock during compaction
2022-10-18 09:23:29 +01:00
Yeastplume
a14a8e3123
Thiserror changeover (#3728)
* WIP remove failure from all `Cargo.toml`

* WIP remove `extern crate failure_derive`

* Use `thiserror` to fix all errors

* StoreErr is still a tuple

* Remove another set of unnecessary `.into()`s

* update fuzz tests

* update pool/fuzz dependencies in cargo.lock

* small changes based on feedback

Co-authored-by: trevyn <trevyn-git@protonmail.com>
2022-07-14 11:08:13 +01:00
Yeastplume
78c9794d30
TUI Freeze Fix - Add manually maintained hash to difficulty iterator (#3684)
* add manually managed hash to difficulty iterator

* text fix

* fix for hash-of-hash, review feedback
2022-01-07 14:23:58 +00:00
Yeastplume
2237f42144
Handle attempts to get block headers at invalid heights (#3683)
* handle attempts to get block headers at invalid heights

* compare requested height against header pmmr size

* gte
2021-12-31 09:47:04 +00:00
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
Yeastplume
7725a05ac1
[SYNC PERFORMANCE] Replace header proof serialisation with more efficient algorithm (#3670)
* replace bitvec with more efficient bitpack algorithm

* optimise proof_unpack_len

* move proof pack length calculation

* small refactor

* integrate suggestions in #3670

* finish compressing compression function

* remove ordering cmp from pack function

* remainder fix for new logic

* remove println statements

* remove ordering import warning
2021-12-06 16:35:23 +00:00
Yeastplume
2f5cfbe4eb
[PIBD] PMMR Desegmenter Structure (Pt. 1) (#3667)
* initial commit of WIP pibd explorations

* correct calling for obtaining and validating first segment

* update test to properly iterate through each segment of the test pmmrs, validating each segment as it goes

* updated test to fully segment and validate PMMRs from compacted and uncompacted sample data. Also contains method of running test againt live chain data

* remove logger change

* change test file name

* change test file name

* change directory reference in test for CI

* add initial (experimental) structure for PIBD desegmenting

* move bitmap desegmentation logic into desegmenter

* added txhashset methods to apply pibd segments (note this only works for fully unpruned trees atm)

* change last_pos to mmr_size

* fix to pmmr::peaks call

* don't verify POW when copying headers

* prepare for commit of work thus far'

* update test paths

* few updates based on early review
2021-12-02 10:43:38 +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
c8275f7e57
[PIBD] Chain Segmenter Validation Test + Block Archive Horizon Change (#3665)
* initial commit of WIP pibd explorations

* correct calling for obtaining and validating first segment

* update test to properly iterate through each segment of the test pmmrs, validating each segment as it goes

* updated test to fully segment and validate PMMRs from compacted and uncompacted sample data. Also contains method of running test againt live chain data

* remove logger change

* change test file name

* change test file name

* change directory reference in test for CI

* remove +1 from segment count

* prediction comment change

* add ignore of full-chain test
2021-11-23 12:38:52 +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
John Tromp
f51b6e1376
implement fix past fees RFC with fee shift since genesis (#3629) 2021-05-11 16:39:09 +01: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
Antioch Peverell
89c06ddab7
client invalidateheader and resetchainhead (#3618)
* wip - "reset_head" via owner api functionality

* jsonrpc pass hash in as a string

* sort of works

* not a reorg if we simply accept several blocks at once

* remember to reset header MMR separately
as it is readonly when interacting with txhashset extension

* basic client integration
needs error handling etc.

* reset sync status when reset chain head

* track "denylist" (todo) and validate headers against this via the ctx

* track denylist (header hashes) in chain itself

* header denylist in play

* expose invalidateheader as client cmd

* rework reset_chain_head - rewind txhashset then header MMR
2021-04-29 11:05:05 +01:00
Antioch Peverell
34413c1cab
track sync_head on header_sync sync status (#3626)
* track sync_head on header_sync sync status
follow header fork as appropriate

* track highest_diff alongside highest_height on HeaderSync status

* cleanup

* not not
2021-04-06 11:16:20 +01:00
trevyn
df91bff0f1
Add test for duplicate rangeproof inflation bug (#3630)
* invalid range proof test

* create output with 1 million grin

* Move `output_negative` into `tests/`

So it cannot be called from outside of tests!

* Verify InvalidBlockProof & InvalidRangeProof types

Co-authored-by: Snape 479 <Severus_Snape93@protonmail.com>
2021-04-06 11:06:52 +01:00
Antioch Peverell
f6ec77a592
never speak of the verifier cache again (#3628) 2021-04-01 15:04:53 +01:00
Antioch Peverell
09c90fc257
cleanup and stop wrapping errors in other/unfit (#3616) 2021-03-30 09:12:48 +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
Antioch Peverell
6690b25f05
Enable block archival sync (#3579)
* wip - body sync for full archive

* allow chain compaction during sync

* placeholder for logic to ensure archive nodes sync from archive nodes

* body sync from archival peers

* allow chain compaction during sync

* placeholder for logic to ensure archive nodes sync from archive nodes
2021-03-16 12:04:09 +00: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
35740204a1
no more conversion to support v2 blocks (#3587)
get_block simply returns None if v2 support required
2021-03-06 21:40:20 +00:00
Quentin Le Sceller
64b2fddbf1
[5.0.x] Fix PIBD segments (#3532) (#3583)
Co-authored-by: jaspervdm <j@sper.dev>
2021-03-03 14:36:47 -05:00
Antioch Peverell
03b7518884
cleanup redundant sync_head and associated MMR (#3556) 2021-02-24 19:11:08 +00:00
Antioch Peverell
7649d361e4
Block sync hash traversal perf (#3558)
* sync traversal performance improvements

* rework how body_sync determines block hashes to request
2021-02-15 13:47:59 +00:00
Antioch Peverell
a3aed4aae5
fix for missing block under certain startup conditions (#3555) 2021-02-09 09:13:39 +00:00
jaspervdm
35ebdea967
Bump master version to 5.1.0-alpha.1 (#3510) 2021-01-04 15:29:50 +00:00
Antioch Peverell
eaf9bcf2bf
Block migration db flag (only migrate once) (#3512)
* rework migrate_db_v2_v3

* db flag to track block migration
2020-12-08 09:37:12 +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
John Tromp
48efb693e2
Fixfees (#3481)
* add FeeFields type

* use FeeFields with ::zero and try_into().unwrap()

* fixed tests

* avoid 0 accept_base_fee

* add aggregate_fee_fields method for transaction

* implement std::fmt::Display trait for FeeFields

* make base_fee argument non-optional in libtx::mod::tx_fee

* add global and thread local accept_fee_base; use to simplify tests

* set unusually high fee base for a change

* revert to optional base fee argument; default coming from either grin-{server,wallet}.toml

* remove optional base fee argument; can be set with global::set_local_accept_fee_base instead

* define constant global::DEFAULT_ACCEPT_FEE_BASE and set global value

* add Transaction::accept_fee() method and use

* Manual (de)ser impl on FeeFields

* fix comment bug

* Serialize FeeFields as int in tx

* allow feefields: u32:into() for tests

* try adding height args everywhere

* make FeeFields shift/fee methods height dependent

* prior to hf4 feefield testing

* rename selected fee_fields back to fee for serialization compatibility

* fix test_fee_fields test, merge conflict, and doctest use of obsolete fee_fields

* make accept_fee height dependent

* Accept any u64 in FeeFields deser

Co-authored-by: Jasper van der Maarel <j@sper.dev>
2020-11-26 18:03:06 +01:00
jaspervdm
96afc766a1
PIBD segment p2p messages (#3496)
* Define PIBD segment p2p messages

* Respond to segment requests

* Use specialized (de)ser for output bitmap segments

* Allowed segment height ranges in const
2020-11-25 21:52:09 +01:00
Antioch Peverell
6e73e00d6b
fix calls to next_diff() in tests to use next height correctly (#3501) 2020-11-25 12:47:30 +00:00
John Tromp
f86102b2a6
fixDAA; implement wtema (#3477)
* implement wtema

* reduce FTL from 12 to 5 mins; fix inaccuracies in cuckoo doc

* rename difficulty window for DampedMovingAverage DAA

* fix FTL error msg

* secondary_scale becomes extended nonce past HF4

* secondary_scale change actually belongs in hardfork4 PR

* make future time limit configurable

* define constant global::DEFAULT_FUTURE_TIME_LIMIT and refactor a bit

* fix typos

* as_ref() feels safer than as_mut() :-)

* remove obsolete mut

* make future_time_limit non-mandatory in grin-server.toml
2020-11-25 10:58:39 +00:00
John Tromp
a5b8968826
HardFork4 (#3478)
* HardFork4 initial commit

* HF4 obsoletes secondary_scale, which becomes an nonce extension 8->12 bytes

* fix TESTNET_FOURTH_HARD_FORK height

* improve predicted height for testnet fork on dec 8

* move local variable as suggested by antiochp
2020-11-24 16:13:28 +00:00
jaspervdm
055b684416
More efficient serialization for bitmap segments (#3492)
* More efficient serialization for bitmap segments

* Rename a const

* Correctly count number of chunks in a segment

* Enum for BitmapBlock (de)ser mode

* Add more segments in test

* Fix duplicate function
2020-11-24 15:19:07 +01: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
Quentin Le Sceller
cf2a65242d
Rename Floonet to Testnet (#3431)
* Rename Floonet to Testnet

* Fix test

* Rename test and docker
2020-10-07 09:36:02 -04: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