Skip to content

Commit

Permalink
Fix parsing of non-legacy receipts (#1356)
Browse files Browse the repository at this point in the history
* Fix parsing of non-legacy receipts

* Clippy
  • Loading branch information
Nashtare authored Nov 14, 2023
1 parent f7d5e7c commit 6f2b334
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion evm/src/generation/mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,24 @@ pub(crate) fn all_mpt_prover_inputs_reversed(
}

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 decoded_receipt: LegacyReceiptRlp =
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((decoded_receipt.status as u8).into());
Expand Down

0 comments on commit 6f2b334

Please sign in to comment.