diff --git a/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index 16742f4fb8..483caa1f7d 100644 --- a/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -101,7 +101,6 @@ pub struct BitcoinRegtestController { burnchain_config: Option, ongoing_block_commit: Option, should_keep_running: Option>, - allow_rbf: bool, } #[derive(Clone)] @@ -357,7 +356,6 @@ impl BitcoinRegtestController { burnchain_config: burnchain, ongoing_block_commit: None, should_keep_running, - allow_rbf: true, } } @@ -403,7 +401,6 @@ impl BitcoinRegtestController { burnchain_config: None, ongoing_block_commit: None, should_keep_running: None, - allow_rbf: true, } } @@ -748,19 +745,14 @@ impl BitcoinRegtestController { // Configure UTXO filter let address = self.get_miner_address(epoch_id, &pubk); - test_debug!( - "Get UTXOs for {} ({}) rbf={}", - pubk.to_hex(), - addr2str(&address), - self.allow_rbf - ); + test_debug!("Get UTXOs for {} ({})", pubk.to_hex(), addr2str(&address),); let filter_addresses = vec![addr2str(&address)]; let mut utxos = loop { let result = BitcoinRPCRequest::list_unspent( &self.config, filter_addresses.clone(), - !self.allow_rbf, // if RBF is disabled, then we can use 0-conf txs + false, total_required, &utxos_to_exclude, block_height, @@ -794,7 +786,7 @@ impl BitcoinRegtestController { let result = BitcoinRPCRequest::list_unspent( &self.config, filter_addresses.clone(), - !self.allow_rbf, // if RBF is disabled, then we can use 0-conf txs + false, total_required, &utxos_to_exclude, block_height, @@ -839,7 +831,6 @@ impl BitcoinRegtestController { epoch_id: StacksEpochId, payload: LeaderKeyRegisterOp, signer: &mut BurnchainOpSigner, - _attempt: u64, ) -> Result { let public_key = signer.get_public_key(); @@ -1509,10 +1500,9 @@ impl BitcoinRegtestController { epoch_id: StacksEpochId, payload: LeaderBlockCommitOp, signer: &mut BurnchainOpSigner, - _attempt: u64, ) -> Result { // Are we currently tracking an operation? - if self.ongoing_block_commit.is_none() || !self.allow_rbf { + if self.ongoing_block_commit.is_none() { // Good to go, let's build the transaction and send it. let res = self.send_block_commit_operation(epoch_id, payload, signer, None, None, None, &[]); @@ -2060,19 +2050,18 @@ impl BitcoinRegtestController { // TODO: add tests from mutation testing results #4866 #[cfg_attr(test, mutants::skip)] - pub fn make_operation_tx( + fn make_operation_tx( &mut self, epoch_id: StacksEpochId, operation: BlockstackOperationType, op_signer: &mut BurnchainOpSigner, - attempt: u64, ) -> Result { let transaction = match operation { BlockstackOperationType::LeaderBlockCommit(payload) => { - self.build_leader_block_commit_tx(epoch_id, payload, op_signer, attempt) + self.build_leader_block_commit_tx(epoch_id, payload, op_signer) } BlockstackOperationType::LeaderKeyRegister(payload) => { - self.build_leader_key_register_tx(epoch_id, payload, op_signer, attempt) + self.build_leader_key_register_tx(epoch_id, payload, op_signer) } BlockstackOperationType::PreStx(payload) => { self.build_pre_stacks_tx(epoch_id, payload, op_signer) @@ -2256,9 +2245,8 @@ impl BurnchainController for BitcoinRegtestController { epoch_id: StacksEpochId, operation: BlockstackOperationType, op_signer: &mut BurnchainOpSigner, - attempt: u64, ) -> Result { - let transaction = self.make_operation_tx(epoch_id, operation, op_signer, attempt)?; + let transaction = self.make_operation_tx(epoch_id, operation, op_signer)?; self.send_transaction(transaction) } @@ -2853,6 +2841,8 @@ mod tests { use std::net::TcpListener; use stacks::burnchains::MagicBytes; + use stacks::chainstate::burn::ConsensusHash; + use stacks::util::vrf::{VRFPrivateKey, VRFPublicKey}; use super::*; use crate::tests::bitcoin_regtest::BURNCHAIN_CONFIG_PEER_PORT_DISABLED; @@ -2946,7 +2936,11 @@ mod tests { } } - pub fn txout_opreturn(op: &LeaderBlockCommitOp, magic: &MagicBytes) -> TxOut { + pub fn txout_opreturn( + op: &T, + magic: &MagicBytes, + value: u64, + ) -> TxOut { let op_bytes = { let mut buffer = vec![]; let mut magic_bytes = magic.as_bytes().to_vec(); @@ -2957,7 +2951,7 @@ mod tests { }; TxOut { - value: op.sunset_burn, + value, script_pubkey: Builder::new() .push_opcode(opcodes::All::OP_RETURN) .push_slice(&op_bytes) @@ -3053,6 +3047,30 @@ mod tests { tx.input[index].clone() } + + pub fn create_templated_leader_key_op() -> LeaderKeyRegisterOp { + LeaderKeyRegisterOp { + consensus_hash: ConsensusHash([0u8; 20]), + public_key: VRFPublicKey::from_private( + &VRFPrivateKey::from_bytes(&[0u8; 32]).unwrap(), + ), + memo: vec![], + txid: Txid([3u8; 32]), + vtxindex: 0, + block_height: 1, + burn_header_hash: BurnchainHeaderHash([9u8; 32]), + } + } + + pub fn create_templated_pre_stx_op() -> PreStxOp { + PreStxOp { + output: StacksAddress::p2pkh_from_hash(false, Hash160::from_data(&[2u8; 20])), + txid: Txid([0u8; 32]), + vtxindex: 0, + block_height: 0, + burn_header_hash: BurnchainHeaderHash([0u8; 32]), + } + } } #[test] @@ -3487,317 +3505,751 @@ mod tests { ); } - #[test] - #[ignore] - fn test_build_leader_block_commit_tx_ok_with_new_commit_op() { - if env::var("BITCOIND_TEST") != Ok("1".into()) { - return; + /// Tests related to Leader Block Commit operation + mod leader_commit_op { + use super::*; + + #[test] + #[ignore] + fn test_build_leader_block_commit_tx_ok_with_new_commit_op() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller + .connect_dbs() + .expect("Dbs initialization required!"); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let mut commit_op = utils::create_templated_commit_op(); + commit_op.sunset_burn = 5_500; + commit_op.burn_fee = 110_000; + + let tx = btc_controller + .build_leader_block_commit_tx( + StacksEpochId::Epoch31, + commit_op.clone(), + &mut op_signer, + ) + .expect("Build leader block commit should work"); + + assert!(op_signer.is_disposed()); + + assert_eq!(1, tx.version); + assert_eq!(0, tx.lock_time); + assert_eq!(1, tx.input.len()); + assert_eq!(4, tx.output.len()); + + // utxos list contains the only existing utxo + let used_utxos = btc_controller.get_all_utxos(&miner_pubkey); + let input_0 = utils::txin_at_index(&tx, &op_signer, &used_utxos, 0); + assert_eq!(input_0, tx.input[0]); + + let op_return = utils::txout_opreturn(&commit_op, &config.burnchain.magic_bytes, 5_500); + let op_commit_1 = utils::txout_opdup_commit_to(&commit_op.commit_outs[0], 55_000); + let op_commit_2 = utils::txout_opdup_commit_to(&commit_op.commit_outs[1], 55_000); + let op_change = utils::txout_opdup_change_legacy(&mut op_signer, 4_999_865_300); + assert_eq!(op_return, tx.output[0]); + assert_eq!(op_commit_1, tx.output[1]); + assert_eq!(op_commit_2, tx.output[2]); + assert_eq!(op_change, tx.output[3]); } - let keychain = utils::create_keychain(); - let miner_pubkey = keychain.get_pub_key(); - let mut op_signer = keychain.generate_op_signer(); + #[test] + #[ignore] + fn test_build_leader_block_commit_tx_fails_resub_same_commit_op_while_prev_not_confirmed() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } - let mut config = utils::create_config(); - config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); - let mut btcd_controller = BitcoinCoreController::new(config.clone()); - btcd_controller - .start_bitcoind() - .expect("bitcoind should be started!"); + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); - let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); - btc_controller - .connect_dbs() - .expect("Dbs initialization required!"); - btc_controller.bootstrap_chain(101); // now, one utxo exists + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config, None); + btc_controller + .connect_dbs() + .expect("Dbs initialization required!"); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let commit_op = utils::create_templated_commit_op(); - let mut commit_op = utils::create_templated_commit_op(); - commit_op.sunset_burn = 5_500; - commit_op.burn_fee = 110_000; + let _first_tx_ok = btc_controller + .build_leader_block_commit_tx( + StacksEpochId::Epoch31, + commit_op.clone(), + &mut op_signer, + ) + .expect("At first, building leader block commit should work"); - let tx = btc_controller - .build_leader_block_commit_tx( + // re-submitting same commit while previous it is not confirmed by the burnchain + let resubmit = btc_controller.build_leader_block_commit_tx( StacksEpochId::Epoch31, - commit_op.clone(), + commit_op, &mut op_signer, - 0, - ) - .expect("Build leader block commit should work"); - - assert!(op_signer.is_disposed()); + ); - assert_eq!(1, tx.version); - assert_eq!(0, tx.lock_time); - assert_eq!(1, tx.input.len()); - assert_eq!(4, tx.output.len()); + assert!(resubmit.is_err()); + assert_eq!( + BurnchainControllerError::IdenticalOperation, + resubmit.unwrap_err() + ); + } - // utxos list contains the only existing utxo - let used_utxos = btc_controller.get_all_utxos(&miner_pubkey); - let input_0 = utils::txin_at_index(&tx, &op_signer, &used_utxos, 0); - assert_eq!(input_0, tx.input[0]); + #[test] + #[ignore] + fn test_build_leader_block_commit_tx_fails_resub_same_commit_op_while_prev_is_confirmed() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } - let op_return = utils::txout_opreturn(&commit_op, &config.burnchain.magic_bytes); - let op_commit_1 = utils::txout_opdup_commit_to(&commit_op.commit_outs[0], 55_000); - let op_commit_2 = utils::txout_opdup_commit_to(&commit_op.commit_outs[1], 55_000); - let op_change = utils::txout_opdup_change_legacy(&mut op_signer, 4_999_865_300); - assert_eq!(op_return, tx.output[0]); - assert_eq!(op_commit_1, tx.output[1]); - assert_eq!(op_commit_2, tx.output[2]); - assert_eq!(op_change, tx.output[3]); - } + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); - #[test] - #[ignore] - fn test_build_leader_block_commit_tx_fails_resub_same_commit_op_while_prev_not_confirmed() { - if env::var("BITCOIND_TEST") != Ok("1".into()) { - return; - } + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); - let keychain = utils::create_keychain(); - let miner_pubkey = keychain.get_pub_key(); - let mut op_signer = keychain.generate_op_signer(); + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); - let mut config = utils::create_config(); - config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + let mut btc_controller = BitcoinRegtestController::new(config, None); + btc_controller + .connect_dbs() + .expect("Dbs initialization required!"); + btc_controller.bootstrap_chain(101); // now, one utxo exists - let mut btcd_controller = BitcoinCoreController::new(config.clone()); - btcd_controller - .start_bitcoind() - .expect("bitcoind should be started!"); + let commit_op = utils::create_templated_commit_op(); - let mut btc_controller = BitcoinRegtestController::new(config, None); - btc_controller - .connect_dbs() - .expect("Dbs initialization required!"); - btc_controller.bootstrap_chain(101); // now, one utxo exists + let first_tx_ok = btc_controller + .build_leader_block_commit_tx( + StacksEpochId::Epoch31, + commit_op.clone(), + &mut op_signer, + ) + .expect("At first, building leader block commit should work"); - let commit_op = utils::create_templated_commit_op(); + utils::mine_tx(&btc_controller, first_tx_ok); // Now tx is confirmed - let _first_tx_ok = btc_controller - .build_leader_block_commit_tx( + // re-submitting same commit while previous it is confirmed by the burnchain + let resubmit = btc_controller.build_leader_block_commit_tx( StacksEpochId::Epoch31, - commit_op.clone(), + commit_op, &mut op_signer, - 0, - ) - .expect("At first, building leader block commit should work"); + ); - // re-submitting same commit while previous it is not confirmed by the burnchain - let resubmit = btc_controller.build_leader_block_commit_tx( - StacksEpochId::Epoch31, - commit_op, - &mut op_signer, - 0, - ); + assert!(resubmit.is_err()); + assert_eq!( + BurnchainControllerError::IdenticalOperation, + resubmit.unwrap_err() + ); + } - assert!(resubmit.is_err()); - assert_eq!( - BurnchainControllerError::IdenticalOperation, - resubmit.unwrap_err() - ); - } + #[test] + #[ignore] + fn test_build_leader_block_commit_tx_ok_rbf_while_prev_is_confirmed() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } - #[test] - #[ignore] - fn test_build_leader_block_commit_tx_fails_resub_same_commit_op_while_prev_is_confirmed() { - if env::var("BITCOIND_TEST") != Ok("1".into()) { - return; + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller + .connect_dbs() + .expect("Dbs initialization required!"); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let mut commit_op = utils::create_templated_commit_op(); + commit_op.sunset_burn = 5_500; + commit_op.burn_fee = 110_000; + + let first_tx_ok = btc_controller + .build_leader_block_commit_tx( + StacksEpochId::Epoch31, + commit_op.clone(), + &mut op_signer, + ) + .expect("At first, building leader block commit should work"); + + let first_txid = first_tx_ok.txid(); + + // Now tx is confirmed: prev utxo is updated and one more utxo is generated + utils::mine_tx(&btc_controller, first_tx_ok); + + //re-gen signer othewise fails because it will be disposed during previous commit tx. + let mut signer = keychain.generate_op_signer(); + //small change to the commit op payload + commit_op.burn_fee += 10; + + let rbf_tx = btc_controller + .build_leader_block_commit_tx( + StacksEpochId::Epoch31, + commit_op.clone(), + &mut signer, + ) + .expect("Commit tx should be rbf-ed"); + + assert!(op_signer.is_disposed()); + + assert_eq!(1, rbf_tx.version); + assert_eq!(0, rbf_tx.lock_time); + assert_eq!(1, rbf_tx.input.len()); + assert_eq!(4, rbf_tx.output.len()); + + // utxos list contains the sole utxo used by prev commit operation + // because has enough amount to cover the rfb commit + let used_utxos: Vec = btc_controller + .get_all_utxos(&miner_pubkey) + .into_iter() + .filter(|utxo| utxo.txid == first_txid) + .collect(); + + let input_0 = utils::txin_at_index(&rbf_tx, &op_signer, &used_utxos, 0); + assert_eq!(input_0, rbf_tx.input[0]); + + let op_return = utils::txout_opreturn(&commit_op, &config.burnchain.magic_bytes, 5_500); + let op_commit_1 = utils::txout_opdup_commit_to(&commit_op.commit_outs[0], 55_005); + let op_commit_2 = utils::txout_opdup_commit_to(&commit_op.commit_outs[1], 55_005); + let op_change = utils::txout_opdup_change_legacy(&mut signer, 4_999_730_590); + assert_eq!(op_return, rbf_tx.output[0]); + assert_eq!(op_commit_1, rbf_tx.output[1]); + assert_eq!(op_commit_2, rbf_tx.output[2]); + assert_eq!(op_change, rbf_tx.output[3]); } - let keychain = utils::create_keychain(); - let miner_pubkey = keychain.get_pub_key(); - let mut op_signer = keychain.generate_op_signer(); + #[test] + #[ignore] + fn test_build_leader_block_commit_tx_ok_rbf_while_prev_not_confirmed() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } - let mut config = utils::create_config(); - config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); - let mut btcd_controller = BitcoinCoreController::new(config.clone()); - btcd_controller - .start_bitcoind() - .expect("bitcoind should be started!"); + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); - let mut btc_controller = BitcoinRegtestController::new(config, None); - btc_controller - .connect_dbs() - .expect("Dbs initialization required!"); - btc_controller.bootstrap_chain(101); // now, one utxo exists + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); - let commit_op = utils::create_templated_commit_op(); + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller + .connect_dbs() + .expect("Dbs initialization required!"); + btc_controller.bootstrap_chain(101); // Now, one utxo exists + + let mut commit_op = utils::create_templated_commit_op(); + commit_op.sunset_burn = 5_500; + commit_op.burn_fee = 110_000; + + let _first_tx_ok = btc_controller + .build_leader_block_commit_tx( + StacksEpochId::Epoch31, + commit_op.clone(), + &mut op_signer, + ) + .expect("At first, building leader block commit should work"); + + //re-gen signer othewise fails because it will be disposed during previous commit tx. + let mut signer = keychain.generate_op_signer(); + //small change to the commit op payload + commit_op.burn_fee += 10; + + let rbf_tx = btc_controller + .build_leader_block_commit_tx( + StacksEpochId::Epoch31, + commit_op.clone(), + &mut signer, + ) + .expect("Commit tx should be rbf-ed"); - let first_tx_ok = btc_controller - .build_leader_block_commit_tx( - StacksEpochId::Epoch31, - commit_op.clone(), - &mut op_signer, - 0, - ) - .expect("At first, building leader block commit should work"); + assert!(op_signer.is_disposed()); - utils::mine_tx(&btc_controller, first_tx_ok); // Now tx is confirmed + assert_eq!(1, rbf_tx.version); + assert_eq!(0, rbf_tx.lock_time); + assert_eq!(1, rbf_tx.input.len()); + assert_eq!(4, rbf_tx.output.len()); - // re-submitting same commit while previous it is confirmed by the burnchain - let resubmit = btc_controller.build_leader_block_commit_tx( - StacksEpochId::Epoch31, - commit_op, - &mut op_signer, - 0, - ); + // utxos list contains the only existing utxo + let used_utxos = btc_controller.get_all_utxos(&miner_pubkey); - assert!(resubmit.is_err()); - assert_eq!( - BurnchainControllerError::IdenticalOperation, - resubmit.unwrap_err() - ); + let input_0 = utils::txin_at_index(&rbf_tx, &op_signer, &used_utxos, 0); + assert_eq!(input_0, rbf_tx.input[0]); + + let op_return = utils::txout_opreturn(&commit_op, &config.burnchain.magic_bytes, 5_500); + let op_commit_1 = utils::txout_opdup_commit_to(&commit_op.commit_outs[0], 55_005); + let op_commit_2 = utils::txout_opdup_commit_to(&commit_op.commit_outs[1], 55_005); + let op_change = utils::txout_opdup_change_legacy(&mut signer, 4_999_862_985); + assert_eq!(op_return, rbf_tx.output[0]); + assert_eq!(op_commit_1, rbf_tx.output[1]); + assert_eq!(op_commit_2, rbf_tx.output[2]); + assert_eq!(op_change, rbf_tx.output[3]); + } + + #[test] + #[ignore] + fn test_make_operation_leader_block_commit_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller + .connect_dbs() + .expect("Dbs initialization required!"); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let mut commit_op = utils::create_templated_commit_op(); + commit_op.sunset_burn = 5_500; + commit_op.burn_fee = 110_000; + + let ser_tx = btc_controller + .make_operation_tx( + StacksEpochId::Epoch31, + BlockstackOperationType::LeaderBlockCommit(commit_op), + &mut op_signer, + ) + .expect("Make op should work"); + + assert!(op_signer.is_disposed()); + + assert_eq!( + "01000000014d9e9dc7d126446e90dd013f023937eba9cb2c88f4d12707400a3ede994a62c5000000008b483045022100e4f934cf20a42ae5709f96505b73ad4e7ab19f41931940257089bfe6935840780220503af1cafd02e42ed008ad473dd619ee591d6926333413275168cf2697ce91430141044227d7e5c0997524ce011c126f0464d43e7518872a9b1ad29436ac5142d73eab5fb48d764676900fc2fac56917412114bf7dfafe51f715cf466fe0c1a6c69d11fdffffff047c15000000000000536a4c5054335be88c3d30cb59a142f83de3b27f897a43bbb0f13316911bb98a3229973dae32afd5b9f21bc1f40f24e2c101ecd13c55b8619e5e03dad81de2c62a1cc1d8c1b375000008a300010000059800015ad8d60000000000001976a914000000000000000000000000000000000000000088acd8d60000000000001976a914000000000000000000000000000000000000000088acd4e3032a010000001976a9145e52c53cb96b55f0e3d719adbca21005bc54cb2e88ac00000000", + ser_tx.to_hex() + ); + } + + #[test] + #[ignore] + fn test_submit_leader_block_commit_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller + .connect_dbs() + .expect("Dbs initialization required!"); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let mut commit_op = utils::create_templated_commit_op(); + commit_op.sunset_burn = 5_500; + commit_op.burn_fee = 110_000; + + let tx_id = btc_controller + .submit_operation( + StacksEpochId::Epoch31, + BlockstackOperationType::LeaderBlockCommit(commit_op), + &mut op_signer, + ) + .expect("Submit op should work"); + + assert!(op_signer.is_disposed()); + + assert_eq!( + "1a74106bd760117892fbd90fca11646b4de46f99fd2b065c9e0706cfdcea0336", + tx_id.to_hex() + ); + } } - #[test] - #[ignore] - fn test_build_leader_block_commit_tx_ok_rbf_while_prev_is_confirmed() { - if env::var("BITCOIND_TEST") != Ok("1".into()) { - return; + /// Tests related to Leader Key Register operation + mod leader_key_op { + use super::*; + + #[test] + #[ignore] + fn test_build_leader_key_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let leader_key_op = utils::create_templated_leader_key_op(); + + let tx = btc_controller + .build_leader_key_register_tx( + StacksEpochId::Epoch31, + leader_key_op.clone(), + &mut op_signer, + ) + .expect("Build leader key should work"); + + assert!(op_signer.is_disposed()); + + assert_eq!(1, tx.version); + assert_eq!(0, tx.lock_time); + assert_eq!(1, tx.input.len()); + assert_eq!(2, tx.output.len()); + + // utxos list contains the only existing utxo + let used_utxos = btc_controller.get_all_utxos(&miner_pubkey); + let input_0 = utils::txin_at_index(&tx, &op_signer, &used_utxos, 0); + assert_eq!(input_0, tx.input[0]); + + let op_return = utils::txout_opreturn(&leader_key_op, &config.burnchain.magic_bytes, 0); + let op_change = utils::txout_opdup_change_legacy(&mut op_signer, 4_999_980_000); + assert_eq!(op_return, tx.output[0]); + assert_eq!(op_change, tx.output[1]); + } + + #[test] + #[ignore] + fn test_build_leader_key_tx_fails_due_to_no_utxos() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(100); // no utxos exist + + let leader_key_op = utils::create_templated_leader_key_op(); + + let error = btc_controller + .build_leader_key_register_tx( + StacksEpochId::Epoch31, + leader_key_op.clone(), + &mut op_signer, + ) + .expect_err("Leader key build should fail!"); + + assert!(!op_signer.is_disposed()); + assert_eq!(BurnchainControllerError::NoUTXOs, error); } - let keychain = utils::create_keychain(); - let miner_pubkey = keychain.get_pub_key(); - let mut op_signer = keychain.generate_op_signer(); + #[test] + #[ignore] + fn test_make_operation_leader_key_register_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } - let mut config = utils::create_config(); - config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); - let mut btcd_controller = BitcoinCoreController::new(config.clone()); - btcd_controller - .start_bitcoind() - .expect("bitcoind should be started!"); + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); - let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); - btc_controller - .connect_dbs() - .expect("Dbs initialization required!"); - btc_controller.bootstrap_chain(101); // now, one utxo exists + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); - let mut commit_op = utils::create_templated_commit_op(); - commit_op.sunset_burn = 5_500; - commit_op.burn_fee = 110_000; + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(101); // now, one utxo exists - let first_tx_ok = btc_controller - .build_leader_block_commit_tx( - StacksEpochId::Epoch31, - commit_op.clone(), - &mut op_signer, - 0, - ) - .expect("At first, building leader block commit should work"); + let leader_key_op = utils::create_templated_leader_key_op(); - let first_txid = first_tx_ok.txid(); + let ser_tx = btc_controller + .make_operation_tx( + StacksEpochId::Epoch31, + BlockstackOperationType::LeaderKeyRegister(leader_key_op), + &mut op_signer, + ) + .expect("Make op should work"); - // Now tx is confirmed: prev utxo is updated and one more utxo is generated - utils::mine_tx(&btc_controller, first_tx_ok); + assert!(op_signer.is_disposed()); - //re-gen signer othewise fails because it will be disposed during previous commit tx. - let mut signer = keychain.generate_op_signer(); - //small change to the commit op payload - commit_op.burn_fee += 10; + assert_eq!( + "01000000014d9e9dc7d126446e90dd013f023937eba9cb2c88f4d12707400a3ede994a62c5000000008b483045022100c8694688b4269585ef63bfeb96d017bafae02621ebd0b5012e7564d3efcb71f70220070528674f75ca3503246030f064a85d2010256336372b246100f29ba21bf28b0141044227d7e5c0997524ce011c126f0464d43e7518872a9b1ad29436ac5142d73eab5fb48d764676900fc2fac56917412114bf7dfafe51f715cf466fe0c1a6c69d11fdffffff020000000000000000396a3754335e00000000000000000000000000000000000000003b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29e0a3052a010000001976a9145e52c53cb96b55f0e3d719adbca21005bc54cb2e88ac00000000", + ser_tx.to_hex() + ); + } + + #[test] + #[ignore] + fn test_submit_operation_leader_key_register_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } - let rbf_tx = btc_controller - .build_leader_block_commit_tx(StacksEpochId::Epoch31, commit_op.clone(), &mut signer, 0) - .expect("Commit tx should be rbf-ed"); + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); - assert!(op_signer.is_disposed()); + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); - assert_eq!(1, rbf_tx.version); - assert_eq!(0, rbf_tx.lock_time); - assert_eq!(1, rbf_tx.input.len()); - assert_eq!(4, rbf_tx.output.len()); + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); - // utxos list contains the sole utxo used by prev commit operation - // because has enough amount to cover the rfb commit - let used_utxos: Vec = btc_controller - .get_all_utxos(&miner_pubkey) - .into_iter() - .filter(|utxo| utxo.txid == first_txid) - .collect(); + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let leader_key_op = utils::create_templated_leader_key_op(); + + let tx_id = btc_controller + .submit_operation( + StacksEpochId::Epoch31, + BlockstackOperationType::LeaderKeyRegister(leader_key_op), + &mut op_signer, + ) + .expect("Submit op should work"); - let input_0 = utils::txin_at_index(&rbf_tx, &op_signer, &used_utxos, 0); - assert_eq!(input_0, rbf_tx.input[0]); + assert!(op_signer.is_disposed()); - let op_return = utils::txout_opreturn(&commit_op, &config.burnchain.magic_bytes); - let op_commit_1 = utils::txout_opdup_commit_to(&commit_op.commit_outs[0], 55_005); - let op_commit_2 = utils::txout_opdup_commit_to(&commit_op.commit_outs[1], 55_005); - let op_change = utils::txout_opdup_change_legacy(&mut signer, 4_999_730_590); - assert_eq!(op_return, rbf_tx.output[0]); - assert_eq!(op_commit_1, rbf_tx.output[1]); - assert_eq!(op_commit_2, rbf_tx.output[2]); - assert_eq!(op_change, rbf_tx.output[3]); + assert_eq!( + "4ecd7ba71bebd1aaed49dd63747ee424473f1c571bb9a576361607a669191024", + tx_id.to_hex() + ); + } } - #[test] - #[ignore] - fn test_build_leader_block_commit_tx_ok_rbf_while_prev_not_confirmed() { - if env::var("BITCOIND_TEST") != Ok("1".into()) { - return; + /// Tests related to Pre Stacks operation + mod pre_stx_op { + use super::*; + + #[test] + #[ignore] + fn test_build_pre_stx_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let mut pre_stx_op = utils::create_templated_pre_stx_op(); + pre_stx_op.output = keychain.get_address(false); + + let tx = btc_controller + .build_pre_stacks_tx(StacksEpochId::Epoch31, pre_stx_op.clone(), &mut op_signer) + .expect("Build leader key should work"); + + assert!(op_signer.is_disposed()); + + assert_eq!(1, tx.version); + assert_eq!(0, tx.lock_time); + assert_eq!(1, tx.input.len()); + assert_eq!(3, tx.output.len()); + + // utxos list contains the only existing utxo + let used_utxos = btc_controller.get_all_utxos(&miner_pubkey); + let input_0 = utils::txin_at_index(&tx, &op_signer, &used_utxos, 0); + assert_eq!(input_0, tx.input[0]); + + let op_return = utils::txout_opreturn(&pre_stx_op, &config.burnchain.magic_bytes, 0); + let op_change = utils::txout_opdup_change_legacy(&mut op_signer, 24_500); + assert_eq!(op_return, tx.output[0]); + assert_eq!(op_change, tx.output[1]); } - let keychain = utils::create_keychain(); - let miner_pubkey = keychain.get_pub_key(); - let mut op_signer = keychain.generate_op_signer(); + #[test] + #[ignore] + fn test_build_pre_stx_tx_fails_due_to_no_utxos() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } - let mut config = utils::create_config(); - config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); - let mut btcd_controller = BitcoinCoreController::new(config.clone()); - btcd_controller - .start_bitcoind() - .expect("bitcoind should be started!"); + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); - let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); - btc_controller - .connect_dbs() - .expect("Dbs initialization required!"); - btc_controller.bootstrap_chain(101); // Now, one utxo exists + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); - let mut commit_op = utils::create_templated_commit_op(); - commit_op.sunset_burn = 5_500; - commit_op.burn_fee = 110_000; + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(100); // no utxo exists - let _first_tx_ok = btc_controller - .build_leader_block_commit_tx( - StacksEpochId::Epoch31, - commit_op.clone(), - &mut op_signer, - 0, - ) - .expect("At first, building leader block commit should work"); - - //re-gen signer othewise fails because it will be disposed during previous commit tx. - let mut signer = keychain.generate_op_signer(); - //small change to the commit op payload - commit_op.burn_fee += 10; - - let rbf_tx = btc_controller - .build_leader_block_commit_tx(StacksEpochId::Epoch31, commit_op.clone(), &mut signer, 0) - .expect("Commit tx should be rbf-ed"); - - assert!(op_signer.is_disposed()); - - assert_eq!(1, rbf_tx.version); - assert_eq!(0, rbf_tx.lock_time); - assert_eq!(1, rbf_tx.input.len()); - assert_eq!(4, rbf_tx.output.len()); - - // utxos list contains the only existing utxo - let used_utxos = btc_controller.get_all_utxos(&miner_pubkey); - - let input_0 = utils::txin_at_index(&rbf_tx, &op_signer, &used_utxos, 0); - assert_eq!(input_0, rbf_tx.input[0]); - - let op_return = utils::txout_opreturn(&commit_op, &config.burnchain.magic_bytes); - let op_commit_1 = utils::txout_opdup_commit_to(&commit_op.commit_outs[0], 55_005); - let op_commit_2 = utils::txout_opdup_commit_to(&commit_op.commit_outs[1], 55_005); - let op_change = utils::txout_opdup_change_legacy(&mut signer, 4_999_862_985); - assert_eq!(op_return, rbf_tx.output[0]); - assert_eq!(op_commit_1, rbf_tx.output[1]); - assert_eq!(op_commit_2, rbf_tx.output[2]); - assert_eq!(op_change, rbf_tx.output[3]); + let mut pre_stx_op = utils::create_templated_pre_stx_op(); + pre_stx_op.output = keychain.get_address(false); + + let error = btc_controller + .build_pre_stacks_tx(StacksEpochId::Epoch31, pre_stx_op.clone(), &mut op_signer) + .expect_err("Leader key build should fail!"); + + assert!(!op_signer.is_disposed()); + assert_eq!(BurnchainControllerError::NoUTXOs, error); + } + + #[test] + #[ignore] + fn test_make_operation_pre_stx_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let mut pre_stx_op = utils::create_templated_pre_stx_op(); + pre_stx_op.output = keychain.get_address(false); + + let ser_tx = btc_controller + .make_operation_tx( + StacksEpochId::Epoch31, + BlockstackOperationType::PreStx(pre_stx_op), + &mut op_signer, + ) + .expect("Make op should work"); + + assert!(op_signer.is_disposed()); + + assert_eq!( + "01000000014d9e9dc7d126446e90dd013f023937eba9cb2c88f4d12707400a3ede994a62c5000000008a47304402203351a9351e887f4b66023893f55e308c3c345aec6f50dd3bd11fc90b7049703102200fbbf08747e4961ec8e0a5f5e991fa5f709cac9083d22772cd48e9325a48bba30141044227d7e5c0997524ce011c126f0464d43e7518872a9b1ad29436ac5142d73eab5fb48d764676900fc2fac56917412114bf7dfafe51f715cf466fe0c1a6c69d11fdffffff030000000000000000056a03543370b45f0000000000001976a9145e52c53cb96b55f0e3d719adbca21005bc54cb2e88ac9c5b052a010000001976a9145e52c53cb96b55f0e3d719adbca21005bc54cb2e88ac00000000", + ser_tx.to_hex() + ); + } + + #[test] + #[ignore] + fn test_submit_operation_pre_stx_tx_ok() { + if env::var("BITCOIND_TEST") != Ok("1".into()) { + return; + } + + let keychain = utils::create_keychain(); + let miner_pubkey = keychain.get_pub_key(); + let mut op_signer = keychain.generate_op_signer(); + + let mut config = utils::create_config(); + config.burnchain.local_mining_public_key = Some(miner_pubkey.to_hex()); + + let mut btcd_controller = BitcoinCoreController::new(config.clone()); + btcd_controller + .start_bitcoind() + .expect("bitcoind should be started!"); + + let mut btc_controller = BitcoinRegtestController::new(config.clone(), None); + btc_controller.bootstrap_chain(101); // now, one utxo exists + + let mut pre_stx_op = utils::create_templated_pre_stx_op(); + pre_stx_op.output = keychain.get_address(false); + + let tx_id = btc_controller + .submit_operation( + StacksEpochId::Epoch31, + BlockstackOperationType::PreStx(pre_stx_op), + &mut op_signer, + ) + .expect("submit op should work"); + + assert!(op_signer.is_disposed()); + + assert_eq!( + "2d061c42c6f13a62fd9d80dc9fdcd19bdb4f9e4a07f786e42530c64c52ed9d1d", + tx_id.to_hex() + ); + } } } diff --git a/stacks-node/src/burnchains/mocknet_controller.rs b/stacks-node/src/burnchains/mocknet_controller.rs index cdcda3a85a..488bed2316 100644 --- a/stacks-node/src/burnchains/mocknet_controller.rs +++ b/stacks-node/src/burnchains/mocknet_controller.rs @@ -167,7 +167,6 @@ impl BurnchainController for MocknetController { _epoch_id: StacksEpochId, operation: BlockstackOperationType, _op_signer: &mut BurnchainOpSigner, - _attempt: u64, ) -> Result { let txid = operation.txid(); self.queued_operations.push_back(operation); diff --git a/stacks-node/src/burnchains/mod.rs b/stacks-node/src/burnchains/mod.rs index 11b946b0cc..70a335348d 100644 --- a/stacks-node/src/burnchains/mod.rs +++ b/stacks-node/src/burnchains/mod.rs @@ -60,7 +60,6 @@ pub trait BurnchainController { epoch_id: StacksEpochId, operation: BlockstackOperationType, op_signer: &mut BurnchainOpSigner, - attempt: u64, ) -> Result; fn sync(&mut self, target_block_height_opt: Option) -> Result<(BurnchainTip, u64), Error>; fn sortdb_ref(&self) -> &SortitionDB; diff --git a/stacks-node/src/nakamoto_node/relayer.rs b/stacks-node/src/nakamoto_node/relayer.rs index e1a19dea30..8ffc7a6bc4 100644 --- a/stacks-node/src/nakamoto_node/relayer.rs +++ b/stacks-node/src/nakamoto_node/relayer.rs @@ -961,7 +961,7 @@ impl RelayerThread { let mut op_signer = self.keychain.generate_op_signer(); if let Ok(txid) = self .bitcoin_controller - .submit_operation(cur_epoch, op, &mut op_signer, 1) + .submit_operation(cur_epoch, op, &mut op_signer) { // advance key registration state self.last_vrf_key_burn_height = Some(burn_block.block_height); @@ -1664,7 +1664,6 @@ impl RelayerThread { *last_committed.get_epoch_id(), BlockstackOperationType::LeaderBlockCommit(last_committed.get_block_commit().clone()), &mut op_signer, - 1, ); let txid = match res { Ok(txid) => txid, diff --git a/stacks-node/src/neon_node.rs b/stacks-node/src/neon_node.rs index 1594b885f4..9fddda7d7e 100644 --- a/stacks-node/src/neon_node.rs +++ b/stacks-node/src/neon_node.rs @@ -2745,7 +2745,7 @@ impl BlockMinerThread { .. } = self.config.get_node_config(false); - let res = bitcoin_controller.submit_operation(target_epoch_id, op, &mut op_signer, attempt); + let res = bitcoin_controller.submit_operation(target_epoch_id, op, &mut op_signer); match res { Ok(_) => { self.failed_to_submit_last_attempt = false; @@ -3613,7 +3613,7 @@ impl RelayerThread { let mut one_off_signer = self.keychain.generate_op_signer(); if let Ok(txid) = self.bitcoin_controller - .submit_operation(cur_epoch, op, &mut one_off_signer, 1) + .submit_operation(cur_epoch, op, &mut one_off_signer) { // advance key registration state self.last_vrf_key_burn_height = burn_block.block_height; diff --git a/stacks-node/src/node.rs b/stacks-node/src/node.rs index d16e21bce5..3ef15d45ab 100644 --- a/stacks-node/src/node.rs +++ b/stacks-node/src/node.rs @@ -560,7 +560,7 @@ impl Node { let key_reg_op = self.generate_leader_key_register_op(vrf_pk, &consensus_hash); let mut op_signer = self.keychain.generate_op_signer(); let key_txid = burnchain_controller - .submit_operation(cur_epoch.epoch_id, key_reg_op, &mut op_signer, 1) + .submit_operation(cur_epoch.epoch_id, key_reg_op, &mut op_signer) .expect("FATAL: failed to submit leader key register operation"); self.leader_key_registers.insert(key_txid); @@ -768,7 +768,7 @@ impl Node { let mut op_signer = self.keychain.generate_op_signer(); let txid = burnchain_controller - .submit_operation(cur_epoch.epoch_id, op, &mut op_signer, 1) + .submit_operation(cur_epoch.epoch_id, op, &mut op_signer) .expect("FATAL: failed to submit block-commit"); self.block_commits.insert(txid); diff --git a/stacks-node/src/tests/epoch_205.rs b/stacks-node/src/tests/epoch_205.rs index a6b47ccc51..882a8dcd4d 100644 --- a/stacks-node/src/tests/epoch_205.rs +++ b/stacks-node/src/tests/epoch_205.rs @@ -627,12 +627,8 @@ fn transition_empty_blocks() { commit_outs, }); let mut op_signer = keychain.generate_op_signer(); - let res = bitcoin_controller.submit_operation( - StacksEpochId::Epoch2_05, - op, - &mut op_signer, - 1, - ); + let res = + bitcoin_controller.submit_operation(StacksEpochId::Epoch2_05, op, &mut op_signer); assert!(res.is_ok(), "Failed to submit block-commit"); } diff --git a/stacks-node/src/tests/epoch_21.rs b/stacks-node/src/tests/epoch_21.rs index 877b4fa4e0..0d1cbde027 100644 --- a/stacks-node/src/tests/epoch_21.rs +++ b/stacks-node/src/tests/epoch_21.rs @@ -670,7 +670,6 @@ fn transition_fixes_bitcoin_rigidity() { StacksEpochId::Epoch2_05, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_signer, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -705,7 +704,6 @@ fn transition_fixes_bitcoin_rigidity() { StacksEpochId::Epoch2_05, BlockstackOperationType::TransferStx(transfer_stx_op), &mut spender_signer, - 1 ) .is_ok(), "Transfer operation should submit successfully" @@ -826,7 +824,6 @@ fn transition_fixes_bitcoin_rigidity() { StacksEpochId::Epoch21, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_signer, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -857,7 +854,6 @@ fn transition_fixes_bitcoin_rigidity() { StacksEpochId::Epoch2_05, BlockstackOperationType::TransferStx(transfer_stx_op), &mut spender_signer, - 1 ) .is_ok(), "Transfer operation should submit successfully" @@ -1899,7 +1895,7 @@ fn transition_empty_blocks() { }); let mut op_signer = keychain.generate_op_signer(); let res = - bitcoin_controller.submit_operation(StacksEpochId::Epoch21, op, &mut op_signer, 1); + bitcoin_controller.submit_operation(StacksEpochId::Epoch21, op, &mut op_signer); assert!(res.is_ok(), "Failed to submit block-commit"); } diff --git a/stacks-node/src/tests/nakamoto_integrations.rs b/stacks-node/src/tests/nakamoto_integrations.rs index 9ad1fa4c8c..2a3ced7e07 100644 --- a/stacks-node/src/tests/nakamoto_integrations.rs +++ b/stacks-node/src/tests/nakamoto_integrations.rs @@ -3490,7 +3490,6 @@ fn vote_for_aggregate_key_burn_op() { StacksEpochId::Epoch30, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_signer, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -3560,7 +3559,6 @@ fn vote_for_aggregate_key_burn_op() { StacksEpochId::Epoch30, vote_for_aggregate_key_op, &mut signer_burnop_signer, - 1 ) .is_ok(), "Vote for aggregate key operation should submit successfully" @@ -4594,7 +4592,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_signer_1, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -4618,7 +4615,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::PreStx(pre_stx_op_2), &mut miner_signer_2, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -4639,7 +4635,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::PreStx(pre_stx_op_3), &mut miner_signer_3, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -4660,7 +4655,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::PreStx(pre_stx_op_4), &mut miner_signer_4, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -4791,7 +4785,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::TransferStx(transfer_stx_op), &mut stacker_burnop_signer_1, - 1 ) .is_ok(), "Transfer STX operation should submit successfully" @@ -4817,7 +4810,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::DelegateStx(del_stx_op), &mut stacker_burnop_signer_2, - 1 ) .is_ok(), "Delegate STX operation should submit successfully" @@ -4847,7 +4839,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::StackStx(stack_stx_op_with_some_signer_key), &mut signer_burnop_signer_1, - 1 ) .is_ok(), "Stack STX operation should submit successfully" @@ -4874,7 +4865,6 @@ fn burn_ops_integration_test() { StacksEpochId::Epoch30, BlockstackOperationType::StackStx(stack_stx_op_with_no_signer_key), &mut signer_burnop_signer_2, - 1 ) .is_ok(), "Stack STX operation should submit successfully" diff --git a/stacks-node/src/tests/neon_integrations.rs b/stacks-node/src/tests/neon_integrations.rs index ef52c03a15..15933bfa15 100644 --- a/stacks-node/src/tests/neon_integrations.rs +++ b/stacks-node/src/tests/neon_integrations.rs @@ -1997,7 +1997,6 @@ fn stx_transfer_btc_integration_test() { StacksEpochId::Epoch2_05, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_signer, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -2027,7 +2026,6 @@ fn stx_transfer_btc_integration_test() { StacksEpochId::Epoch2_05, BlockstackOperationType::TransferStx(transfer_stx_op), &mut spender_signer, - 1 ) .is_ok(), "Transfer operation should submit successfully" @@ -2266,7 +2264,6 @@ fn stx_delegate_btc_integration_test() { StacksEpochId::Epoch21, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_signer, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -2295,7 +2292,6 @@ fn stx_delegate_btc_integration_test() { StacksEpochId::Epoch21, BlockstackOperationType::DelegateStx(del_stx_op), &mut spender_signer, - 1 ) .is_ok(), "Delegate operation should submit successfully" @@ -2555,7 +2551,6 @@ fn stack_stx_burn_op_test() { StacksEpochId::Epoch25, BlockstackOperationType::PreStx(pre_stx_op_1), &mut miner_signer_1, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -2576,7 +2571,6 @@ fn stack_stx_burn_op_test() { StacksEpochId::Epoch25, BlockstackOperationType::PreStx(pre_stx_op_2), &mut miner_signer_2, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -2663,7 +2657,6 @@ fn stack_stx_burn_op_test() { StacksEpochId::Epoch25, stack_stx_op_with_some_signer_key, &mut spender_signer_1, - 1 ) .is_ok(), "Stack STX operation with some signer key should submit successfully" @@ -2691,7 +2684,6 @@ fn stack_stx_burn_op_test() { StacksEpochId::Epoch25, stack_stx_op_with_no_signer_key, &mut spender_signer_2, - 1 ) .is_ok(), "Stack STX operation with no signer key should submit successfully" @@ -2991,7 +2983,6 @@ fn vote_for_aggregate_key_burn_op_test() { StacksEpochId::Epoch25, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_signer, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -3048,7 +3039,6 @@ fn vote_for_aggregate_key_burn_op_test() { StacksEpochId::Epoch25, vote_for_aggregate_key_op, &mut spender_signer, - 1 ) .is_ok(), "Vote for aggregate key operation should submit successfully" diff --git a/stacks-node/src/tests/signer/v0.rs b/stacks-node/src/tests/signer/v0.rs index f0a6ba492c..f2ada12d5a 100644 --- a/stacks-node/src/tests/signer/v0.rs +++ b/stacks-node/src/tests/signer/v0.rs @@ -3799,7 +3799,6 @@ fn tx_replay_btc_on_stx_invalidation() { StacksEpochId::Epoch30, BlockstackOperationType::PreStx(pre_stx_op), &mut miner_keychain, - 1 ) .is_ok(), "Pre-stx operation should submit successfully" @@ -3828,8 +3827,7 @@ fn tx_replay_btc_on_stx_invalidation() { .submit_operation( StacksEpochId::Epoch30, BlockstackOperationType::TransferStx(transfer_stx_op), - &mut sender_burnop_signer, - 1 + &mut sender_burnop_signer ) .is_ok(), "Transfer STX operation should submit successfully"