Skip to content

Commit a3640b4

Browse files
committed
chore: PR feedback
1 parent 6ddfd6c commit a3640b4

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

stackslib/src/chainstate/nakamoto/shadow.rs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,16 @@ impl NakamotoBlock {
117117
/// Verify that if this shadow block has a coinbase, that its VRF proof is consistent with the leader
118118
/// public key's VRF key. If there is no coinbase tx, then this is a no-op.
119119
pub(crate) fn check_shadow_coinbase_tx(&self, mainnet: bool) -> Result<(), ChainstateError> {
120-
assert!(self.is_shadow_block());
120+
if !self.is_shadow_block() {
121+
error!(
122+
"FATAL: tried to validate non-shadow block in a shadow-block-specific validator"
123+
);
124+
panic!();
125+
}
121126

122-
// If this block has a coinbase, then verify that its VRF proof was generated by this
123-
// block's miner. We'll verify that the seed of this block-commit was generated from the
124-
// parnet tenure's VRF proof via the `validate_vrf_seed()` method, which requires that we
125-
// already have the parent block.
127+
// If this shadow block has a coinbase, then verify that it has a VRF proof (which will be
128+
// verified later) and that its recipient is the burn address. Shadow blocks do not award
129+
// STX.
126130
if let Some(coinbase_tx) = self.get_coinbase_tx() {
127131
let (_, recipient_opt, vrf_proof_opt) = coinbase_tx
128132
.try_as_coinbase()
@@ -177,7 +181,12 @@ impl NakamotoBlock {
177181
tenure_burn_chain_tip: &BlockSnapshot,
178182
expected_burn: Option<u64>,
179183
) -> Result<(), ChainstateError> {
180-
assert!(self.is_shadow_block());
184+
if !self.is_shadow_block() {
185+
error!(
186+
"FATAL: tried to validate non-shadow block in a shadow-block-specific validator"
187+
);
188+
panic!();
189+
}
181190
self.common_validate_against_burnchain(tenure_burn_chain_tip, expected_burn)?;
182191
self.check_tenure_tx()?;
183192
self.check_shadow_coinbase_tx(mainnet)?;
@@ -257,7 +266,12 @@ impl NakamotoChainState {
257266
mainnet: bool,
258267
chain_id: u32,
259268
) -> Result<(), ChainstateError> {
260-
assert!(block.is_shadow_block());
269+
if !self.is_shadow_block() {
270+
error!(
271+
"FATAL: tried to validate non-shadow block in a shadow-block-specific validator"
272+
);
273+
panic!();
274+
}
261275

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

499-
debug!("Build Nakamoto block from {} transactions", txs.len());
513+
debug!(
514+
"Build shadow Nakamoto block from {} transactions",
515+
txs.len()
516+
);
500517
let (mut chainstate, _) = chainstate_handle.reopen()?;
501518

502519
let mut tenure_cause = None;
@@ -569,7 +586,7 @@ impl NakamotoBlockBuilder {
569586

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

0 commit comments

Comments
 (0)