Skip to content

Commit d80fcf6

Browse files
authored
Fix: invalid tx input error in anvil component (#11488)
refactor: return RlpError instead of panicking
1 parent 6aedaea commit d80fcf6

File tree

1 file changed

+4
-4
lines changed
  • crates/anvil/core/src/eth/transaction

1 file changed

+4
-4
lines changed

crates/anvil/core/src/eth/transaction/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,14 +1034,14 @@ impl Decodable2718 for TypedTransaction {
10341034
TxEnvelope::Eip1559(tx) => Ok(Self::EIP1559(tx)),
10351035
TxEnvelope::Eip4844(tx) => Ok(Self::EIP4844(tx)),
10361036
TxEnvelope::Eip7702(tx) => Ok(Self::EIP7702(tx)),
1037-
_ => unreachable!(),
1037+
_ => Err(Eip2718Error::RlpError(alloy_rlp::Error::Custom("unexpected tx type"))),
10381038
}
10391039
}
10401040

10411041
fn fallback_decode(buf: &mut &[u8]) -> Result<Self, Eip2718Error> {
10421042
match TxEnvelope::fallback_decode(buf)? {
10431043
TxEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)),
1044-
_ => unreachable!(),
1044+
_ => Err(Eip2718Error::RlpError(alloy_rlp::Error::Custom("unexpected tx type"))),
10451045
}
10461046
}
10471047
}
@@ -1411,14 +1411,14 @@ impl Decodable2718 for TypedReceipt {
14111411
ReceiptEnvelope::Eip2930(tx) => Ok(Self::EIP2930(tx)),
14121412
ReceiptEnvelope::Eip1559(tx) => Ok(Self::EIP1559(tx)),
14131413
ReceiptEnvelope::Eip4844(tx) => Ok(Self::EIP4844(tx)),
1414-
_ => unreachable!(),
1414+
_ => Err(Eip2718Error::RlpError(alloy_rlp::Error::Custom("unexpected tx type"))),
14151415
}
14161416
}
14171417

14181418
fn fallback_decode(buf: &mut &[u8]) -> Result<Self, Eip2718Error> {
14191419
match ReceiptEnvelope::fallback_decode(buf)? {
14201420
ReceiptEnvelope::Legacy(tx) => Ok(Self::Legacy(tx)),
1421-
_ => unreachable!(),
1421+
_ => Err(Eip2718Error::RlpError(alloy_rlp::Error::Custom("unexpected tx type"))),
14221422
}
14231423
}
14241424
}

0 commit comments

Comments
 (0)