diff --git a/crates/consensus/common/src/validation.rs b/crates/consensus/common/src/validation.rs index 4e6c85c29..59367ee97 100644 --- a/crates/consensus/common/src/validation.rs +++ b/crates/consensus/common/src/validation.rs @@ -481,10 +481,6 @@ mod tests { } impl WithdrawalsProvider for Provider { - fn latest_withdrawal(&self) -> Result> { - self.withdrawals_provider.latest_withdrawal() - } - fn withdrawals_by_block( &self, _id: BlockHashOrNumber, @@ -492,6 +488,10 @@ mod tests { ) -> RethResult>> { self.withdrawals_provider.withdrawals_by_block(_id, _timestamp) } + + fn latest_withdrawal(&self) -> Result> { + self.withdrawals_provider.latest_withdrawal() + } } fn mock_tx(nonce: u64) -> TransactionSignedEcRecovered { diff --git a/crates/net/eth-wire/src/capability.rs b/crates/net/eth-wire/src/capability.rs index da8f7e4d1..6bdfd85bd 100644 --- a/crates/net/eth-wire/src/capability.rs +++ b/crates/net/eth-wire/src/capability.rs @@ -84,8 +84,6 @@ impl<'a> arbitrary::Arbitrary<'a> for Capability { #[cfg(any(test, feature = "arbitrary"))] impl proptest::arbitrary::Arbitrary for Capability { type Parameters = ParamsFor; - type Strategy = BoxedStrategy; - fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { any_with::(args) // TODO: what possible values? .prop_flat_map(move |name| { @@ -94,6 +92,8 @@ impl proptest::arbitrary::Arbitrary for Capability { }) .boxed() } + + type Strategy = BoxedStrategy; } /// Represents all capabilities of a node. diff --git a/crates/primitives/src/chain/mod.rs b/crates/primitives/src/chain/mod.rs index b99d272ea..f10d08bfd 100644 --- a/crates/primitives/src/chain/mod.rs +++ b/crates/primitives/src/chain/mod.rs @@ -221,14 +221,14 @@ use proptest::{ #[cfg(any(test, feature = "arbitrary"))] impl proptest::arbitrary::Arbitrary for Chain { type Parameters = ParamsFor; - type Strategy = BoxedStrategy; - fn arbitrary_with(_: Self::Parameters) -> Self::Strategy { let named = any::() .prop_map(move |sel| Chain::Named(sel.select(ethers_core::types::Chain::iter()))); let id = any::().prop_map(Chain::from); proptest::strategy::Union::new_weighted(vec![(50, named.boxed()), (50, id.boxed())]).boxed() } + + type Strategy = BoxedStrategy; } #[cfg(test)] diff --git a/crates/primitives/src/hex_bytes.rs b/crates/primitives/src/hex_bytes.rs index 63aac34ba..322b9ff04 100644 --- a/crates/primitives/src/hex_bytes.rs +++ b/crates/primitives/src/hex_bytes.rs @@ -202,13 +202,13 @@ use proptest::strategy::Strategy; #[cfg(any(test, feature = "arbitrary"))] impl proptest::prelude::Arbitrary for Bytes { type Parameters = proptest::arbitrary::ParamsFor; - type Strategy = proptest::prelude::BoxedStrategy; - fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { proptest::collection::vec(proptest::arbitrary::any_with::(args), 0..80) .prop_map(move |vec| bytes::Bytes::from(vec).into()) .boxed() } + + type Strategy = proptest::prelude::BoxedStrategy; } #[cfg(any(test, feature = "arbitrary"))] diff --git a/crates/stages/src/stages/merkle.rs b/crates/stages/src/stages/merkle.rs index 6547043d2..96d92a7b5 100644 --- a/crates/stages/src/stages/merkle.rs +++ b/crates/stages/src/stages/merkle.rs @@ -461,6 +461,11 @@ mod tests { } impl UnwindStageTestRunner for MerkleTestRunner { + fn validate_unwind(&self, _input: UnwindInput) -> Result<(), TestRunnerError> { + // The unwind is validated within the stage + Ok(()) + } + fn before_unwind(&self, input: UnwindInput) -> Result<(), TestRunnerError> { let target_block = input.unwind_to + 1; @@ -532,10 +537,5 @@ mod tests { .unwrap(); Ok(()) } - - fn validate_unwind(&self, _input: UnwindInput) -> Result<(), TestRunnerError> { - // The unwind is validated within the stage - Ok(()) - } } } diff --git a/crates/storage/db/src/abstraction/mock.rs b/crates/storage/db/src/abstraction/mock.rs index a647a9cfa..adf118f2f 100644 --- a/crates/storage/db/src/abstraction/mock.rs +++ b/crates/storage/db/src/abstraction/mock.rs @@ -91,6 +91,10 @@ impl<'a> DbTxMut<'a> for TxMock { todo!() } + fn clear(&self) -> Result<(), DatabaseError> { + todo!() + } + fn cursor_write( &self, ) -> Result<>::CursorMut, DatabaseError> { @@ -102,10 +106,6 @@ impl<'a> DbTxMut<'a> for TxMock { ) -> Result<>::DupCursorMut, DatabaseError> { todo!() } - - fn clear(&self) -> Result<(), DatabaseError> { - todo!() - } } impl<'a> TableImporter<'a> for TxMock {} diff --git a/crates/storage/db/src/implementation/mdbx/tx.rs b/crates/storage/db/src/implementation/mdbx/tx.rs index c8a0ddd08..8e91463ed 100644 --- a/crates/storage/db/src/implementation/mdbx/tx.rs +++ b/crates/storage/db/src/implementation/mdbx/tx.rs @@ -85,16 +85,12 @@ impl<'a, K: TransactionKind, E: EnvironmentKind> DbTxMutGAT<'a> for Tx<'_, K, E> impl<'a, E: EnvironmentKind> TableImporter<'a> for Tx<'_, RW, E> {} impl<'tx, K: TransactionKind, E: EnvironmentKind> DbTx<'tx> for Tx<'tx, K, E> { - // Iterate over read only values in database. - fn cursor_read(&self) -> Result<>::Cursor, DatabaseError> { - self.new_cursor() - } - - /// Iterate over read only values in database. - fn cursor_dup_read( - &self, - ) -> Result<>::DupCursor, DatabaseError> { - self.new_cursor() + fn get(&self, key: T::Key) -> Result::Value>, DatabaseError> { + self.inner + .get(self.get_dbi::()?, key.encode().as_ref()) + .map_err(|e| DatabaseError::Read(e.into()))? + .map(decode_one::) + .transpose() } fn commit(self) -> Result { @@ -108,12 +104,16 @@ impl<'tx, K: TransactionKind, E: EnvironmentKind> DbTx<'tx> for Tx<'tx, K, E> { drop(self.inner) } - fn get(&self, key: T::Key) -> Result::Value>, DatabaseError> { - self.inner - .get(self.get_dbi::()?, key.encode().as_ref()) - .map_err(|e| DatabaseError::Read(e.into()))? - .map(decode_one::) - .transpose() + // Iterate over read only values in database. + fn cursor_read(&self) -> Result<>::Cursor, DatabaseError> { + self.new_cursor() + } + + /// Iterate over read only values in database. + fn cursor_dup_read( + &self, + ) -> Result<>::DupCursor, DatabaseError> { + self.new_cursor() } } diff --git a/crates/storage/db/src/tables/codecs/scale.rs b/crates/storage/db/src/tables/codecs/scale.rs index 60bca6fa1..6d42325b0 100644 --- a/crates/storage/db/src/tables/codecs/scale.rs +++ b/crates/storage/db/src/tables/codecs/scale.rs @@ -17,13 +17,13 @@ where { type Compressed = Vec; - fn compress_to_buf>(self, buf: &mut B) { - buf.put_slice(&parity_scale_codec::Encode::encode(&self)) - } - fn compress(self) -> Self::Compressed { parity_scale_codec::Encode::encode(&self) } + + fn compress_to_buf>(self, buf: &mut B) { + buf.put_slice(&parity_scale_codec::Encode::encode(&self)) + } } impl Decompress for T diff --git a/crates/storage/db/src/tables/raw.rs b/crates/storage/db/src/tables/raw.rs index c9cc0cc1e..aa23bffce 100644 --- a/crates/storage/db/src/tables/raw.rs +++ b/crates/storage/db/src/tables/raw.rs @@ -111,6 +111,11 @@ impl AsRef<[u8]> for RawValue> { impl Compress for RawValue { type Compressed = Vec; + fn uncompressable_ref(&self) -> Option<&[u8]> { + // Already compressed + Some(&self.value) + } + fn compress(self) -> Self::Compressed { self.value } @@ -118,11 +123,6 @@ impl Compress for RawValue { fn compress_to_buf>(self, buf: &mut B) { buf.put_slice(self.value.as_slice()) } - - fn uncompressable_ref(&self) -> Option<&[u8]> { - // Already compressed - Some(&self.value) - } } impl Decompress for RawValue { diff --git a/crates/storage/provider/src/test_utils/mock.rs b/crates/storage/provider/src/test_utils/mock.rs index b041bd74a..a94e26a4f 100644 --- a/crates/storage/provider/src/test_utils/mock.rs +++ b/crates/storage/provider/src/test_utils/mock.rs @@ -276,11 +276,11 @@ impl BlockNumProvider for MockEthProvider { } impl BlockIdProvider for MockEthProvider { - fn safe_block_num_hash(&self) -> Result> { + fn pending_block_num_hash(&self) -> Result> { Ok(None) } - fn pending_block_num_hash(&self) -> Result> { + fn safe_block_num_hash(&self) -> Result> { Ok(None) } diff --git a/crates/trie/benches/prefix_set.rs b/crates/trie/benches/prefix_set.rs index 13e9c7f79..33de35cf9 100644 --- a/crates/trie/benches/prefix_set.rs +++ b/crates/trie/benches/prefix_set.rs @@ -120,13 +120,13 @@ mod implementations { } impl PrefixSetAbstraction for BTreeAnyPrefixSet { - fn contains(&mut self, key: Nibbles) -> bool { - self.keys.iter().any(|k| k.has_prefix(&key)) - } - fn insert(&mut self, key: Nibbles) { self.keys.insert(key); } + + fn contains(&mut self, key: Nibbles) -> bool { + self.keys.iter().any(|k| k.has_prefix(&key)) + } } #[derive(Default)] @@ -136,6 +136,10 @@ mod implementations { } impl PrefixSetAbstraction for BTreeRangeLastCheckedPrefixSet { + fn insert(&mut self, key: Nibbles) { + self.keys.insert(key); + } + fn contains(&mut self, prefix: Nibbles) -> bool { let range = match self.last_checked.as_ref() { // presumably never hit @@ -157,10 +161,6 @@ mod implementations { false } - - fn insert(&mut self, key: Nibbles) { - self.keys.insert(key); - } } #[derive(Default)] @@ -170,6 +170,11 @@ mod implementations { } impl PrefixSetAbstraction for VecBinarySearchPrefixSet { + fn insert(&mut self, key: Nibbles) { + self.sorted = false; + self.keys.push(key); + } + fn contains(&mut self, prefix: Nibbles) -> bool { if !self.sorted { self.keys.sort(); @@ -184,11 +189,6 @@ mod implementations { }, } } - - fn insert(&mut self, key: Nibbles) { - self.sorted = false; - self.keys.push(key); - } } #[derive(Default)] @@ -199,6 +199,11 @@ mod implementations { } impl PrefixSetAbstraction for VecCursorPrefixSet { + fn insert(&mut self, nibbles: Nibbles) { + self.sorted = false; + self.keys.push(nibbles); + } + fn contains(&mut self, prefix: Nibbles) -> bool { if !self.sorted { self.keys.sort(); @@ -225,11 +230,6 @@ mod implementations { false } - - fn insert(&mut self, nibbles: Nibbles) { - self.sorted = false; - self.keys.push(nibbles); - } } #[derive(Default)] @@ -240,6 +240,11 @@ mod implementations { } impl PrefixSetAbstraction for VecBinarySearchWithLastFoundPrefixSet { + fn insert(&mut self, key: Nibbles) { + self.sorted = false; + self.keys.push(key); + } + fn contains(&mut self, prefix: Nibbles) -> bool { if !self.sorted { self.keys.sort(); @@ -261,10 +266,5 @@ mod implementations { }, } } - - fn insert(&mut self, key: Nibbles) { - self.sorted = false; - self.keys.push(key); - } } }