Skip to content

Commit

Permalink
Better logic for zero values check
Browse files Browse the repository at this point in the history
  • Loading branch information
poplexity committed Sep 30, 2024
1 parent 196e950 commit 80266c3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions translator/src/rlp/telos_rlp_decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,15 @@ impl TelosTxDecodable for TxLegacy {
tx.chain_id = sig.v().chain_id();

let signed = tx.into_signed(sig);
if buf.len() + header.payload_length != original_len {
for b in buf.iter() {
if *b != 128 {
error!("Transaction has trailing non-zero RLP values: {:?}", signed);
return Err(Error::ListLengthMismatch {
expected: header.payload_length,
got: original_len - buf.len(),
});
}
}
if buf.len() + header.payload_length == original_len || buf.iter().all(|&b| b == 128) {
return Ok(signed);
}

Ok(signed)
error!("Transaction has trailing non-zero RLP values: {:?}", signed);
Err(Error::ListLengthMismatch {
expected: header.payload_length,
got: original_len - buf.len(),
})
}
}

Expand Down

0 comments on commit 80266c3

Please sign in to comment.