Skip to content

Commit

Permalink
Fix: don't overflow on target adjustment (#76)
Browse files Browse the repository at this point in the history
* don't panic on overflow

* update wasm

* change u64 cast
  • Loading branch information
olga24912 authored Nov 26, 2024
1 parent 6bb84f8 commit 1ee8047
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,9 @@ impl BtcLightClient {
.headers_pool
.get(&interval_tail_header_hash)
.unwrap_or_else(|| env::panic_str(ERR_KEY_NOT_EXIST));
let prev_block_time = prev_block_header.block_header.time;
let mut actual_time_taken = u64::from(
prev_block_header.block_header.time - interval_tail_extend_header.block_header.time,
prev_block_time.saturating_sub(interval_tail_extend_header.block_header.time),
);

if actual_time_taken < EXPECTED_TIME / MAX_ADJUSTMENT_FACTOR {
Expand Down
Binary file modified res/btc_light_client_mainnet.wasm
Binary file not shown.
Binary file modified res/btc_light_client_testnet.wasm
Binary file not shown.

0 comments on commit 1ee8047

Please sign in to comment.