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

[Debt] Update to latest Alloy and remove patches from Cargo.toml + CI #41

Merged
merged 5 commits into from
Apr 1, 2024
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
16 changes: 0 additions & 16 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,6 @@ jobs:
sed -i 's/\(alloy-provider = { git = "https:\/\/github.com\/alloy-rs\/alloy", rev = "\)[^"]*/\1'"$latest_alloy_commit"'/' \
examples/subscriptions/Cargo.toml

# Temporary patch until `patch` section in Alloy is removed
sed -i 's/\(alloy-core = { git = "https:\/\/github.com\/alloy-rs\/core", rev = "\)[^"]*/\1'"$latest_alloy_core_commit"'/' \
Cargo.toml
sed -i 's/\(alloy-dyn-abi = { git = "https:\/\/github.com\/alloy-rs\/core", rev = "\)[^"]*/\1'"$latest_alloy_core_commit"'/' \
Cargo.toml
sed -i 's/\(alloy-json-abi = { git = "https:\/\/github.com\/alloy-rs\/core", rev = "\)[^"]*/\1'"$latest_alloy_core_commit"'/' \
Cargo.toml
sed -i 's/\(alloy-primitives = { git = "https:\/\/github.com\/alloy-rs\/core", rev = "\)[^"]*/\1'"$latest_alloy_core_commit"'/' \
Cargo.toml
sed -i 's/\(alloy-sol-macro = { git = "https:\/\/github.com\/alloy-rs\/core", rev = "\)[^"]*/\1'"$latest_alloy_core_commit"'/' \
Cargo.toml
sed -i 's/\(alloy-sol-types = { git = "https:\/\/github.com\/alloy-rs\/core", rev = "\)[^"]*/\1'"$latest_alloy_core_commit"'/' \
Cargo.toml
sed -i 's/\(syn-solidity = { git = "https:\/\/github.com\/alloy-rs\/core", rev = "\)[^"]*/\1'"$latest_alloy_core_commit"'/' \
Cargo.toml

# Update to the latest commit
cargo update

Expand Down
11 changes: 1 addition & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ unnecessary_struct_initialization = "allow"
use_self = "allow"

[workspace.dependencies]
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192", features = [
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
# "dyn-abi",
# "json-abi",
# "json",
Expand Down Expand Up @@ -123,12 +123,3 @@ tokio = "1"

# misc
eyre = "0.6.12"

[patch.crates-io]
alloy-core = { git = "https://github.com/alloy-rs/core", rev = "525a233" }
alloy-dyn-abi = { git = "https://github.com/alloy-rs/core", rev = "525a233" }
alloy-json-abi = { git = "https://github.com/alloy-rs/core", rev = "525a233" }
alloy-primitives = { git = "https://github.com/alloy-rs/core", rev = "525a233" }
alloy-sol-macro = { git = "https://github.com/alloy-rs/core", rev = "525a233" }
alloy-sol-types = { git = "https://github.com/alloy-rs/core", rev = "525a233" }
syn-solidity = { git = "https://github.com/alloy-rs/core", rev = "525a233" }
10 changes: 5 additions & 5 deletions examples/providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ workspace = true
[dev-dependencies]
alloy.workspace = true
# Temp dependency fix to enable relevant features - Ref: https://github.com/alloy-rs/examples/pull/3#discussion_r1537842062
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192", features = [
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
"pubsub",
"ipc",
"ws",
] }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192", features = [
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
"pubsub",
"ws",
"ipc",
] }

alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af" }

alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af" }
eyre.workspace = true
futures-util = "0.3"
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
6 changes: 3 additions & 3 deletions examples/providers/examples/connect_builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ async fn main() -> Result<()> {

// Instantiate a HTTP transport provider by passing the http endpoint url
let http_provider =
RootProvider::<Ethereum, BoxTransport>::connect_builtin(http.as_str()).await?;
RootProvider::<BoxTransport, Ethereum>::connect_builtin(http.as_str()).await?;

// Get latest block number
let block_number = http_provider.get_block_number().await?;

println!("Latest block number: {block_number:?}");

// This requires the `pubsub` and `ws` features to be enabled on alloy-provider
let ws_provider = RootProvider::<Ethereum, BoxTransport>::connect_builtin(ws.as_str()).await?;
let ws_provider = RootProvider::<BoxTransport, Ethereum>::connect_builtin(ws.as_str()).await?;

let sub = ws_provider.subscribe_blocks().await?;

Expand All @@ -44,7 +44,7 @@ async fn main() -> Result<()> {

// This requires the `pubsub` and `ipc` features to be enabled on alloy-provider
// This would throw a runtime error if the ipc does not exist
let ipc_provider = RootProvider::<Ethereum, BoxTransport>::connect_builtin(ipc_path).await?;
let ipc_provider = RootProvider::<BoxTransport, Ethereum>::connect_builtin(ipc_path).await?;

let _block_number = ipc_provider.get_block_number().await?;

Expand Down
6 changes: 3 additions & 3 deletions examples/providers/examples/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use alloy::{
network::Ethereum,
providers::{HttpProvider, Provider},
providers::{Provider, ReqwestProvider},
rpc::client::RpcClient,
};
use eyre::Result;
Expand All @@ -15,9 +15,9 @@ async fn main() -> Result<()> {
// Create the RPC client.
let rpc_client = RpcClient::new_http(rpc_url);

// Provider can then be instantiated using the RPC client, HttpProvider is an alias
// Provider can then be instantiated using the RPC client, ReqwestProvider is an alias
// RootProvider. RootProvider requires two generics N: Network and T: Transport
let provider = HttpProvider::<Ethereum>::new(rpc_client);
let provider = ReqwestProvider::<Ethereum>::new(rpc_client);

// Get latest block number.
let latest_block = provider.get_block_number().await?;
Expand Down
2 changes: 1 addition & 1 deletion examples/providers/examples/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() -> Result<()> {
let ipc_client = RpcClient::connect_pubsub(ipc).await?;

// Create the provider.
let provider = RootProvider::<Ethereum, _>::new(ipc_client);
let provider = RootProvider::<_, Ethereum>::new(ipc_client);

let latest_block = provider.get_block_number().await?;

Expand Down
2 changes: 1 addition & 1 deletion examples/providers/examples/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() -> Result<()> {
let rpc_client = RpcClient::connect_pubsub(ws_transport).await?;

// Create the provider.
let provider = RootProvider::<Ethereum, _>::new(rpc_client);
let provider = RootProvider::<_, Ethereum>::new(rpc_client);

// Subscribe to new blocks.
let sub = provider.subscribe_blocks().await?;
Expand Down
4 changes: 2 additions & 2 deletions examples/providers/examples/ws_with_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ async fn main() -> Result<()> {
let rpc_client_bearer = RpcClient::connect_pubsub(ws_transport_bearer).await?;

// Create the provider.
let provider_basic = RootProvider::<Ethereum, _>::new(rpc_client_basic);
let provider_bearer = RootProvider::<Ethereum, _>::new(rpc_client_bearer);
let provider_basic = RootProvider::<_, Ethereum>::new(rpc_client_basic);
let provider_bearer = RootProvider::<_, Ethereum>::new(rpc_client_bearer);

// Subscribe to new blocks.
let sub_basic = provider_basic.subscribe_blocks();
Expand Down
4 changes: 2 additions & 2 deletions examples/queries/examples/query_contract_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
use alloy::{
network::Ethereum,
primitives::{address, U256},
providers::{Provider, RootProvider},
providers::{Provider, ReqwestProvider},
};
use eyre::Result;

#[tokio::main]
async fn main() -> Result<()> {
// Create a provider.
let rpc_url = "https://eth.merkle.io".parse()?;
let provider = RootProvider::<Ethereum, _>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Get storage slot 0 from the Uniswap V3 USDC-ETH pool on Ethereum mainnet.
let pool_address = address!("88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640");
Expand Down
4 changes: 2 additions & 2 deletions examples/queries/examples/query_deployed_bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use alloy::{
network::Ethereum,
primitives::address,
providers::{Provider, RootProvider},
providers::{Provider, ReqwestProvider},
rpc::types::eth::{BlockId, BlockNumberOrTag},
};
use eyre::Result;
Expand All @@ -12,7 +12,7 @@ use eyre::Result;
async fn main() -> Result<()> {
// Create a provider.
let rpc_url = "https://eth.merkle.io".parse()?;
let provider = RootProvider::<Ethereum, _>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Get the bytecode of the Uniswap V3 USDC-ETH pool on Ethereum mainnet.
let pool_address = address!("88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640");
Expand Down
4 changes: 2 additions & 2 deletions examples/queries/examples/query_logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use alloy::{
network::Ethereum,
primitives::{address, b256},
providers::{Provider, RootProvider},
providers::{Provider, ReqwestProvider},
rpc::types::eth::Filter,
};
use eyre::Result;
Expand All @@ -12,7 +12,7 @@ use eyre::Result;
async fn main() -> Result<()> {
// Create a provider.
let rpc_url = "https://eth.merkle.io".parse()?;
let provider = RootProvider::<Ethereum, _>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Get logs from the latest block
let latest_block = provider.get_block_number().await?;
Expand Down
4 changes: 2 additions & 2 deletions examples/subscriptions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ workspace = true
[dev-dependencies]
alloy.workspace = true
# Temp fix for enabling features. Ref: https://github.com/alloy-rs/examples/pull/3/#discussion_r1537842062
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192", features = [
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
"pubsub",
"ws",
] }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "66fa192", features = [
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8acf6af", features = [
"pubsub",
] }
# alloy-contract.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions examples/subscriptions/examples/event_multiplexer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Example of multiplexing the watching of event logs.

use alloy::{network::Ethereum, node_bindings::Anvil, primitives::I256, sol, sol_types::SolEvent};
use alloy_provider::RootProvider;
use alloy::{node_bindings::Anvil, primitives::I256, sol, sol_types::SolEvent};
use alloy_provider::ProviderBuilder;
use alloy_rpc_client::{RpcClient, WsConnect};
use eyre::Result;
use futures_util::StreamExt;
Expand Down Expand Up @@ -44,7 +44,7 @@ async fn main() -> Result<()> {

// Create a provider.
let ws = WsConnect::new(anvil.ws_endpoint());
let provider = RootProvider::<Ethereum, _>::new(RpcClient::connect_pubsub(ws).await?);
let provider = ProviderBuilder::new().on_client(RpcClient::connect_pubsub(ws).await?);

// Deploy the `EventExample` contract.
let contract = EventMultiplexer::deploy(provider).await?;
Expand Down Expand Up @@ -102,7 +102,7 @@ async fn main() -> Result<()> {
}
};

let topic = &log.topics[0];
let topic = &log.topics()[0];

if topic == add_log {
println!("Received Add: {log:?}");
Expand Down
6 changes: 3 additions & 3 deletions examples/subscriptions/examples/subscribe_blocks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Example of subscribing to blocks and watching block headers by polling.

use alloy::{network::Ethereum, node_bindings::Anvil};
use alloy_provider::{Provider, RootProvider};
use alloy::node_bindings::Anvil;
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use eyre::Result;
use futures_util::{stream, StreamExt};
Expand All @@ -14,7 +14,7 @@ async fn main() -> Result<()> {

// Create a provider.
let ws = alloy_rpc_client::WsConnect::new(anvil.ws_endpoint());
let provider = RootProvider::<Ethereum, _>::new(RpcClient::connect_pubsub(ws).await?);
let provider = ProviderBuilder::new().on_client(RpcClient::connect_pubsub(ws).await?);

// Subscribe to blocks.
let subscription = provider.subscribe_blocks().await?;
Expand Down
6 changes: 3 additions & 3 deletions examples/subscriptions/examples/watch_contract_event.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Example of subscribing to blocks and watching contract events by WebSocket subscription.

use alloy::{network::Ethereum, node_bindings::Anvil, sol};
use alloy_provider::RootProvider;
use alloy::{node_bindings::Anvil, sol};
use alloy_provider::ProviderBuilder;
use alloy_rpc_client::RpcClient;
use eyre::Result;
use futures_util::StreamExt;
Expand Down Expand Up @@ -38,7 +38,7 @@ async fn main() -> Result<()> {
// Create a WebSocket provider.
let ws_rpc_url = anvil.ws_endpoint();
let ws = alloy_rpc_client::WsConnect::new(ws_rpc_url);
let provider = RootProvider::<Ethereum, _>::new(RpcClient::connect_pubsub(ws).await?);
let provider = ProviderBuilder::new().on_client(RpcClient::connect_pubsub(ws).await?);

// Deploy the `Counter` contract.
let contract = Counter::deploy(provider.clone()).await?;
Expand Down
4 changes: 2 additions & 2 deletions examples/transactions/examples/gas_price_usd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy::{
network::Ethereum,
node_bindings::Anvil,
primitives::{address, utils::format_units, Address, Bytes, U256},
providers::{HttpProvider, Provider},
providers::{Provider, ReqwestProvider},
rpc::types::eth::TransactionRequest,
sol,
sol_types::SolCall,
Expand All @@ -31,7 +31,7 @@ async fn main() -> Result<()> {

// Create a provider.
let rpc_url = anvil.endpoint().parse()?;
let provider = HttpProvider::<Ethereum>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Create a call to get the latest answer from the Chainlink ETH/USD feed.
let call = latestAnswerCall {}.abi_encode();
Expand Down
4 changes: 2 additions & 2 deletions examples/transactions/examples/trace_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use alloy::{
network::Ethereum,
primitives::{address, U256},
providers::{HttpProvider, Provider},
providers::{Provider, ReqwestProvider},
rpc::types::{
eth::{BlockId, BlockNumberOrTag, TransactionRequest},
trace::parity::TraceType,
Expand All @@ -15,7 +15,7 @@ use eyre::Result;
async fn main() -> Result<()> {
// Create a provider.
let rpc_url = "https://eth.merkle.io".parse()?;
let provider = HttpProvider::<Ethereum>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Create two users, Alice and Bob.
let alice = address!("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266");
Expand Down
4 changes: 2 additions & 2 deletions examples/transactions/examples/trace_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy::{
network::Ethereum,
node_bindings::Anvil,
primitives::b256,
providers::{HttpProvider, Provider},
providers::{Provider, ReqwestProvider},
rpc::types::trace::geth::{
GethDebugBuiltInTracerType, GethDebugTracerType, GethDebugTracingOptions,
GethDefaultTracingOptions,
Expand All @@ -20,7 +20,7 @@ async fn main() -> Result<()> {

// Create a provider.
let rpc_url = anvil.endpoint().parse()?;
let provider = HttpProvider::<Ethereum>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Hash of the tx we want to trace
let hash = b256!("97a02abf405d36939e5b232a5d4ef5206980c5a6661845436058f30600c52df7");
Expand Down
8 changes: 4 additions & 4 deletions examples/transactions/examples/transfer_erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy::{
network::Ethereum,
node_bindings::Anvil,
primitives::{Address, Bytes, U256},
providers::{HttpProvider, Provider},
providers::{Provider, ReqwestProvider},
rpc::types::eth::TransactionRequest,
sol,
sol_types::SolCall,
Expand All @@ -26,7 +26,7 @@ async fn main() -> Result<()> {

// Create a provider.
let rpc_url = anvil.endpoint().parse()?;
let provider = HttpProvider::<Ethereum>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Create two users, Alice and Bob.
let alice = anvil.addresses()[0];
Expand Down Expand Up @@ -63,7 +63,7 @@ async fn main() -> Result<()> {
}

async fn deploy_token_contract(
provider: &HttpProvider<Ethereum>,
provider: &ReqwestProvider<Ethereum>,
from: Address,
) -> Result<Address> {
// Compile the contract.
Expand All @@ -89,7 +89,7 @@ async fn deploy_token_contract(
}

async fn balance_of(
provider: &HttpProvider<Ethereum>,
provider: &ReqwestProvider<Ethereum>,
account: Address,
contract_address: Address,
) -> Result<U256> {
Expand Down
4 changes: 2 additions & 2 deletions examples/transactions/examples/transfer_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy::{
network::Ethereum,
node_bindings::Anvil,
primitives::U256,
providers::{HttpProvider, Provider},
providers::{Provider, ReqwestProvider},
rpc::types::eth::TransactionRequest,
};
use eyre::Result;
Expand All @@ -17,7 +17,7 @@ async fn main() -> Result<()> {

// Create a provider.
let rpc_url = anvil.endpoint().parse()?;
let provider = HttpProvider::<Ethereum>::new_http(rpc_url);
let provider = ReqwestProvider::<Ethereum>::new_http(rpc_url);

// Create two users, Alice and Bob.
let alice = anvil.addresses()[0];
Expand Down
Loading