@@ -774,7 +774,7 @@ impl MultipleMinerTest {
774
774
let contract_tx = make_contract_publish (
775
775
& self . sender_sk ,
776
776
self . sender_nonce ,
777
- self . send_fee ,
777
+ self . send_fee + contract_name . len ( ) as u64 + contract_src . len ( ) as u64 ,
778
778
self . signer_test . running_nodes . conf . burnchain . chain_id ,
779
779
contract_name,
780
780
contract_src,
@@ -12589,7 +12589,6 @@ fn miner_rejection_by_contract_call_execution_time_expired() {
12589
12589
12590
12590
miners. wait_for_test_observer_blocks ( 60 ) ;
12591
12591
12592
- miners. send_fee = 300 ;
12593
12592
// First, lets deploy the contract
12594
12593
let dummy_contract_src = "(define-public (dummy (number uint)) (begin (ok (+ number u1))))" ;
12595
12594
@@ -12664,3 +12663,111 @@ fn miner_rejection_by_contract_call_execution_time_expired() {
12664
12663
info ! ( "------------------------- Shutdown -------------------------" ) ;
12665
12664
miners. shutdown ( ) ;
12666
12665
}
12666
+
12667
+ /// Test a scenario where:
12668
+ /// Two miners boot to Nakamoto (first miner has max_execution_time set to 0).
12669
+ /// Sortition occurs. Miner 1 wins.
12670
+ /// Miner 1 fails to mine block N with contract-publish
12671
+ /// Sortition occurs. Miner 2 wins.
12672
+ /// Miner 2 successfully mines block N including the contract-publish previously rejected by miner 1
12673
+ /// Ensures both the miners are aligned
12674
+ #[ test]
12675
+ #[ ignore]
12676
+ fn miner_rejection_by_contract_publish_execution_time_expired ( ) {
12677
+ if env:: var ( "BITCOIND_TEST" ) != Ok ( "1" . into ( ) ) {
12678
+ return ;
12679
+ }
12680
+
12681
+ let num_signers = 5 ;
12682
+ let num_txs = 3 ;
12683
+
12684
+ let mut miners = MultipleMinerTest :: new_with_config_modifications (
12685
+ num_signers,
12686
+ num_txs,
12687
+ |signer_config| {
12688
+ // Lets make sure we never time out since we need to stall some things to force our scenario
12689
+ signer_config. block_proposal_validation_timeout = Duration :: from_secs ( 1800 ) ;
12690
+ signer_config. tenure_last_block_proposal_timeout = Duration :: from_secs ( 1800 ) ;
12691
+ signer_config. first_proposal_burn_block_timing = Duration :: from_secs ( 1800 ) ;
12692
+ } ,
12693
+ |config| config. miner . max_execution_time_secs = Some ( 0 ) ,
12694
+ |config| config. miner . max_execution_time_secs = None ,
12695
+ ) ;
12696
+ let rl1_skip_commit_op = miners
12697
+ . signer_test
12698
+ . running_nodes
12699
+ . counters
12700
+ . naka_skip_commit_op
12701
+ . clone ( ) ;
12702
+ let rl2_skip_commit_op = miners. rl2_counters . naka_skip_commit_op . clone ( ) ;
12703
+
12704
+ let ( conf_1, _) = miners. get_node_configs ( ) ;
12705
+ let ( miner_pkh_1, miner_pkh_2) = miners. get_miner_public_key_hashes ( ) ;
12706
+ let ( _miner_pk_1, _) = miners. get_miner_public_keys ( ) ;
12707
+
12708
+ info ! ( "------------------------- Pause Miner 2's Block Commits -------------------------" ) ;
12709
+
12710
+ // Make sure Miner 2 cannot win a sortition at first.
12711
+ rl2_skip_commit_op. set ( true ) ;
12712
+
12713
+ miners. boot_to_epoch_3 ( ) ;
12714
+
12715
+ let burnchain = conf_1. get_burnchain ( ) ;
12716
+ let sortdb = burnchain. open_sortition_db ( true ) . unwrap ( ) ;
12717
+
12718
+ info ! ( "------------------------- Pause Miner 1's Block Commits -------------------------" ) ;
12719
+ rl1_skip_commit_op. set ( true ) ;
12720
+
12721
+ info ! ( "------------------------- Miner 1 Mines a Nakamoto Block N -------------------------" ) ;
12722
+ miners
12723
+ . mine_bitcoin_block_and_tenure_change_tx ( & sortdb, TenureChangeCause :: BlockFound , 60 )
12724
+ . expect ( "Failed to mine BTC block followed by Block N" ) ;
12725
+
12726
+ miners. wait_for_test_observer_blocks ( 60 ) ;
12727
+
12728
+ // First, lets deploy the contract
12729
+ let dummy_contract_src =
12730
+ "(define-public (dummy (number uint)) (begin (ok (+ number u1))))(+ 1 1)" ;
12731
+
12732
+ let tx1 = miners. send_transfer_tx ( ) ;
12733
+
12734
+ let contract_publish_txid = miners
12735
+ . send_and_mine_contract_publish ( "dummy-contract" , dummy_contract_src, 60 )
12736
+ . expect ( "Failed to publish contract in a new block" ) ;
12737
+
12738
+ miners. wait_for_test_observer_blocks ( 60 ) ;
12739
+
12740
+ assert_eq ! ( last_block_contains_txid( & tx1) , true ) ;
12741
+
12742
+ assert_eq ! ( last_block_contains_txid( & contract_publish_txid) , false ) ;
12743
+
12744
+ verify_sortition_winner ( & sortdb, & miner_pkh_1) ;
12745
+
12746
+ info ! ( "------------------------- Miner 2 Submits a Block Commit -------------------------" ) ;
12747
+ miners. submit_commit_miner_2 ( & sortdb) ;
12748
+
12749
+ info ! ( "------------------------- Mine Tenure -------------------------" ) ;
12750
+ miners
12751
+ . mine_bitcoin_block_and_tenure_change_tx ( & sortdb, TenureChangeCause :: BlockFound , 60 )
12752
+ . expect ( "Failed to mine BTC block followed by Block N+3" ) ;
12753
+
12754
+ info ! ( "------------------------- Miner 2 Mines Block N+1 -------------------------" ) ;
12755
+
12756
+ miners. sender_nonce -= 1 ;
12757
+
12758
+ let contract_publish_txid = miners
12759
+ . send_and_mine_contract_publish ( "dummy-contract" , dummy_contract_src, 60 )
12760
+ . expect ( "Failed to publish contract in a new block" ) ;
12761
+
12762
+ miners. wait_for_test_observer_blocks ( 60 ) ;
12763
+
12764
+ assert_eq ! ( last_block_contains_txid( & contract_publish_txid) , true ) ;
12765
+
12766
+ verify_sortition_winner ( & sortdb, & miner_pkh_2) ;
12767
+
12768
+ // ensure both miners are aligned
12769
+ miners. wait_for_chains ( 60 ) ;
12770
+
12771
+ info ! ( "------------------------- Shutdown -------------------------" ) ;
12772
+ miners. shutdown ( ) ;
12773
+ }
0 commit comments