zebra icon indicating copy to clipboard operation
zebra copied to clipboard

fix(consensus): Update `median_timespan()` method to align with zcashd implementation

Open arya2 opened this issue 2 months ago • 1 comments

Motivation

This PR fixes a minor mistake in the median_timespan() method below block height 28. The bug does not affect checkpoint validation, and does not affect Mainnet or the default Testnet because Zebra requires checkpoint verification until well past block height 28 for those networks.

https://github.com/zcash/zcash/blob/master/src/pow.cpp#L47-L84

Depends-On: #8475.

PR Author Checklist

Check before marking the PR as ready for review:

  • [x] Will the PR name make sense to users?
  • [x] Does the PR have a priority label?
  • [x] Have you added or updated tests?
  • [x] Is the documentation up to date?
For significant changes:
  • [x] Is there a summary in the CHANGELOG?
  • [x] Can these changes be split into multiple PRs?

If a checkbox isn't relevant to the PR, mark it as done.

Specifications

Section 7.7.3, page 132 of the specification

Solution

Use the MedianTime of the genesis block as the older_median if there are fewer than PoWAveragingWindow blocks in the relevant chain.

Other changes:

  • Fixes a typo in dependabot in this PR so CI passes.

Review

Anyone can review, @upbqdn may be interested.

Reviewer Checklist

Check before approving the PR:

  • [ ] Does the PR scope match the ticket?
  • [ ] Are there enough tests to make sure it works? Do the tests cover the PR motivation?
  • [ ] Are all the PR blockers dealt with? PR blockers can be dealt with in new tickets or PRs.

And check the PR Author checklist is complete.

arya2 avatar May 02 '24 16:05 arya2

@arya, this PR needs a manual conflict resolution.

upbqdn avatar May 02 '24 20:05 upbqdn