diff --git a/crates/net/eth-wire/src/types/broadcast.rs b/crates/net/eth-wire/src/types/broadcast.rs index 236924e03a77..17d4579aed94 100644 --- a/crates/net/eth-wire/src/types/broadcast.rs +++ b/crates/net/eth-wire/src/types/broadcast.rs @@ -283,10 +283,22 @@ pub struct NewPooledTransactionHashes68 { /// instead use the [`Encodable`](alloy_rlp::Encodable) and [`Decodable`](alloy_rlp::Decodable) /// implementations for `&[u8]` instead, which encodes into a RLP string, and expects an RLP /// string when decoding. + #[cfg_attr( + any(test, feature = "arbitrary"), + proptest(strategy = "proptest::collection::vec(proptest::arbitrary::any::(), 100)") + )] pub types: Vec, /// Transaction sizes for new transactions that have appeared on the network. + #[cfg_attr( + any(test, feature = "arbitrary"), + proptest(strategy = "proptest::collection::vec(proptest::arbitrary::any::(), 100)") + )] pub sizes: Vec, /// Transaction hashes for new transactions that have appeared on the network. + #[cfg_attr( + any(test, feature = "arbitrary"), + proptest(strategy = "proptest::collection::vec(proptest::arbitrary::any::(), 100)") + )] pub hashes: Vec, } @@ -342,7 +354,26 @@ impl Decodable for NewPooledTransactionHashes68 { } let encodable = EncodableNewPooledTransactionHashes68::decode(buf)?; - Ok(Self { types: encodable.types.into(), sizes: encodable.sizes, hashes: encodable.hashes }) + let msg = Self { + types: encodable.types.into(), + sizes: encodable.sizes, + hashes: encodable.hashes, + }; + + if msg.hashes.len() != msg.types.len() { + return Err(alloy_rlp::Error::ListLengthMismatch { + expected: msg.hashes.len(), + got: msg.types.len(), + }) + } + if msg.hashes.len() != msg.sizes.len() { + return Err(alloy_rlp::Error::ListLengthMismatch { + expected: msg.hashes.len(), + got: msg.sizes.len(), + }) + } + + Ok(msg) } }