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

feat: add index for stacks block id in nakamoto_block_headers #5414

Merged
merged 5 commits into from
Nov 2, 2024

Conversation

kantai
Copy link
Member

@kantai kantai commented Nov 1, 2024

Description

Optimization: add index for index_block_hash in nakamoto_block_headers

@kantai kantai requested a review from a team as a code owner November 1, 2024 18:37
hstove
hstove previously approved these changes Nov 1, 2024
saralab
saralab previously approved these changes Nov 1, 2024
jcnelson
jcnelson previously approved these changes Nov 1, 2024
Copy link
Member

@jcnelson jcnelson left a comment

Choose a reason for hiding this comment

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

Do we need a new schema version?

@kantai
Copy link
Member Author

kantai commented Nov 1, 2024

Do we need a new schema version?

I didn't think so -- doesn't the index creation code just always run and check if indexes need to be created?

@jcnelson
Copy link
Member

jcnelson commented Nov 1, 2024

Ah, yes, you're right -- specifically for the chainstate (we really should do something about that too -- I bet those transactions are really unecessary)

oops, I missed the Self::need_schema_migrations() call

@kantai
Copy link
Member Author

kantai commented Nov 1, 2024

Ah, yes, you're right -- specifically for the chainstate (we really should do something about that too -- I bet those transactions are really unecessary)

Nope, I was wrong!

        if create_flag {
            // instantiate!
            StacksChainState::instantiate_db(mainnet, chain_id, index_path, true)
        } else {
            let mut marf = StacksChainState::open_index(index_path)?;
            if !Self::need_schema_migrations(marf.sqlite_conn(), mainnet, chain_id)? {
                return Ok(marf);
            }

            // need a migration
            let tx = marf.storage_tx()?;
            StacksChainState::apply_schema_migrations(&tx, mainnet, chain_id)?;
            StacksChainState::add_indexes(&tx)?;
            tx.commit()?;

Will add a schema version.

@kantai kantai dismissed stale reviews from jcnelson, saralab, and hstove via 7d2c13c November 1, 2024 19:31
CharlieC3
CharlieC3 previously approved these changes Nov 1, 2024
Copy link
Member

@CharlieC3 CharlieC3 left a comment

Choose a reason for hiding this comment

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

Minor nit, but fine to ignore
:shipit:

stackslib/src/chainstate/stacks/db/mod.rs Outdated Show resolved Hide resolved
jcnelson
jcnelson previously approved these changes Nov 1, 2024
jferrant
jferrant previously approved these changes Nov 2, 2024
@kantai kantai dismissed stale reviews from jferrant, jcnelson, and CharlieC3 via 20f2f4d November 2, 2024 14:33
@kantai kantai requested a review from a team as a code owner November 2, 2024 15:00
obycode
obycode previously approved these changes Nov 2, 2024
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

LGTM, just the comment nit.

jferrant
jferrant previously approved these changes Nov 2, 2024
CharlieC3
CharlieC3 previously approved these changes Nov 2, 2024
@kantai kantai dismissed stale reviews from CharlieC3, jferrant, and obycode via 722d01b November 2, 2024 19:53
Copy link
Member

@CharlieC3 CharlieC3 left a comment

Choose a reason for hiding this comment

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

LGTM!

@kantai kantai added this pull request to the merge queue Nov 2, 2024
Merged via the queue into develop with commit babcc9a Nov 2, 2024
146 checks passed
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.

7 participants