@@ -899,349 +899,3 @@ fn test_cost_limit_switch_version205() {
899899
900900 channel. stop_chains_coordinator ( ) ;
901901}
902-
903- // mine a stream of microblocks, and verify that microblock streams can get bigger after the epoch
904- // transition
905- #[ test]
906- #[ ignore]
907- fn bigger_microblock_streams_in_2_05 ( ) {
908- if env:: var ( "BITCOIND_TEST" ) != Ok ( "1" . into ( ) ) {
909- return ;
910- }
911-
912- let spender_sks: Vec < _ > = ( 0 ..10 ) . map ( |_| StacksPrivateKey :: random ( ) ) . collect ( ) ;
913- let spender_addrs: Vec < PrincipalData > = spender_sks. iter ( ) . map ( |x| to_addr ( x) . into ( ) ) . collect ( ) ;
914-
915- let ( mut conf, miner_account) = neon_integration_test_conf ( ) ;
916-
917- for spender_addr in spender_addrs. iter ( ) {
918- conf. initial_balances . push ( InitialBalance {
919- address : spender_addr. clone ( ) ,
920- amount : 10492300000 ,
921- } ) ;
922- }
923-
924- conf. node . mine_microblocks = true ;
925- conf. node . wait_time_for_microblocks = 0 ;
926- conf. node . microblock_frequency = 0 ;
927- conf. node . max_microblocks = 65536 ;
928- conf. burnchain . max_rbf = 1000000 ;
929-
930- conf. miner . first_attempt_time_ms = i64:: MAX as u64 ;
931- conf. miner . subsequent_attempt_time_ms = i64:: MAX as u64 ;
932-
933- conf. burnchain . epochs = Some ( EpochList :: new ( & [
934- StacksEpoch {
935- epoch_id : StacksEpochId :: Epoch20 ,
936- start_height : 0 ,
937- end_height : 206 ,
938- block_limit : ExecutionCost {
939- write_length : 15000000 ,
940- write_count : 7750 ,
941- read_length : 100000000 ,
942- read_count : 7750 ,
943- runtime : 5000000000 ,
944- } ,
945- network_epoch : PEER_VERSION_EPOCH_2_0 ,
946- } ,
947- StacksEpoch {
948- epoch_id : StacksEpochId :: Epoch2_05 ,
949- start_height : 206 ,
950- end_height : 10_002 ,
951- block_limit : ExecutionCost {
952- write_length : 15000000 ,
953- write_count : 7750 * 2 ,
954- read_length : 100000000 ,
955- read_count : 7750 * 2 ,
956- runtime : 5000000000 ,
957- } ,
958- network_epoch : PEER_VERSION_EPOCH_2_05 ,
959- } ,
960- StacksEpoch {
961- epoch_id : StacksEpochId :: Epoch21 ,
962- start_height : 10_002 ,
963- end_height : 9223372036854775807 ,
964- block_limit : ExecutionCost {
965- write_length : 15000000 ,
966- write_count : 7750 * 2 ,
967- read_length : 100000000 ,
968- read_count : 7750 * 2 ,
969- runtime : 5000000000 ,
970- } ,
971- network_epoch : PEER_VERSION_EPOCH_2_05 ,
972- } ,
973- ] ) ) ;
974- conf. burnchain . pox_2_activation = Some ( 10_003 ) ;
975-
976- let txs: Vec < Vec < _ > > = spender_sks
977- . iter ( )
978- . enumerate ( )
979- . map ( |( ix, spender_sk) | {
980- // almost fills a whole block
981- make_contract_publish_microblock_only (
982- spender_sk,
983- 0 ,
984- 1049230 ,
985- conf. burnchain . chain_id ,
986- & format ! ( "large-{ix}" ) ,
987- & format ! ( "
988- ;; a single one of these transactions consumes over half the runtime budget
989- (define-constant BUFF_TO_BYTE (list
990- 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
991- 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f
992- 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2a 0x2b 0x2c 0x2d 0x2e 0x2f
993- 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3a 0x3b 0x3c 0x3d 0x3e 0x3f
994- 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4a 0x4b 0x4c 0x4d 0x4e 0x4f
995- 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5a 0x5b 0x5c 0x5d 0x5e 0x5f
996- 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f
997- 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77 0x78 0x79 0x7a 0x7b 0x7c 0x7d 0x7e 0x7f
998- 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f
999- 0x90 0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f
1000- 0xa0 0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae 0xaf
1001- 0xb0 0xb1 0xb2 0xb3 0xb4 0xb5 0xb6 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf
1002- 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 0xc7 0xc8 0xc9 0xca 0xcb 0xcc 0xcd 0xce 0xcf
1003- 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf
1004- 0xe0 0xe1 0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef
1005- 0xf0 0xf1 0xf2 0xf3 0xf4 0xf5 0xf6 0xf7 0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff
1006- ))
1007- (define-private (crash-me-folder (input (buff 1)) (ctr uint))
1008- (begin
1009- (unwrap-panic (index-of BUFF_TO_BYTE input))
1010- (unwrap-panic (index-of BUFF_TO_BYTE input))
1011- (unwrap-panic (index-of BUFF_TO_BYTE input))
1012- (unwrap-panic (index-of BUFF_TO_BYTE input))
1013- (unwrap-panic (index-of BUFF_TO_BYTE input))
1014- (unwrap-panic (index-of BUFF_TO_BYTE input))
1015- (unwrap-panic (index-of BUFF_TO_BYTE input))
1016- (unwrap-panic (index-of BUFF_TO_BYTE input))
1017- (+ u1 ctr)
1018- )
1019- )
1020- (define-public (crash-me (name (string-ascii 128)))
1021- (begin
1022- (fold crash-me-folder BUFF_TO_BYTE u0)
1023- (print name)
1024- (ok u0)
1025- )
1026- )
1027- (begin
1028- (crash-me \" large-contract-{ix}\" ))
1029- "
1030- )
1031- )
1032- } )
1033- . collect ( ) ;
1034-
1035- test_observer:: spawn ( ) ;
1036- test_observer:: register_any ( & mut conf) ;
1037-
1038- let mut btcd_controller = BitcoinCoreController :: new ( conf. clone ( ) ) ;
1039- btcd_controller
1040- . start_bitcoind ( )
1041- . map_err ( |_e| ( ) )
1042- . expect ( "Failed starting bitcoind" ) ;
1043-
1044- let mut btc_regtest_controller = BitcoinRegtestController :: new ( conf. clone ( ) , None ) ;
1045- let http_origin = format ! ( "http://{}" , & conf. node. rpc_bind) ;
1046-
1047- btc_regtest_controller. bootstrap_chain ( 201 ) ;
1048-
1049- eprintln ! ( "Chain bootstrapped..." ) ;
1050-
1051- let mut run_loop = neon:: RunLoop :: new ( conf) ;
1052- let blocks_processed = run_loop. get_blocks_processed_arc ( ) ;
1053- let microblocks_processed = run_loop. get_microblocks_processed_arc ( ) ;
1054-
1055- let channel = run_loop. get_coordinator_channel ( ) . unwrap ( ) ;
1056-
1057- thread:: spawn ( move || run_loop. start ( None , 0 ) ) ;
1058-
1059- // give the run loop some time to start up!
1060- wait_for_runloop ( & blocks_processed) ;
1061-
1062- // zeroth block wakes up the run loop
1063- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1064-
1065- // first block will hold our VRF registration
1066- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1067-
1068- // second block will be the first mined Stacks block
1069- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1070-
1071- // let's query the miner's account nonce:
1072- let account = get_account ( & http_origin, & miner_account) ;
1073- assert_eq ! ( account. nonce, 1 ) ;
1074- assert_eq ! ( account. balance, 0 ) ;
1075-
1076- for spender_addr in spender_addrs. iter ( ) {
1077- let account = get_account ( & http_origin, & spender_addr) ;
1078- assert_eq ! ( account. nonce, 0 ) ;
1079- assert_eq ! ( account. balance, 10492300000 ) ;
1080- }
1081-
1082- let mut ctr = 0 ;
1083- while ctr < txs. len ( ) {
1084- submit_tx ( & http_origin, & txs[ ctr] ) ;
1085- if !wait_for_microblocks ( & microblocks_processed, 30 ) {
1086- // we time out if we *can't* mine any more microblocks
1087- break ;
1088- }
1089- ctr += 1 ;
1090- }
1091- microblocks_processed. store ( 0 , Ordering :: SeqCst ) ;
1092-
1093- // only one fit
1094- assert_eq ! ( ctr, 1 ) ;
1095- sleep_ms ( 5_000 ) ;
1096-
1097- // confirm it
1098- eprintln ! ( "confirm epoch 2.0 microblock stream" ) ;
1099- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1100-
1101- // send the rest of the transactions
1102- while ctr < txs. len ( ) {
1103- submit_tx ( & http_origin, & txs[ ctr] ) ;
1104- ctr += 1 ;
1105- }
1106-
1107- eprintln ! ( "expect epoch transition" ) ;
1108-
1109- microblocks_processed. store ( 0 , Ordering :: SeqCst ) ;
1110-
1111- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1112- // don't bother waiting for a microblock stream
1113-
1114- eprintln ! ( "expect epoch 2.05 microblock stream" ) ;
1115-
1116- microblocks_processed. store ( 0 , Ordering :: SeqCst ) ;
1117- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1118- wait_for_microblocks ( & microblocks_processed, 180 ) ;
1119-
1120- microblocks_processed. store ( 0 , Ordering :: SeqCst ) ;
1121-
1122- // this test can sometimes miss a mine block event.
1123- sleep_ms ( 120_000 ) ;
1124- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1125-
1126- let mut epoch_20_stream_cost = ExecutionCost :: ZERO ;
1127- let mut epoch_205_stream_cost = ExecutionCost :: ZERO ;
1128-
1129- // max == largest number of transactions per stream in a given epoch (2.0 or 2.05)
1130- // total == number of transactions across all streams in a given epoch (2.0 or 2.05)
1131- let mut max_big_txs_per_microblock_20 = 0 ;
1132- let mut total_big_txs_per_microblock_20 = 0 ;
1133-
1134- let mut max_big_txs_per_microblock_205 = 0 ;
1135- let mut total_big_txs_per_microblock_205 = 0 ;
1136-
1137- let mut in_205;
1138- let mut have_confirmed_205_stream;
1139-
1140- for i in 0 ..10 {
1141- let blocks = test_observer:: get_blocks ( ) ;
1142-
1143- max_big_txs_per_microblock_20 = 0 ;
1144- total_big_txs_per_microblock_20 = 0 ;
1145-
1146- max_big_txs_per_microblock_205 = 0 ;
1147- total_big_txs_per_microblock_205 = 0 ;
1148-
1149- in_205 = false ;
1150- have_confirmed_205_stream = false ;
1151-
1152- // NOTE: this only counts the number of txs per stream, not in each microblock
1153- for block in blocks {
1154- let transactions = block. get ( "transactions" ) . unwrap ( ) . as_array ( ) . unwrap ( ) ;
1155- eprintln ! ( "{}" , transactions. len( ) ) ;
1156-
1157- let mut num_big_microblock_txs = 0 ;
1158- let mut total_execution_cost = ExecutionCost :: ZERO ;
1159-
1160- for tx in transactions. iter ( ) {
1161- let raw_tx = tx. get ( "raw_tx" ) . unwrap ( ) . as_str ( ) . unwrap ( ) ;
1162- if raw_tx == "0x00" {
1163- continue ;
1164- }
1165- let tx_bytes = hex_bytes ( & raw_tx[ 2 ..] ) . unwrap ( ) ;
1166- let parsed = StacksTransaction :: consensus_deserialize ( & mut & tx_bytes[ ..] ) . unwrap ( ) ;
1167- if let TransactionPayload :: SmartContract ( tsc, ..) = parsed. payload {
1168- if tsc. name . to_string ( ) . contains ( "costs-2" ) {
1169- in_205 = true ;
1170- } else if tsc. name . to_string ( ) . contains ( "large" ) {
1171- num_big_microblock_txs += 1 ;
1172- if in_205 {
1173- total_big_txs_per_microblock_205 += 1 ;
1174- } else {
1175- total_big_txs_per_microblock_20 += 1 ;
1176- }
1177- }
1178- }
1179- let execution_cost = tx. get ( "execution_cost" ) . unwrap ( ) ;
1180- total_execution_cost. read_count +=
1181- execution_cost. get ( "read_count" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as u64 ;
1182- total_execution_cost. read_length +=
1183- execution_cost. get ( "read_length" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as u64 ;
1184- total_execution_cost. write_count +=
1185- execution_cost. get ( "write_count" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as u64 ;
1186- total_execution_cost. write_length += execution_cost
1187- . get ( "write_length" )
1188- . unwrap ( )
1189- . as_i64 ( )
1190- . unwrap ( ) as u64 ;
1191- total_execution_cost. runtime +=
1192- execution_cost. get ( "runtime" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as u64 ;
1193- }
1194- if in_205 && num_big_microblock_txs > max_big_txs_per_microblock_205 {
1195- max_big_txs_per_microblock_205 = num_big_microblock_txs;
1196- }
1197- if !in_205 && num_big_microblock_txs > max_big_txs_per_microblock_20 {
1198- max_big_txs_per_microblock_20 = num_big_microblock_txs;
1199- }
1200-
1201- eprintln ! ( "Epoch size: {total_execution_cost:?}" ) ;
1202-
1203- if !in_205 && total_execution_cost. exceeds ( & epoch_20_stream_cost) {
1204- epoch_20_stream_cost = total_execution_cost;
1205- break ;
1206- }
1207- if in_205 && total_execution_cost. exceeds ( & ExecutionCost :: ZERO ) {
1208- have_confirmed_205_stream = true ;
1209- epoch_205_stream_cost = total_execution_cost;
1210- break ;
1211- }
1212- }
1213-
1214- if have_confirmed_205_stream {
1215- break ;
1216- } else {
1217- eprintln ! ( "Trying to confirm a stream again (attempt {})" , i + 1 ) ;
1218- sleep_ms ( ( i + 2 ) * 60_000 ) ;
1219- next_block_and_wait ( & mut btc_regtest_controller, & blocks_processed) ;
1220- }
1221- }
1222-
1223- eprintln ! (
1224- "max_big_txs_per_microblock_20: {max_big_txs_per_microblock_20}, total_big_txs_per_microblock_20: {total_big_txs_per_microblock_20}"
1225- ) ;
1226- eprintln ! (
1227- "max_big_txs_per_microblock_205: {max_big_txs_per_microblock_205}, total_big_txs_per_microblock_205: {total_big_txs_per_microblock_205}"
1228- ) ;
1229- eprintln ! ( "confirmed stream execution in 2.0: {epoch_20_stream_cost:?}" ) ;
1230- eprintln ! ( "confirmed stream execution in 2.05: {epoch_205_stream_cost:?}" ) ;
1231-
1232- // stuff happened
1233- assert ! ( epoch_20_stream_cost. runtime > 0 ) ;
1234- assert ! ( epoch_205_stream_cost. runtime > 0 ) ;
1235-
1236- // more stuff happened in epoch 2.05
1237- assert ! ( epoch_205_stream_cost. read_count > epoch_20_stream_cost. read_count) ;
1238- assert ! ( epoch_205_stream_cost. read_length > epoch_20_stream_cost. read_length) ;
1239- assert ! ( epoch_205_stream_cost. write_count > epoch_20_stream_cost. write_count) ;
1240- assert ! ( epoch_205_stream_cost. write_length > epoch_20_stream_cost. write_length) ;
1241-
1242- // but epoch 2.05 was *cheaper* in terms of CPU
1243- assert ! ( epoch_205_stream_cost. runtime < epoch_20_stream_cost. runtime) ;
1244-
1245- test_observer:: clear ( ) ;
1246- channel. stop_chains_coordinator ( ) ;
1247- }
0 commit comments