|
14 | 14 | // You should have received a copy of the GNU General Public License
|
15 | 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 | use std::collections::{BTreeMap, HashMap, HashSet};
|
| 17 | +use std::ops::RangeBounds; |
17 | 18 | use std::sync::atomic::{AtomicU64, Ordering};
|
18 | 19 | use std::sync::mpsc::{channel, Receiver, Sender};
|
19 | 20 | use std::sync::{Arc, Mutex};
|
@@ -1437,6 +1438,26 @@ fn wait_for_first_naka_block_commit(timeout_secs: u64, naka_commits_submitted: &
|
1437 | 1438 | }
|
1438 | 1439 | }
|
1439 | 1440 |
|
| 1441 | +// Check for missing burn blocks in `range`, but allow for a missed block at |
| 1442 | +// the epoch 3 transition. Panic if any other blocks are missing. |
| 1443 | +fn check_nakamoto_no_missing_blocks(conf: &Config, range: impl RangeBounds<u64>) { |
| 1444 | + let epoch_3 = &conf.burnchain.epochs.as_ref().unwrap()[StacksEpochId::Epoch30]; |
| 1445 | + let missing = test_observer::get_missing_burn_blocks(range).unwrap(); |
| 1446 | + let missing_is_error: Vec<_> = missing |
| 1447 | + .into_iter() |
| 1448 | + .filter(|&i| { |
| 1449 | + (i != epoch_3.start_height - 1) || { |
| 1450 | + warn!("Missing burn block {} at epoch 3 transition", i); |
| 1451 | + false |
| 1452 | + } |
| 1453 | + }) |
| 1454 | + .collect(); |
| 1455 | + |
| 1456 | + if !missing_is_error.is_empty() { |
| 1457 | + panic!("Missing the following burn blocks: {missing_is_error:?}"); |
| 1458 | + } |
| 1459 | +} |
| 1460 | + |
1440 | 1461 | #[test]
|
1441 | 1462 | #[ignore]
|
1442 | 1463 | /// This test spins up a nakamoto-neon node.
|
@@ -1628,28 +1649,9 @@ fn simple_neon_integration() {
|
1628 | 1649 | assert!(tip.anchored_header.as_stacks_nakamoto().is_some());
|
1629 | 1650 | assert!(tip.stacks_block_height >= block_height_pre_3_0 + 30);
|
1630 | 1651 |
|
1631 |
| - // Check that we aren't missing burn blocks |
| 1652 | + // Check that we aren't missing burn blocks (except during the Nakamoto transition) |
1632 | 1653 | let bhh = u64::from(tip.burn_header_height);
|
1633 |
| - let missing = test_observer::get_missing_burn_blocks(220..=bhh).unwrap(); |
1634 |
| - |
1635 |
| - // This test was flakey because it was sometimes missing burn block 230, which is right at the Nakamoto transition |
1636 |
| - // So it was possible to miss a burn block during the transition |
1637 |
| - // But I don't it matters at this point since the Nakamoto transition has already happened on mainnet |
1638 |
| - // So just print a warning instead, don't count it as an error |
1639 |
| - let missing_is_error: Vec<_> = missing |
1640 |
| - .into_iter() |
1641 |
| - .filter(|i| match i { |
1642 |
| - 230 => { |
1643 |
| - warn!("Missing burn block {i}"); |
1644 |
| - false |
1645 |
| - } |
1646 |
| - _ => true, |
1647 |
| - }) |
1648 |
| - .collect(); |
1649 |
| - |
1650 |
| - if !missing_is_error.is_empty() { |
1651 |
| - panic!("Missing the following burn blocks: {missing_is_error:?}"); |
1652 |
| - } |
| 1654 | + check_nakamoto_no_missing_blocks(&naka_conf, 220..=bhh); |
1653 | 1655 |
|
1654 | 1656 | // make sure prometheus returns an updated number of processed blocks
|
1655 | 1657 | #[cfg(feature = "monitoring_prom")]
|
@@ -9941,9 +9943,9 @@ fn skip_mining_long_tx() {
|
9941 | 9943 | assert_eq!(sender_2_nonce, 0);
|
9942 | 9944 | assert_eq!(sender_1_nonce, 4);
|
9943 | 9945 |
|
9944 |
| - // Check that we aren't missing burn blocks |
| 9946 | + // Check that we aren't missing burn blocks (except during the Nakamoto transition) |
9945 | 9947 | let bhh = u64::from(tip.burn_header_height);
|
9946 |
| - test_observer::contains_burn_block_range(220..=bhh).unwrap(); |
| 9948 | + check_nakamoto_no_missing_blocks(&naka_conf, 220..=bhh); |
9947 | 9949 |
|
9948 | 9950 | check_nakamoto_empty_block_heuristics();
|
9949 | 9951 |
|
|
0 commit comments