Skip to content

Conversation

@raychu86
Copy link
Collaborator

Motivation

This PR unifies the target calculations in both Ledger::construct_block_template and Block::verify_solutions into a singular to_next_targets helper method. Previously the two implementations were disjoint and could lead to differences in expected value. The unified helper method reduces the possibility of error and makes it easier to update if there are changes in the future.

Test Plan

The use of a helper method also allows us to test the expected behavior outside the monolith of block production. Tests have been added to check that the expected values based on hitting/missing the target threshold are correct.

This PR is based on and merges into #2410.

Base automatically changed from update/is-coinbase-target-is-met to mainnet-staging April 2, 2024 16:29
@howardwu howardwu merged commit 925b3ca into mainnet-staging Apr 2, 2024
@howardwu howardwu deleted the unify-target-calculations branch April 2, 2024 16:29
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