Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: overflow in calculate_next_target to match Bitcoin Core #24

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

EthanYuan
Copy link
Collaborator

@EthanYuan EthanYuan commented Nov 4, 2024

Converted start_time and end_time to i64 for safe subtraction, avoiding overflow in nActualTimespan. Ensures consistency with Bitcoin Core’s difficulty adjustment logic CalculateNextWorkRequired(..) in Bitcoin source code.

service side log:

[2024-11-04T08:30:10Z INFO  ckb_bitcoin_spv_service::cli::serve] Try to update SPV instance
thread 'main' panicked at /usr/local/cargo/git/checkouts/ckb-bitcoin-spv-984d49c27aa7958d/bfc71d7/verifier/src/utilities/bitcoin.rs:25:26:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@EthanYuan EthanYuan requested review from jjyr and Flouse November 4, 2024 17:17
@EthanYuan EthanYuan added this pull request to the merge queue Nov 5, 2024
Merged via the queue into utxostack:master with commit 6c3f3d1 Nov 5, 2024
5 checks passed
@EthanYuan EthanYuan deleted the fix-calculate-next-target branch November 5, 2024 03:58
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.

2 participants