Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 16, 2023

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 -.-

crates/anvil/core/src/eth/transaction/mod.rs Outdated Show resolved Hide resolved
crates/anvil/core/src/eth/transaction/mod.rs Outdated Show resolved Hide resolved
@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

@DaniPopes DaniPopes merged commit 43d3645 into master Nov 16, 2023
20 checks passed
@DaniPopes DaniPopes deleted the dani/fix-anvil-tx-rlp branch November 16, 2023 02:59
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