From f70be1b4651ef0fcdf215b69ac2b3579c50b2896 Mon Sep 17 00:00:00 2001 From: refcell Date: Sun, 5 Nov 2023 19:54:52 +0100 Subject: [PATCH] exhaustive compat matching on tx type primitive --- crates/primitives/src/transaction/tx_type.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/primitives/src/transaction/tx_type.rs b/crates/primitives/src/transaction/tx_type.rs index 4f0f91f2863e..42dc132c5c79 100644 --- a/crates/primitives/src/transaction/tx_type.rs +++ b/crates/primitives/src/transaction/tx_type.rs @@ -72,7 +72,15 @@ impl Compact for TxType { TxType::Legacy => 0, TxType::EIP2930 => 1, TxType::EIP1559 => 2, - _ => { + TxType::EIP4844 => { + // Write the full transaction type to the buffer when encoding > 3. + // This allows compat decoding the [TyType] from a single byte as + // opposed to 2 bits for the backwards-compatible encoding. + buf.put_u8(self as u8); + 3 + } + #[cfg(feature = "optimism")] + TxType::DEPOSIT => { buf.put_u8(self as u8); 3 }