Skip to content

fix: bump alloy + bump revm + fix ci build #199

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resolver = "2"
[workspace.package]
version = "0.1.0"
edition = "2021"
rust-version = "1.81"
rust-version = "1.83"
authors = ["Alloy Contributors"]
license = "MIT OR Apache-2.0"
homepage = "https://github.com/alloy-rs/examples"
Expand Down Expand Up @@ -95,7 +95,7 @@ significant_drop_tightening = "allow"
needless_return = "allow"

[workspace.dependencies]
alloy = { version = "0.14", features = [
alloy = { version = "0.15", features = [
"eips",
"full",
"json-rpc",
Expand All @@ -114,7 +114,7 @@ alloy = { version = "0.14", features = [

# async
futures-util = "0.3"
tokio = "1.44"
tokio = "1.45"

# misc
eyre = "0.6"
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/rlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ fn rlp(c: &mut Criterion) {
g.bench_with_input("Alloy-Rlp/Encoding", &my_struct, |b, my_struct| {
b.iter(|| {
let mut out = Vec::new();
let _ = my_struct.encode(&mut out);
my_struct.encode(&mut out);
black_box(out);
})
});

let mut encoded = Vec::new();
let _ = my_struct.encode(&mut encoded);
my_struct.encode(&mut encoded);

// Parity RLP decoding
g.bench_with_input("Parity-Rlp/Decoding", &encoded, |b, encoded| {
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.81"
msrv = "1.83"
18 changes: 9 additions & 9 deletions examples/advanced/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ workspace = true

[dev-dependencies]
alloy.workspace = true
# foundry-fork-db = "0.12"
foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db.git", rev = "cdbbe64" }

# # reth
# revm-primitives = { version = "17.0.0", default-features = false }
# revm = { version = "21.0.0", default-features = false }
# reth-db = { git = "https://github.com/paradigmxyz/reth", package = "reth-db", rev = "v1.3.8" }
# reth-provider = { git = "https://github.com/paradigmxyz/reth", package = "reth-provider", rev = "v1.3.8" }
# reth-node-types = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-types", rev = "v1.3.8" }
# reth-chainspec = { git = "https://github.com/paradigmxyz/reth", package = "reth-chainspec", rev = "v1.3.8" }
# reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-ethereum", rev = "v1.3.8" }
# reth
revm = { version = "22.0.1", default-features = false }
revm-primitives = { version = "18.0.0", default-features = false }
reth-db = { git = "https://github.com/paradigmxyz/reth", package = "reth-db", rev = "7029951" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", package = "reth-provider", rev = "7029951" }
reth-node-types = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-types", rev = "7029951" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", package = "reth-chainspec", rev = "7029951" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", package = "reth-node-ethereum", rev = "7029951" }

eyre.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
Expand Down
3 changes: 2 additions & 1 deletion examples/advanced/examples/any_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ async fn main() -> Result<()> {

// Create a provider with the Arbitrum Sepolia network and the wallet.
let rpc_url = "https://sepolia-rollup.arbitrum.io/rpc".parse()?;
let provider = ProviderBuilder::new().network::<AnyNetwork>().wallet(signer).on_http(rpc_url);
let provider =
ProviderBuilder::new().network::<AnyNetwork>().wallet(signer).connect_http(rpc_url);

// Create a contract instance.
let contract = Counter::new(COUNTER_CONTRACT_ADDRESS, &provider);
Expand Down
3 changes: 2 additions & 1 deletion examples/advanced/examples/foundry_fork_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use revm_primitives::{BlobExcessGasAndPrice, BlockEnv, TxEnv};
#[tokio::main]
async fn main() -> Result<()> {
let anvil = Anvil::new().spawn();
let provider = ProviderBuilder::new().network::<AnyNetwork>().on_http(anvil.endpoint_url());
let provider =
ProviderBuilder::new().network::<AnyNetwork>().connect_http(anvil.endpoint_url());

let block = provider.get_block(BlockId::latest()).await?.unwrap();

Expand Down
9 changes: 5 additions & 4 deletions examples/advanced/examples/reth_db_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ async fn main() -> Result<()> {
// Initialize the provider with the reth-db layer. The reth-db layer intercepts the rpc
// requests and returns the results from the reth-db database.
// Any RPC method that is not implemented in the RethDbProvider gracefully falls back to the
// RPC provider specified in the `on_http` method.
let provider =
ProviderBuilder::new().layer(RethDbLayer::new(db_path)).on_http(reth.endpoint_url());
// RPC provider specified in the `connect_http` method.
let provider = ProviderBuilder::new()
.layer(RethDbLayer::new(db_path))
.connect_http(reth.endpoint_url());

// Initialize the RPC provider to compare the time taken to fetch the results.
let rpc_provider = ProviderBuilder::new().on_http(reth.endpoint_url());
let rpc_provider = ProviderBuilder::new().connect_http(reth.endpoint_url());

println!("--------get_block_number---------");

Expand Down
6 changes: 3 additions & 3 deletions examples/comparison/examples/compare_new_heads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ async fn main() -> Result<()> {
let provider = match ProviderBuilder::new().network::<AnyNetwork>().connect(&url).await {
Ok(provider) => provider,
Err(e) => {
eprintln!("skipping {} at {} because of error: {}", name, url, e);
eprintln!("skipping {name} at {url} because of error: {e}");
continue;
}
};

let mut stream = match provider.subscribe_blocks().await {
Ok(stream) => stream.into_stream().take(10),
Err(e) => {
eprintln!("skipping {} at {} because of error: {}", name, url, e);
eprintln!("skipping {name} at {url} because of error: {e}");
continue;
}
};
Expand All @@ -53,7 +53,7 @@ async fn main() -> Result<()> {
let _p = provider; // keep provider alive
while let Some(header) = stream.next().await {
if let Err(e) = sx.send((name.clone(), header, Utc::now())) {
eprintln!("sending to channel failed: {}", e);
eprintln!("sending to channel failed: {e}");
}
}
}));
Expand Down
8 changes: 4 additions & 4 deletions examples/comparison/examples/compare_pending_txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> Result<()> {
let mut rpcs = vec![];
for (name, url) in tmp {
if url.starts_with("http") {
eprintln!("skipping {} at {} because it is not a websocket/ipc endpoint", name, url);
eprintln!("skipping {name} at {url} because it is not a websocket/ipc endpoint");
continue;
}
rpcs.push((name, url));
Expand All @@ -41,15 +41,15 @@ async fn main() -> Result<()> {
let provider = match ProviderBuilder::new().network::<AnyNetwork>().connect(&url).await {
Ok(provider) => provider,
Err(e) => {
eprintln!("skipping {} at {} because of error: {}", name, url, e);
eprintln!("skipping {name} at {url} because of error: {e}");
continue;
}
};

let mut stream = match provider.subscribe_pending_transactions().await {
Ok(stream) => stream.into_stream().take(50),
Err(e) => {
eprintln!("skipping {} at {} because of error: {}", name, url, e);
eprintln!("skipping {name} at {url} because of error: {e}");
continue;
}
};
Expand All @@ -60,7 +60,7 @@ async fn main() -> Result<()> {
let _p = provider; // keep provider alive
while let Some(tx_hash) = stream.next().await {
if let Err(e) = sx.send((name.clone(), tx_hash, Utc::now())) {
eprintln!("sending to channel failed: {}", e);
eprintln!("sending to channel failed: {e}");
}
}
}));
Expand Down
3 changes: 2 additions & 1 deletion examples/contracts/examples/arb_profit_calc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Simple arbitrage profit calculator for WETH/DAI pools
//! Reads the balaces of the Uniswap V2 and SushiSwap pools and calculates a basic arb opportunity.
//! Reads the balaces of the Uniswap V2 and `SushiSwap` pools and calculates a basic arb
//! opportunity.

mod helpers;
use crate::helpers::{get_amount_in, get_amount_out, get_sushi_pair, get_uniswap_pair};
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/examples/deploy_and_link_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn main() -> Result<()> {

// Spin up a local Anvil node.
// Ensure `anvil` is available in $PATH.
let provider = ProviderBuilder::new().on_anvil_with_wallet();
let provider = ProviderBuilder::new().connect_anvil_with_wallet();

// Deploy the library (instead of using existing ones)
let lib_addr: Address = Comparators::deploy_builder(&provider).deploy().await?;
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/examples/deploy_from_artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sol!(
async fn main() -> Result<()> {
// Spin up a local Anvil node.
// Ensure `anvil` is available in $PATH.
let provider = ProviderBuilder::new().on_anvil_with_wallet();
let provider = ProviderBuilder::new().connect_anvil_with_wallet();

// Deploy the `Counter` contract.
let contract = Counter::deploy(&provider).await?;
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/examples/deploy_from_bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sol! {
async fn main() -> Result<()> {
// Spin up a local Anvil node.
// Ensure `anvil` is available in $PATH.
let provider = ProviderBuilder::new().on_anvil_with_wallet();
let provider = ProviderBuilder::new().connect_anvil_with_wallet();

// Deploy the `Counter` contract from bytecode at runtime.
let bytecode = hex::decode(
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/examples/deploy_from_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sol! {
async fn main() -> Result<()> {
// Spin up a local Anvil node.
// Ensure `anvil` is available in $PATH.
let provider = ProviderBuilder::new().on_anvil_with_wallet();
let provider = ProviderBuilder::new().connect_anvil_with_wallet();

// Deploy the `Counter` contract.
let contract = Counter::deploy(&provider).await?;
Expand Down
4 changes: 2 additions & 2 deletions examples/contracts/examples/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Helpers for the UniswapV2 and Sushiswap arb simulation.
//! Helpers for the `UniswapV2` and Sushiswap arb simulation.
#![allow(missing_docs, dead_code)]
use std::ops::{Add, Div, Mul, Sub};

Expand Down Expand Up @@ -143,4 +143,4 @@ pub(crate) async fn set_hash_storage_slot<P: Provider>(
Ok(())
}

fn main() {}
const fn main() {}
2 changes: 1 addition & 1 deletion examples/contracts/examples/interact_with_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn main() -> Result<()> {
// Ensure `anvil` is available in $PATH.
let rpc_url = "https://reth-ethereum.ithaca.xyz/rpc";
let provider =
ProviderBuilder::new().on_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url))?;
ProviderBuilder::new().connect_anvil_with_wallet_and_config(|anvil| anvil.fork(rpc_url))?;

// Create a contract instance.
let contract = IWETH9::new(address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"), provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use eyre::Result;
async fn main() -> Result<()> {
// Spin up a local Anvil node.
// Ensure `anvil` is available in $PATH.
let provider = ProviderBuilder::new().on_anvil_with_wallet();
let provider = ProviderBuilder::new().connect_anvil_with_wallet();

// Deploy the `Counter` contract from bytecode at runtime.
let bytecode = hex::decode(
Expand Down
8 changes: 4 additions & 4 deletions examples/contracts/examples/revert_decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sol! {
async fn main() -> Result<()> {
// Setup an Anvil provider with a wallet.
// Make sure `anvil` is in your $PATH.
let provider = ProviderBuilder::new().on_anvil_with_wallet();
let provider = ProviderBuilder::new().connect_anvil_with_wallet();

// Deploy the contract.
let contract = ThrowsError::deploy(&provider).await?;
Expand All @@ -38,7 +38,7 @@ async fn main() -> Result<()> {
// Get the raw bytes of the revert data.
let revert_data = err.as_revert_data().unwrap();

println!("Decoding revert data: {:?}", revert_data);
println!("Decoding revert data: {revert_data:?}");

// Decode the revert data as a custom error.
let decoded_err = err.as_decoded_error::<SomeCustomError>().unwrap();
Expand All @@ -55,11 +55,11 @@ async fn main() -> Result<()> {
// The above returns an enum with the errors as its variants.
match decoded_err {
ErrorsErrors::SomeCustomError(err) => {
println!("Decoded as: {:?}", err);
println!("Decoded as: {err:?}");
assert_eq!(err.a, U256::from(1));
}
ErrorsErrors::AnotherError(err) => {
println!("Decoded as: {:?}", err);
println!("Decoded as: {err:?}");
assert_eq!(err.b, 0);
}
}
Expand Down
9 changes: 5 additions & 4 deletions examples/contracts/examples/simulation_uni_v2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Simulates an arbitrage between Uniswap V2 and SushiSwap by forking anvil and using the
//! FlashBotsMultiCall contract.
//! Simulates an arbitrage between Uniswap V2 and `SushiSwap` by forking anvil and using the
//! `FlashBotsMultiCall` contract.
use alloy::{
hex,
network::TransactionBuilder,
Expand Down Expand Up @@ -46,8 +46,9 @@ async fn main() -> Result<()> {
let sushi_pair = get_sushi_pair();

let wallet_address: Address = anvil.addresses()[0];
let provider =
ProviderBuilder::new().wallet(anvil.wallet().unwrap()).on_http(anvil.endpoint().parse()?);
let provider = ProviderBuilder::new()
.wallet(anvil.wallet().unwrap())
.connect_http(anvil.endpoint().parse()?);

let executor = FlashBotsMultiCall::deploy(provider.clone(), wallet_address).await?;
let iweth = IERC20::new(WETH_ADDR, provider.clone());
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/examples/unknown_return_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use eyre::Result;
async fn main() -> Result<()> {
// Spin up a local Anvil node.
// Ensure `anvil` is available in $PATH.
let provider = ProviderBuilder::new().on_anvil_with_wallet();
let provider = ProviderBuilder::new().connect_anvil_with_wallet();

// Get the first account from the wallet, Alice.
let alice = provider.get_accounts().await?[0];
Expand Down
2 changes: 1 addition & 1 deletion examples/fillers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ alloy.workspace = true
eyre.workspace = true
serde_json.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
reqwest = "0.12.10"
reqwest = "0.12.15"
7 changes: 5 additions & 2 deletions examples/fillers/examples/gas_filler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ use eyre::Result;
async fn main() -> Result<()> {
// Spin up a local Anvil node.
// Ensure `anvil` is available in $PATH.
let provider = ProviderBuilder::default()
let provider = ProviderBuilder::new()
// You can disable the recommended fillers by calling the `disable_recommended_fillers()`
// and pick the fillers of your choice.
.disable_recommended_fillers()
// Add the `GasFiller` to the provider.
// It is generally recommended to use the recommended fillers which includes the GasFiller,
// enabled by building the provider using ProviderBuilder::new().
.with_gas_estimation()
.on_anvil_with_wallet();
.connect_anvil_with_wallet();

// Build an EIP-1559 type transaction to send 100 wei to Vitalik.
let vitalik = address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
Expand Down
2 changes: 1 addition & 1 deletion examples/fillers/examples/nonce_filler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn main() -> Result<()> {
// reorganizations.
.with_cached_nonce_management()
// .with_simple_nonce_management()
.on_anvil_with_wallet();
.connect_anvil_with_wallet();

// Build an EIP-1559 type transaction to send 100 wei to Vitalik.
let vitalik = address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
Expand Down
2 changes: 1 addition & 1 deletion examples/fillers/examples/recommended_fillers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() -> Result<()> {
// This is the recommended way to set up the provider.
// One can disable the recommended fillers by calling the `disable_recommended_fillers()`
// method or building the provider with `ProviderBuilder::default()`.
.on_anvil_with_wallet();
.connect_anvil_with_wallet();

// Build an EIP-1559 type transaction to send 100 wei to Vitalik.
// Notice that the `nonce` field is set by the `NonceFiller`.
Expand Down
10 changes: 4 additions & 6 deletions examples/fillers/examples/urgent_filler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ impl<N: Network> TxFiller<N> for UrgentQueue {
Ok(res) => res,
Err(e) => {
return Err(RpcError::Transport(TransportErrorKind::Custom(Box::new(
std::io::Error::new(
std::io::ErrorKind::Other,
format!("Failed to fetch gas price, {}", e),
),
std::io::Error::other(format!("Failed to fetch gas price, {e}")),
))));
}
};
Expand All @@ -107,14 +104,15 @@ impl<N: Network> TxFiller<N> for UrgentQueue {
#[tokio::main]
async fn main() -> Result<()> {
// Instantiate the provider with the UrgentQueue filler
let provider = ProviderBuilder::new().filler(UrgentQueue::default()).on_anvil_with_wallet();
let provider =
ProviderBuilder::new().filler(UrgentQueue::default()).connect_anvil_with_wallet();
let bob = Address::from([0x42; 20]);
let tx = TransactionRequest::default().with_to(bob).with_value(U256::from(1));

let bob_balance_before = provider.get_balance(bob).await?;
let res = provider.send_transaction(tx).await?.get_receipt().await?;
let bob_balance_after = provider.get_balance(bob).await?;
println!("Balance before: {}\nBalance after: {}", bob_balance_before, bob_balance_after);
println!("Balance before: {bob_balance_before}\nBalance after: {bob_balance_after}");

let tx = provider.get_transaction_by_hash(res.transaction_hash).await?.unwrap();
println!("Max fee per gas: {:?}", tx.max_fee_per_gas());
Expand Down
2 changes: 1 addition & 1 deletion examples/fillers/examples/wallet_filler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn main() -> Result<()> {
let provider = ProviderBuilder::new()
// Add the `WalletFiller` to the provider
.wallet(signer)
.on_http(rpc_url);
.connect_http(rpc_url);

// Build an EIP-1559 type transaction to send 100 wei to Vitalik.
let vitalik = address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
Expand Down
Loading
Loading