1.43.56. check web3_clientVersion
This commit is contained in:
parent
da7bb4b07c
commit
4585724c08
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -6412,9 +6412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc"
|
||||
dependencies = [
|
||||
"getrandom 0.2.10",
|
||||
"rand 0.8.5",
|
||||
"serde",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -6575,7 +6573,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "web3_proxy"
|
||||
version = "1.43.55"
|
||||
version = "1.43.56"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
@ -6650,7 +6648,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "web3_proxy_cli"
|
||||
version = "1.43.55"
|
||||
version = "1.43.56"
|
||||
dependencies = [
|
||||
"console-subscriber",
|
||||
"env_logger",
|
||||
@ -6846,27 +6844,6 @@ version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96f8f25c15a0edc9b07eb66e7e6e97d124c0505435c382fde1ab7ceb188aa956"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "855e0f6af9cd72b87d8a6c586f3cb583f5cdcc62c2c80869d8cd7e96fdf7ee20"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.38",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.6.0"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "web3_proxy"
|
||||
version = "1.43.55"
|
||||
version = "1.43.56"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@ -91,7 +91,7 @@ tower-http = { version = "0.4.4", features = ["cors", "normalize-path", "sensiti
|
||||
tracing = "0.1"
|
||||
ulid = { version = "1.1.0", features = ["rand", "uuid", "serde"] }
|
||||
url = { version = "2.4.1" }
|
||||
uuid = { version = "1.5.0", default-features = false, features = ["fast-rng", "v4", "zerocopy"] }
|
||||
uuid = { version = "1.5.0", default-features = false }
|
||||
|
||||
# TODO: why doesn't this work in dev-dependencies. i think because of how we split web3_proxy and web3_proxy_cli. im not sure that is even helping anymore
|
||||
test-log = { version = "0.2.13", default-features = false, features = ["trace"] }
|
||||
|
@ -42,6 +42,7 @@ use url::Url;
|
||||
pub struct Web3Rpc {
|
||||
pub name: String,
|
||||
pub chain_id: u64,
|
||||
pub client_version: RwLock<Option<String>>,
|
||||
pub block_interval: Duration,
|
||||
pub display_name: Option<String>,
|
||||
pub db_conn: Option<DatabaseConnection>,
|
||||
@ -492,6 +493,34 @@ impl Web3Rpc {
|
||||
/// query the web3 provider to confirm it is on the expected chain with the expected data available
|
||||
/// TODO: this currently checks only the http if both http and ws are set. it should check both and make sure they match
|
||||
async fn check_provider(self: &Arc<Self>, chain_id: u64) -> Web3ProxyResult<()> {
|
||||
// TODO: different handlers for backup vs primary
|
||||
let error_handler = Some(Level::TRACE.into());
|
||||
|
||||
match self
|
||||
.internal_request::<_, String>(
|
||||
"web3_clientVersion".into(),
|
||||
&(),
|
||||
error_handler,
|
||||
Some(Duration::from_secs(5)),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(client_version) => {
|
||||
// this is a sync lock, but we only keep it open for a short time
|
||||
// TODO: something more friendly to async that also works with serde's Serialize
|
||||
let mut lock = self.client_version.write();
|
||||
|
||||
*lock = Some(client_version);
|
||||
}
|
||||
Err(err) => {
|
||||
let mut lock = self.client_version.write();
|
||||
|
||||
*lock = Some(format!("error: {}", err));
|
||||
|
||||
error!(?err, "failed fetching client version of {}", self);
|
||||
}
|
||||
}
|
||||
|
||||
// check the server's chain_id here
|
||||
// TODO: some public rpcs (on bsc and fantom) do not return an id and so this ends up being an error
|
||||
// TODO: what should the timeout be? should there be a request timeout?
|
||||
@ -500,7 +529,7 @@ impl Web3Rpc {
|
||||
.internal_request(
|
||||
"eth_chainId".into(),
|
||||
&[(); 0],
|
||||
Some(Level::TRACE.into()),
|
||||
error_handler,
|
||||
Some(Duration::from_secs(5)),
|
||||
)
|
||||
.await?;
|
||||
@ -1337,7 +1366,7 @@ impl Serialize for Web3Rpc {
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let mut state = serializer.serialize_struct("Web3Rpc", 15)?;
|
||||
let mut state = serializer.serialize_struct("Web3Rpc", 16)?;
|
||||
|
||||
// the url is excluded because it likely includes private information. just show the name that we use in keys
|
||||
state.serialize_field("name", &self.name)?;
|
||||
@ -1346,6 +1375,8 @@ impl Serialize for Web3Rpc {
|
||||
|
||||
state.serialize_field("backup", &self.backup)?;
|
||||
|
||||
state.serialize_field("web3_clientVersion", &self.client_version.read().as_ref())?;
|
||||
|
||||
match self.block_data_limit.load(atomic::Ordering::Acquire) {
|
||||
u64::MAX => {
|
||||
state.serialize_field("block_data_limit", &None::<()>)?;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "web3_proxy_cli"
|
||||
version = "1.43.55"
|
||||
version = "1.43.56"
|
||||
edition = "2021"
|
||||
default-run = "web3_proxy_cli"
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
wrk.method = "POST"
|
||||
wrk.body = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":420}"
|
||||
wrk.headers["Content-Type"] = "application/json"
|
||||
|
||||
response = function(status, headers, body)
|
||||
if status ~= 200 then
|
||||
io.write("Status: ".. status .."\n")
|
||||
io.write("Body:\n")
|
||||
io.write(body .. "\n")
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,12 @@
|
||||
wrk.method = "POST"
|
||||
wrk.body = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"latest\", false],\"id\":420}"
|
||||
wrk.headers["Content-Type"] = "application/json"
|
||||
|
||||
response = function(status, headers, body)
|
||||
if status ~= 200 then
|
||||
io.write("Status: ".. status .."\n")
|
||||
io.write("Body:\n")
|
||||
io.write(body .. "\n")
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user