mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-06 07:43:10 +00:00
Fix parsing of non-legacy receipts (#1356)
* Fix parsing of non-legacy receipts * Clippy
This commit is contained in:
parent
f7d5e7c47c
commit
6f2b3349a1
@ -68,10 +68,24 @@ pub(crate) fn all_mpt_prover_inputs_reversed(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_receipts(rlp: &[u8]) -> Result<Vec<U256>, ProgramError> {
|
pub(crate) fn parse_receipts(rlp: &[u8]) -> Result<Vec<U256>, ProgramError> {
|
||||||
|
let txn_type = match rlp.first().ok_or(ProgramError::InvalidRlp)? {
|
||||||
|
1 => 1,
|
||||||
|
2 => 2,
|
||||||
|
_ => 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
// If this is not a legacy transaction, we skip the leading byte.
|
||||||
|
let rlp = if txn_type == 0 { rlp } else { &rlp[1..] };
|
||||||
|
|
||||||
let payload_info = PayloadInfo::from(rlp).map_err(|_| ProgramError::InvalidRlp)?;
|
let payload_info = PayloadInfo::from(rlp).map_err(|_| ProgramError::InvalidRlp)?;
|
||||||
let decoded_receipt: LegacyReceiptRlp =
|
let decoded_receipt: LegacyReceiptRlp =
|
||||||
rlp::decode(rlp).map_err(|_| ProgramError::InvalidRlp)?;
|
rlp::decode(rlp).map_err(|_| ProgramError::InvalidRlp)?;
|
||||||
let mut parsed_receipt = Vec::new();
|
|
||||||
|
let mut parsed_receipt = if txn_type == 0 {
|
||||||
|
Vec::new()
|
||||||
|
} else {
|
||||||
|
vec![txn_type.into()]
|
||||||
|
};
|
||||||
|
|
||||||
parsed_receipt.push(payload_info.value_len.into()); // payload_len of the entire receipt
|
parsed_receipt.push(payload_info.value_len.into()); // payload_len of the entire receipt
|
||||||
parsed_receipt.push((decoded_receipt.status as u8).into());
|
parsed_receipt.push((decoded_receipt.status as u8).into());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user