@@ -3885,6 +3885,60 @@ impl NakamotoChainState {
3885
3885
Ok ( ( ) )
3886
3886
}
3887
3887
3888
+ pub ( crate ) fn make_non_advancing_receipt < ' a > (
3889
+ clarity_commit : PreCommitClarityBlock < ' a > ,
3890
+ burn_dbconn : & SortitionHandleConn ,
3891
+ parent_ch : & ConsensusHash ,
3892
+ evaluated_epoch : StacksEpochId ,
3893
+ matured_rewards : Vec < MinerReward > ,
3894
+ tx_receipts : Vec < StacksTransactionReceipt > ,
3895
+ matured_rewards_info_opt : Option < MinerRewardInfo > ,
3896
+ block_execution_cost : ExecutionCost ,
3897
+ applied_epoch_transition : bool ,
3898
+ signers_updated : bool ,
3899
+ ) -> Result <
3900
+ (
3901
+ StacksEpochReceipt ,
3902
+ PreCommitClarityBlock < ' a > ,
3903
+ Option < RewardSetData > ,
3904
+ ) ,
3905
+ ChainstateError ,
3906
+ > {
3907
+ // get burn block stats, for the transaction receipt
3908
+
3909
+ let parent_sn = SortitionDB :: get_block_snapshot_consensus ( burn_dbconn, & parent_ch) ?
3910
+ . ok_or_else ( || {
3911
+ // shouldn't happen
3912
+ warn ! (
3913
+ "CORRUPTION: {} does not correspond to a burn block" ,
3914
+ & parent_ch
3915
+ ) ;
3916
+ ChainstateError :: InvalidStacksBlock ( "No parent consensus hash" . into ( ) )
3917
+ } ) ?;
3918
+ let ( parent_burn_block_hash, parent_burn_block_height, parent_burn_block_timestamp) = (
3919
+ parent_sn. burn_header_hash ,
3920
+ parent_sn. block_height ,
3921
+ parent_sn. burn_header_timestamp ,
3922
+ ) ;
3923
+
3924
+ let epoch_receipt = StacksEpochReceipt {
3925
+ header : StacksHeaderInfo :: regtest_genesis ( ) ,
3926
+ tx_receipts,
3927
+ matured_rewards,
3928
+ matured_rewards_info : matured_rewards_info_opt,
3929
+ parent_microblocks_cost : ExecutionCost :: zero ( ) ,
3930
+ anchored_block_cost : block_execution_cost,
3931
+ parent_burn_block_hash,
3932
+ parent_burn_block_height : u32:: try_from ( parent_burn_block_height) . unwrap_or ( 0 ) , // shouldn't be fatal
3933
+ parent_burn_block_timestamp,
3934
+ evaluated_epoch,
3935
+ epoch_transition : applied_epoch_transition,
3936
+ signers_updated,
3937
+ } ;
3938
+
3939
+ return Ok ( ( epoch_receipt, clarity_commit, None ) ) ;
3940
+ }
3941
+
3888
3942
/// Append a Nakamoto Stacks block to the Stacks chain state.
3889
3943
/// NOTE: This does _not_ set the block as processed! The caller must do this.
3890
3944
pub ( crate ) fn append_block < ' a > (
@@ -4279,43 +4333,20 @@ impl NakamotoChainState {
4279
4333
. map ( |rewards| rewards. reward_info . clone ( ) ) ;
4280
4334
4281
4335
if do_not_advance {
4282
- // get burn block stats, for the transaction receipt
4283
- let ( parent_burn_block_hash, parent_burn_block_height, parent_burn_block_timestamp) =
4284
- if block. is_first_mined ( ) {
4285
- ( BurnchainHeaderHash ( [ 0 ; 32 ] ) , 0 , 0 )
4286
- } else {
4287
- let sn = SortitionDB :: get_block_snapshot_consensus ( burn_dbconn, & parent_ch) ?
4288
- . ok_or_else ( || {
4289
- // shouldn't happen
4290
- warn ! (
4291
- "CORRUPTION: {} does not correspond to a burn block" ,
4292
- & parent_ch
4293
- ) ;
4294
- ChainstateError :: InvalidStacksBlock ( "No parent consensus hash" . into ( ) )
4295
- } ) ?;
4296
- (
4297
- sn. burn_header_hash ,
4298
- sn. block_height ,
4299
- sn. burn_header_timestamp ,
4300
- )
4301
- } ;
4302
-
4303
- let epoch_receipt = StacksEpochReceipt {
4304
- header : StacksHeaderInfo :: regtest_genesis ( ) ,
4305
- tx_receipts,
4306
- matured_rewards,
4307
- matured_rewards_info : matured_rewards_info_opt,
4308
- parent_microblocks_cost : ExecutionCost :: zero ( ) ,
4309
- anchored_block_cost : block_execution_cost,
4310
- parent_burn_block_hash,
4311
- parent_burn_block_height : u32:: try_from ( parent_burn_block_height) . unwrap_or ( 0 ) , // shouldn't be fatal
4312
- parent_burn_block_timestamp,
4336
+ // if we're performing a block replay, and we don't want to advance any
4337
+ // of the db state, return a fake receipt
4338
+ return Self :: make_non_advancing_receipt (
4339
+ clarity_commit,
4340
+ burn_dbconn,
4341
+ & parent_ch,
4313
4342
evaluated_epoch,
4314
- epoch_transition : applied_epoch_transition,
4315
- signers_updated : signer_set_calc. is_some ( ) ,
4316
- } ;
4317
-
4318
- return Ok ( ( epoch_receipt, clarity_commit, None ) ) ;
4343
+ matured_rewards,
4344
+ tx_receipts,
4345
+ matured_rewards_info_opt,
4346
+ block_execution_cost,
4347
+ applied_epoch_transition,
4348
+ signer_set_calc. is_some ( ) ,
4349
+ ) ;
4319
4350
}
4320
4351
4321
4352
let new_tip = Self :: advance_tip (
0 commit comments