Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/sanitycheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ci/test_prevouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ci/test_sanity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Loading