Commit Graph

13 Commits

Author SHA1 Message Date
Za Wilcox 3bef54b764
change(consensus): Refactor production code for network consensus rules to `Network` methods (#8340)
* begin refactor suggested as "step 2": https://github.com/ZcashFoundation/zebra/issues/7968#issue-2003245309
Squashed from multiple commits to enable partial rebase

* break out more little traits

* add activation implementation leveraging From<Network> for lrz::cons::

* for transfer of ownership I cannot return a type that's owned by the method

* hrp_sapling_extended_full_viewing_key

* complete implementation of interface of Parameters on Network reuse Parameters on zcash Network where possible

* move doc-comments to trait declarations (from impls)

* Simplify/complete Parameters impl for Network

* Add checkpoint_list method, move documentation, etc

* move last match network to inside network method

* add back comment

* use zcash_address for parameter types in zebra-chain

* use inherent methods instead of big parameters passthrough

* revert to implementation of From on zcash_primitives::..::Network vs &zcash_prim...

* move match

* add test to block maximum time rule

* update changelog

* finish porting target_difficutly_limit

* remove obscelete code comment

* revert non-functional change

* finish migrating target_difficulty_limit, checkpoint_list

* update changelog

---------

Co-authored-by: Hazel OHearn <gygaxis@zingolabs.org>
2024-03-12 21:41:44 +00:00
teor af82a76d18
cleanup(clippy): Remove unnecessary `try_into()` with `cargo clippy --fix` (#7940)
* Remove unnecessary try_into() with cargo clippy --fix

* Manually remove some unnecessary try_from()s

* impl From<Diversifier> for pallas::Affine instead of TryFrom

* Remove unused imports

* cargo fmt --all

* Remove redundant comma
2023-11-14 20:31:49 +00:00
Marek 2a48d4cf25
change(chain): Refactor the handling of height differences (#6330)
* Unify the `impl`s of `Sub` and `Add` for `Height`

* Adjust tests for `Height` subtraction

* Use `Height` instead of `i32`

* Use `block:Height` in RPC tests

* Use `let .. else` statement

Co-authored-by: Arya <aryasolhi@gmail.com>

* Update zebra-consensus/src/block/subsidy/general.rs

* Refactor the handling of height differences

* Remove a redundant comment

* Update zebrad/src/components/sync/progress.rs

Co-authored-by: Arya <aryasolhi@gmail.com>

* Update progress.rs

* impl TryFrom<u32> for Height

* Make some test assertions clearer

* Refactor estimate_up_to()

* Restore a comment that was accidentally removed

* Document when estimate_distance_to_network_chain_tip() returns None

* Change HeightDiff to i64 and make Height.sub(Height) return HeightDiff (no Option)

* Update chain tip estimates for HeightDiff i64

* Update subsidy for HeightDiff i64

* Fix some height calculation test edge cases

* Fix the funding stream interval calculation

---------

Co-authored-by: Arya <aryasolhi@gmail.com>
Co-authored-by: teor <teor@riseup.net>
2023-03-29 23:06:31 +00:00
teor ea64585c62
Refactor block subsidy to handle Height::MAX without panicking (#5787) 2022-12-13 00:59:52 +00:00
teor 7e13677197
change(rpc): generate coinbase transactions in the getblocktemplate RPC (#5580)
* Add a getblocktemplate-rpcs feature to zebra-chain, and fix missing feature deps

* Add a coinbase transaction creation stub

* Add coinbase creation to zebra-chain

* Add coinbase creation and miner subsidy to zebra-consensus

* Add the miner config to the GetBlockTemplateRpcImpl

* Generate the coinbase transaction in the getblocktemplate RPC

* Provide fake valid block heights to getblocktemplate RPC tests

* Update getblocktemplate RPC snapshots

* Add a getblocktemplate.coinbase_tx deserialized transaction snapshot test

* Update snapshots

* Return funding stream outputs in the same order every time

* Update snapshots

* Fix a script bytes bug

* Update snapshots
2022-11-10 00:12:27 +00:00
Conrado Gouvea 6fd750e168
build(deps): bump insta from 1.15.0 to 1.17.1 (#4884)
* build(deps): bump insta from 1.15.0 to 1.17.1

Bumps [insta](https://github.com/mitsuhiko/insta) from 1.15.0 to 1.17.1.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.15.0...1.17.1)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* make zebra_test::init() return the insta drop guard

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-08-04 15:44:44 +00:00
Alfredo Garcia 6821ba9791
remove founders reward code (#3430)
* remove founders reward code

* panic if a block before Canopy is validated for subsidy

Co-Authored-By: Daira Hopwood <daira@jacaranda.org>

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-01-28 19:14:46 -03:00
Alfredo Garcia a61eae0065
Validate miner transaction fees (#3067)
* validate consensus rule: negative fee not allowed

* fix a test TODO

* fix imports

* move import back

* fix panic text

* join consensus rule check code

* match assertion better in tests

* fix test

* fix consensus rule validation

* remove panics

* Delete a TODO

Co-authored-by: teor <teor@riseup.net>
2021-11-24 03:36:17 +00:00
Alfredo Garcia d321e8f0cf
Validate funding stream addresses (#3040)
* validate funding stream addresses

* simplify a bit funder stream address check

* add integer division code comment

* document constant

* replace some unwraps

* fix some doc comments

* check at least one output has calculated address and amount

* create a convinient storage for funding stream addresses

* replace some unwraps

* docs: change `7.7` protocol sections to `7.8`

* change errors text

* change function name

* refactor `FundingStreamReceiver::receivers()`

* refactor FUNDING_STREAM_ADDRESSES

Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>

* remove a `clone()`

Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>

* fix consensus rule check

* use a constant for testnet first halving height

Co-authored-by: teor <teor@riseup.net>

Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
Co-authored-by: teor <teor@riseup.net>
2021-11-12 15:20:31 -03:00
Alfredo Garcia 62bfa15e96
Validate funding stream amounts in coinbase transaction (#3017)
* validate funding stream amounts in the coinbase

* clippy

* use `i64::from()` and remove `number()` method from `Amount`

* move tests to their own file

* refactor the funding stream check

* use `Amount`s in funding streams calculation

* remove unused import

* add import to tests

* expand test vectors

* add notes to `funding_stream_values()`
2021-11-08 22:33:12 +00:00
teor 873127aac1 Replace smart quotes with ascii quotes
Some tools don't deal well with unicode text. And we're not using it
consistently in Zebra anyway.
2021-03-15 03:18:10 -04:00
Alfredo Garcia 128643d81e
Call `zebra_test::init` where needed. (#1227)
* Add missing `zebra_test::init()` to zebra-chain
* Add missing `zebra_test::init()` to zebra-consensus
* Add missing `zebra_test::init()` to zebra-network
* Add missing `zebra_test::init()` to zebra-state
* Add missing `zebra_test::init()` to zebra-test
* Add missing `zebra_test::init()` to zebrad
2020-11-10 10:29:25 +10:00
Alfredo Garcia c93f0b3a2e
Block Subsidy and Founders Reward Amounts (#1051)
* add general and founders reward subsidy modules
* validate founders reward
* Use funding streams after Canopy on testnet
ZIP-1014 only applies to mainnet, where Canopy is at the first halving.
On testnet, Canopy is before the first halving, and the dev fund rules
apply from Canopy. (See ZIP-214.)
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Jane Lusby <jlusby42@gmail.com>

* pass all test vectors through current subsidy validation
* Add testnet and halving subsidy tests
* add subsidy validation error tests

* rename block validation methods
* add network to block verifier

* add amount operators
* Implement Ord, Eq, and Hash for Amount
* Implement Add<Height> for Height
And make the existing Height operators do range checks.
* Apply operator suggestions
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-10-13 06:54:48 +10:00