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

bound height to 100 from canonical tip as to not have to scan large portion of index #254

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

ClaytonNorthey92
Copy link
Contributor

@ClaytonNorthey92 ClaytonNorthey92 commented Sep 11, 2024

Summary
When getting the "effective height", we were not bounding the possible heights, this causes the query to scan over an entire index until it finds a height that is satisfactory to the rest of the query.

We use "effective height" in our "finality" calculation:

Finality = Min(100, (Canonical Tip Height - Effective Height - 9 + 1))

Since Finality cannot be more than 100, it is futile to look for an effective height that would be >= 100 blocks from the tip.

So we should only be concerned with effective heights >= tip - 100.

Changes
Bound the effective height calculation to 100 blocks from the tip to ensure that we don't scan over needless parts of the height index.

Important Note: if no results are returned, then the effective height gets "coalesced" to 0 which would result in and effective height of 0, and thus a finality of 100, which is expected.

@ClaytonNorthey92 ClaytonNorthey92 requested a review from a team as a code owner September 11, 2024 14:25
@github-actions github-actions bot added the area: bfg This is a change to BFG (Bitcoin Finality Governor) label Sep 11, 2024
Copy link
Contributor

@jcvernaleo jcvernaleo left a comment

Choose a reason for hiding this comment

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

OK

@ClaytonNorthey92 ClaytonNorthey92 merged commit b10557b into main Sep 11, 2024
6 checks passed
@ClaytonNorthey92 ClaytonNorthey92 deleted the clayton/smaller-scan branch September 11, 2024 16:07
web3cryptoguy pushed a commit to web3cryptoguy/heminetwork that referenced this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: bfg This is a change to BFG (Bitcoin Finality Governor)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants