diag: reproducer also reports script bytes-header consistency
This commit is contained in:
parent
d71b543ae6
commit
a627403492
1 changed files with 42 additions and 0 deletions
|
|
@ -91,6 +91,48 @@ fn main() {
|
|||
if let Some(pos) = find_subseq(&tx_bytes, &script_bytes) {
|
||||
println!("✅ FOUND input script bytes verbatim at tx-body offset {}", pos);
|
||||
println!(" pallas-txbuilder serialized them clean.");
|
||||
|
||||
// BUT: check the bytes-header that precedes them. In CBOR, a
|
||||
// bytestring of length N has a leader byte of 0x40+N for N<24,
|
||||
// 0x58 + 1 length byte for N<=255, 0x59 + 2 length bytes for
|
||||
// N<=65535. For 7213, header = 0x59 0x1c 0x2d. If the header
|
||||
// claims a different length, encoding is inconsistent.
|
||||
if pos >= 3 {
|
||||
let h = &tx_bytes[pos - 3..pos];
|
||||
println!(
|
||||
" bytes-header preceding script: {:02x} {:02x} {:02x}",
|
||||
h[0], h[1], h[2]
|
||||
);
|
||||
if h[0] == 0x59 {
|
||||
let claimed_len = u16::from_be_bytes([h[1], h[2]]) as usize;
|
||||
if claimed_len == script_bytes.len() {
|
||||
println!(
|
||||
" ✅ header length {} == input length {} — consistent.",
|
||||
claimed_len,
|
||||
script_bytes.len()
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
" ❌ header length {} != input length {} — encoder is OFF BY {}.",
|
||||
claimed_len,
|
||||
script_bytes.len(),
|
||||
script_bytes.len() as i64 - claimed_len as i64
|
||||
);
|
||||
}
|
||||
} else {
|
||||
println!(
|
||||
" ⚠️ preceding byte not 0x59 (uint16 bytes header) — different size class?"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Print the very first 100 bytes of tx body for inspection
|
||||
let preview_len = 100.min(tx_bytes.len());
|
||||
let preview: String = tx_bytes[..preview_len]
|
||||
.iter()
|
||||
.map(|b| format!("{:02x}", b))
|
||||
.collect();
|
||||
println!(" tx body first {} bytes: {}", preview_len, preview);
|
||||
} else {
|
||||
println!("❌ DID NOT find input script bytes verbatim in tx body.");
|
||||
println!(" pallas-txbuilder mutated the bytes during encoding.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue