Skip to content

keep all data needed for btc finality in one table#519

Merged
ClaytonNorthey92 merged 9 commits intomainfrom
clayton/constant-finality-lookup
May 28, 2025
Merged

keep all data needed for btc finality in one table#519
ClaytonNorthey92 merged 9 commits intomainfrom
clayton/constant-finality-lookup

Conversation

@ClaytonNorthey92
Copy link
Copy Markdown
Contributor

@ClaytonNorthey92 ClaytonNorthey92 commented May 24, 2025

Summary
prior, we were calculating finality at request/query-time. this is a relatively-expensive (and complex) calculation.

Changes
now, store the "lowest btc block height" in the l2_keystones table. this allows us to return finality with no joins at request/query-time. this is all done during bitcoin block processing.

our finality lookup for a keystone is, for lack of a better term, now "constant-time" lookup. as the l2_keystone_abrev_hash is indexed (and that's our lookup key).

@github-actions github-actions bot added the area: bfg This is a change to BFG (Bitcoin Finality Governor) label May 24, 2025
@ClaytonNorthey92 ClaytonNorthey92 changed the title checkpoint Constant Time BTC Finality Lookup May 24, 2025
prior, we were calculating finality at request/query-time.  this is a relatively-expensive (and complex) calculation. now, store the "lowest btc block height" in the l2_keystones table.  this allows us to return finality with no joins at request/query-time.  this is all done during bitcoin block processing.

our finality lookup for a keystone is, for lack of a better term, now "constant-time" lookup. as the l2_keystone_abrev_hash is indexed (and that's our lookup key).
@ClaytonNorthey92 ClaytonNorthey92 force-pushed the clayton/constant-finality-lookup branch from a8ac33a to b0c64ca Compare May 27, 2025 12:42
@ClaytonNorthey92 ClaytonNorthey92 changed the title Constant Time BTC Finality Lookup keep all data needed for btc finality in one table; "constant-time" lookup May 27, 2025
@ClaytonNorthey92 ClaytonNorthey92 changed the title keep all data needed for btc finality in one table; "constant-time" lookup keep all data needed for btc finality in one table May 27, 2025
@ClaytonNorthey92 ClaytonNorthey92 marked this pull request as ready for review May 27, 2025 13:02
@ClaytonNorthey92 ClaytonNorthey92 requested a review from a team as a code owner May 27, 2025 13:02
@ClaytonNorthey92 ClaytonNorthey92 marked this pull request as draft May 27, 2025 13:11
@ClaytonNorthey92 ClaytonNorthey92 marked this pull request as ready for review May 27, 2025 13:54
log.Tracef("BtcBlockUpdateKeystones")
defer log.Tracef("BtcBlockUpdateKeystones exit")

// give me all distinct l2 block numbers mined to this btc block
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"distinct l2 keystone abrev hashes"

Copy link
Copy Markdown
Contributor

@AL-CT AL-CT left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
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 0a4044e into main May 28, 2025
12 checks passed
@ClaytonNorthey92 ClaytonNorthey92 deleted the clayton/constant-finality-lookup branch May 28, 2025 19:14
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