Commit Graph

6 Commits

Author SHA1 Message Date
teor e49c1d7034
feat(state): add transparent address indexes to the non-finalized state (#4022)
* Derive Hash for transparent address index types

* Expose some types used by transparent address indexes

* Add an empty transparent transfers type for transparent address indexes

* Update TransparentTransfers with created UTXOs

* Add spent transparent outputs to ContextuallyValidBlock

* Update TransparentTransfers with spent transparent outputs

* Ignore missing spent outputs, so that tests pass

* Remove empty TransparentTransfers after a spend revert

* Update TransparentTransfers with creating and spending transaction IDs

* Ignore duplicate created UTXOs, so that tests pass

* Add some TODO comments

* Remove accidental doctest formatting

* Add address transfers index accessor methods

* Use TransactionLocation in the non-finalized state

* Apply more address index assertions to production code

* Refactor deeply nested code and apply more assertions

* Return UTXOs in chain order

* Return transaction hashes in chain order

* Stop indexing each transparent output multiple times

* Run some more asserts during tests

* Tidy TODO comments

* Fix an incorrect assert condition

* Use OrderedUtxos so that spent UTXOs can be stored in chain order

* Update tests to use OrderedUtxos

* Update the index API for the getaddressutxos query

* Remove redundant arguments in tests

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-12 17:21:46 +00:00
teor 20429b5efa
7. change(db): Use smaller keys for height and transaction indexes (#3874)
* Increment the database format version

* Update IntoDisk and FromDisk docs

* Rename fixed_byte_len to fixed_disk_byte_len

* Add functions that truncate and extend serialized bytes

* Store heights in 3 bytes on disk

* Update database raw data snapshots for 3-byte heights

* Log an error if we ever get close to the maximum disk height

* Store transaction indexes in 2 bytes on disk

* Update database raw data snapshots for 2-byte transaction indexes

* Make doc comment phrasing consistent

* Replace IntoDiskFixed with fixed constants

* Replace u32 byte length literal with a constant calculation

* Fix off-by-one error in MAX_ON_DISK_HEIGHT

* Add proptest seeds for the MAX_ON_DISK_HEIGHT off-by-one error

* Remove redundant module from a Height type

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-03-22 06:19:50 +00:00
teor 081cda7990
3. refactor(db): add disk serialization types for transactions (#3741)
* refactor(db): simplify block height serialization

* refactor(db): make height serialization length generic

* refactor(db): create a TransactionIndex type

This changes the names of some snapshot types,
but doesn't change any data.

* refactor(db): create transparent OutputIndex and OutputLocation types

This keeps the same serialization, to avoid changing the database version.

* doc(rfc/db): make transparent database type names consistent

* doc(rfc/db): fix a bug in the Utxo.is_coinbase derivation

* fix(db): use the correct serialized size for OutputLocation
2022-03-09 01:22:00 +00:00
teor 0f5eced5c7
Reject duplicate sprout nullifiers in the state (#2477)
* Reject duplicate sprout nullifiers in the state

* Improve docs and error messages

* Clarify "must be present" assert logs

* Move nullifier checks to their own module

Also:
* make non-finalized nullifier checks and errors generic over
  sprout, sapling, and orchard
* create and update module and function documentation

* Fix a block type name in docs

* Move state assertions or skip them during tests

These changes enable state testing, while still asserting in production.

* Add sprout duplicate nullifier tests

* Improve comments

* Set value balance to 0 to pass future chain value pool checks

* Test finalized state in sprout nullifier accept test

* Replace assert with expect

* Improve assertion messages
2021-07-14 09:06:43 -03:00
teor 936168b40d
Fix failing legacy chain tests (#2427)
* Skip invalid legacy chain check test cases

Add proptest seeds for the failing test.
And improve some unclear documentation.

* Fix the legacy chain test blocks order

Also fix unclear documentation that might have led to this bug.
2021-07-02 09:21:22 +10:00
teor 55e398c10a
Stop generating V1-V3 transactions for non-finalized state proptests (#2159)
These transactions cause a test panic in `UpdateWith`, in the rare cases
where the test gets that far.
2021-05-19 18:53:44 -04:00