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

[Mar 27 Backport] Theoretical Hotfix for testnet3 branch #2417

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions ledger/block/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,8 @@ impl<N: Network> Block<N> {
let height = self.height();
let timestamp = self.timestamp();

let (combined_proof_target, expected_cumulative_proof_target, is_coinbase_target_reached) = match &self
.solutions
{
// Compute the combined proof target and the cumulative proof target.
let (combined_proof_target, cumulative_proof_target) = match &self.solutions {
Some(coinbase) => {
// Ensure the number of solutions is within the allowed range.
ensure!(
Expand Down Expand Up @@ -306,26 +305,27 @@ impl<N: Network> Block<N> {
// Compute the actual cumulative proof target (which can exceed the coinbase target).
let cumulative_proof_target =
previous_block.cumulative_proof_target().saturating_add(combined_proof_target);
// Determine if the coinbase target is reached.
let is_coinbase_target_reached = cumulative_proof_target >= previous_block.coinbase_target() as u128;
// Compute the block cumulative proof target (which cannot exceed the coinbase target).
let expected_cumulative_proof_target = match is_coinbase_target_reached {
true => 0u128,
false => cumulative_proof_target,
};

(combined_proof_target, expected_cumulative_proof_target, is_coinbase_target_reached)

(combined_proof_target, cumulative_proof_target)
}
None => {
// Set the combined proof target.
let combined_proof_target = 0;
// Determine the cumulative proof target.
let expected_cumulative_proof_target = previous_block.cumulative_proof_target();
let cumulative_proof_target = previous_block.cumulative_proof_target();

(combined_proof_target, expected_cumulative_proof_target, false)
(combined_proof_target, cumulative_proof_target)
}
};

// Determine if the coinbase target is reached.
let is_coinbase_target_reached = cumulative_proof_target >= previous_block.coinbase_target() as u128;
// Compute the block cumulative proof target (which cannot exceed the coinbase target).
let expected_cumulative_proof_target = match is_coinbase_target_reached {
true => 0u128,
false => cumulative_proof_target,
};

// Compute the expected cumulative weight.
let expected_cumulative_weight = previous_block.cumulative_weight().saturating_add(combined_proof_target);

Expand Down