From e7ae2fc275ca01f3c666d106dac99f392ade56e4 Mon Sep 17 00:00:00 2001 From: gabriel-aranha-cw Date: Tue, 4 Feb 2025 17:05:55 -0300 Subject: [PATCH] chore: remove ethers rng utils --- Cargo.lock | 1 + Cargo.toml | 1 + src/eth/primitives/address.rs | 2 +- src/eth/primitives/block_header.rs | 2 +- src/eth/primitives/block_number.rs | 2 +- src/eth/primitives/chain_id.rs | 2 +- src/eth/primitives/code_hash.rs | 2 +- src/eth/primitives/difficulty.rs | 2 +- src/eth/primitives/execution_result.rs | 2 +- src/eth/primitives/gas.rs | 2 +- src/eth/primitives/hash.rs | 2 +- src/eth/primitives/log_topic.rs | 2 +- src/eth/primitives/miner_nonce.rs | 2 +- src/eth/primitives/nonce.rs | 2 +- src/eth/primitives/size.rs | 2 +- src/eth/primitives/slot_index.rs | 2 +- src/eth/primitives/slot_value.rs | 2 +- src/eth/primitives/transaction_input.rs | 2 +- src/eth/primitives/unix_time.rs | 2 +- src/eth/primitives/wei.rs | 2 +- 20 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b0f9d100..e84660832 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5389,6 +5389,7 @@ dependencies = [ "prost-types", "quick_cache", "rand", + "rand_core", "rdkafka", "reqwest 0.12.4", "revm", diff --git a/Cargo.toml b/Cargo.toml index c31049380..fb1b160ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ paste = "=1.0.15" phf = "=0.11.2" pin-project = "=1.1.5" rand = { version = "=0.8.5", features = ["small_rng"] } +rand_core = "=0.6.4" rust_decimal = "=1.36.0" rustc-hash = "=2.0.0" smallvec = "=1.13.2" diff --git a/src/eth/primitives/address.rs b/src/eth/primitives/address.rs index ae268d9df..29f01f1ca 100644 --- a/src/eth/primitives/address.rs +++ b/src/eth/primitives/address.rs @@ -57,7 +57,7 @@ impl Display for Address { } impl Dummy for Address { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { H160::random_using(rng).into() } } diff --git a/src/eth/primitives/block_header.rs b/src/eth/primitives/block_header.rs index 646ae3f7d..7a1a47fa4 100644 --- a/src/eth/primitives/block_header.rs +++ b/src/eth/primitives/block_header.rs @@ -87,7 +87,7 @@ impl BlockHeader { } impl Dummy for BlockHeader { - fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { Self { number: faker.fake_with_rng(rng), hash: faker.fake_with_rng(rng), diff --git a/src/eth/primitives/block_number.rs b/src/eth/primitives/block_number.rs index 584995e3d..0f4189a25 100644 --- a/src/eth/primitives/block_number.rs +++ b/src/eth/primitives/block_number.rs @@ -71,7 +71,7 @@ impl BlockNumber { } impl Dummy for BlockNumber { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/chain_id.rs b/src/eth/primitives/chain_id.rs index 5375cace3..ab01269c3 100644 --- a/src/eth/primitives/chain_id.rs +++ b/src/eth/primitives/chain_id.rs @@ -12,7 +12,7 @@ use crate::gen_newtype_try_from; pub struct ChainId(pub U64); impl Dummy for ChainId { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/code_hash.rs b/src/eth/primitives/code_hash.rs index 38793f951..d63dff495 100644 --- a/src/eth/primitives/code_hash.rs +++ b/src/eth/primitives/code_hash.rs @@ -14,7 +14,7 @@ use crate::gen_newtype_from; pub struct CodeHash(pub H256); impl Dummy for CodeHash { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { Self(H256::random_using(rng)) } } diff --git a/src/eth/primitives/difficulty.rs b/src/eth/primitives/difficulty.rs index 15ec5c8ee..100b424af 100644 --- a/src/eth/primitives/difficulty.rs +++ b/src/eth/primitives/difficulty.rs @@ -11,7 +11,7 @@ use crate::gen_newtype_from; pub struct Difficulty(pub U256); impl Dummy for Difficulty { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/execution_result.rs b/src/eth/primitives/execution_result.rs index 29e35e3a5..c46ee64f2 100644 --- a/src/eth/primitives/execution_result.rs +++ b/src/eth/primitives/execution_result.rs @@ -27,7 +27,7 @@ pub enum ExecutionResult { pub struct RevertReason(pub Cow<'static, str>); impl fake::Dummy for RevertReason { - fn dummy_with_rng(_: &Faker, _rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, _rng: &mut R) -> Self { RevertReason(Cow::Borrowed("reverted")) } } diff --git a/src/eth/primitives/gas.rs b/src/eth/primitives/gas.rs index 2e477c7f0..27532bb2b 100644 --- a/src/eth/primitives/gas.rs +++ b/src/eth/primitives/gas.rs @@ -22,7 +22,7 @@ impl Gas { } impl Dummy for Gas { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/hash.rs b/src/eth/primitives/hash.rs index e04ccfc0e..63a7bfdd6 100644 --- a/src/eth/primitives/hash.rs +++ b/src/eth/primitives/hash.rs @@ -30,7 +30,7 @@ impl Display for Hash { } impl Dummy for Hash { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { H256::random_using(rng).into() } } diff --git a/src/eth/primitives/log_topic.rs b/src/eth/primitives/log_topic.rs index a53f2dcbf..05b12e26a 100644 --- a/src/eth/primitives/log_topic.rs +++ b/src/eth/primitives/log_topic.rs @@ -20,7 +20,7 @@ impl Display for LogTopic { } impl Dummy for LogTopic { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { Self(H256::random_using(rng)) } } diff --git a/src/eth/primitives/miner_nonce.rs b/src/eth/primitives/miner_nonce.rs index 04eb65656..210e4ddd4 100644 --- a/src/eth/primitives/miner_nonce.rs +++ b/src/eth/primitives/miner_nonce.rs @@ -11,7 +11,7 @@ use crate::gen_newtype_from; pub struct MinerNonce(H64); impl Dummy for MinerNonce { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { H64::random_using(rng).into() } } diff --git a/src/eth/primitives/nonce.rs b/src/eth/primitives/nonce.rs index 7d5ac4ec8..7e9bac4fb 100644 --- a/src/eth/primitives/nonce.rs +++ b/src/eth/primitives/nonce.rs @@ -21,7 +21,7 @@ impl Nonce { } impl Dummy for Nonce { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/size.rs b/src/eth/primitives/size.rs index 0bce30fd9..0fae09b2f 100644 --- a/src/eth/primitives/size.rs +++ b/src/eth/primitives/size.rs @@ -14,7 +14,7 @@ use crate::gen_newtype_from; pub struct Size(U64); impl Dummy for Size { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/slot_index.rs b/src/eth/primitives/slot_index.rs index 63dbc0e39..45fe20f4c 100644 --- a/src/eth/primitives/slot_index.rs +++ b/src/eth/primitives/slot_index.rs @@ -38,7 +38,7 @@ impl SlotIndex { } impl Dummy for SlotIndex { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/slot_value.rs b/src/eth/primitives/slot_value.rs index 83fc15137..744859a2c 100644 --- a/src/eth/primitives/slot_value.rs +++ b/src/eth/primitives/slot_value.rs @@ -25,7 +25,7 @@ impl Display for SlotValue { } impl Dummy for SlotValue { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/transaction_input.rs b/src/eth/primitives/transaction_input.rs index f3900fc97..40c2c9c1c 100644 --- a/src/eth/primitives/transaction_input.rs +++ b/src/eth/primitives/transaction_input.rs @@ -44,7 +44,7 @@ pub struct TransactionInput { } impl Dummy for TransactionInput { - fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(faker: &Faker, rng: &mut R) -> Self { Self { tx_type: Some(rng.next_u64().into()), chain_id: faker.fake_with_rng(rng), diff --git a/src/eth/primitives/unix_time.rs b/src/eth/primitives/unix_time.rs index a827db67d..853d19249 100644 --- a/src/eth/primitives/unix_time.rs +++ b/src/eth/primitives/unix_time.rs @@ -46,7 +46,7 @@ impl Deref for UnixTime { } impl Dummy for UnixTime { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } } diff --git a/src/eth/primitives/wei.rs b/src/eth/primitives/wei.rs index 6dc4b0887..5189a96ce 100644 --- a/src/eth/primitives/wei.rs +++ b/src/eth/primitives/wei.rs @@ -24,7 +24,7 @@ impl Wei { } impl Dummy for Wei { - fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &Faker, rng: &mut R) -> Self { rng.next_u64().into() } }