reth icon indicating copy to clipboard operation
reth copied to clipboard

fix: prevent CREATE tx for EIP-4844 types

Open fgimenez opened this issue 1 year ago • 1 comments

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 avatar May 16 '24 17:05 fgimenez

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.

joshieDo avatar May 17 '24 12:05 joshieDo