|
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};
|
@@ -1488,6 +1489,26 @@ fn wait_for_first_naka_block_commit(timeout_secs: u64, naka_commits_submitted: &
|
1488 | 1489 | }
|
1489 | 1490 | }
|
1490 | 1491 |
|
| 1492 | +// Check for missing burn blocks in `range`, but allow for a missed block at |
| 1493 | +// the epoch 3 transition. Panic if any other blocks are missing. |
| 1494 | +fn check_nakamoto_no_missing_blocks(conf: &Config, range: impl RangeBounds<u64>) { |
| 1495 | + let epoch_3 = &conf.burnchain.epochs.as_ref().unwrap()[StacksEpochId::Epoch30]; |
| 1496 | + let missing = test_observer::get_missing_burn_blocks(range).unwrap(); |
| 1497 | + let missing_is_error: Vec<_> = missing |
| 1498 | + .into_iter() |
| 1499 | + .filter(|&i| { |
| 1500 | + (i != epoch_3.start_height - 1) || { |
| 1501 | + warn!("Missing burn block {} at epoch 3 transition", i); |
| 1502 | + false |
| 1503 | + } |
| 1504 | + }) |
| 1505 | + .collect(); |
| 1506 | + |
| 1507 | + if !missing_is_error.is_empty() { |
| 1508 | + panic!("Missing the following burn blocks: {missing_is_error:?}"); |
| 1509 | + } |
| 1510 | +} |
| 1511 | + |
1491 | 1512 | #[test]
|
1492 | 1513 | #[ignore]
|
1493 | 1514 | /// This test spins up a nakamoto-neon node.
|
@@ -1689,27 +1710,8 @@ fn simple_neon_integration() {
|
1689 | 1710 | assert!(tip.stacks_block_height >= block_height_pre_3_0 + 30);
|
1690 | 1711 |
|
1691 | 1712 | // Check that we aren't missing burn blocks (except during the Nakamoto transition)
|
1692 |
| - let epoch_3 = &naka_conf.burnchain.epochs.unwrap()[StacksEpochId::Epoch30]; |
1693 | 1713 | let bhh = u64::from(tip.burn_header_height);
|
1694 |
| - let missing = test_observer::get_missing_burn_blocks(220..=bhh).unwrap(); |
1695 |
| - |
1696 |
| - // This test was flaky because it was sometimes missing burn block 230, which is right at the Nakamoto transition |
1697 |
| - // So it was possible to miss a burn block during the transition |
1698 |
| - // But I don't think it matters at this point since the Nakamoto transition has already happened on mainnet |
1699 |
| - // So just print a warning instead, don't count it as an error |
1700 |
| - let missing_is_error: Vec<_> = missing |
1701 |
| - .into_iter() |
1702 |
| - .filter(|&i| { |
1703 |
| - (i != epoch_3.start_height - 1) || { |
1704 |
| - warn!("Missing burn block {} at epoch 3 transition", i); |
1705 |
| - false |
1706 |
| - } |
1707 |
| - }) |
1708 |
| - .collect(); |
1709 |
| - |
1710 |
| - if !missing_is_error.is_empty() { |
1711 |
| - panic!("Missing the following burn blocks: {missing_is_error:?}"); |
1712 |
| - } |
| 1714 | + check_nakamoto_no_missing_blocks(&naka_conf, 220..=bhh); |
1713 | 1715 |
|
1714 | 1716 | // make sure prometheus returns an updated number of processed blocks
|
1715 | 1717 | #[cfg(feature = "monitoring_prom")]
|
@@ -10106,22 +10108,8 @@ fn skip_mining_long_tx() {
|
10106 | 10108 | assert_eq!(sender_1_nonce, 4);
|
10107 | 10109 |
|
10108 | 10110 | // Check that we aren't missing burn blocks (except during the Nakamoto transition)
|
10109 |
| - let epoch_3 = &naka_conf.burnchain.epochs.unwrap()[StacksEpochId::Epoch30]; |
10110 | 10111 | let bhh = u64::from(tip.burn_header_height);
|
10111 |
| - let missing = test_observer::get_missing_burn_blocks(220..=bhh).unwrap(); |
10112 |
| - let missing_is_error: Vec<_> = missing |
10113 |
| - .into_iter() |
10114 |
| - .filter(|&i| { |
10115 |
| - (i != epoch_3.start_height - 1) || { |
10116 |
| - warn!("Missing burn block {} at epoch 3 transition", i); |
10117 |
| - false |
10118 |
| - } |
10119 |
| - }) |
10120 |
| - .collect(); |
10121 |
| - |
10122 |
| - if !missing_is_error.is_empty() { |
10123 |
| - panic!("Missing the following burn blocks: {missing_is_error:?}"); |
10124 |
| - } |
| 10112 | + check_nakamoto_no_missing_blocks(&naka_conf, 220..=bhh); |
10125 | 10113 |
|
10126 | 10114 | check_nakamoto_empty_block_heuristics();
|
10127 | 10115 |
|
|
0 commit comments