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/shadow block tooling #5362

Merged
merged 33 commits into from
Nov 20, 2024
Merged

Feat/shadow block tooling #5362

merged 33 commits into from
Nov 20, 2024

Conversation

jcnelson
Copy link
Member

This adds tooling to stacks-inspect to generate and insert shadow blocks into a production chainstate.

It'll probably get more commits as we test it out, but it's opened here for review so we can start making images off of it and testing it out on Nakamoto testnet.

@jcnelson jcnelson requested a review from a team as a code owner October 23, 2024 02:58
@jcnelson jcnelson changed the base branch from develop to fix/5285 October 23, 2024 02:59
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!

stackslib/src/main.rs Outdated Show resolved Hide resolved
@jcnelson jcnelson requested a review from a team as a code owner October 24, 2024 21:38
@jcnelson jcnelson requested a review from kantai October 28, 2024 16:59
}
};

let chain_state_path = format!("{}/{}/chainstate/", chainstate_dir, dirname);
Copy link
Collaborator

@jferrant jferrant Nov 8, 2024

Choose a reason for hiding this comment

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

Not important, but would be nice if chain_state_path and sort_db_path used in place formatting :) (similarly throughout, but just a nit and not required of course)

let (miner_pk_hash160, stacks_parent_ch, committed_block_hash, last_sortition_ch) =
if !sortition_sn.sortition {
if !sortition_sn.sortition && !is_shadow {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit of a personal preference, but I find this code block easier to understand if you do the following:

            if !sortition_sn.sortition {
                if !is_shadow {
                    let handle = sortdb.index_handle(&sortition_sn.sortition_id);
                    let last_sortition =
                        handle.get_last_snapshot_with_sortition(sortition_sn.block_height)?;
                    (None, None, None, Some(last_sortition.consensus_hash))
                } else {
                    // this is a shadow tenure.
                    let parent_tenure_ch = chainstate
                        .index_conn()
                        .get_parent_tenure_consensus_hash(tip, &sortition_sn.consensus_hash)?
                        .ok_or_else(|| DBError::NotFoundError)?;

                    let parent_tenure_start_header =
                        NakamotoChainState::get_nakamoto_tenure_start_block_header(
                            &mut chainstate.index_conn(),
                            tip,
                            &parent_tenure_ch,
                        )?
                        .ok_or_else(|| DBError::NotFoundError)?;

                    (
                        Some(Hash160([0x00; 20])),
                        Some(parent_tenure_ch.clone()),
                        Some(BlockHeaderHash(
                            parent_tenure_start_header.index_block_hash().0,
                        )),
                        Some(parent_tenure_ch),
                    )
                }
            } else {
                let block_commit = SortitionDB::get_block_commit(sortdb.conn(), &sortition_sn.winning_block_txid,
            ...

@wileyj wileyj merged commit d038752 into fix/5285 Nov 20, 2024
156 of 157 checks passed
@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Status: Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

7 participants