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: prevent CREATE tx for EIP-4844 types #8291

Merged

Conversation

fgimenez
Copy link
Member

EIP-4844 transactions have a restriction that they should not allow CREATE transactions.

In this PR the to field in TxEip4844 is changed from TxKind to Address, so that it can't be decoded into TxKind::Create.

@fgimenez fgimenez added A-rpc Related to the RPC implementation C-security Issue or pull request related to security. labels May 16, 2024
Copy link
Collaborator

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

ty, pending @joshieDo

I believe this should be okay.

Comment on lines +49 to +54
/// The 160-bit address of the message call’s recipient.
pub to: Address,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@joshieDo please check if this is sound:

ref #7276 (comment)

@joshieDo
Copy link
Collaborator

joshieDo commented May 17, 2024

this is most likely not sound. TxKind occupies one bit inside the bitflag struct. If set, it will decode an address, otherwise it wont. This bitflag struct more or less dictates what to decode or how many bytes to decode from.

Changing this to Address, will make it not backwards compatible since, this bit will now be part of the next field which is not right.

Note the cargo expansion below B1.

main:

#[allow(clippy::identity_op)]
            pub struct TxEip4844Flags {
                bytes: [::core::primitive::u8; {
                    ((({
                        0usize + <B4 as ::modular_bitfield::Specifier>::BITS
                            + <B4 as ::modular_bitfield::Specifier>::BITS
                            + <B4 as ::modular_bitfield::Specifier>::BITS
                            + <B5 as ::modular_bitfield::Specifier>::BITS
                            + <B5 as ::modular_bitfield::Specifier>::BITS
                            + <B1 as ::modular_bitfield::Specifier>::BITS
                            + <B6 as ::modular_bitfield::Specifier>::BITS
                            + <B5 as ::modular_bitfield::Specifier>::BITS
                            + <B6 as ::modular_bitfield::Specifier>::BITS
                    } - 1) / 8) + 1) * 8
                } / 8usize],

this branch:

#[allow(clippy::identity_op)]
            pub struct TxEip4844Flags {
                bytes: [::core::primitive::u8; {
                    ((({
                        0usize + <B4 as ::modular_bitfield::Specifier>::BITS
                            + <B4 as ::modular_bitfield::Specifier>::BITS
                            + <B4 as ::modular_bitfield::Specifier>::BITS
                            + <B5 as ::modular_bitfield::Specifier>::BITS
                            + <B5 as ::modular_bitfield::Specifier>::BITS
                            + <B6 as ::modular_bitfield::Specifier>::BITS
                            + <B5 as ::modular_bitfield::Specifier>::BITS
                            + <B7 as ::modular_bitfield::Specifier>::BITS
                    } - 1) / 8) + 1) * 8
                } / 8usize],

Note the missing bit on this branch macro expansion.

@fgimenez fgimenez force-pushed the fgimenez/prevent-create-tx-for-eip-4844 branch from d7fc72c to 20e587d Compare May 20, 2024 09:05
@fgimenez fgimenez requested a review from joshieDo May 20, 2024 13:00
Copy link
Collaborator

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

this is a bit ugly,

I wonder if we could actually replace the tx types with alloy now and add some compact glue code?

@mattsse mattsse enabled auto-merge May 21, 2024 08:36
@mattsse mattsse added this pull request to the merge queue May 21, 2024
Merged via the queue into paradigmxyz:main with commit 5100ddd May 21, 2024
28 checks passed
mw2000 pushed a commit to mw2000/reth that referenced this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-security Issue or pull request related to security.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants