Zebra/zebra-state/src
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
..
service fix(state): Use correct end heights for end of block subtrees during the full sync (#7566) 2023-09-19 14:49:36 +00:00
tests change(state): Insert only the first tree in each series of identical trees into finalized state (#7266) 2023-08-09 00:32:27 +00:00
arbitrary.rs change(state): Refactor the structure of verified blocks (#7025) 2023-06-21 16:58:11 +00:00
config.rs fix(db): use the correct state version for databases without a state version file (#7385) 2023-08-28 17:01:01 +00:00
constants.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
error.rs Replace a chain length assertion with a NotReadyToBeCommitted error (#7072) 2023-06-27 06:50:35 +00:00
lib.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
request.rs change(state): Refactor docs for `z_getsubtreesbyindex` RPC state requests (#7462) 2023-09-06 07:15:18 +00:00
response.rs change(state): Add state requests and support code for the `z_getsubtreesbyindex` RPC (#7408) 2023-09-03 22:18:41 +00:00
service.rs change(state): Add state requests and support code for the `z_getsubtreesbyindex` RPC (#7408) 2023-09-03 22:18:41 +00:00
tests.rs Fix the position of coinbase tx (#7217) 2023-07-15 16:24:51 +00:00