Skip to content

Comments

fix(anvil): TypedTransaction rlp decode, bump k256#6327

Merged
DaniPopes merged 3 commits intomasterfrom
dani/fix-anvil-tx-rlp
Nov 16, 2023
Merged

fix(anvil): TypedTransaction rlp decode, bump k256#6327
DaniPopes merged 3 commits intomasterfrom
dani/fix-anvil-tx-rlp

Conversation

@DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Nov 16, 2023

Motivation

RLP decoding is incomplete: rlp.data() decodes a header and returns the next header.num bytes, but this is always 0 if the raw rlp data already starts with a tx type

See also Reth impl and docs https://github.com/paradigmxyz/reth/blob/0b46e16dcdc9012810726bee410047fea8be7cf9/crates/primitives/src/transaction/mod.rs#L1317C1-L1347C2

Solution

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gg boss
dbg nits

}
if first == 0x02 {
return rlp::decode(s).map(TypedTransaction::EIP1559)
let [first, s @ ..] = rlp.as_raw() else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to get used to this -.-

@mattsse
Copy link
Member

mattsse commented Nov 16, 2023

possible that this is broken due to

// the [TypedTransaction] requires a valid rlp input,
// but EIP-1559 prepends a version byte, so we need to encode the data first to get a
// valid rlp and then rlp decode impl of `TypedTransaction` will remove and check the
// version byte
let extend = rlp::encode(&data);
let tx = match rlp::decode::<TypedTransaction>(&extend[..]) {
Ok(transaction) => transaction,
Err(_) => return Err(BlockchainError::FailedToDecodeSignedTransaction),
};

I guess we no longer need to ensure the input is rlp now that we don't decode the header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants