Commit graph

496 commits

Author SHA1 Message Date
Joseph Goulden
6d864a813c fix: split state validation status into kernel and rproof updates. (#3096)
* 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
2019-11-17 22:12:10 +01:00
Joseph Goulden
29b871841a fix: for TUI status try to acquire read lock on pmmr_header but if no… (#3119)
fix: for TUI status try to acquire read lock on pmmr_header but if not available just leave the header stats alone
2019-11-15 08:21:42 +01:00
Yeastplume
38e6497919
Retrieve outputs within a block height range (#3103)
* 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
2019-11-04 15:04:21 +00:00
Antioch Peverell
50ce7ba043
Refactor transaction building combinators (#3057)
* 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
2019-11-01 10:56:58 +00:00
Antioch Peverell
a362888ab9
read header_head and sync_head from the header and sync MMR respectively (#3045)
no need to maintain header_head and sync_head in the db explicitly
2019-10-29 16:47:08 +00:00
hashmap
1f5de6beb9
Verify headers and blocks only when needed (#3023)
* 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
2019-10-27 08:40:52 +01:00
Yeastplume
24cf75cead
update versioning to 3.0.0 alpha (#3080) 2019-10-04 10:51:55 +01:00
Antioch Peverell
b78ace8329
bump version to v2.1.0-beta.3 (#3075) 2019-10-03 10:36:54 +01:00
Quentin Le Sceller
6be6391225 Change 2018 to 2019 in copyright files (#3072) 2019-10-02 09:40:20 +01:00
Antioch Peverell
751ca06560
bump version number (#3066) 2019-09-30 10:58:49 +01:00
Antioch Peverell
fc4e2985d5
add block_hash to head_info so we can easily use them later (#3060) 2019-09-26 14:59:03 +01:00
Yeastplume
ae556a8a2a
change release versioning for 2.1.0 beta build (#3056) 2019-09-24 13:54:12 +01:00
Antioch Peverell
973a03c826
support for v2 txhashset (but only using v1 in mainnent and floonet) (#3051) 2019-09-24 09:57:34 +01:00
Antioch Peverell
1c072f535c
DB v1->v2 migration (#3044)
* wip

* exhaustive match

* wip

* cleanup docs and move migration fns to chain itself
2019-09-19 21:00:14 +01:00
Joseph Goulden
02cee80229 fix: Add some more stats to basic status page of TUI (disk usage, chain timestamp, tx pool size) (#3046)
* 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
2019-09-19 20:57:26 +01:00
Antioch Peverell
f3baceb51b
bump version for 2.1.0 dev (still on master) (#3050) 2019-09-19 15:03:44 +01:00
Quentin Le Sceller
b209244d17
Add sync_status in status Node API (#2966)
* Add sync_status in status Node API
2019-09-17 11:12:42 -04:00
hashmap
80a8f76c4c
Optimize Option to Error conversion (#3036)
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.
2019-09-10 14:38:36 +02:00
Gary Yu
7a07541c26
Clean the unused build_index (#3026) 2019-09-10 07:55:24 +08:00
Gary Yu
fa0fed9de5
fix: find common header between the header chain and the current body chain (#3033)
* fix: find common header between the header chain and the current body chain

* add some code comments
2019-09-10 07:54:42 +08:00
Antioch Peverell
383985292c Split header MMR (and sync MMR) out from txhashset (#3004)
* 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
2019-09-07 07:28:26 +08:00
Gary Yu
d55ebe8a2b fix: the race condition in compact (#3015) 2019-09-04 19:51:28 +01:00
Antioch Peverell
b291467b96 use head (not header_head) when rewinding full blocks (#3017)
* 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
2019-09-04 08:02:45 +08:00
Gary Yu
928279a676 schnorr signature batch verification (#2961)
* 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?
2019-09-03 15:44:10 +01:00
jaspervdm
30156cdcf9 Kernel lookup api method (#3000)
* 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
2019-08-30 10:03:12 +01:00
Gary Yu
d36a0b29ef store both mmr index and block height into database for output (#2903)
* 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
2019-08-29 17:14:39 +01:00
Antioch Peverell
357bc11746
Fix invalid root (#3005)
* use the correct (header) head for the header extension

* add test coverage for header first fork scenario
2019-08-29 10:15:41 +01:00
Antioch Peverell
dcd405e263
cleanup deprecation warnings about missing dyn with trait objects (#2997) 2019-08-26 21:17:47 +01:00
j01tz
d220410571 Improve error handling when computing PMMR roots (#2988)
* Improve error handling for invalid PMMR roots

* Update tests that rely on pmmr root

* Fix pmmr store tests
2019-08-09 15:10:54 +01:00
j01tz
ea1d14ddb0 Improve validation when processing orphan blocks (#2981) 2019-08-03 09:07:01 +01:00
Quentin Le Sceller
f79d05ba53 TxHashSet Download Improvement (#2984)
* 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
2019-08-01 17:46:06 +01:00
Antioch Peverell
515fa54614
Rewind head and header_head consistently. (#2918)
* 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
2019-07-26 08:36:24 +01:00
Joseph Goulden
2ae76d39bb fix: move checks for automated test mode into global.rs (#2956)
* fix: move checks for test/production mode into one place - global.rs

* chore: rustfmt
2019-07-25 10:08:24 +01:00
Quentin Le Sceller
38ddc32cf3
Move SyncStatus and SyncState to chain crate (#2964)
* Moved SyncState and SyncStatus to chain

* Rustfmt

* Fix typo in SyncError
2019-07-23 16:47:59 +02:00
Quentin Le Sceller
4966dc04f7
[2.x.x] Generate txhashset archives on 720 block intervals. (#2951)
Generate txhashset archives on 720 block intervals.
2019-07-23 10:46:29 +02:00
hashmap
d3dbafa80b
[2.x.x] Use blocking IO in P2P to reduce CPU load (#2855)
* Use blocking IO in P2P to reduce CPU load
2019-07-12 23:17:38 +02:00
Antioch Peverell
1395074a25
[2.x.x] simplify txhashset zip creation and extraction (#2908)
* 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
2019-07-12 10:50:27 +01:00
Joseph Goulden
3a4752635a fix: One less DB call when verifying block sums (#2945) 2019-07-12 10:47:04 +01:00
Antioch Peverell
2348214719
fix our check_known check for blocks/headers (#2943) 2019-07-11 17:08:36 +01:00
Antioch Peverell
d284d8f6de
[2.x.x] Writeable protocol version aware (#2856)
* 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
2019-07-06 15:51:03 +01:00
Antioch Peverell
b6daf1edfd
check for known robustly when processing header (#2834) 2019-07-04 12:30:22 +01:00
Antioch Peverell
5aaf2d058d
[2.x.x] deserialization now protocol version aware (#2824)
* 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
2019-06-27 17:19:41 +01:00
Yeastplume
9398578947
update version number 2019-06-25 15:43:46 +01:00
Yeastplume
71d16d1b4d
Update version number for next (potential) release 2019-06-18 21:17:48 +01:00
jaspervdm
e3f3064414 Support new Bulletproof rewind scheme (#2848)
* Update keychain with new rewind scheme

* Refactor: proof builder trait

* Update tests, cleanup

* rustfmt

* Move conversion of SwitchCommitmentType

* Add proof build trait to tx builders

* Cache hashes in proof builders

* Proof builder tests

* Add ViewKey struct

* Fix some warnings

* Zeroize proof builder secrets on drop
2019-06-12 10:28:55 +01:00
Yeastplume
75c229ba68
create 2.0.0 branch 2019-06-05 20:36:57 +01:00
Yeastplume
a89a1024b6
update version numbers for 1.1.0 release 2019-06-05 19:39:01 +01:00
eupn
249fe03d5c Remove needless lifetimes (#2845)
* Remove lifetimes that could be elided

* rustfmt
2019-05-25 17:13:36 +01:00
eupn
f17dd5fa44 Fix warnings in tests (#2846) 2019-05-25 17:13:09 +01:00
eupn
a2a350dac7 txhashset: remove unnecessary mutability from self references in getters (#2844)
* txhashset.rs: make self references immutable in getters

* rustfmt
2019-05-25 17:12:32 +01:00