zebra/zebra-chain/src/block
teor 7a7d79dfaf
fix(state): Use correct end heights for end of block subtrees during the full sync (#7566)
* Avoid manual handling of previous sapling trees by using iterator windows instead

* Avoid manual sapling subtree index handling by comparing prev and current subtree indexes instead

* Simplify adding notes by using the exact number of remaining notes

* Simplify by skipping the first block, because it can't complete a subtree

* Re-use existing tree update code

* Apply the sapling changes to orchard subtree updates

* add a reverse database column family iterator function

* Make skipping the lowest tree independent of iteration order

* Move new subtree checks into the iterator, rename to end_height

* Split subtree calculation into a new method

* Split the calculate and write methods

* Quickly check the first subtree before running the full upgrade

* Do the quick checks every time Zebra runs, and refactor slow check error handling

* Do quick checks for orchard as well

* Make orchard tree upgrade match sapling upgrade code

* Upgrade subtrees in reverse height order

* Bump the database patch version so the upgrade runs again

* Reset previous subtree upgrade data before doing this one

* Add extra checks to subtree calculation to diagnose errors

* Use correct heights for subtrees completed at the end of a block

* Add even more checks to diagnose issues

* Instrument upgrade methods to improve diagnostics

* Prevent modification of re-used trees

* Debug with subtree positions as well

* Fix an off-by-one error with completed subtrees

* Fix typos and confusing comments

Co-authored-by: Marek <mail@marek.onl>

* Fix mistaken previous tree handling and end tree comments

* Remove unnecessary subtraction in remaining leaves calc

* Log heights when assertions fail

* Fix new subtree detection filter

* Move new subtree check into a method, cleanup unused code

* Remove redundant assertions

* Wait for subtree upgrade before testing RPCs

* Fix subtree search in quick check

* Temporarily upgrade subtrees in forward height order

* Clarify some comments

* Fix missing test imports

* Fix subtree logging

* Add a comment about a potential hang with future upgrades

* Fix zebrad var ownership

* Log more info when add_subtrees.rs fails

* cargo fmt --all

* Fix unrelated clippy::unnecessary_unwrap

* cargo clippy --fix --all-features --all-targets; cargo fmt --all

* Stop the quick check depending on tree de-duplication

* Refactor waiting for the upgrade into functions

* Wait for state upgrades whenever the cached state is updated

* Wait for the testnet upgrade in the right place

* Fix unused variable

* Fix a subtree detection bug and comments

* Remove an early reference to reverse direction

* Stop skipping subtrees completed at the end of blocks

* Actually fix new subtree code

---------

Co-authored-by: Marek <mail@marek.onl>
2023-09-19 14:49:36 +00:00
..
height change(utils): Add a direct connection mode to zebra-checkpoints (#6516) 2023-04-26 23:35:53 +00:00
tests change(deps): Run `cargo update` (#7429) 2023-08-31 00:49:01 +00:00
arbitrary.rs fix(state): Use correct end heights for end of block subtrees during the full sync (#7566) 2023-09-19 14:49:36 +00:00
commitment.rs fix(diagnostics): Hex-encode debug format of commitments, nonces, and nullifiers (#5960) 2023-01-17 13:57:22 +00:00
error.rs remove dead code from zebra-chain (#5464) 2022-10-25 03:23:50 +00:00
hash.rs change(rpc): Refactor get block template RPC into stages (#5837) 2022-12-13 21:25:04 +00:00
header.rs fix(diagnostics): Hex-encode debug format of commitments, nonces, and nullifiers (#5960) 2023-01-17 13:57:22 +00:00
height.rs change(state): Deduplicate note commitment trees stored in the finalized state (#7312) 2023-08-17 00:41:11 +00:00
merkle.rs cleanup(rust): Fix new nightly clippy warnings (#7135) 2023-07-05 07:11:27 +00:00
serialize.rs fix(chain): Validate header versions when serializing blocks (#6475) 2023-04-12 04:54:02 +00:00
tests.rs change(docs): Replaces XXX with TODO (#6417) 2023-03-28 04:13:04 +00:00