* Refactor SyncState
Method sync_error() retrun type was simplified.
update_txhashset_download() was made type safe, which eliminates a runtime enum variant's check, added an atomic status update
* Node API: don't error on missing output
* Propagate errors from get_output*
* Rename is_unspent and small refactor
* Forgot to rename function in tests
* Change Batch get_output_pos_height type signature
* no need to rehash with index to compare output with input spending it
* compare output identifier when checking is_unspent()
* output identifier from cleanup
* first pass at rewind_single_block
and reworking rewind to simply iterate over blocks, rewinding each incrementally
* commit
* commit
* cleanup
* add test coverage for output_pos index transactional semantics during rewind
* commit
* do not store commitments in spent_index
just use the order of the inputs in the block
* compare key with commitment when cleaning output_pos index
* remove unused OutputPos struct
* no need for AsFixedBytes we can just use AsRef<[u8]>
* cleanup FixedLength trait
* revert this change for now
* fix store tests
* cleanup and fix tests after rebase
* fix tests
* update based on PR review
less hard-coded values now
* cleanup
* Refactor to pass batch around explicitly rather than keeping it in the extension.
We would like to be able to pass an extension around and potentially clone it.
* cleanup, pass header around where it makes sense
* Node API v2
* Update gitignore
* Add get_pmmr_indices method
* Add Foreign and Owner API each one with specific secret
* Fix failing tests
* Revert to 'Option<u64>'
* add bitmap accumulator
refactor vec backend so we can use it outside of tests
introduce a "hash only" vec backend for the accumulator
* get core tests passing
* initial test coverage for bitmap_accumulator
* better test coverage for bitmap accumulator and cleanup code
* refactor txhashset roots, call validate() on roots during block validation
* fix store tests
* log the "merged" root when validating roots
* cleanup, revise based on feedback
* cleanup
* rework it to pass explicit size into bitmap accumulator when applying
* fix: split state validation status into kernel and rproof updates. And fix sync status for these two states
* fix: show correct number of leaves for pruned MMR as well as unpruned
* docs: better docs for kernel/range proof validation
* fix: ordering of kernel and rproofs validation in TUI
* fix: typo in rangeproofs api and comments
* add function to retrieve a set of pmmr indices between a given block height range
* typo
* change APU to just return required indices
* change pmmr index retrieval, change new function to only return pmmr indices between blocks
* tx combinators now take operate on Result to allow for more robust errors handling
replace with_fee() and with_lock_height() with a more flexible with_features()
* pass kernel features in as arg to build::transaction()
* fix chain tests
* fix pool tests
* do not pass kernel around in the combinators
just set it once on the tx when building
* build::partial_transaction now takes a existing tx to build on
* Verify headers and blocks only when needed
Curretnly we have some lightweigt validation implemented as part of
entity deserialization, which is safer and allows us to not parse the
entire object if some part is invalid. At the same time this logic
always applies when we read an entity, eg when reading from DB.
This PR introduces UntrustedHeader/Block which is used when we read from
the network. It does partial validation during read, then it is supposed
to be converted into regular header/block which doesn't validate itself.
Also this PR adds "lightweight" validation to block header read like we have
for block body, so we don't parse block body if the header is invalid.
Fixes#1642
* Move version validation to untrusted header
* update fuzz tests
* fix: Add some more stats to basic status page of TUI (disk usage, chain timestamp, tx pool size)
* chore: add latest header timestamp to TUI
* fix: calculate total disk usage of database to show in TUI
To convert option to error we generate an error message. In some places
it contains header or block hash code or other data which is costly to
produce. So during the initial header sync we spend 12% of all time on
generating those messages (in 99% cases we don't use it). This PR
introduces a lazy generation of error messages which completely
eliminates CPU load during the header sync.
* wip
* sync sort of works now
* get rid of the deadlock during compaction
there is *always* a deadlock in there when we make changes like this...
* cleanup how we rebuild the sync MMR on init
* cleanup rewind logic
* roll the "fix invalid root" changes into this PR
* move rebuild_height_pos_index into txhashset
and pass in header_pmmr for header lookups
* cleanup and remember to setup sync head on init
* cleanup unnecessary ref muts
* rebuild_height_pos_index when writing txhashset
* use head (not header_head) when rewinding to find fork point for full blocks
* get rid of shortcut when nothing to rewind - always something to rewind
* schnorr signature batch verification
* Split the fee and lock_height verification out from the batch signature verification
* Remove the new added fee_height_verify to comply with #2859
* fix: the last n could not be leaf?
* Kernel lookup api
* Min and max height parameters, scan backwards
* Return null instead of 404 if kernel not found
* Return TxKernel instead of TxKernelPrintable
* Update description of KernelHandler
* store both mmr index and block height into database for output
* rustfmt
* fix: mmr position is 1-based instead of 0-based
* (Hash, u64, u64) deserves a type
* Ban on cannot get block header in txhashset_write
* Rusfmt
* Fix typo
* Missing error handling
* Rustfmt
* Only accept txhashset from corresponding peer
* Switch to AtomicBool instead of RwLock<bool>
* Rustfmt
* maintain header_head as distinctly separate from head
* cleanup corrupted storage log msg
* simplify process_header and check_header_known
* remember to commit the batch when successfully processing a header...
* rework sync_block_headers for consistency with process_block_header
* cleanup unrelated code
* fix pool tests
* cleanup chain tests
* cleanup chain tests (reuse helpers more)
* cleanup - head not header on an extension
shortcircuit "rewind and apply fork" for headers if next header
* simplify how we extract files from the txhashset zip archive
* bump version of zip-rs
cleanup create_zip (was compress)
use explicit list of files when creating zip archive
* rework zip tests for our simplified impl
* periodic debug during txhashset download
* rework list_files to return something usable
* introduce protocol version to deserialize and read
* thread protocol version through our reader
* cleanup
* cleanup
* streaming_reader cleanup
* Pass protocol version into BinWriter to allow for version specific serialization rules.
* rustfmt
* read and write now protocol version specific
* introduce protocol version to deserialize and read
* thread protocol version through our reader
* example protocol version access in kernel read
* fix our StreamingReader impl (WouldBlock woes)
* debug log progress of txhashset download
* Calculate reorg depth in BlockStatus::Reorg enum member
* rustfmt
* Fix reorg height calculation and implement reorg test
* rustfmt
* Report reorg depth in webhook payload
* Add optional depth field to the block webhook JSON reply
* fix: try to fix issue #2585 by adding block cleanup from db directly.
Signed-off-by: Mike Tang <daogangtang@gmail.com>
* use another effective algorithm to do old block and short-lived block cleaup.
Signed-off-by: Mike Tang <daogangtang@gmail.com>
* 1. rename iter_lived_blocks to blocks_iter;
2. comments and iterator calling optimiztions.
Signed-off-by: Mike Tang <daogangtang@gmail.com>
* Fix locking bug when calling is_on_current_chain() in batch.blocks_iter just by removing it.
Because "we want to delete block older (i.e. lower height) than tail.height".
Signed-off-by: Mike Tang <daogangtang@gmail.com>
* introduce HeaderVersion (was u16) for type safety
cleanup pow ser/deser (version unused)
* fixup tests for HeaderVersion
* validate header version during header deserialization