Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pin alloy providers to repo & test fixup #6414

Merged
merged 8 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ alloy-dyn-abi = "0.4.1"
alloy-json-abi = "0.4.1"
alloy-sol-types = "0.4.1"
syn-solidity = "0.4.1"
alloy-providers = { path = "../../alloy-rs/alloy/crates/providers" }
alloy-transport = { path = "../../alloy-rs/alloy/crates/transport" }
alloy-transport-http = { path = "../../alloy-rs/alloy/crates/transport-http" }
alloy-rpc-types = { path = "../../alloy-rs/alloy/crates/rpc-types" }
alloy-providers = "0.1.0"
alloy-transport = "0.1.0"
alloy-transport-http = "0.1.0"
alloy-rpc-types = "0.1.0"

alloy-chains = "0.1.2"
alloy-rlp = "0.3.3"
Expand Down Expand Up @@ -211,6 +211,11 @@ ethers-middleware = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea
ethers-etherscan = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" }
ethers-solc = { git = "https://github.com/gakonst/ethers-rs", rev = "546ea029362a7502365667c6f99fac92ad0aeb9f" }

alloy-providers = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy/", branch = "onbjerg/alloy-temp-provider-trait" }

alloy-dyn-abi = { git = "https://github.com/alloy-rs/core/" }
alloy-primitives = { git = "https://github.com/alloy-rs/core/" }
alloy-json-abi = { git = "https://github.com/alloy-rs/core/" }
Expand Down
7 changes: 2 additions & 5 deletions crates/anvil/core/src/eth/transaction/ethers_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub fn to_ethers_state_override(ov: StateOverride) -> EthStateOverride {
pub fn to_alloy_state_override(ov: EthStateOverride) -> StateOverride {
ov.into_iter()
.map(|(addr, o)| (addr.to_alloy(), AlloyAccountOverride {
nonce: o.nonce.map(|n| rU64::from(n)),
nonce: o.nonce.map(rU64::from),
balance: o.balance.map(|b| b.to_alloy()),
code: o.code.map(|c| c.0.into()),
state_diff: o.state_diff.map(|s| s.into_iter().map(|(k, v)| (k.to_alloy(), rU256::from_be_bytes(v.to_alloy().0))).collect()),
Expand Down Expand Up @@ -305,7 +305,7 @@ fn to_alloy_transaction_with_hash_and_sender(
max_priority_fee_per_gas: Some(t.gas_price.to_alloy().to::<rU128>()),
gas: t.gas_limit.to_alloy(),
input: t.input.clone().0.into(),
chain_id: t.chain_id().map(|c| rU64::from(c)),
chain_id: t.chain_id().map(rU64::from),
signature: Some(Signature {
r: t.signature.r.to_alloy(),
s: t.signature.s.to_alloy(),
Expand All @@ -316,7 +316,6 @@ fn to_alloy_transaction_with_hash_and_sender(
transaction_type: None,
max_fee_per_blob_gas: None,
blob_versioned_hashes: vec![],
..Default::default()
},
TypedTransaction::EIP2930(t) => AlloyTransaction {
hash: hash.to_alloy(),
Expand All @@ -343,7 +342,6 @@ fn to_alloy_transaction_with_hash_and_sender(
transaction_type: Some(rU64::from(1)),
max_fee_per_blob_gas: None,
blob_versioned_hashes: vec![],
..Default::default()
},
TypedTransaction::EIP1559(t) => AlloyTransaction {
hash: hash.to_alloy(),
Expand All @@ -370,7 +368,6 @@ fn to_alloy_transaction_with_hash_and_sender(
transaction_type: Some(rU64::from(2)),
max_fee_per_blob_gas: None,
blob_versioned_hashes: vec![],
..Default::default()
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ impl NodeArgs {
};

NodeConfig::default()
.with_gas_limit(self.evm_opts.gas_limit.map(|g| U256::from(g)))
.with_gas_limit(self.evm_opts.gas_limit.map(U256::from))
.disable_block_gas_limit(self.evm_opts.disable_block_gas_limit)
.with_gas_price(self.evm_opts.gas_price.map(|g| U256::from(g)))
.with_gas_price(self.evm_opts.gas_price.map(U256::from))
.with_hardfork(self.hardfork)
.with_blocktime(self.block_time.map(Duration::from_secs))
.with_no_mining(self.no_mining)
Expand All @@ -210,13 +210,13 @@ impl NodeArgs {
.or_else(|| self.evm_opts.fork_url.as_ref().and_then(|f| f.block)),
)
.with_fork_headers(self.evm_opts.fork_headers)
.with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from).map(|c| U256::from(c)))
.with_fork_chain_id(self.evm_opts.fork_chain_id.map(u64::from).map(U256::from))
.fork_request_timeout(self.evm_opts.fork_request_timeout.map(Duration::from_millis))
.fork_request_retries(self.evm_opts.fork_request_retries)
.fork_retry_backoff(self.evm_opts.fork_retry_backoff.map(Duration::from_millis))
.fork_compute_units_per_second(compute_units_per_second)
.with_eth_rpc_url(self.evm_opts.fork_url.map(|fork| fork.url))
.with_base_fee(self.evm_opts.block_base_fee_per_gas.map(|f| U256::from(f)))
.with_base_fee(self.evm_opts.block_base_fee_per_gas.map(U256::from))
.with_storage_caching(self.evm_opts.no_storage_caching)
.with_server_config(self.server_config)
.with_host(self.host)
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ impl NodeConfig {
#[must_use]
pub fn with_gas_limit(mut self, gas_limit: Option<U256>) -> Self {
if let Some(gas_limit) = gas_limit {
self.gas_limit = gas_limit.into();
self.gas_limit = gas_limit;
}
self
}
Expand Down
48 changes: 24 additions & 24 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
validate::TransactionValidator,
},
error::{
decode_revert_reason, BlockchainError, FeeHistoryError, InvalidTransactionError,
BlockchainError, FeeHistoryError, InvalidTransactionError,
Result, ToRpcResponseResult,
},
fees::{FeeDetails, FeeHistoryCache},
Expand Down Expand Up @@ -602,10 +602,10 @@ impl EthApi {
if let BlockRequest::Number(number) = &block_request {
if let Some(fork) = self.get_fork() {
if fork.predates_fork(number.to::<u64>()) {
return Ok(fork
return fork
.get_balance(address, number.to::<u64>())
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
}
Expand Down Expand Up @@ -768,10 +768,10 @@ impl EthApi {
if let BlockRequest::Number(number) = &block_request {
if let Some(fork) = self.get_fork() {
if fork.predates_fork(number.to::<u64>()) {
return Ok(fork
return fork
.get_code(address, number.to::<u64>())
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
}
Expand All @@ -796,10 +796,10 @@ impl EthApi {
// if we're in forking mode, or still on the forked block (no blocks mined yet) then
// we can delegate the call
if fork.predates_fork_inclusive(number.to::<u64>()) {
return Ok(fork
return fork
.get_proof(address, keys, Some((*number).into()))
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
}
Expand Down Expand Up @@ -984,10 +984,10 @@ impl EthApi {
"not available on past forked blocks".to_string(),
));
}
return Ok(fork
return fork
.call(&request, Some(number.to::<u64>().into()))
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
}
Expand Down Expand Up @@ -1035,10 +1035,10 @@ impl EthApi {
if let BlockRequest::Number(number) = &block_request {
if let Some(fork) = self.get_fork() {
if fork.predates_fork(number.to::<u64>()) {
return Ok(fork
return fork
.create_access_list(&request, Some(number.to::<u64>().into()))
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
}
Expand Down Expand Up @@ -1166,10 +1166,10 @@ impl EthApi {
self.backend.ensure_block_number(Some(BlockId::Hash(block_hash.into()))).await?;
if let Some(fork) = self.get_fork() {
if fork.predates_fork_inclusive(number) {
return Ok(fork
return fork
.uncle_by_block_hash_and_index(block_hash, idx.into())
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
// It's impossible to have uncles outside of fork mode
Expand All @@ -1188,10 +1188,10 @@ impl EthApi {
let number = self.backend.ensure_block_number(Some(BlockId::Number(block_number))).await?;
if let Some(fork) = self.get_fork() {
if fork.predates_fork_inclusive(number) {
return Ok(fork
return fork
.uncle_by_block_number_and_index(number, idx.into())
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
// It's impossible to have uncles outside of fork mode
Expand Down Expand Up @@ -1266,14 +1266,14 @@ impl EthApi {
// if we're still at the forked block we don't have any history and can't compute it
// efficiently, instead we fetch it from the fork
if fork.predates_fork_inclusive(number) {
return Ok(fork
return fork
.fee_history(
block_count,
BlockNumber::Number(number),
&reward_percentiles,
)
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}

Expand Down Expand Up @@ -1788,7 +1788,7 @@ impl EthApi {
latest_block_number: latest_block_number_uint,
instance_id: *self.instance_id.read(),
forked_network: fork_config.map(|cfg| ForkedNetwork {
chain_id: U256::from(cfg.chain_id()).into(),
chain_id: U256::from(cfg.chain_id()),
fork_block_number: U64::from(cfg.block_number()),
fork_block_hash: cfg.block_hash(),
}),
Expand Down Expand Up @@ -1910,7 +1910,7 @@ impl EthApi {
};
for tx in block_txs.iter_mut() {
if let Some(receipt) = self.backend.mined_transaction_receipt(tx.hash) {
if let Some(output) = receipt.out {
if let Some(_output) = receipt.out {
// insert revert reason if failure
// TODO: Support for additional fields
// if receipt.inner.status_code.unwrap_or_default().to::<u64>() == 0 {
Expand Down Expand Up @@ -2161,10 +2161,10 @@ impl EthApi {
if let BlockRequest::Number(number) = &block_request {
if let Some(fork) = self.get_fork() {
if fork.predates_fork(number.to::<u64>()) {
return Ok(fork
return fork
.estimate_gas(&request, Some((*number).into()))
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
}
Expand Down Expand Up @@ -2539,10 +2539,10 @@ impl EthApi {
if let BlockRequest::Number(number) = &block_request {
if let Some(fork) = self.get_fork() {
if fork.predates_fork_inclusive(number.to::<u64>()) {
return Ok(fork
return fork
.get_nonce(address, (*number).to::<u64>())
.await
.map_err(|_| BlockchainError::DataUnavailable)?);
.map_err(|_| BlockchainError::DataUnavailable);
}
}
}
Expand All @@ -2566,7 +2566,7 @@ impl EthApi {
) -> Result<(U256, U256)> {
let highest_nonce =
self.get_transaction_count(from, Some(BlockId::Number(BlockNumber::Pending))).await?;
let nonce = request.nonce.map(|n| U256::from(n)).unwrap_or(highest_nonce);
let nonce = request.nonce.map(U256::from).unwrap_or(highest_nonce);

Ok((nonce, highest_nonce))
}
Expand Down
8 changes: 4 additions & 4 deletions crates/anvil/src/eth/backend/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl ClientFork {
self.config.write().update_url(url)?;
let override_chain_id = self.config.read().override_chain_id;
let chain_id = if let Some(chain_id) = override_chain_id {
chain_id.into()
chain_id
} else {
self.provider().get_chain_id().await?.to::<u64>()
};
Expand Down Expand Up @@ -239,7 +239,7 @@ impl ClientFork {
number: Option<BlockNumber>,
) -> Result<StorageValue, TransportError> {
let index = B256::from(index);
self.provider().get_storage_at(address, index.into(), number.map(Into::into)).await
self.provider().get_storage_at(address, index, number.map(Into::into)).await
}

pub async fn logs(&self, filter: &Filter) -> Result<Vec<Log>, TransportError> {
Expand Down Expand Up @@ -353,7 +353,7 @@ impl ClientFork {

let mut storage = self.storage_write();
storage.transactions.insert(hash, tx.clone());
return Ok(Some(tx));
Ok(Some(tx))
}

pub async fn trace_transaction(&self, hash: B256) -> Result<Vec<Trace>, TransportError> {
Expand Down Expand Up @@ -481,7 +481,7 @@ impl ClientFork {
};
storage.transactions.extend(block_txs.iter().map(|tx| (tx.hash, tx.clone())));
storage.hashes.insert(block_number, hash);
storage.blocks.insert(hash, block.clone().into());
storage.blocks.insert(hash, block.clone());
return Ok(Some(block));
}

Expand Down
Loading
Loading