-
Notifications
You must be signed in to change notification settings - Fork 670
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
base: fix/5285
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…so we can use them for testing
Co-authored-by: Brice Dobry <[email protected]>
…-network/stacks-blockchain into feat/shadow-block-tooling
…hadow tenure entry
} | ||
}; | ||
|
||
let chain_state_path = format!("{}/{}/chainstate/", chainstate_dir, dirname); |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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,
...
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.