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
7 changes: 7 additions & 0 deletions prdoc/pr_10290.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: 'pallet-revive: fix eth tx decoding'
doc:
- audience: Runtime Dev
description: 'Fix Ethereum transaction decoding'
crates:
- name: pallet-revive
bump: patch
21 changes: 14 additions & 7 deletions substrate/frame/revive/src/evm/api/rlp_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,22 @@ impl TransactionSigned {

/// Decode the Ethereum transaction from bytes.
pub fn decode(data: &[u8]) -> Result<Self, rlp::DecoderError> {
if data.len() < 1 {
if data.is_empty() {
return Err(rlp::DecoderError::RlpIsTooShort);
}
match data[0] {
TYPE_EIP2930 => rlp::decode::<Transaction2930Signed>(&data[1..]).map(Into::into),
TYPE_EIP1559 => rlp::decode::<Transaction1559Signed>(&data[1..]).map(Into::into),
TYPE_EIP4844 => rlp::decode::<Transaction4844Signed>(&data[1..]).map(Into::into),
TYPE_EIP7702 => rlp::decode::<Transaction7702Signed>(&data[1..]).map(Into::into),
_ => rlp::decode::<TransactionLegacySigned>(data).map(Into::into),
let first_byte = data[0];

// EIP-2718: Typed transactions use type identifiers in [0x00, 0x7f].
if first_byte <= 0x7f {
match first_byte {
TYPE_EIP2930 => rlp::decode::<Transaction2930Signed>(&data[1..]).map(Into::into),
TYPE_EIP1559 => rlp::decode::<Transaction1559Signed>(&data[1..]).map(Into::into),
TYPE_EIP4844 => rlp::decode::<Transaction4844Signed>(&data[1..]).map(Into::into),
TYPE_EIP7702 => rlp::decode::<Transaction7702Signed>(&data[1..]).map(Into::into),
_ => Err(rlp::DecoderError::Custom("Unknown transaction type")),
Comment thread
pgherveou marked this conversation as resolved.
}
} else {
rlp::decode::<TransactionLegacySigned>(data).map(Into::into)
}
}
}
Expand Down
Loading