mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-28 16:48:13 -05:00
chore: apply same impl order (#2937)
This commit is contained in:
@@ -481,10 +481,6 @@ mod tests {
|
||||
}
|
||||
|
||||
impl WithdrawalsProvider for Provider {
|
||||
fn latest_withdrawal(&self) -> Result<Option<Withdrawal>> {
|
||||
self.withdrawals_provider.latest_withdrawal()
|
||||
}
|
||||
|
||||
fn withdrawals_by_block(
|
||||
&self,
|
||||
_id: BlockHashOrNumber,
|
||||
@@ -492,6 +488,10 @@ mod tests {
|
||||
) -> RethResult<Option<Vec<Withdrawal>>> {
|
||||
self.withdrawals_provider.withdrawals_by_block(_id, _timestamp)
|
||||
}
|
||||
|
||||
fn latest_withdrawal(&self) -> Result<Option<Withdrawal>> {
|
||||
self.withdrawals_provider.latest_withdrawal()
|
||||
}
|
||||
}
|
||||
|
||||
fn mock_tx(nonce: u64) -> TransactionSignedEcRecovered {
|
||||
|
||||
@@ -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<String>;
|
||||
type Strategy = BoxedStrategy<Capability>;
|
||||
|
||||
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
|
||||
any_with::<String>(args) // TODO: what possible values?
|
||||
.prop_flat_map(move |name| {
|
||||
@@ -94,6 +92,8 @@ impl proptest::arbitrary::Arbitrary for Capability {
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
|
||||
type Strategy = BoxedStrategy<Capability>;
|
||||
}
|
||||
|
||||
/// Represents all capabilities of a node.
|
||||
|
||||
@@ -221,14 +221,14 @@ use proptest::{
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
impl proptest::arbitrary::Arbitrary for Chain {
|
||||
type Parameters = ParamsFor<u32>;
|
||||
type Strategy = BoxedStrategy<Chain>;
|
||||
|
||||
fn arbitrary_with(_: Self::Parameters) -> Self::Strategy {
|
||||
let named = any::<Selector>()
|
||||
.prop_map(move |sel| Chain::Named(sel.select(ethers_core::types::Chain::iter())));
|
||||
let id = any::<u64>().prop_map(Chain::from);
|
||||
proptest::strategy::Union::new_weighted(vec![(50, named.boxed()), (50, id.boxed())]).boxed()
|
||||
}
|
||||
|
||||
type Strategy = BoxedStrategy<Chain>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -202,13 +202,13 @@ use proptest::strategy::Strategy;
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
impl proptest::prelude::Arbitrary for Bytes {
|
||||
type Parameters = proptest::arbitrary::ParamsFor<u8>;
|
||||
type Strategy = proptest::prelude::BoxedStrategy<Bytes>;
|
||||
|
||||
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
|
||||
proptest::collection::vec(proptest::arbitrary::any_with::<u8>(args), 0..80)
|
||||
.prop_map(move |vec| bytes::Bytes::from(vec).into())
|
||||
.boxed()
|
||||
}
|
||||
|
||||
type Strategy = proptest::prelude::BoxedStrategy<Bytes>;
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,10 @@ impl<'a> DbTxMut<'a> for TxMock {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn clear<T: Table>(&self) -> Result<(), DatabaseError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn cursor_write<T: Table>(
|
||||
&self,
|
||||
) -> Result<<Self as DbTxMutGAT<'_>>::CursorMut<T>, DatabaseError> {
|
||||
@@ -102,10 +106,6 @@ impl<'a> DbTxMut<'a> for TxMock {
|
||||
) -> Result<<Self as DbTxMutGAT<'_>>::DupCursorMut<T>, DatabaseError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn clear<T: Table>(&self) -> Result<(), DatabaseError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableImporter<'a> for TxMock {}
|
||||
|
||||
@@ -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<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, DatabaseError> {
|
||||
self.new_cursor()
|
||||
}
|
||||
|
||||
/// Iterate over read only values in database.
|
||||
fn cursor_dup_read<T: DupSort>(
|
||||
&self,
|
||||
) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, DatabaseError> {
|
||||
self.new_cursor()
|
||||
fn get<T: Table>(&self, key: T::Key) -> Result<Option<<T as Table>::Value>, DatabaseError> {
|
||||
self.inner
|
||||
.get(self.get_dbi::<T>()?, key.encode().as_ref())
|
||||
.map_err(|e| DatabaseError::Read(e.into()))?
|
||||
.map(decode_one::<T>)
|
||||
.transpose()
|
||||
}
|
||||
|
||||
fn commit(self) -> Result<bool, DatabaseError> {
|
||||
@@ -108,12 +104,16 @@ impl<'tx, K: TransactionKind, E: EnvironmentKind> DbTx<'tx> for Tx<'tx, K, E> {
|
||||
drop(self.inner)
|
||||
}
|
||||
|
||||
fn get<T: Table>(&self, key: T::Key) -> Result<Option<<T as Table>::Value>, DatabaseError> {
|
||||
self.inner
|
||||
.get(self.get_dbi::<T>()?, key.encode().as_ref())
|
||||
.map_err(|e| DatabaseError::Read(e.into()))?
|
||||
.map(decode_one::<T>)
|
||||
.transpose()
|
||||
// Iterate over read only values in database.
|
||||
fn cursor_read<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, DatabaseError> {
|
||||
self.new_cursor()
|
||||
}
|
||||
|
||||
/// Iterate over read only values in database.
|
||||
fn cursor_dup_read<T: DupSort>(
|
||||
&self,
|
||||
) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, DatabaseError> {
|
||||
self.new_cursor()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ where
|
||||
{
|
||||
type Compressed = Vec<u8>;
|
||||
|
||||
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(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<B: bytes::BufMut + AsMut<[u8]>>(self, buf: &mut B) {
|
||||
buf.put_slice(&parity_scale_codec::Encode::encode(&self))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Decompress for T
|
||||
|
||||
@@ -111,6 +111,11 @@ impl AsRef<[u8]> for RawValue<Vec<u8>> {
|
||||
impl<V: Value> Compress for RawValue<V> {
|
||||
type Compressed = Vec<u8>;
|
||||
|
||||
fn uncompressable_ref(&self) -> Option<&[u8]> {
|
||||
// Already compressed
|
||||
Some(&self.value)
|
||||
}
|
||||
|
||||
fn compress(self) -> Self::Compressed {
|
||||
self.value
|
||||
}
|
||||
@@ -118,11 +123,6 @@ impl<V: Value> Compress for RawValue<V> {
|
||||
fn compress_to_buf<B: bytes::BufMut + AsMut<[u8]>>(self, buf: &mut B) {
|
||||
buf.put_slice(self.value.as_slice())
|
||||
}
|
||||
|
||||
fn uncompressable_ref(&self) -> Option<&[u8]> {
|
||||
// Already compressed
|
||||
Some(&self.value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<V: Value> Decompress for RawValue<V> {
|
||||
|
||||
@@ -276,11 +276,11 @@ impl BlockNumProvider for MockEthProvider {
|
||||
}
|
||||
|
||||
impl BlockIdProvider for MockEthProvider {
|
||||
fn safe_block_num_hash(&self) -> Result<Option<reth_primitives::BlockNumHash>> {
|
||||
fn pending_block_num_hash(&self) -> Result<Option<reth_primitives::BlockNumHash>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn pending_block_num_hash(&self) -> Result<Option<reth_primitives::BlockNumHash>> {
|
||||
fn safe_block_num_hash(&self) -> Result<Option<reth_primitives::BlockNumHash>> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user