Merge branch 'next' into feat/native-segwit

This commit is contained in:
Jude Nelson
2022-10-18 17:29:15 +00:00
committed by GitHub
3 changed files with 104 additions and 18 deletions

View File

@@ -68,6 +68,8 @@ jobs:
- tests::neon_integrations::fuzzed_median_fee_rate_estimation_test_window10
- tests::neon_integrations::use_latest_tip_integration_test
- tests::neon_integrations::test_flash_block_skip_tenure
- tests::neon_integrations::test_chainwork_first_intervals
- tests::neon_integrations::test_chainwork_partial_interval
- tests::epoch_205::test_dynamic_db_method_costs
- tests::epoch_205::transition_empty_blocks
- tests::epoch_205::test_cost_limit_switch_version205

View File

@@ -472,22 +472,36 @@ impl BitcoinIndexer {
let interval_start_block =
(start_block / BLOCK_DIFFICULTY_CHUNK_SIZE).saturating_sub(2);
let base_block = interval_start_block * BLOCK_DIFFICULTY_CHUNK_SIZE;
let interval_headers =
canonical_spv_client.read_block_headers(base_block, start_block + 1)?;
assert!(
interval_headers.len() >= (start_block - base_block) as usize,
"BUG: missing headers for {}-{}",
base_block,
start_block
);
test_debug!(
"Copy headers {}-{}",
base_block,
base_block + interval_headers.len() as u64
);
reorg_spv_client
.insert_block_headers_before(base_block - 1, interval_headers)?;
if base_block > 0 {
let interval_headers =
canonical_spv_client.read_block_headers(base_block, start_block + 1)?;
assert!(
interval_headers.len() >= (start_block - base_block) as usize,
"BUG: missing headers for {}-{}",
base_block,
start_block
);
debug!(
"Copy headers {}-{}",
base_block,
base_block + interval_headers.len() as u64
);
reorg_spv_client
.insert_block_headers_before(base_block - 1, interval_headers)?;
} else {
let interval_headers =
canonical_spv_client.read_block_headers(1, start_block + 1)?;
assert!(
interval_headers.len() >= start_block as usize,
"BUG: missing headers for 1-{}",
start_block
);
debug!("Copy headers 1-{}", interval_headers.len() as u64);
reorg_spv_client.insert_block_headers_before(0, interval_headers)?;
}
let last_interval = canonical_spv_client.find_highest_work_score_interval()?;
@@ -545,12 +559,12 @@ impl BitcoinIndexer {
let mut new_tip = 0;
let mut found_common_ancestor = false;
let orig_spv_client = SpvClient::new(
let mut orig_spv_client = SpvClient::new(
canonical_headers_path,
0,
None,
self.runtime.network_id,
false,
true,
false,
)?;
@@ -718,7 +732,7 @@ impl BitcoinIndexer {
if check_chain_work {
let reorg_total_work = reorg_spv_client.update_chain_work()?;
let orig_total_work = orig_spv_client.get_chain_work()?;
let orig_total_work = orig_spv_client.update_chain_work()?;
debug!("Bitcoin headers history is consistent up to {}", new_tip;
"Orig chainwork" => %orig_total_work,

View File

@@ -7325,3 +7325,73 @@ fn test_flash_block_skip_tenure() {
channel.stop_chains_coordinator();
}
#[test]
#[ignore]
fn test_chainwork_first_intervals() {
if env::var("BITCOIND_TEST") != Ok("1".into()) {
return;
}
let (mut conf, miner_account) = neon_integration_test_conf();
let mut btcd_controller = BitcoinCoreController::new(conf.clone());
btcd_controller
.start_bitcoind()
.map_err(|_e| ())
.expect("Failed starting bitcoind");
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
let http_origin = format!("http://{}", &conf.node.rpc_bind);
btc_regtest_controller.bootstrap_chain(2016 * 2 - 1);
eprintln!("Chain bootstrapped...");
let mut run_loop = neon::RunLoop::new(conf);
let blocks_processed = run_loop.get_blocks_processed_arc();
let missed_tenures = run_loop.get_missed_tenures_arc();
let channel = run_loop.get_coordinator_channel().unwrap();
thread::spawn(move || run_loop.start(None, 0));
// give the run loop some time to start up!
wait_for_runloop(&blocks_processed);
channel.stop_chains_coordinator();
}
#[test]
#[ignore]
fn test_chainwork_partial_interval() {
if env::var("BITCOIND_TEST") != Ok("1".into()) {
return;
}
let (mut conf, miner_account) = neon_integration_test_conf();
let mut btcd_controller = BitcoinCoreController::new(conf.clone());
btcd_controller
.start_bitcoind()
.map_err(|_e| ())
.expect("Failed starting bitcoind");
let mut btc_regtest_controller = BitcoinRegtestController::new(conf.clone(), None);
let http_origin = format!("http://{}", &conf.node.rpc_bind);
btc_regtest_controller.bootstrap_chain(2016 - 1);
eprintln!("Chain bootstrapped...");
let mut run_loop = neon::RunLoop::new(conf);
let blocks_processed = run_loop.get_blocks_processed_arc();
let missed_tenures = run_loop.get_missed_tenures_arc();
let channel = run_loop.get_coordinator_channel().unwrap();
thread::spawn(move || run_loop.start(None, 0));
// give the run loop some time to start up!
wait_for_runloop(&blocks_processed);
channel.stop_chains_coordinator();
}