Commit Graph

21 Commits

Author SHA1 Message Date
Alfredo Garcia c0a14ecc8c
move genesis parameters to zebra-chain (#1151) 2020-10-12 14:08:23 -07:00
Alfredo Garcia c616c7ffd2
Move consensus verification errors (#1070)
* refactor block and tx validation errors

* rename errors module to error

* move NoTransactions to BlockError

* clarify some errors, use dbg format for hash in error

* mnake is_coinbase_first return BlockError

* add new error types for each consensus Service

Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-09-21 11:54:06 -07:00
Henry de Valence 6dd7c6495b consensus: make ChainVerifier a router
Instead of conditionally parsing the hardcoded checkpoint list and
optionally making a CheckpointVerifier, make one unconditionally, and
use the config settings to decide whether to route responses to it.

Then, fix up all of the places needed to make it compile and remove all
of the dead code.
2020-09-11 13:37:49 -07:00
teor 78201b456d feature: Implement checkpoint_sync for checkpoint verification
* add CheckpointList::new_up_to(limit: NetworkUpgrade)
* if checkpoint_sync is false, limit checkpoints to Sapling
* update tests for CheckpointList and chain::init
2020-08-24 15:34:46 +10:00
Henry de Valence 103b663c40 chain: rename BlockHeight to block::Height 2020-08-17 11:46:34 -07:00
Henry de Valence 61dea90e2f chain: rename BlockHeaderHash to block::Hash
This is the first in a sequence of changes that change the block:: items
to not include Block as a prefix in their name, in accordance with the
Rust API guidelines.
2020-08-17 11:46:34 -07:00
Henry de Valence 948b067808 chain: move Network, NetworkUpgrade to parameters
Also, avoid using star-imports of the enum variants, which pollutes the
namespace.
2020-08-17 11:46:34 -07:00
Henry de Valence dad6340cd3 chain: move BlockHeight into block 2020-08-17 11:46:34 -07:00
teor e74ff18708 refactor: Move the checkpoint list tests to their own file 2020-07-31 07:21:43 +10:00
teor 5b9703f95a fix: Avoid creating a CheckpointVerifier if it is not needed
Also:
* make sure the checkpoints cover all pre-Sapling blocks
* do some minor refactoring to reduce duplicate code
2020-07-30 13:30:18 +10:00
teor 359febb2e2 doc: Update a CheckpointList comment 2020-07-23 15:52:18 +10:00
teor b8b1239ac4 feature: Implement a basic ChainVerifier service
The ChainVerifier service chooses between CheckpointVerifier and
BlockVerifier, based on the block's height.
2020-07-22 12:51:19 +10:00
teor f1a0036824 feature: Expect the hard-coded checkpoint lists to parse 2020-07-22 12:51:19 +10:00
teor 1b0c0f027f
Add Hard-Coded Checkpoint Lists (#674)
* Add checkpoint list generation scripts
* Limit the checkpoint block data size
* Limit the checkpoint height gap
* Add Mainnet and Testnet checkpoint lists
* Parse hard-coded checkpoint lists

The lists were generated using the following limits:
- 256 MB spacing, based on block byte size, and
- 2000 blocks.
2020-07-21 23:11:51 +10:00
teor c13907d1af fix: Combine two matches 2020-07-16 10:06:29 -07:00
teor 39e67c8748 feature: Check the genesis hash in checkpoint lists
And use the consensus parameters to get the genesis previous block hash.
2020-07-16 10:06:29 -07:00
teor 1915634d2b
Check for bad heights or hashes in checkpoint lists (#639)
* Add MIN and MAX for BlockHeight and LockTime
* Remove duplicate test cases
* fix a comment about the minimum lock time

The minimum LockTime::Time is 5 November 1985 00:53:20 UTC, so the first
day that only contains valid times is 6 November 1985 (in all timezones).

Similarly, the maximum LockTime::Time is 7 February 2106 06::28::15 UTC,
so the last day that only contains valid times in all time zones is
5 February 2106.

* fix: Reject checkpoint lists with bad hashes or heights

Reject the all-zeroes hash, because it is the parent hash of the genesis
block, and should never appear in a checkpoint list.

Reject checkpoint heights that are greater than the maximum block
height.
2020-07-16 15:09:22 +10:00
Jane Lusby 72ec79dd5e Update zebra-consensus/src/checkpoint/list.rs
Co-authored-by: Alfredo Garcia <oxarbitrage@gmail.com>
2020-07-15 09:16:54 -07:00
teor e58c913897 refactor: Make max_height call max_height_in_range
Closes #630.
2020-07-15 09:16:54 -07:00
teor 870a0be928 fix: Make sure checkpoint heights and hashes are unique
Previously, CheckpointList would silently ignore duplicate heights or
hashes.

Closes #632.
2020-07-10 10:53:32 -07:00
teor 8b5ec155f0
Consensus refactor (#629)
* Flatten consensus::verify::* to consensus::*
* Move consensus::*::tests into their own files
* Move CheckpointList into its own file
* Move Progress and Target into a types module

QueuedBlock and QueuedBlockList can stay in checkpoint.rs, because
they are tightly coupled to CheckpointVerifier.
2020-07-10 16:51:01 +10:00