diff --git a/.github/workflows/sanitycheck.yml b/.github/workflows/sanitycheck.yml index bdc08aa..4992346 100644 --- a/.github/workflows/sanitycheck.yml +++ b/.github/workflows/sanitycheck.yml @@ -28,9 +28,7 @@ jobs: with: path: .cache/prevouts key: prevouts-v2-${{ hashFiles('blocks/*.bin') }} - restore-keys: | - prevouts-v2- - prevouts-v1- + restore-keys: prevouts-v2- - name: validate data and test validator run: | python -m venv .venv diff --git a/ci/test_prevouts.py b/ci/test_prevouts.py index 80cc36e..98e6139 100644 --- a/ci/test_prevouts.py +++ b/ci/test_prevouts.py @@ -8,7 +8,7 @@ from unittest.mock import patch from urllib.error import URLError -from bitcoin.core import CBlock, CBlockHeader, b2lx +from bitcoin.core import CBlock, CBlockHeader, b2lx, lx from block_evidence import read_transaction, sha256d from prevouts import ( PARENT_TXIDS_LIMIT, decode_parent_header, decode_parent_txids, decode_previous, @@ -20,7 +20,7 @@ class PrevoutChecks(unittest.TestCase): def setUp(self): self.wire, self.stripped = transaction(witness=True) - self.txid = sha256d(self.stripped)[::-1].hex() + self.txid = b2lx(sha256d(self.stripped)) self.temp = tempfile.TemporaryDirectory() self.addCleanup(self.temp.cleanup) self.cache = Path(self.temp.name) @@ -65,7 +65,7 @@ def test_cache_lifecycle(self, sleep): self.assertEqual(path.read_bytes(), self.stripped) self.assertEqual(len(list(self.cache.iterdir())), 1) with self.subTest(case="cache hit"), patch("prevouts.urlopen", side_effect=AssertionError("network on a cache hit")): - self.assertIn(bytes.fromhex(self.txid)[::-1], load_previous(txs, self.cache, fetch=True)) + self.assertIn(lx(self.txid), load_previous(txs, self.cache, fetch=True)) path.write_bytes(transaction(amount=2)[1]) with self.subTest(case="corrupt entry"), self.assertRaisesRegex(ValueError, "identity mismatch"): load_previous(txs, self.cache, fetch=True) diff --git a/ci/test_sanity_check.py b/ci/test_sanity_check.py index cc11794..25e0674 100644 --- a/ci/test_sanity_check.py +++ b/ci/test_sanity_check.py @@ -241,7 +241,7 @@ def test_retarget_requires_different_valid_target_at_boundary(self): """Retarget evidence needs a valid differing expected target at a retarget height.""" self.record = self.for_rule("nbits_retarget_not_applied") original = copy.deepcopy(self.record) - bits = bytes.fromhex(self.record["header"])[72:76][::-1].hex() + bits = f"{CBlockHeader.deserialize(bytes.fromhex(self.record['header'])).nBits:08x}" for expected in (bits, "00000000", "1d80ffff"): with self.subTest(expected=expected): self.record["context"]["expected_nbits"] = expected diff --git a/docs/schema.md b/docs/schema.md index b47be7c..fa8b731 100644 --- a/docs/schema.md +++ b/docs/schema.md @@ -221,7 +221,6 @@ The cache stores the header's hex response as `{prev_hash}.header`, the ordered Header downloads are limited to 256 bytes and txid-list downloads to 2 MiB. Both cached and downloaded evidence undergo the same checks; missing or corrupt evidence fails validation. `--fetch-prevouts` permits downloads, and a warmed cache supports offline checks. -CI uses a `prevouts-v2-` cache prefix with older `prevouts-v1-` archives retained as a restore fallback, since the new files do not replace the existing evidence formats. The cache retention and scheduled-workflow limits described above also apply to these files. The checker considers only the immediate canonical parent, not older ancestors or the UTXO set, and does not execute scripts or replay historical `ConnectBlock`.