Skip to content

Conversation

@karim-en
Copy link
Collaborator

@karim-en karim-en commented Jul 10, 2025

Added timestamp and version checks for Bitcoin, Litecoin, Zcash.
The extrta dogecoin cehck should be added in #116

@karim-en karim-en changed the base branch from main to develop July 10, 2025 13:27
@karim-en karim-en requested a review from a team July 10, 2025 13:27
@karim-en karim-en marked this pull request as ready for review July 14, 2025 23:09

// Reject blocks with outdated version
require!(
block_header.version >= 4,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should also reject future versions as an additional safeguard in case we don't update the light client in time?
However, this line matches the reference

use crate::u256::U256;

pub const ZCASH_MEDIAN_TIME_SPAN: usize = 11;
pub const MEDIAN_TIME_SPAN: usize = 11;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add links to the places where these constants are taken from?

* Maximum amount of time that a block timestamp is allowed to be ahead of the
* current local time.
*/
pub const MAX_FUTURE_BLOCK_TIME_LOCAL: u32 = 2 * 60 * 60;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add to the variable name that this is in SEC?

) -> u32 {
use btc_types::network::ZCASH_MEDIAN_TIME_SPAN;

if let Some(pow_allow_min_difficulty_blocks_after_height) =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have require checks further down that weren’t triggered before, but now, after moving the code to the end, they might start triggering. Do we want them to trigger?

@karim-en karim-en merged commit 4deb7a3 into develop Aug 20, 2025
6 of 8 checks passed
karim-en added a commit that referenced this pull request Aug 20, 2025
* Zcash: add timestamps verification

* Remove irrelevant comment

* Fix error message

* Fix typo

* Add timestamp & version verification for bitcoin

* litecoin: add timestamp verification

* Align error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants