Skip to content
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
30 changes: 30 additions & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ alloy-json-abi = { version = "1.5.7", default-features = false }
alloy-json-rpc = { version = "1.7.3", default-features = false }
alloy-network = { version = "1.7.3", default-features = false }
alloy-primitives = { version = "1.5.2", default-features = false }
alloy-provider = { version = "1.7.3", default-features = false }
# enabling `reqwest-default-tls` on the workspace level because missing this feature
# leads to runtime errors instead of compile time errors. Also feature unification
# is error prone and we must never lack https support.
alloy-provider = { version = "1.7.3", default-features = false, features = ["reqwest-default-tls"] }
alloy-rpc-client = { version = "1.7.3", default-features = false }
alloy-rpc-types = { version = "1.7.3", default-features = false }
alloy-signer = { version = "1.7.3", default-features = false }
Expand Down
22 changes: 22 additions & 0 deletions crates/ethrpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,25 @@ pub fn web3(args: Config, url: &Url, label: Option<&str>) -> Web3 {
wallet,
}
}

#[cfg(test)]
mod test {
use {super::*, alloy_eips::BlockId, alloy_provider::Provider};

#[tokio::test]
async fn test_https() {
let provider = Web3::new_from_url("https://rpc.mevblocker.io");
let response = provider.provider.get_block(BlockId::latest()).await;

if let Err(err) = response {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no more specific matching?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and no. When printing the error you get this:

Transport(Custom("batch call failed: Transport(Custom(reqwest::Error { kind: Request, url: \"https://rpc.mevblocker.io/\", source: hyper_util::client::legacy::Error(Connect, ConnectError(\"invalid URL, scheme is not http\")) }))"))

We could try to match down to the ConnectError but it seems to be the case that the connection could fail for other reasons than https support. Also the fact that the error variant identifier contains legacy is not very confidence inspiring.
Given that this check should only kick in when mevblocker is down I think this should be sufficient.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching on transport was good enough tbh, but for what it is, this works just fine and once it breaks again we'll review

// only fail the CI if we are sure the error is due to missing
// `https` support
if err.to_string().contains("scheme is not http") {
eprintln!("{err:?}");
panic!("https support is not enabled");
} else {
eprintln!("mevblocker error unrelated to https support: {err:?}");
}
}
}
}
Loading