Skip to content

Commit

Permalink
chore: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jcnelson committed Nov 21, 2024
1 parent 6ddfd6c commit a3640b4
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions stackslib/src/chainstate/nakamoto/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,16 @@ impl NakamotoBlock {
/// Verify that if this shadow block has a coinbase, that its VRF proof is consistent with the leader
/// public key's VRF key. If there is no coinbase tx, then this is a no-op.
pub(crate) fn check_shadow_coinbase_tx(&self, mainnet: bool) -> Result<(), ChainstateError> {
assert!(self.is_shadow_block());
if !self.is_shadow_block() {
error!(
"FATAL: tried to validate non-shadow block in a shadow-block-specific validator"
);
panic!();
}

// If this block has a coinbase, then verify that its VRF proof was generated by this
// block's miner. We'll verify that the seed of this block-commit was generated from the
// parnet tenure's VRF proof via the `validate_vrf_seed()` method, which requires that we
// already have the parent block.
// If this shadow block has a coinbase, then verify that it has a VRF proof (which will be
// verified later) and that its recipient is the burn address. Shadow blocks do not award
// STX.
if let Some(coinbase_tx) = self.get_coinbase_tx() {
let (_, recipient_opt, vrf_proof_opt) = coinbase_tx
.try_as_coinbase()
Expand Down Expand Up @@ -177,7 +181,12 @@ impl NakamotoBlock {
tenure_burn_chain_tip: &BlockSnapshot,
expected_burn: Option<u64>,
) -> Result<(), ChainstateError> {
assert!(self.is_shadow_block());
if !self.is_shadow_block() {
error!(
"FATAL: tried to validate non-shadow block in a shadow-block-specific validator"
);
panic!();
}
self.common_validate_against_burnchain(tenure_burn_chain_tip, expected_burn)?;
self.check_tenure_tx()?;
self.check_shadow_coinbase_tx(mainnet)?;
Expand Down Expand Up @@ -257,7 +266,12 @@ impl NakamotoChainState {
mainnet: bool,
chain_id: u32,
) -> Result<(), ChainstateError> {
assert!(block.is_shadow_block());
if !self.is_shadow_block() {

Check failure on line 269 in stackslib/src/chainstate/nakamoto/shadow.rs

View workflow job for this annotation

GitHub Actions / Create Test Cache / Test Archive

expected value, found module `self`
error!(
"FATAL: tried to validate non-shadow block in a shadow-block-specific validator"
);
panic!();
}

// this block must already be stored
if !staging_db.has_shadow_nakamoto_block_with_index_hash(&block.block_id())? {
Expand Down Expand Up @@ -496,7 +510,10 @@ impl NakamotoBlockBuilder {
) -> Result<(NakamotoBlock, u64, ExecutionCost), Error> {
use clarity::vm::ast::ASTRules;

debug!("Build Nakamoto block from {} transactions", txs.len());
debug!(
"Build shadow Nakamoto block from {} transactions",
txs.len()
);
let (mut chainstate, _) = chainstate_handle.reopen()?;

let mut tenure_cause = None;
Expand Down Expand Up @@ -569,7 +586,7 @@ impl NakamotoBlockBuilder {

/// Produce a single-block shadow tenure.
/// Used by tooling to synthesize shadow blocks in case of an emergency.
/// The details and circumatances will be recorded in an accompanying SIP.
/// The details and circumstances will be recorded in an accompanying SIP.
///
/// `naka_tip_id` is the Stacks chain tip on top of which the shadow block will be built.
/// `tenure_id_consensus_hash` is the sortition in which the shadow block will be built.
Expand Down

0 comments on commit a3640b4

Please sign in to comment.