From a1ffcfcbbbcaad44b9cb1cf43e27f7f47679d1b0 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 01:38:15 -0400 Subject: [PATCH 01/10] fix: upgrade to axum 0.7 --- Cargo.lock | 356 ++++++++++++++++++++++++---------- Cargo.toml | 17 +- src/extractors/method.rs | 19 -- src/extractors/mod.rs | 2 - src/extractors/protocol.rs | 32 --- src/handlers/identity.rs | 6 +- src/handlers/mod.rs | 9 +- src/handlers/profile/utils.rs | 2 - src/lib.rs | 91 ++++++--- src/providers/aurora.rs | 22 +-- src/providers/base.rs | 22 +-- src/providers/binance.rs | 22 +-- src/providers/coinbase.rs | 5 - src/providers/getblock.rs | 19 +- src/providers/infura.rs | 18 +- src/providers/mantle.rs | 22 +-- src/providers/mod.rs | 5 +- src/providers/near.rs | 22 +-- src/providers/pokt.rs | 18 +- src/providers/publicnode.rs | 22 +-- src/providers/quicknode.rs | 18 +- src/providers/zerion.rs | 28 +-- src/providers/zksync.rs | 22 +-- src/providers/zora.rs | 22 +-- src/utils/crypto.rs | 6 +- tests/context/server.rs | 2 + tests/functional/http/mod.rs | 41 +--- tests/utils/mod.rs | 27 ++- 28 files changed, 466 insertions(+), 431 deletions(-) delete mode 100644 src/extractors/method.rs delete mode 100644 src/extractors/mod.rs delete mode 100644 src/extractors/protocol.rs diff --git a/Cargo.lock b/Cargo.lock index fba9f05e5..9d8ca3781 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "alloc" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "metrics", "serde", @@ -98,7 +98,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "analytics" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "anyhow", "async-trait", @@ -186,9 +186,9 @@ dependencies = [ [[package]] name = "async-tungstenite" -version = "0.20.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0388bb7a400072bbb41ceb75d65c3baefb2ea99672fa22e85278452cd9b58b" +checksum = "2cca750b12e02c389c1694d35c16539f88b8bbaa5945934fdc1b41a776688589" dependencies = [ "futures-io", "futures-util", @@ -197,7 +197,7 @@ dependencies = [ "pin-project-lite", "tokio", "tokio-native-tls", - "tungstenite 0.18.0", + "tungstenite 0.21.0", ] [[package]] @@ -259,7 +259,7 @@ dependencies = [ "fastrand", "hex", "http 0.2.12", - "hyper", + "hyper 0.14.28", "ring 0.17.8", "time", "tokio", @@ -297,7 +297,7 @@ dependencies = [ "bytes", "fastrand", "http 0.2.12", - "http-body", + "http-body 0.4.6", "percent-encoding", "pin-project-lite", "tracing", @@ -329,7 +329,7 @@ dependencies = [ "hex", "hmac", "http 0.2.12", - "http-body", + "http-body 0.4.6", "lru", "once_cell", "percent-encoding", @@ -459,7 +459,7 @@ dependencies = [ "crc32fast", "hex", "http 0.2.12", - "http-body", + "http-body 0.4.6", "md-5", "pin-project-lite", "sha1", @@ -491,7 +491,7 @@ dependencies = [ "bytes-utils", "futures-core", "http 0.2.12", - "http-body", + "http-body 0.4.6", "once_cell", "percent-encoding", "pin-project-lite", @@ -530,10 +530,10 @@ dependencies = [ "aws-smithy-types", "bytes", "fastrand", - "h2", + "h2 0.3.25", "http 0.2.12", - "http-body", - "hyper", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls", "once_cell", "pin-project-lite", @@ -571,7 +571,7 @@ dependencies = [ "bytes-utils", "futures-core", "http 0.2.12", - "http-body", + "http-body 0.4.6", "itoa", "num-integer", "pin-project-lite", @@ -609,19 +609,20 @@ dependencies = [ [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", "base64 0.21.7", - "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.12", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -634,19 +635,20 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper", + "sync_wrapper 1.0.0", "tokio", - "tokio-tungstenite 0.20.1", + "tokio-tungstenite 0.21.0", "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-client-ip" -version = "0.4.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef117890a418b7832678d9ea1e1c08456dd7b2fd1dadb9676cd6f0fe7eb4b21" +checksum = "5e7c467bdcd2bd982ce5c8742a1a178aba7b03db399fd18f5d5d438f5aa91cb4" dependencies = [ "axum", "forwarded-header-value", @@ -655,38 +657,41 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-tungstenite" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e8cca61c9b88dec1ac7443ac7afdfe648718fb77d8774fb91751a2738dfc785" +version = "0.3.0" +source = "git+https://github.com/Astralchroma/axum-tungstenite?rev=0906fea#0906fea50fe6df57fbb15bd422bc84bdc902e5f6" dependencies = [ "async-trait", "axum-core", - "base64 0.20.0", + "base64 0.21.7", "bytes", "futures-util", - "http 0.2.12", - "http-body", - "hyper", + "http 1.1.0", + "http-body 0.4.6", + "hyper 0.14.28", "sha-1", "tokio", - "tokio-tungstenite 0.18.0", + "tokio-tungstenite 0.21.0", ] [[package]] @@ -722,12 +727,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" - [[package]] name = "base64" version = "0.21.7" @@ -971,7 +970,7 @@ dependencies = [ "async-trait", "once_cell", "regex", - "reqwest", + "reqwest 0.11.27", "serde", "thiserror", ] @@ -1352,6 +1351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -1549,6 +1549,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "enum-as-inner" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +dependencies = [ + "heck", + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 2.0.57", +] + [[package]] name = "enum-iterator" version = "0.8.1" @@ -1743,7 +1755,7 @@ dependencies = [ "proc-macro2 1.0.79", "quote 1.0.35", "regex", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "syn 2.0.57", @@ -1802,7 +1814,7 @@ source = "git+https://github.com/gakonst/ethers-rs#5394d899adca736a602e316e6f0c0 dependencies = [ "chrono", "ethers-core", - "reqwest", + "reqwest 0.11.27", "semver", "serde", "serde_json", @@ -1826,7 +1838,7 @@ dependencies = [ "futures-locks", "futures-util", "instant", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "thiserror", @@ -1857,7 +1869,7 @@ dependencies = [ "jsonwebtoken", "once_cell", "pin-project", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "thiserror", @@ -2067,7 +2079,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "future" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "metrics", "pin-project", @@ -2219,15 +2231,15 @@ dependencies = [ [[package]] name = "geoip" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "aws-sdk-s3", "axum-client-ip", "bitflags 2.5.0", "bytes", "futures", - "http-body", - "hyper", + "http-body 1.0.0", + "hyper 1.2.0", "maxminddb", "thiserror", "tower", @@ -2336,6 +2348,25 @@ dependencies = [ "tracing", ] +[[package]] +name = "h2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 1.1.0", + "indexmap 2.2.6", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -2421,10 +2452,10 @@ dependencies = [ [[package]] name = "http" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "future", - "hyper", + "hyper 1.2.0", "metrics", "tokio", ] @@ -2463,10 +2494,27 @@ dependencies = [ ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +dependencies = [ + "bytes", + "futures-core", + "http 1.1.0", + "http-body 1.0.0", + "pin-project-lite", +] [[package]] name = "httparse" @@ -2490,9 +2538,9 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2", + "h2 0.3.25", "http 0.2.12", - "http-body", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -2504,6 +2552,27 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186548d73ac615b32a73aafe38fb4f56c0d340e110e5a200bcadbaf2e199263a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.2" @@ -2512,7 +2581,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper", + "hyper 0.14.28", "log", "rustls", "rustls-native-certs", @@ -2527,12 +2596,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.28", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.2.0", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.2.0", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -2948,7 +3053,7 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "metrics" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "once_cell", "opentelemetry", @@ -3836,14 +3941,14 @@ dependencies = [ [[package]] name = "prometheus-http-query" -version = "0.6.7" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6704e3a7a78545b1496524d518658005a6cc308abc90ce5fccf01891ecdc298b" +checksum = "e0de773a6ba25c9164ed9d86d653a92fac759a6f0e683fd141d56bb96e80fd8b" dependencies = [ + "enum-as-inner", "mime", - "reqwest", + "reqwest 0.11.27", "serde", - "serde_json", "time", "url", ] @@ -3962,7 +4067,7 @@ dependencies = [ [[package]] name = "rate_limit" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "chrono", "deadpool-redis", @@ -4084,18 +4189,17 @@ version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ - "async-compression", "base64 0.21.7", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2", + "h2 0.3.25", "http 0.2.12", - "http-body", - "hyper", + "http-body 0.4.6", + "hyper 0.14.28", "hyper-rustls", - "hyper-tls", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", @@ -4109,12 +4213,11 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-native-tls", "tokio-rustls", - "tokio-util", "tower-service", "url", "wasm-bindgen", @@ -4124,6 +4227,50 @@ dependencies = [ "winreg", ] +[[package]] +name = "reqwest" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" +dependencies = [ + "async-compression", + "base64 0.21.7", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.4", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-tls 0.6.0", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration", + "tokio", + "tokio-native-tls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "rfc6979" version = "0.3.1" @@ -4248,8 +4395,9 @@ dependencies = [ "envy", "ethers", "futures-util", - "hyper", - "hyper-tls", + "hyper 1.2.0", + "hyper-tls 0.5.0", + "hyper-util", "ipnet", "jsonrpc", "moka", @@ -4261,7 +4409,7 @@ dependencies = [ "prometheus-http-query", "rand", "regex", - "reqwest", + "reqwest 0.12.2", "rmp-serde", "serde", "serde-aux", @@ -5133,7 +5281,7 @@ dependencies = [ "fs2", "hex", "once_cell", - "reqwest", + "reqwest 0.11.27", "semver", "serde", "serde_json", @@ -5182,6 +5330,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384595c11a4e2969895cad5a8c4029115f5ab956a9e5ef4de79d11a426e5f20c" + [[package]] name = "sysinfo" version = "0.30.7" @@ -5464,29 +5618,29 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.18.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54319c93411147bced34cb5609a80e0a8e44c5999c93903a81cd866630ec0bfd" +checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", + "rustls", "tokio", - "tungstenite 0.18.0", + "tokio-rustls", + "tungstenite 0.20.1", + "webpki-roots", ] [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" dependencies = [ "futures-util", "log", - "rustls", "tokio", - "tokio-rustls", - "tungstenite 0.20.1", - "webpki-roots", + "tungstenite 0.21.0", ] [[package]] @@ -5588,17 +5742,15 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.5.0", "bytes", - "futures-core", - "futures-util", - "http 0.2.12", - "http-body", - "http-range-header", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "pin-project-lite", "tower", "tower-layer", @@ -5714,18 +5866,18 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.18.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ee6ab729cd4cf0fd55218530c4522ed30b7b6081752839b68fcec8d0960788" +checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" dependencies = [ - "base64 0.13.1", "byteorder", "bytes", + "data-encoding", "http 0.2.12", "httparse", "log", - "native-tls", "rand", + "rustls", "sha1", "thiserror", "url", @@ -5734,18 +5886,18 @@ dependencies = [ [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" dependencies = [ "byteorder", "bytes", "data-encoding", - "http 0.2.12", + "http 1.1.0", "httparse", "log", + "native-tls", "rand", - "rustls", "sha1", "thiserror", "url", @@ -6077,7 +6229,7 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wc" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.9.0#e2bc55dd0e06f30471d39bfbaedc71362136b677" +source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" dependencies = [ "alloc", "analytics", diff --git a/Cargo.toml b/Cargo.toml index e8a1ca61e..24bd6faac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,23 +9,24 @@ authors = [ build = "build.rs" [dependencies] -wc = { git = "https://github.com/WalletConnect/utils-rs.git", tag = "v0.9.0", features = ["alloc", "analytics", "future", "http", "metrics", "geoip", "geoblock", "rate_limit"] } +wc = { git = "https://github.com/WalletConnect/utils-rs.git", branch = "feat/axum-0.7", features = ["alloc", "analytics", "future", "http", "metrics", "geoip", "geoblock", "rate_limit"] } # Async async-trait = "0.1.57" tokio = { version = "1", features = ["full"] } # Web -hyper = "0.14.4" +hyper = "1.2.0" +hyper-util = "0.1.3" hyper-tls = "0.5.0" tap = "1.0" -axum = { version = "0.6", features = ["json", "tokio", "ws"] } +axum = { version = "0.7.5", features = ["json", "tokio", "ws"] } tower = "0.4.11" -tower-http = { version = "0.4.0", features = ["cors", "trace", "request-id", "util"] } +tower-http = { version = "0.5.2", features = ["cors", "trace", "request-id", "util"] } jsonrpc = "0.14.0" -async-tungstenite = { version = "0.20.0", features = ["tokio", "tokio-runtime", "tokio-native-tls"] } +async-tungstenite = { version = "0.25.1", features = ["tokio", "tokio-runtime", "tokio-native-tls"] } url = "2.5" -reqwest = { version= "0.11", features = ["deflate", "brotli", "gzip"] } +reqwest = { version= "0.12.2", features = ["deflate", "brotli", "gzip", "json"] } # Serialization rmp-serde = "1.1" @@ -65,10 +66,10 @@ parquet_derive = { git = "https://github.com/WalletConnect/arrow-rs.git", rev = chrono = { version = "0.4", features = ["serde"] } futures-util = "0.3.28" tokio-stream = "0.1.12" -axum-tungstenite = "0.2.0" +axum-tungstenite = { git = "https://github.com/Astralchroma/axum-tungstenite", rev = "0906fea" } # https://github.com/davidpdrsn/axum-tungstenite/pull/13 rand = "0.8.4" -prometheus-http-query = "0.6.6" +prometheus-http-query = "0.8.2" ethers = { version = "2.0.11", git = "https://github.com/gakonst/ethers-rs" } # using Git version because crates.io version fails clippy bytes = "1.4.0" diff --git a/src/extractors/method.rs b/src/extractors/method.rs deleted file mode 100644 index 38616f497..000000000 --- a/src/extractors/method.rs +++ /dev/null @@ -1,19 +0,0 @@ -use { - async_trait::async_trait, - axum::{extract::FromRequestParts, http::request::Parts}, - hyper::StatusCode, -}; - -pub struct Method(pub hyper::http::Method); - -#[async_trait] -impl FromRequestParts for Method -where - S: Send + Sync, -{ - type Rejection = (StatusCode, &'static str); - - async fn from_request_parts(parts: &mut Parts, _: &S) -> Result { - Ok(Method(parts.method.clone())) - } -} diff --git a/src/extractors/mod.rs b/src/extractors/mod.rs deleted file mode 100644 index 9ab00fa42..000000000 --- a/src/extractors/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod method; -pub mod protocol; diff --git a/src/extractors/protocol.rs b/src/extractors/protocol.rs deleted file mode 100644 index 438712ff1..000000000 --- a/src/extractors/protocol.rs +++ /dev/null @@ -1,32 +0,0 @@ -use { - crate::error::RpcError, - async_trait::async_trait, - axum::{extract::FromRequestParts, http::request::Parts}, -}; - -#[derive(Debug)] -pub enum Protocol { - Http, - WebSocket, - Other(String), -} - -#[async_trait] -impl FromRequestParts for Protocol -where - S: Send + Sync, -{ - // type Rejection = (StatusCode, &'static str); - type Rejection = RpcError; - - async fn from_request_parts(parts: &mut Parts, _: &S) -> Result { - if let Some(scheme) = parts.uri.scheme_str() { - return Ok(match scheme.to_lowercase().as_str() { - "http" | "https" => Protocol::Http, - "wss" | "ws" => Protocol::WebSocket, - other => Self::Other(other.to_string()), - }); - }; - return Err(RpcError::InvalidScheme); - } -} diff --git a/src/handlers/identity.rs b/src/handlers/identity.rs index 629d4ce0f..d0e0c4d12 100644 --- a/src/handlers/identity.rs +++ b/src/handlers/identity.rs @@ -10,6 +10,7 @@ use { }, async_trait::async_trait, axum::{ + body::to_bytes, extract::{ConnectInfo, MatchedPath, Path, Query, State}, response::{IntoResponse, Response}, Json, @@ -20,7 +21,7 @@ use { providers::{JsonRpcClient, Middleware, Provider, ProviderError}, types::H160, }, - hyper::{body::to_bytes, HeaderMap, StatusCode}, + hyper::{HeaderMap, StatusCode}, serde::{de::DeserializeOwned, Deserialize, Serialize}, std::{ net::SocketAddr, @@ -394,7 +395,8 @@ impl JsonRpcClient for SelfProvider { }); } - let bytes = to_bytes(response.into_body()) + const MAX_BODY: usize = 1024 * 1024 * 10; // prolly too big but better than usize::MAX + let bytes = to_bytes(response.into_body(), MAX_BODY) .await .map_err(SelfProviderError::ProviderBody)?; diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index d2e37ee68..613d276ae 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -1,8 +1,7 @@ use { crate::{error::RpcError, state::AppState, utils::network}, axum::{ - extract::{MatchedPath, State}, - http::Request, + extract::{MatchedPath, Request, State}, middleware::Next, response::{IntoResponse, Response}, }, @@ -45,10 +44,10 @@ pub struct SuccessResponse { /// Rate limit middleware that uses `rate_limiting`` token bucket sub crate /// from the `utils-rs`. IP address and matched path are used as the token key. -pub async fn rate_limit_middleware( +pub async fn rate_limit_middleware( State(state): State>, - req: Request, - next: Next, + req: Request, + next: Next, ) -> Response { let headers = req.headers().clone(); let ip = match network::get_forwarded_ip(headers.clone()) { diff --git a/src/handlers/profile/utils.rs b/src/handlers/profile/utils.rs index b7dbefac7..b95e2f3f3 100644 --- a/src/handlers/profile/utils.rs +++ b/src/handlers/profile/utils.rs @@ -111,8 +111,6 @@ mod tests { use { super::*, crate::handlers::profile::{ATTRIBUTES_VALUE_MAX_LENGTH, SUPPORTED_ATTRIBUTES}, - ethers::types::H160, - std::str::FromStr, }; #[test] diff --git a/src/lib.rs b/src/lib.rs index b57ef0d7d..b842327c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ use { aws_config::meta::region::RegionProviderChain, aws_sdk_s3::{config::Region, Client as S3Client}, axum::{ - extract::connect_info::IntoMakeServiceWithConnectInfo, + body::Body, middleware, response::Response, routing::{get, post}, @@ -33,7 +33,8 @@ use { }, error::RpcResult, http::Request, - hyper::{header::HeaderName, http, server::conn::AddrIncoming, Body, Server}, + hyper::{body::Incoming, header::HeaderName, http}, + hyper_util::{rt::TokioIo, server}, providers::{ AuroraProvider, BaseProvider, @@ -53,11 +54,13 @@ use { }, sqlx::postgres::PgPoolOptions, std::{ + convert::Infallible, net::{IpAddr, Ipv4Addr, SocketAddr}, sync::Arc, time::Duration, }, - tower::ServiceBuilder, + tokio::net::TcpListener, + tower::{Service, ServiceBuilder, ServiceExt}, tower_http::{ cors::{Any, CorsLayer}, request_id::MakeRequestUuid, @@ -77,15 +80,14 @@ use { }; const SERVICE_TASK_TIMEOUT: Duration = Duration::from_secs(15); -const KEEPALIVE_IDLE_DURATION: Duration = Duration::from_secs(65); -const KEEPALIVE_INTERVAL: Duration = Duration::from_secs(65); -const KEEPALIVE_RETRIES: u32 = 1; +// const KEEPALIVE_IDLE_DURATION: Duration = Duration::from_secs(65); +// const KEEPALIVE_INTERVAL: Duration = Duration::from_secs(65); +// const KEEPALIVE_RETRIES: u32 = 1; mod analytics; pub mod database; pub mod env; pub mod error; -mod extractors; pub mod handlers; mod json_rpc; mod metrics; @@ -365,8 +367,8 @@ pub async fn bootstrap(config: Config) -> RpcResult<()> { .route("/metrics", get(handlers::metrics::handler)) .with_state(state_arc.clone()); - let public_server = create_server("public_server", app, &addr); - let private_server = create_server("private_server", private_app, &private_addr); + let public_server = create_server("public_server", app, addr); + let private_server = create_server("private_server", private_app, private_addr); let weights_updater = { let state_arc = state_arc.clone(); @@ -419,22 +421,65 @@ pub async fn bootstrap(config: Config) -> RpcResult<()> { Ok(()) } -fn create_server( +async fn create_server( name: &'static str, app: Router, - addr: &SocketAddr, -) -> Server, ServiceTaskExecutor> { - let executor = ServiceTaskExecutor::new() - .name(Some(name)) - .timeout(Some(SERVICE_TASK_TIMEOUT)); - - axum::Server::bind(addr) - .executor(executor) - .tcp_keepalive(Some(KEEPALIVE_IDLE_DURATION)) - .tcp_keepalive_interval(Some(KEEPALIVE_INTERVAL)) - .tcp_keepalive_retries(Some(KEEPALIVE_RETRIES)) - .tcp_sleep_on_accept_errors(false) - .serve(app.into_make_service_with_connect_info::()) + addr: SocketAddr, +) -> Result<(), std::io::Error> { + // https://tokio.rs/blog/2023-11-27-announcing-axum-0-7-0#a-new-axumserve-function + // https://github.com/tokio-rs/axum/blob/50c035c20b7bf7987b9b9b126574852318e92e2c/examples/serve-with-hyper/src/main.rs#L81 + + let listener = TcpListener::bind(addr).await?; + + // .tcp_keepalive(Some(KEEPALIVE_IDLE_DURATION)) + // .tcp_keepalive_interval(Some(KEEPALIVE_INTERVAL)) + // .tcp_keepalive_retries(Some(KEEPALIVE_RETRIES)) + // .tcp_sleep_on_accept_errors(false) + + // let socket = TcpSocket::new_v4()?; + // // option only available in lower-layer socket2 which isn't accessible + // socket.set_keepalive(keepalive) + // socket.bind(addr)?; + // const BACKLOG: u32 = 1024; // copied from + // mio::net::tcp::listener::TcpListener::bind() let listener = + // socket.listen(BACKLOG)?; + + let mut make_service = app.into_make_service_with_connect_info::(); + + loop { + let (socket, remote_addr) = listener.accept().await.unwrap(); + + // We don't need to call `poll_ready` because `IntoMakeServiceWithConnectInfo` + // is always ready. + let tower_service = unwrap_infallible(make_service.call(remote_addr).await); + + tokio::spawn(async move { + let socket = TokioIo::new(socket); + + let hyper_service = hyper::service::service_fn(move |request: Request| { + tower_service.clone().oneshot(request) + }); + + // TODO consider replacing with timeout: https://github.com/tokio-rs/axum/discussions/1383 + let executor = ServiceTaskExecutor::new() + .name(Some(name)) + .timeout(Some(SERVICE_TASK_TIMEOUT)); + + if let Err(err) = server::conn::auto::Builder::new(executor) + .serve_connection_with_upgrades(socket, hyper_service) + .await + { + eprintln!("failed to serve connection: {err:#}"); + } + }); + } +} + +fn unwrap_infallible(result: Result) -> T { + match result { + Ok(value) => value, + Err(err) => match err {}, + } } fn init_providers(config: &ProvidersConfig) -> ProviderRepository { diff --git a/src/providers/aurora.rs b/src/providers/aurora.rs index ecfce0352..161d4dcbb 100644 --- a/src/providers/aurora.rs +++ b/src/providers/aurora.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct AuroraProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -54,15 +52,15 @@ impl RpcProvider for AuroraProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -84,16 +82,12 @@ impl RpcProvider for AuroraProvider { impl RpcProviderFactory for AuroraProvider { #[tracing::instrument] fn new(provider_config: &AuroraConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - AuroraProvider { - client: forward_proxy_client, - supported_chains, - } + AuroraProvider { supported_chains } } } diff --git a/src/providers/base.rs b/src/providers/base.rs index 8ea0775d0..8e3012cb9 100644 --- a/src/providers/base.rs +++ b/src/providers/base.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct BaseProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -54,15 +52,15 @@ impl RpcProvider for BaseProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -84,16 +82,12 @@ impl RpcProvider for BaseProvider { impl RpcProviderFactory for BaseProvider { #[tracing::instrument] fn new(provider_config: &BaseConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - BaseProvider { - client: forward_proxy_client, - supported_chains, - } + BaseProvider { supported_chains } } } diff --git a/src/providers/binance.rs b/src/providers/binance.rs index 5e250136d..4587a5cb8 100644 --- a/src/providers/binance.rs +++ b/src/providers/binance.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct BinanceProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -54,15 +52,15 @@ impl RpcProvider for BinanceProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -84,16 +82,12 @@ impl RpcProvider for BinanceProvider { impl RpcProviderFactory for BinanceProvider { #[tracing::instrument] fn new(provider_config: &BinanceConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - BinanceProvider { - client: forward_proxy_client, - supported_chains, - } + BinanceProvider { supported_chains } } } diff --git a/src/providers/coinbase.rs b/src/providers/coinbase.rs index 9ddf5b03d..4df092444 100644 --- a/src/providers/coinbase.rs +++ b/src/providers/coinbase.rs @@ -20,8 +20,6 @@ use { utils::crypto::ChainId, }, async_trait::async_trait, - hyper::Client, - hyper_tls::HttpsConnector, serde::{Deserialize, Serialize}, tracing::log::error, url::Url, @@ -31,17 +29,14 @@ use { pub struct CoinbaseProvider { pub api_key: String, pub app_id: String, - pub http_client: Client>, pub base_api_url: String, } impl CoinbaseProvider { pub fn new(api_key: String, app_id: String, base_api_url: String) -> Self { - let http_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); Self { api_key, app_id, - http_client, base_api_url, } } diff --git a/src/providers/getblock.rs b/src/providers/getblock.rs index 3c8af5db5..1ebe57fc7 100644 --- a/src/providers/getblock.rs +++ b/src/providers/getblock.rs @@ -9,8 +9,7 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; @@ -18,7 +17,6 @@ use { #[derive(Debug)] pub struct GetBlockProvider { base_api_url: String, - client: Client>, supported_chains: HashMap, } @@ -54,16 +52,15 @@ impl RpcProvider for GetBlockProvider { let uri = format!("{}/{}", self.base_api_url, access_token_api); - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; - - let response = self.client.request(hyper_request).await?; + .body(body) + .send() + .await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -85,7 +82,6 @@ impl RpcProvider for GetBlockProvider { impl RpcProviderFactory for GetBlockProvider { #[tracing::instrument] fn new(provider_config: &GetBlockConfig) -> Self { - let client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -95,7 +91,6 @@ impl RpcProviderFactory for GetBlockProvider { GetBlockProvider { base_api_url, - client, supported_chains, } } diff --git a/src/providers/infura.rs b/src/providers/infura.rs index 8bff10053..5e084acac 100644 --- a/src/providers/infura.rs +++ b/src/providers/infura.rs @@ -20,8 +20,7 @@ use { response::{IntoResponse, Response}, }, axum_tungstenite::WebSocketUpgrade, - hyper::{client::HttpConnector, http, Client, Method, StatusCode}, - hyper_tls::HttpsConnector, + hyper::{http, StatusCode}, std::collections::HashMap, tracing::info, wc::future::FutureExt, @@ -29,7 +28,6 @@ use { #[derive(Debug)] pub struct InfuraProvider { - pub client: Client>, pub project_id: String, pub supported_chains: HashMap, } @@ -125,15 +123,15 @@ impl RpcProvider for InfuraProvider { let uri = format!("https://{}.infura.io/v3/{}", chain, self.project_id); - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if let Some(error) = &response.error { @@ -160,7 +158,6 @@ impl RpcProvider for InfuraProvider { impl RpcProviderFactory for InfuraProvider { #[tracing::instrument] fn new(provider_config: &InfuraConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -168,7 +165,6 @@ impl RpcProviderFactory for InfuraProvider { .collect(); InfuraProvider { - client: forward_proxy_client, supported_chains, project_id: provider_config.project_id.clone(), } diff --git a/src/providers/mantle.rs b/src/providers/mantle.rs index 2ef22c61b..f8db1835d 100644 --- a/src/providers/mantle.rs +++ b/src/providers/mantle.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct MantleProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -51,15 +49,15 @@ impl RpcProvider for MantleProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -81,16 +79,12 @@ impl RpcProvider for MantleProvider { impl RpcProviderFactory for MantleProvider { #[tracing::instrument] fn new(provider_config: &MantleConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - MantleProvider { - client: forward_proxy_client, - supported_chains, - } + MantleProvider { supported_chains } } } diff --git a/src/providers/mod.rs b/src/providers/mod.rs index ff96daf2d..16935d492 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -319,7 +319,7 @@ impl ProviderRepository { pub async fn update_weights(&self, metrics: &crate::Metrics) { info!("Updating weights"); - let Ok(header_value) = HeaderValue::from_str(&self.prometheus_workspace_header) else { + let Ok(_header_value) = HeaderValue::from_str(&self.prometheus_workspace_header) else { warn!( "Failed to parse prometheus workspace header from {}", self.prometheus_workspace_header @@ -330,7 +330,8 @@ impl ProviderRepository { match self .prometheus_client .query("round(increase(provider_status_code_counter_total[3h]))") - .header("host", header_value) + // FIXME + // .header("host", header_value.to_str().unwrap()) .get() .await { diff --git a/src/providers/near.rs b/src/providers/near.rs index 8b2b7bd1f..0e3e9a3ad 100644 --- a/src/providers/near.rs +++ b/src/providers/near.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct NearProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -51,15 +49,15 @@ impl RpcProvider for NearProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -81,16 +79,12 @@ impl RpcProvider for NearProvider { impl RpcProviderFactory for NearProvider { #[tracing::instrument] fn new(provider_config: &NearConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - NearProvider { - client: forward_proxy_client, - supported_chains, - } + NearProvider { supported_chains } } } diff --git a/src/providers/pokt.rs b/src/providers/pokt.rs index 0169e8f31..a01eb1102 100644 --- a/src/providers/pokt.rs +++ b/src/providers/pokt.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{self, client::HttpConnector, Client, Method, StatusCode}, - hyper_tls::HttpsConnector, + hyper::StatusCode, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct PoktProvider { - pub client: Client>, pub project_id: String, pub supported_chains: HashMap, } @@ -78,15 +76,15 @@ impl RpcProvider for PoktProvider { let uri = format!("https://{}.rpc.grove.city/v1/{}", chain, self.project_id); - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if let Some(error) = &response.error { @@ -116,7 +114,6 @@ impl RpcProvider for PoktProvider { impl RpcProviderFactory for PoktProvider { #[tracing::instrument] fn new(provider_config: &PoktConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -124,7 +121,6 @@ impl RpcProviderFactory for PoktProvider { .collect(); PoktProvider { - client: forward_proxy_client, supported_chains, project_id: provider_config.project_id.clone(), } diff --git a/src/providers/publicnode.rs b/src/providers/publicnode.rs index 44c7963dc..085b305eb 100644 --- a/src/providers/publicnode.rs +++ b/src/providers/publicnode.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct PublicnodeProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -53,15 +51,15 @@ impl RpcProvider for PublicnodeProvider { let uri = format!("https://{}.publicnode.com", chain); - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -83,16 +81,12 @@ impl RpcProvider for PublicnodeProvider { impl RpcProviderFactory for PublicnodeProvider { #[tracing::instrument] fn new(provider_config: &PublicnodeConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - PublicnodeProvider { - client: forward_proxy_client, - supported_chains, - } + PublicnodeProvider { supported_chains } } } diff --git a/src/providers/quicknode.rs b/src/providers/quicknode.rs index a9e0c9047..05eb4d0d7 100644 --- a/src/providers/quicknode.rs +++ b/src/providers/quicknode.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct QuicknodeProvider { - pub client: Client>, pub api_token: String, pub supported_chains: HashMap, } @@ -57,15 +55,15 @@ impl RpcProvider for QuicknodeProvider { let uri = format!("https://{}.quiknode.pro/{}", chain, self.api_token); - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -87,7 +85,6 @@ impl RpcProvider for QuicknodeProvider { impl RpcProviderFactory for QuicknodeProvider { #[tracing::instrument] fn new(provider_config: &QuicknodeConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -95,7 +92,6 @@ impl RpcProviderFactory for QuicknodeProvider { .collect(); QuicknodeProvider { - client: forward_proxy_client, supported_chains, api_token: provider_config.api_token.clone(), } diff --git a/src/providers/zerion.rs b/src/providers/zerion.rs index 8ae16bb8f..23d26ad8c 100644 --- a/src/providers/zerion.rs +++ b/src/providers/zerion.rs @@ -27,9 +27,6 @@ use { }, async_trait::async_trait, axum::body::Bytes, - futures_util::StreamExt, - hyper::Client, - hyper_tls::HttpsConnector, serde::{Deserialize, Serialize}, tracing::log::error, url::Url, @@ -38,16 +35,11 @@ use { #[derive(Debug)] pub struct ZerionProvider { pub api_key: String, - pub http_client: Client>, } impl ZerionProvider { pub fn new(api_key: String) -> Self { - let http_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); - Self { - api_key, - http_client, - } + Self { api_key } } } @@ -366,13 +358,13 @@ impl PortfolioProvider for ZerionProvider { url.query_pairs_mut() .append_pair("currency", ¶ms.currency.unwrap_or("usd".to_string())); - let hyper_request = hyper::http::Request::builder() - .uri(url.as_str()) + let response = reqwest::Client::new() + .get(url.as_str()) .header("Content-Type", "application/json") .header("authorization", format!("Basic {}", self.api_key)) - .body(hyper::body::Body::from(body))?; - - let response = self.http_client.request(hyper_request).await?; + .body(body) + .send() + .await?; if !response.status().is_success() { error!( @@ -382,13 +374,9 @@ impl PortfolioProvider for ZerionProvider { return Err(RpcError::PortfolioProviderError); } - let mut body = response.into_body(); - let mut bytes = Vec::new(); - while let Some(next) = body.next().await { - bytes.extend_from_slice(&next?); - } + let body = response.bytes().await?; let body: ZerionResponseBody> = - match serde_json::from_slice(&bytes) { + match serde_json::from_slice(&body) { Ok(body) => body, Err(e) => { error!("Error on parsing zerion portfolio response: {:?}", e); diff --git a/src/providers/zksync.rs b/src/providers/zksync.rs index bbd0a28bd..98d0e7ea7 100644 --- a/src/providers/zksync.rs +++ b/src/providers/zksync.rs @@ -9,15 +9,13 @@ use { http::HeaderValue, response::{IntoResponse, Response}, }, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct ZKSyncProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -51,15 +49,15 @@ impl RpcProvider for ZKSyncProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -81,16 +79,12 @@ impl RpcProvider for ZKSyncProvider { impl RpcProviderFactory for ZKSyncProvider { #[tracing::instrument] fn new(provider_config: &ZKSyncConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - ZKSyncProvider { - client: forward_proxy_client, - supported_chains, - } + ZKSyncProvider { supported_chains } } } diff --git a/src/providers/zora.rs b/src/providers/zora.rs index f505bf3a5..ea1648c27 100644 --- a/src/providers/zora.rs +++ b/src/providers/zora.rs @@ -20,8 +20,7 @@ use { response::{IntoResponse, Response}, }, axum_tungstenite::WebSocketUpgrade, - hyper::{client::HttpConnector, http, Client, Method}, - hyper_tls::HttpsConnector, + hyper::http, std::collections::HashMap, tracing::info, wc::future::FutureExt, @@ -29,7 +28,6 @@ use { #[derive(Debug)] pub struct ZoraProvider { - pub client: Client>, pub supported_chains: HashMap, } @@ -119,15 +117,15 @@ impl RpcProvider for ZoraProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let hyper_request = hyper::http::Request::builder() - .method(Method::POST) - .uri(uri) + let response = reqwest::Client::new() + .post(uri) .header("Content-Type", "application/json") - .body(hyper::body::Body::from(body))?; + .body(body) + .send() + .await?; - let response = self.client.request(hyper_request).await?; let status = response.status(); - let body = hyper::body::to_bytes(response.into_body()).await?; + let body = response.bytes().await?; if let Ok(response) = serde_json::from_slice::(&body) { if response.error.is_some() && status.is_success() { @@ -149,17 +147,13 @@ impl RpcProvider for ZoraProvider { impl RpcProviderFactory for ZoraProvider { #[tracing::instrument] fn new(provider_config: &ZoraConfig) -> Self { - let forward_proxy_client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - ZoraProvider { - client: forward_proxy_client, - supported_chains, - } + ZoraProvider { supported_chains } } } diff --git a/src/utils/crypto.rs b/src/utils/crypto.rs index 2713d836f..ed8650a61 100644 --- a/src/utils/crypto.rs +++ b/src/utils/crypto.rs @@ -175,11 +175,7 @@ pub fn constant_time_eq(a: impl AsRef<[u8]>, b: impl AsRef<[u8]>) -> bool { #[cfg(test)] mod tests { - use { - super::*, - ethers::types::H160, - std::{collections::HashMap, str::FromStr}, - }; + use {super::*, std::collections::HashMap}; #[test] fn test_verify_message_signature_valid() { diff --git a/tests/context/server.rs b/tests/context/server.rs index 8c29fa888..2f3668a0f 100644 --- a/tests/context/server.rs +++ b/tests/context/server.rs @@ -12,7 +12,9 @@ use { pub struct RpcProxy { pub public_addr: String, + #[allow(unused)] pub public_port: Option, + #[allow(unused)] pub private_addr: Option, pub project_id: String, } diff --git a/tests/functional/http/mod.rs b/tests/functional/http/mod.rs index 2a3d97338..918c4a03c 100644 --- a/tests/functional/http/mod.rs +++ b/tests/functional/http/mod.rs @@ -1,7 +1,6 @@ use { crate::{context::ServerContext, utils::send_jsonrpc_request, JSONRPC_VERSION}, - hyper::{Body, Client, Method, Request, StatusCode}, - hyper_tls::HttpsConnector, + hyper::StatusCode, rpc_proxy::{handlers::history::HistoryResponseBody, providers::ProviderKind}, test_context::test_context, }; @@ -30,7 +29,6 @@ async fn check_if_rpc_is_responding_correctly_for_supported_chain( ctx.server.public_addr, ctx.server.project_id, provider_id ); - let client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let request = jsonrpc::Request { method: "eth_chainId", params: &[], @@ -38,7 +36,7 @@ async fn check_if_rpc_is_responding_correctly_for_supported_chain( jsonrpc: JSONRPC_VERSION, }; - let (status, rpc_response) = send_jsonrpc_request(client, addr, chaind_id, request).await; + let (status, rpc_response) = send_jsonrpc_request(addr, chaind_id, &request).await; match status { StatusCode::OK => { @@ -61,7 +59,6 @@ async fn check_if_rpc_is_responding_correctly_for_near_protocol( ctx.server.public_addr, ctx.server.project_id, provider_id ); - let client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let request = jsonrpc::Request { method: "EXPERIMENTAL_genesis_config", params: &[], @@ -69,7 +66,7 @@ async fn check_if_rpc_is_responding_correctly_for_near_protocol( jsonrpc: JSONRPC_VERSION, }; - let (status, rpc_response) = send_jsonrpc_request(client, addr, "near:mainnet", request).await; + let (status, rpc_response) = send_jsonrpc_request(addr, "near:mainnet", &request).await; #[derive(serde::Deserialize)] struct GenesisConfig { @@ -101,7 +98,6 @@ async fn check_if_rpc_is_responding_correctly_for_solana( ctx.server.public_addr, ctx.server.project_id, provider_id ); - let client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); let request = jsonrpc::Request { method: "getHealth", params: &[], @@ -110,7 +106,7 @@ async fn check_if_rpc_is_responding_correctly_for_solana( }; let (status, rpc_response) = - send_jsonrpc_request(client, addr, &format!("solana:{}", chain_id), request).await; + send_jsonrpc_request(addr, &format!("solana:{}", chain_id), &request).await; // Verify that HTTP communication was successful assert_eq!(status, StatusCode::OK); @@ -127,15 +123,7 @@ async fn check_if_rpc_is_responding_correctly_for_solana( async fn health_check(ctx: &mut ServerContext) { let addr = format!("{}/health", ctx.server.public_addr); - let client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); - - let request = Request::builder() - .method(Method::GET) - .uri(addr) - .body(Body::default()) - .unwrap(); - - let response = client.request(request).await.unwrap(); + let response = reqwest::get(addr).await.unwrap(); assert_eq!(response.status(), StatusCode::OK) } @@ -150,22 +138,13 @@ async fn account_history_check(ctx: &mut ServerContext) { ctx.server.public_addr, account, project_id ); - let client = Client::builder().build::<_, hyper::Body>(HttpsConnector::new()); - - let request = Request::builder() - .method(Method::GET) - .uri(addr) - .body(Body::default()) - .unwrap(); - - let response = client.request(request).await.unwrap(); + let response = reqwest::get(addr).await.unwrap(); let status = response.status(); assert_eq!(status, StatusCode::OK); - let bytes = hyper::body::to_bytes(response.into_body()).await.unwrap(); - let body_str = String::from_utf8_lossy(&bytes); - - let json_response: HistoryResponseBody = - serde_json::from_str(&body_str).expect("Failed to parse response body"); + let json_response = response + .json::() + .await + .expect("Failed to parse response body"); assert!(!json_response.data.is_empty()); } diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs index 6751b933d..7117dab00 100644 --- a/tests/utils/mod.rs +++ b/tests/utils/mod.rs @@ -1,44 +1,39 @@ use { axum::http::HeaderValue, - hyper::{body, client::HttpConnector, Body, Client, Method, Request, StatusCode}, - hyper_tls::HttpsConnector, + hyper::StatusCode, rand::{distributions::Alphanumeric, Rng}, sqlx::{postgres::PgPoolOptions, PgPool}, std::env, }; pub async fn send_jsonrpc_request( - client: Client>, base_addr: String, chain: &str, - rpc_request: jsonrpc::Request<'static>, + rpc_request: &jsonrpc::Request<'static>, ) -> (StatusCode, jsonrpc::Response) { let addr = base_addr + chain; - let json = serde_json::to_string(&rpc_request).unwrap(); - let req_body = Body::from(json.clone()); - - let request = Request::builder() - .method(Method::POST) - .uri(addr.clone()) + let response = reqwest::Client::new() + .post(addr.clone()) .header("Content-Type", "application/json") - .body(req_body) + .json(rpc_request) + .send() + .await .unwrap(); - let response = client.request(request).await.unwrap(); assert_eq!( response.headers().get("Content-Type"), Some(&HeaderValue::from_static("application/json")) ); - let (parts, body) = response.into_parts(); - let body = body::to_bytes(body).await.unwrap(); + let status = response.status(); + let body = response.bytes().await.unwrap(); ( - parts.status, + status, serde_json::from_slice(&body).unwrap_or_else(|_| { panic!( "Failed to parse response '{:?}' ({} / {:?})", - &body, &addr, &json + &body, &addr, &rpc_request ) }), ) From ccc8c8d040cb0c685adb0aa907bbdeef37c80f48 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 01:41:32 -0400 Subject: [PATCH 02/10] chore: comment --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index b842327c4..c835b27bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -460,7 +460,8 @@ async fn create_server( tower_service.clone().oneshot(request) }); - // TODO consider replacing with timeout: https://github.com/tokio-rs/axum/discussions/1383 + // TODO consider replacing with timeout and switching to simple axum::serve: + // https://github.com/tokio-rs/axum/discussions/1383 let executor = ServiceTaskExecutor::new() .name(Some(name)) .timeout(Some(SERVICE_TASK_TIMEOUT)); From 8499426e430c4257199de6f90e520e67aab5c76f Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 12:55:32 -0400 Subject: [PATCH 03/10] fix: use compatible prometheus-http-query --- Cargo.lock | 5 ++--- Cargo.toml | 4 ++-- src/providers/mod.rs | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d8ca3781..54207255f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3942,12 +3942,11 @@ dependencies = [ [[package]] name = "prometheus-http-query" version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0de773a6ba25c9164ed9d86d653a92fac759a6f0e683fd141d56bb96e80fd8b" +source = "git+https://github.com/WalletConnect/prometheus-http-query?branch=feat/reqwest-v12#82fa7b4d6df30adf39cb9826081cffbca8374bb5" dependencies = [ "enum-as-inner", "mime", - "reqwest 0.11.27", + "reqwest 0.12.2", "serde", "time", "url", diff --git a/Cargo.toml b/Cargo.toml index 24bd6faac..1615bb414 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ tower-http = { version = "0.5.2", features = ["cors", "trace", "request-id", "ut jsonrpc = "0.14.0" async-tungstenite = { version = "0.25.1", features = ["tokio", "tokio-runtime", "tokio-native-tls"] } url = "2.5" -reqwest = { version= "0.12.2", features = ["deflate", "brotli", "gzip", "json"] } +reqwest = { version = "0.12.2", features = ["deflate", "brotli", "gzip", "json"] } # Serialization rmp-serde = "1.1" @@ -69,7 +69,7 @@ tokio-stream = "0.1.12" axum-tungstenite = { git = "https://github.com/Astralchroma/axum-tungstenite", rev = "0906fea" } # https://github.com/davidpdrsn/axum-tungstenite/pull/13 rand = "0.8.4" -prometheus-http-query = "0.8.2" +prometheus-http-query = { git = "https://github.com/WalletConnect/prometheus-http-query", branch = "feat/reqwest-v12" } ethers = { version = "2.0.11", git = "https://github.com/gakonst/ethers-rs" } # using Git version because crates.io version fails clippy bytes = "1.4.0" diff --git a/src/providers/mod.rs b/src/providers/mod.rs index 16935d492..ff96daf2d 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -319,7 +319,7 @@ impl ProviderRepository { pub async fn update_weights(&self, metrics: &crate::Metrics) { info!("Updating weights"); - let Ok(_header_value) = HeaderValue::from_str(&self.prometheus_workspace_header) else { + let Ok(header_value) = HeaderValue::from_str(&self.prometheus_workspace_header) else { warn!( "Failed to parse prometheus workspace header from {}", self.prometheus_workspace_header @@ -330,8 +330,7 @@ impl ProviderRepository { match self .prometheus_client .query("round(increase(provider_status_code_counter_total[3h]))") - // FIXME - // .header("host", header_value.to_str().unwrap()) + .header("host", header_value) .get() .await { From a22a7a8e2ea280be1271fa23a9572909dd0808a6 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 12:58:01 -0400 Subject: [PATCH 04/10] chore: comment --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1615bb414..2da17fb79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ tokio-stream = "0.1.12" axum-tungstenite = { git = "https://github.com/Astralchroma/axum-tungstenite", rev = "0906fea" } # https://github.com/davidpdrsn/axum-tungstenite/pull/13 rand = "0.8.4" -prometheus-http-query = { git = "https://github.com/WalletConnect/prometheus-http-query", branch = "feat/reqwest-v12" } +prometheus-http-query = { git = "https://github.com/WalletConnect/prometheus-http-query", branch = "feat/reqwest-v12" } # https://github.com/puetzp/prometheus-http-query/pull/13 ethers = { version = "2.0.11", git = "https://github.com/gakonst/ethers-rs" } # using Git version because crates.io version fails clippy bytes = "1.4.0" From 262557743fda25cab6313e4320b0928aff9e51b5 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 13:10:16 -0400 Subject: [PATCH 05/10] chore: bump ci_workflows --- .github/workflows/dispatch_deploy.yml | 2 +- .github/workflows/dispatch_publish.yml | 4 ++-- .github/workflows/dispatch_validate.yml | 2 +- .github/workflows/event_pr.yml | 2 +- .github/workflows/event_release.yml | 2 +- .github/workflows/sub-cd.yml | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dispatch_deploy.yml b/.github/workflows/dispatch_deploy.yml index 88e6ed48c..51feb351c 100644 --- a/.github/workflows/dispatch_deploy.yml +++ b/.github/workflows/dispatch_deploy.yml @@ -49,7 +49,7 @@ jobs: name: Lookup deployed version if: ${{ inputs.version-type == 'current' }} secrets: inherit - uses: WalletConnect/ci_workflows/.github/workflows/release-get_deployed_version.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/release-get_deployed_version.yml@fix/udeps-build with: task-name-stage: prod task-name: ${{ vars.TASK_NAME }} diff --git a/.github/workflows/dispatch_publish.yml b/.github/workflows/dispatch_publish.yml index 2a071f60b..7bf2ae914 100644 --- a/.github/workflows/dispatch_publish.yml +++ b/.github/workflows/dispatch_publish.yml @@ -25,7 +25,7 @@ permissions: jobs: ci: name: CI - uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@fix/udeps-build secrets: inherit with: check-infra: false @@ -33,7 +33,7 @@ jobs: release: name: Release - uses: WalletConnect/ci_workflows/.github/workflows/release.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/release.yml@fix/udeps-build secrets: inherit with: infra-changed: false diff --git a/.github/workflows/dispatch_validate.yml b/.github/workflows/dispatch_validate.yml index 35f9f1b0b..51f810097 100644 --- a/.github/workflows/dispatch_validate.yml +++ b/.github/workflows/dispatch_validate.yml @@ -32,7 +32,7 @@ permissions: jobs: ci: name: CI - uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@fix/udeps-build secrets: inherit with: check-infra: ${{ inputs.check-infra }} diff --git a/.github/workflows/event_pr.yml b/.github/workflows/event_pr.yml index afbb01dd1..ea009c21c 100644 --- a/.github/workflows/event_pr.yml +++ b/.github/workflows/event_pr.yml @@ -46,7 +46,7 @@ jobs: ci: name: CI needs: [ paths-filter ] - uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@fix/udeps-build secrets: inherit with: check-app: ${{ needs.paths-filter.outputs.app == 'true' }} diff --git a/.github/workflows/event_release.yml b/.github/workflows/event_release.yml index b9892ea09..9fe6e9abd 100644 --- a/.github/workflows/event_release.yml +++ b/.github/workflows/event_release.yml @@ -44,7 +44,7 @@ jobs: release: name: Release needs: [ paths_filter ] - uses: WalletConnect/ci_workflows/.github/workflows/release.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/release.yml@fix/udeps-build secrets: inherit with: task-name: ${{ vars.TASK_NAME }} diff --git a/.github/workflows/sub-cd.yml b/.github/workflows/sub-cd.yml index 2c9b2f991..57a9d2476 100644 --- a/.github/workflows/sub-cd.yml +++ b/.github/workflows/sub-cd.yml @@ -31,7 +31,7 @@ jobs: cd-staging: name: Staging secrets: inherit - uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@fix/udeps-build with: deploy-infra: ${{ inputs.deploy-infra }} deploy-app: ${{ inputs.deploy-app && !inputs.deploy-infra }} @@ -57,7 +57,7 @@ jobs: needs: [ validate-staging ] if: ${{ inputs.deploy-prod }} secrets: inherit - uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@0.2.8 + uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@fix/udeps-build with: deploy-infra: ${{ inputs.deploy-infra }} deploy-app: ${{ inputs.deploy-app && !inputs.deploy-infra }} From 88814d8c88335ac53d1aca8f610a912157459218 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 13:49:34 -0400 Subject: [PATCH 06/10] chore: fix formatting --- justfile | 43 ++++---- rustfmt.toml | 28 ++--- src/analytics/mod.rs | 46 ++++---- src/env/mod.rs | 152 +++++++++++++-------------- src/error.rs | 4 +- src/handlers/balance.rs | 26 +++-- src/handlers/metrics.rs | 5 +- src/handlers/profile/address.rs | 8 +- src/handlers/profile/attributes.rs | 4 +- src/handlers/profile/register.rs | 23 ++-- src/lib.rs | 32 +----- src/metrics.rs | 139 +++++++++++++----------- src/project/config.rs | 4 +- src/project/metrics/mod.rs | 9 +- src/project/storage/config.rs | 3 +- src/providers/coinbase.rs | 10 +- src/providers/infura.rs | 10 +- src/providers/mod.rs | 36 ++++--- src/providers/one_inch.rs | 8 +- src/providers/zerion.rs | 19 ++-- src/providers/zora.rs | 10 +- src/storage/redis/mod.rs | 3 +- tests/functional/database.rs | 78 ++++++++------ tests/functional/http/aurora.rs | 6 +- tests/functional/http/base.rs | 6 +- tests/functional/http/binance.rs | 6 +- tests/functional/http/infura.rs | 6 +- tests/functional/http/mantle.rs | 6 +- tests/functional/http/near.rs | 6 +- tests/functional/http/publicnode.rs | 6 +- tests/functional/http/quicknode.rs | 6 +- tests/functional/http/zksync.rs | 6 +- tests/functional/http/zora.rs | 6 +- tests/functional/websocket/infura.rs | 3 +- tests/functional/websocket/zora.rs | 3 +- 35 files changed, 356 insertions(+), 410 deletions(-) diff --git a/justfile b/justfile index e038402ec..efac9004d 100644 --- a/justfile +++ b/justfile @@ -39,7 +39,6 @@ alias clean := cargo-clean alias check := cargo-check alias clippy := cargo-clippy alias udeps := cargo-udeps -alias checkfmt := cargo-checkfmt alias tfsec := tf-tfsec alias tflint := tf-tflint @@ -47,13 +46,6 @@ alias tflint := tf-tflint ################################################################################ # Meta recipes -# Format the project code -fmt target='all': (_check-string-in-set target "all,rust,tf") - #!/bin/bash - set -euo pipefail - [[ '{{ target }}' == 'all' || '{{ target }}' == 'rust' ]] && { just cargo-fmt; } - [[ '{{ target }}' == 'all' || '{{ target }}' == 'tf' ]] && { just tf-fmt; } - # Update project documentation docs target='all': (_check-string-in-set target "all,rust,tf") #!/bin/bash @@ -62,7 +54,7 @@ docs target='all': (_check-string-in-set target "all,rust,tf") [[ '{{ target }}' == 'all' || '{{ target }}' == 'tf' ]] && { just tf-docs; } # Run linting and tests -devloop: lint cargo-test-all +devloop: lint cargo-test-all fmt-imports ################################################################################ # Linting recipes @@ -76,7 +68,7 @@ lint target='all': (_check-string-in-set target "all,rust,tf") # Lint the rust project for any quality issues -lint-rust: cargo-check cargo-clippy cargo-udeps cargo-checkfmt +lint-rust: cargo-clippy fmt cargo-udeps # Lint the terrafrom project for any quality issues lint-tf: tf-checkfmt tf-validate tf-tfsec tf-tflint @@ -116,7 +108,6 @@ cargo target='' sub-target='': (_check-string-in-set target "open-docs,build-doc [[ '{{ target }}' == 'check' ]] && { just cargo-check; } [[ '{{ target }}' == 'clippy' ]] && { just cargo-clippy; } [[ '{{ target }}' == 'udeps' ]] && { just cargo-udeps; } - [[ '{{ target }}' == 'checkfmt' ]] && { just cargo-checkfmt; } # Open rust project documentation in your local browser cargo-open-docs: (_cargo-build-docs "open" "nodeps") @@ -129,10 +120,27 @@ cargo-build-docs: (_cargo-build-docs "" "nodeps") echo "==> Building project documentation @$JUST_ROOT/target/doc" cargo doc --all-features --document-private-items ${nodeps:+--no-deps} ${open:+--open} -# Format the application code -@cargo-fmt: _check-cmd-cargo-fmt - printf '==> Running {{ color-cmd }}rustfmt{{ nocolor }}\n' - cargo +nightly fmt +fmt: + #!/bin/bash + set -euo pipefail + + if command -v cargo-fmt >/dev/null; then + echo '==> Running rustfmt' + cargo fmt + else + echo '==> rustfmt not found in PATH, skipping' + fi + +fmt-imports: + #!/bin/bash + set -euo pipefail + + if command -v cargo-fmt >/dev/null; then + echo '==> Running rustfmt' + cargo +nightly fmt -- --config group_imports=StdExternalCrate,imports_granularity=One + else + echo '==> rustfmt not found in PATH, skipping' + fi # Build service for development cargo-build: _check-cmd-cargo @@ -191,11 +199,6 @@ cargo-udeps: _check-cmd-cargo-udeps @printf '==> Running {{ color-cmd }}udeps{{ nocolor }}\n' cargo +nightly udeps -# Check the rust code formatting -cargo-checkfmt: _check-cmd-cargo-fmt - @printf '==> Running {{ color-cmd }}rustfmt{{ nocolor }} --check\n' - cargo +nightly fmt --check - ################################################################################ # Terraform recipes diff --git a/rustfmt.toml b/rustfmt.toml index c39c39ab4..e58473296 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,18 +1,22 @@ edition = "2021" -fn_single_line = false -format_code_in_doc_comments = true -format_strings = true -imports_layout = "HorizontalVertical" -imports_granularity = "One" -normalize_comments = true -normalize_doc_attributes = true + reorder_imports = true -reorder_impl_items = true -group_imports = "StdExternalCrate" use_try_shorthand = true -wrap_comments = true -overflow_delimited_expr = true remove_nested_parens = true reorder_modules = true -unstable_features = true use_field_init_shorthand = true + +## We only use settings available in the stable channel + +#fn_single_line = false +#format_code_in_doc_comments = true +#format_strings = true +#imports_layout = "HorizontalVertical" +#imports_granularity = "One" +#normalize_comments = true +#normalize_doc_attributes = true +#reorder_impl_items = true +#group_imports = "StdExternalCrate" +#wrap_comments = true +#overflow_delimited_expr = true +#unstable_features = true diff --git a/src/analytics/mod.rs b/src/analytics/mod.rs index e48139260..9d392a848 100644 --- a/src/analytics/mod.rs +++ b/src/analytics/mod.rs @@ -5,17 +5,8 @@ use { tracing::info, wc::{ analytics::{ - self, - AnalyticsExt, - ArcCollector, - AwsConfig, - AwsExporter, - BatchCollector, - BatchObserver, - CollectionObserver, - Collector, - CollectorConfig, - ExportObserver, + self, AnalyticsExt, ArcCollector, AwsConfig, AwsExporter, BatchCollector, + BatchObserver, CollectionObserver, Collector, CollectorConfig, ExportObserver, ParquetBatchFactory, }, geoip::{self, MaxMindResolver, Resolver}, @@ -23,10 +14,8 @@ use { }, }; pub use { - config::Config, - history_lookup_info::HistoryLookupInfo, - identity_lookup_info::IdentityLookupInfo, - message_info::MessageInfo, + config::Config, history_lookup_info::HistoryLookupInfo, + identity_lookup_info::IdentityLookupInfo, message_info::MessageInfo, onramp_history_lookup_info::OnrampHistoryLookupInfo, }; @@ -79,10 +68,11 @@ where let size = res.as_deref().map(|data| data.len()).unwrap_or(0); let elapsed = elapsed.as_millis() as u64; - wc::metrics::counter!("analytics_batches_finished", 1, &[ - self.0.as_kv(), - success_kv(res.is_ok()) - ]); + wc::metrics::counter!( + "analytics_batches_finished", + 1, + &[self.0.as_kv(), success_kv(res.is_ok())] + ); if let Err(err) = res { tracing::warn!( @@ -106,10 +96,11 @@ where E: std::error::Error, { fn observe_collection(&self, res: &Result<(), E>) { - wc::metrics::counter!("analytics_records_collected", 1, &[ - self.0.as_kv(), - success_kv(res.is_ok()) - ]); + wc::metrics::counter!( + "analytics_records_collected", + 1, + &[self.0.as_kv(), success_kv(res.is_ok())] + ); if let Err(err) = res { tracing::warn!( @@ -126,10 +117,11 @@ where E: std::error::Error, { fn observe_export(&self, elapsed: Duration, res: &Result<(), E>) { - wc::metrics::counter!("analytics_batches_exported", 1, &[ - self.0.as_kv(), - success_kv(res.is_ok()) - ]); + wc::metrics::counter!( + "analytics_batches_exported", + 1, + &[self.0.as_kv(), success_kv(res.is_ok())] + ); let elapsed = elapsed.as_millis() as u64; diff --git a/src/env/mod.rs b/src/env/mod.rs index a8843a848..33941f5db 100644 --- a/src/env/mod.rs +++ b/src/env/mod.rs @@ -12,19 +12,8 @@ use { std::{collections::HashMap, fmt::Display}, }; pub use { - aurora::*, - base::*, - binance::*, - getblock::*, - infura::*, - mantle::*, - near::*, - pokt::*, - publicnode::*, - quicknode::*, - server::*, - zksync::*, - zora::*, + aurora::*, base::*, binance::*, getblock::*, infura::*, mantle::*, near::*, pokt::*, + publicnode::*, quicknode::*, server::*, zksync::*, zora::*, }; mod aurora; mod base; @@ -182,72 +171,77 @@ mod test { values.iter().for_each(set_env_var); - assert_eq!(Config::from_env().unwrap(), Config { - server: ServerConfig { - host: "1.2.3.4".to_owned(), - port: 123, - prometheus_port: 234, - log_level: "TRACE".to_owned(), - external_ip: Some(Ipv4Addr::new(2, 3, 4, 5).into()), - blocked_countries: vec![ - "KP".to_owned(), - "IR".to_owned(), - "CU".to_owned(), - "SY".to_owned(), - ], - s3_endpoint: None, - geoip_db_bucket: Some("GEOIP_DB_BUCKET".to_owned()), - geoip_db_key: Some("GEOIP_DB_KEY".to_owned()), - testing_project_id: Some("TESTING_PROJECT_ID".to_owned()), - validate_project_id: true, - }, - registry: project::Config { - api_url: Some("API_URL".to_owned()), - api_auth_token: Some("API_AUTH_TOKEN".to_owned()), - project_data_cache_ttl: 345, - }, - storage: project::storage::Config { - redis_max_connections: 456, - project_data_redis_addr_read: Some("redis://127.0.0.1/data/read".to_owned()), - project_data_redis_addr_write: Some("redis://127.0.0.1/data/write".to_owned()), - identity_cache_redis_addr_read: Some("redis://127.0.0.1/identity/read".to_owned()), - identity_cache_redis_addr_write: Some( - "redis://127.0.0.1/identity/write".to_owned() - ), - rate_limiting_cache_redis_addr_read: Some( - "redis://127.0.0.1/rate_limit/read".to_owned() - ), - rate_limiting_cache_redis_addr_write: Some( - "redis://127.0.0.1/rate_limit/write".to_owned() - ), - }, - postgres: PostgresConfig { - uri: "postgres://postgres@localhost:5432/postgres".to_owned(), - max_connections: 32, - }, - analytics: analytics::Config { - s3_endpoint: Some("s3://127.0.0.1".to_owned()), - export_bucket: Some("EXPORT_BUCKET".to_owned()), - }, - profiler: ProfilerConfig {}, - providers: ProvidersConfig { - prometheus_query_url: Some("PROMETHEUS_QUERY_URL".to_owned()), - prometheus_workspace_header: Some("PROMETHEUS_WORKSPACE_HEADER".to_owned()), - infura_project_id: "INFURA_PROJECT_ID".to_string(), - pokt_project_id: "POKT_PROJECT_ID".to_string(), - quicknode_api_token: "QUICKNODE_API_TOKEN".to_string(), - zerion_api_key: Some("ZERION_API_KEY".to_owned()), - coinbase_api_key: Some("COINBASE_API_KEY".to_owned()), - coinbase_app_id: Some("COINBASE_APP_ID".to_owned()), - one_inch_api_key: Some("ONE_INCH_API_KEY".to_owned()), - getblock_access_tokens: Some("{}".to_owned()), - }, - rate_limiting: RateLimitingConfig { - max_tokens: Some(100), - refill_interval_sec: Some(1), - refill_rate: Some(10), - }, - }); + assert_eq!( + Config::from_env().unwrap(), + Config { + server: ServerConfig { + host: "1.2.3.4".to_owned(), + port: 123, + prometheus_port: 234, + log_level: "TRACE".to_owned(), + external_ip: Some(Ipv4Addr::new(2, 3, 4, 5).into()), + blocked_countries: vec![ + "KP".to_owned(), + "IR".to_owned(), + "CU".to_owned(), + "SY".to_owned(), + ], + s3_endpoint: None, + geoip_db_bucket: Some("GEOIP_DB_BUCKET".to_owned()), + geoip_db_key: Some("GEOIP_DB_KEY".to_owned()), + testing_project_id: Some("TESTING_PROJECT_ID".to_owned()), + validate_project_id: true, + }, + registry: project::Config { + api_url: Some("API_URL".to_owned()), + api_auth_token: Some("API_AUTH_TOKEN".to_owned()), + project_data_cache_ttl: 345, + }, + storage: project::storage::Config { + redis_max_connections: 456, + project_data_redis_addr_read: Some("redis://127.0.0.1/data/read".to_owned()), + project_data_redis_addr_write: Some("redis://127.0.0.1/data/write".to_owned()), + identity_cache_redis_addr_read: Some( + "redis://127.0.0.1/identity/read".to_owned() + ), + identity_cache_redis_addr_write: Some( + "redis://127.0.0.1/identity/write".to_owned() + ), + rate_limiting_cache_redis_addr_read: Some( + "redis://127.0.0.1/rate_limit/read".to_owned() + ), + rate_limiting_cache_redis_addr_write: Some( + "redis://127.0.0.1/rate_limit/write".to_owned() + ), + }, + postgres: PostgresConfig { + uri: "postgres://postgres@localhost:5432/postgres".to_owned(), + max_connections: 32, + }, + analytics: analytics::Config { + s3_endpoint: Some("s3://127.0.0.1".to_owned()), + export_bucket: Some("EXPORT_BUCKET".to_owned()), + }, + profiler: ProfilerConfig {}, + providers: ProvidersConfig { + prometheus_query_url: Some("PROMETHEUS_QUERY_URL".to_owned()), + prometheus_workspace_header: Some("PROMETHEUS_WORKSPACE_HEADER".to_owned()), + infura_project_id: "INFURA_PROJECT_ID".to_string(), + pokt_project_id: "POKT_PROJECT_ID".to_string(), + quicknode_api_token: "QUICKNODE_API_TOKEN".to_string(), + zerion_api_key: Some("ZERION_API_KEY".to_owned()), + coinbase_api_key: Some("COINBASE_API_KEY".to_owned()), + coinbase_app_id: Some("COINBASE_APP_ID".to_owned()), + one_inch_api_key: Some("ONE_INCH_API_KEY".to_owned()), + getblock_access_tokens: Some("{}".to_owned()), + }, + rate_limiting: RateLimitingConfig { + max_tokens: Some(100), + refill_interval_sec: Some(1), + refill_rate: Some(10), + }, + } + ); values.iter().for_each(reset_env_var); } diff --git a/src/error.rs b/src/error.rs index c4f81fa7a..8a0a7fd12 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,8 +1,6 @@ use { crate::{ - project::ProjectDataError, - storage::error::StorageError, - utils::crypto::CryptoUitlsError, + project::ProjectDataError, storage::error::StorageError, utils::crypto::CryptoUitlsError, }, axum::{response::IntoResponse, Json}, cerberus::registry::RegistryError, diff --git a/src/handlers/balance.rs b/src/handlers/balance.rs index 9adaa6120..550bedb6f 100644 --- a/src/handlers/balance.rs +++ b/src/handlers/balance.rs @@ -30,17 +30,21 @@ pub enum BalanceCurrencies { impl Display for BalanceCurrencies { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", match self { - BalanceCurrencies::BTC => "btc", - BalanceCurrencies::ETH => "eth", - BalanceCurrencies::USD => "usd", - BalanceCurrencies::EUR => "eur", - BalanceCurrencies::GBP => "gbp", - BalanceCurrencies::AUD => "aud", - BalanceCurrencies::CAD => "cad", - BalanceCurrencies::INR => "inr", - BalanceCurrencies::JPY => "jpy", - }) + write!( + f, + "{}", + match self { + BalanceCurrencies::BTC => "btc", + BalanceCurrencies::ETH => "eth", + BalanceCurrencies::USD => "usd", + BalanceCurrencies::EUR => "eur", + BalanceCurrencies::GBP => "gbp", + BalanceCurrencies::AUD => "aud", + BalanceCurrencies::CAD => "cad", + BalanceCurrencies::INR => "inr", + BalanceCurrencies::JPY => "jpy", + } + ) } } diff --git a/src/handlers/metrics.rs b/src/handlers/metrics.rs index b59468567..60d92880e 100644 --- a/src/handlers/metrics.rs +++ b/src/handlers/metrics.rs @@ -1,8 +1,5 @@ use { - axum::response::IntoResponse, - hyper::StatusCode, - tracing::error, - wc::metrics::ServiceMetrics, + axum::response::IntoResponse, hyper::StatusCode, tracing::error, wc::metrics::ServiceMetrics, }; pub async fn handler() -> impl IntoResponse { diff --git a/src/handlers/profile/address.rs b/src/handlers/profile/address.rs index 328232c7b..438094486 100644 --- a/src/handlers/profile/address.rs +++ b/src/handlers/profile/address.rs @@ -1,11 +1,7 @@ use { super::{ - super::HANDLER_TASK_METRICS, - utils::is_timestamp_within_interval, - Eip155SupportedChains, - RegisterRequest, - UpdateAddressPayload, - UNIXTIMESTAMP_SYNC_THRESHOLD, + super::HANDLER_TASK_METRICS, utils::is_timestamp_within_interval, Eip155SupportedChains, + RegisterRequest, UpdateAddressPayload, UNIXTIMESTAMP_SYNC_THRESHOLD, }, crate::{ database::{ diff --git a/src/handlers/profile/attributes.rs b/src/handlers/profile/attributes.rs index 241c1ab2a..f42995f8b 100644 --- a/src/handlers/profile/attributes.rs +++ b/src/handlers/profile/attributes.rs @@ -2,9 +2,7 @@ use { super::{ super::HANDLER_TASK_METRICS, utils::{check_attributes, is_timestamp_within_interval}, - Eip155SupportedChains, - RegisterRequest, - UpdateAttributesPayload, + Eip155SupportedChains, RegisterRequest, UpdateAttributesPayload, UNIXTIMESTAMP_SYNC_THRESHOLD, }, crate::{ diff --git a/src/handlers/profile/register.rs b/src/handlers/profile/register.rs index 0f3d13ed2..a2460371d 100644 --- a/src/handlers/profile/register.rs +++ b/src/handlers/profile/register.rs @@ -2,16 +2,10 @@ use { super::{ super::HANDLER_TASK_METRICS, utils::{ - check_attributes, - is_name_format_correct, - is_name_in_allowed_zones, - is_name_length_correct, - is_timestamp_within_interval, + check_attributes, is_name_format_correct, is_name_in_allowed_zones, + is_name_length_correct, is_timestamp_within_interval, }, - Eip155SupportedChains, - RegisterPayload, - RegisterRequest, - ALLOWED_ZONES, + Eip155SupportedChains, RegisterPayload, RegisterRequest, ALLOWED_ZONES, UNIXTIMESTAMP_SYNC_THRESHOLD, }, crate::{ @@ -122,10 +116,13 @@ pub async fn handler_internal( } // Register (insert) a new domain with address - let addresses: ENSIP11AddressesMap = HashMap::from([(register_request.coin_type, Address { - address: register_request.address, - created_at: None, - })]); + let addresses: ENSIP11AddressesMap = HashMap::from([( + register_request.coin_type, + Address { + address: register_request.address, + created_at: None, + }, + )]); let insert_result = insert_name( payload.name.clone(), diff --git a/src/lib.rs b/src/lib.rs index c835b27bf..34c100920 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,39 +18,17 @@ use { Router, }, env::{ - AuroraConfig, - BaseConfig, - BinanceConfig, - GetBlockConfig, - InfuraConfig, - MantleConfig, - NearConfig, - PoktConfig, - PublicnodeConfig, - QuicknodeConfig, - ZKSyncConfig, - ZoraConfig, + AuroraConfig, BaseConfig, BinanceConfig, GetBlockConfig, InfuraConfig, MantleConfig, + NearConfig, PoktConfig, PublicnodeConfig, QuicknodeConfig, ZKSyncConfig, ZoraConfig, }, error::RpcResult, http::Request, hyper::{body::Incoming, header::HeaderName, http}, hyper_util::{rt::TokioIo, server}, providers::{ - AuroraProvider, - BaseProvider, - BinanceProvider, - GetBlockProvider, - InfuraProvider, - InfuraWsProvider, - MantleProvider, - NearProvider, - PoktProvider, - ProviderRepository, - PublicnodeProvider, - QuicknodeProvider, - ZKSyncProvider, - ZoraProvider, - ZoraWsProvider, + AuroraProvider, BaseProvider, BinanceProvider, GetBlockProvider, InfuraProvider, + InfuraWsProvider, MantleProvider, NearProvider, PoktProvider, ProviderRepository, + PublicnodeProvider, QuicknodeProvider, ZKSyncProvider, ZoraProvider, ZoraWsProvider, }, sqlx::postgres::PgPoolOptions, std::{ diff --git a/src/metrics.rs b/src/metrics.rs index a4aed5202..004c011b2 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -6,11 +6,7 @@ use { hyper::http, std::time::{Duration, SystemTime}, sysinfo::{ - CpuRefreshKind, - MemoryRefreshKind, - RefreshKind, - System, - MINIMUM_CPU_UPDATE_INTERVAL, + CpuRefreshKind, MemoryRefreshKind, RefreshKind, System, MINIMUM_CPU_UPDATE_INTERVAL, }, wc::metrics::{ otel::{ @@ -258,33 +254,41 @@ impl Metrics { impl Metrics { pub fn add_rpc_call(&self, chain_id: String) { - self.rpc_call_counter - .add(&otel::Context::new(), 1, &[otel::KeyValue::new( - "chain.id", chain_id, - )]); + self.rpc_call_counter.add( + &otel::Context::new(), + 1, + &[otel::KeyValue::new("chain.id", chain_id)], + ); } pub fn add_http_call(&self, code: u16, route: String) { - self.http_call_counter.add(&otel::Context::new(), 1, &[ - otel::KeyValue::new("code", i64::from(code)), - otel::KeyValue::new("route", route), - ]); + self.http_call_counter.add( + &otel::Context::new(), + 1, + &[ + otel::KeyValue::new("code", i64::from(code)), + otel::KeyValue::new("route", route), + ], + ); } pub fn add_http_latency(&self, code: u16, route: String, latency: f64) { - self.http_latency_tracker - .record(&otel::Context::new(), latency, &[ + self.http_latency_tracker.record( + &otel::Context::new(), + latency, + &[ otel::KeyValue::new("code", i64::from(code)), otel::KeyValue::new("route", route), - ]) + ], + ) } pub fn add_external_http_latency(&self, provider_kind: ProviderKind, latency: f64) { - self.http_external_latency_tracker - .record(&otel::Context::new(), latency, &[otel::KeyValue::new( - "provider", - provider_kind.to_string(), - )]) + self.http_external_latency_tracker.record( + &otel::Context::new(), + latency, + &[otel::KeyValue::new("provider", provider_kind.to_string())], + ) } pub fn add_rejected_project(&self) { @@ -298,27 +302,36 @@ impl Metrics { } pub fn add_rate_limited_call(&self, provider: &dyn RpcProvider, project_id: String) { - self.rate_limited_call_counter - .add(&otel::Context::new(), 1, &[ + self.rate_limited_call_counter.add( + &otel::Context::new(), + 1, + &[ otel::KeyValue::new("provider_kind", provider.provider_kind().to_string()), otel::KeyValue::new("project_id", project_id), - ]) + ], + ) } pub fn add_failed_provider_call(&self, provider: &dyn RpcProvider) { - self.provider_failed_call_counter - .add(&otel::Context::new(), 1, &[otel::KeyValue::new( + self.provider_failed_call_counter.add( + &otel::Context::new(), + 1, + &[otel::KeyValue::new( "provider", provider.provider_kind().to_string(), - )]) + )], + ) } pub fn add_finished_provider_call(&self, provider: &dyn RpcProvider) { - self.provider_finished_call_counter - .add(&otel::Context::new(), 1, &[otel::KeyValue::new( + self.provider_finished_call_counter.add( + &otel::Context::new(), + 1, + &[otel::KeyValue::new( "provider", provider.provider_kind().to_string(), - )]) + )], + ) } pub fn add_status_code_for_provider( @@ -327,20 +340,26 @@ impl Metrics { status: http::StatusCode, chain_id: String, ) { - self.provider_status_code_counter - .add(&otel::Context::new(), 1, &[ + self.provider_status_code_counter.add( + &otel::Context::new(), + 1, + &[ otel::KeyValue::new("provider", provider.provider_kind().to_string()), otel::KeyValue::new("status_code", format!("{}", status.as_u16())), otel::KeyValue::new("chain_id", chain_id), - ]) + ], + ) } pub fn record_provider_weight(&self, provider: &ProviderKind, chain_id: String, weight: u64) { - self.weights_value_recorder - .record(&otel::Context::new(), weight, &[ + self.weights_value_recorder.record( + &otel::Context::new(), + weight, + &[ otel::KeyValue::new("provider", provider.to_string()), otel::KeyValue::new("chain_id", chain_id), - ]) + ], + ) } pub fn add_identity_lookup(&self) { @@ -349,11 +368,11 @@ impl Metrics { } pub fn add_identity_lookup_success(&self, source: &IdentityLookupSource) { - self.identity_lookup_success_counter - .add(&otel::Context::new(), 1, &[otel::KeyValue::new( - "source", - source.as_str(), - )]); + self.identity_lookup_success_counter.add( + &otel::Context::new(), + 1, + &[otel::KeyValue::new("source", source.as_str())], + ); } pub fn add_identity_lookup_latency(&self, latency: Duration, source: &IdentityLookupSource) { @@ -428,26 +447,27 @@ impl Metrics { } pub fn add_websocket_connection(&self, chain_id: String) { - self.websocket_connection_counter - .add(&otel::Context::new(), 1, &[otel::KeyValue::new( - "chain_id", chain_id, - )]); + self.websocket_connection_counter.add( + &otel::Context::new(), + 1, + &[otel::KeyValue::new("chain_id", chain_id)], + ); } pub fn add_history_lookup(&self, provider: &ProviderKind) { - self.history_lookup_counter - .add(&otel::Context::new(), 1, &[otel::KeyValue::new( - "provider", - provider.to_string(), - )]); + self.history_lookup_counter.add( + &otel::Context::new(), + 1, + &[otel::KeyValue::new("provider", provider.to_string())], + ); } pub fn add_history_lookup_success(&self, provider: &ProviderKind) { - self.history_lookup_success_counter - .add(&otel::Context::new(), 1, &[otel::KeyValue::new( - "provider", - provider.to_string(), - )]); + self.history_lookup_success_counter.add( + &otel::Context::new(), + 1, + &[otel::KeyValue::new("provider", provider.to_string())], + ); } pub fn add_history_lookup_latency(&self, provider: &ProviderKind, latency: Duration) { @@ -459,10 +479,11 @@ impl Metrics { } fn add_cpu_usage(&self, usage: f64, cpu_id: f64) { - self.cpu_usage - .record(&otel::Context::new(), usage, &[otel::KeyValue::new( - "cpu", cpu_id, - )]); + self.cpu_usage.record( + &otel::Context::new(), + usage, + &[otel::KeyValue::new("cpu", cpu_id)], + ); } fn add_memory_total(&self, memory: f64) { diff --git a/src/project/config.rs b/src/project/config.rs index 85339342e..fd08a2852 100644 --- a/src/project/config.rs +++ b/src/project/config.rs @@ -1,7 +1,5 @@ use { - serde::Deserialize, - serde_piecewise_default::DeserializePiecewiseDefault, - std::time::Duration, + serde::Deserialize, serde_piecewise_default::DeserializePiecewiseDefault, std::time::Duration, }; #[derive(DeserializePiecewiseDefault, Debug, Clone, PartialEq, Eq)] diff --git a/src/project/metrics/mod.rs b/src/project/metrics/mod.rs index 0b46dbd52..efb8784ee 100644 --- a/src/project/metrics/mod.rs +++ b/src/project/metrics/mod.rs @@ -59,10 +59,11 @@ impl ProjectDataMetrics { } pub fn request(&self, time: Duration, source: ResponseSource, resp: &ProjectDataResult) { - self.requests_total.add(&otel::Context::new(), 1, &[ - source_tag(source), - response_tag(resp), - ]); + self.requests_total.add( + &otel::Context::new(), + 1, + &[source_tag(source), response_tag(resp)], + ); self.total_time .record(&otel::Context::new(), duration_ms(time), &[]); } diff --git a/src/project/storage/config.rs b/src/project/storage/config.rs index 8f1debd72..0e9717f0b 100644 --- a/src/project/storage/config.rs +++ b/src/project/storage/config.rs @@ -1,6 +1,5 @@ use { - crate::storage::redis::Addr as RedisAddr, - serde::Deserialize, + crate::storage::redis::Addr as RedisAddr, serde::Deserialize, serde_piecewise_default::DeserializePiecewiseDefault, }; diff --git a/src/providers/coinbase.rs b/src/providers/coinbase.rs index 4df092444..880d8680a 100644 --- a/src/providers/coinbase.rs +++ b/src/providers/coinbase.rs @@ -4,13 +4,9 @@ use { error::{RpcError, RpcResult}, handlers::{ history::{ - HistoryQueryParams, - HistoryResponseBody, - HistoryTransaction, - HistoryTransactionFungibleInfo, - HistoryTransactionMetadata, - HistoryTransactionTransfer, - HistoryTransactionTransferQuantity, + HistoryQueryParams, HistoryResponseBody, HistoryTransaction, + HistoryTransactionFungibleInfo, HistoryTransactionMetadata, + HistoryTransactionTransfer, HistoryTransactionTransferQuantity, }, onramp::{ options::{OnRampBuyOptionsParams, OnRampBuyOptionsResponse}, diff --git a/src/providers/infura.rs b/src/providers/infura.rs index 5e084acac..79a9bacf2 100644 --- a/src/providers/infura.rs +++ b/src/providers/infura.rs @@ -1,13 +1,7 @@ use { super::{ - Provider, - ProviderKind, - RateLimited, - RpcProvider, - RpcProviderFactory, - RpcQueryParams, - RpcWsProvider, - WS_PROXY_TASK_METRICS, + Provider, ProviderKind, RateLimited, RpcProvider, RpcProviderFactory, RpcQueryParams, + RpcWsProvider, WS_PROXY_TASK_METRICS, }, crate::{ env::InfuraConfig, diff --git a/src/providers/mod.rs b/src/providers/mod.rs index ff96daf2d..25b71f05c 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -373,22 +373,26 @@ pub enum ProviderKind { impl Display for ProviderKind { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", match self { - ProviderKind::Aurora => "Aurora", - ProviderKind::Infura => "Infura", - ProviderKind::Pokt => "Pokt", - ProviderKind::Binance => "Binance", - ProviderKind::ZKSync => "zkSync", - ProviderKind::Publicnode => "Publicnode", - ProviderKind::Base => "Base", - ProviderKind::Zora => "Zora", - ProviderKind::Zerion => "Zerion", - ProviderKind::Coinbase => "Coinbase", - ProviderKind::Quicknode => "Quicknode", - ProviderKind::Near => "Near", - ProviderKind::Mantle => "Mantle", - ProviderKind::GetBlock => "GetBlock", - }) + write!( + f, + "{}", + match self { + ProviderKind::Aurora => "Aurora", + ProviderKind::Infura => "Infura", + ProviderKind::Pokt => "Pokt", + ProviderKind::Binance => "Binance", + ProviderKind::ZKSync => "zkSync", + ProviderKind::Publicnode => "Publicnode", + ProviderKind::Base => "Base", + ProviderKind::Zora => "Zora", + ProviderKind::Zerion => "Zerion", + ProviderKind::Coinbase => "Coinbase", + ProviderKind::Quicknode => "Quicknode", + ProviderKind::Near => "Near", + ProviderKind::Mantle => "Mantle", + ProviderKind::GetBlock => "GetBlock", + } + ) } } diff --git a/src/providers/one_inch.rs b/src/providers/one_inch.rs index 1a3e0530b..88ebe562c 100644 --- a/src/providers/one_inch.rs +++ b/src/providers/one_inch.rs @@ -3,17 +3,13 @@ use { error::{RpcError, RpcResult}, handlers::convert::{ approve::{ - ConvertApproveQueryParams, - ConvertApproveResponseBody, - ConvertApproveTx, + ConvertApproveQueryParams, ConvertApproveResponseBody, ConvertApproveTx, ConvertApproveTxEip155, }, quotes::{ConvertQuoteQueryParams, ConvertQuoteResponseBody, QuoteItem}, tokens::{TokenItem, TokensListQueryParams, TokensListResponseBody}, transaction::{ - ConvertTransactionQueryParams, - ConvertTransactionResponseBody, - ConvertTx, + ConvertTransactionQueryParams, ConvertTransactionResponseBody, ConvertTx, ConvertTxEip155, }, }, diff --git a/src/providers/zerion.rs b/src/providers/zerion.rs index 23d26ad8c..439f6dc7d 100644 --- a/src/providers/zerion.rs +++ b/src/providers/zerion.rs @@ -6,19 +6,12 @@ use { balance::{BalanceQueryParams, BalanceResponseBody}, fungible_price::{FungiblePriceItem, PriceCurrencies, PriceResponseBody}, history::{ - HistoryQueryParams, - HistoryResponseBody, - HistoryTransaction, - HistoryTransactionFungibleInfo, - HistoryTransactionMetadata, - HistoryTransactionMetadataApplication, - HistoryTransactionNFTContent, - HistoryTransactionNFTInfo, - HistoryTransactionNFTInfoFlags, - HistoryTransactionTransfer, - HistoryTransactionTransferQuantity, - HistoryTransactionURLItem, - HistoryTransactionURLandContentTypeItem, + HistoryQueryParams, HistoryResponseBody, HistoryTransaction, + HistoryTransactionFungibleInfo, HistoryTransactionMetadata, + HistoryTransactionMetadataApplication, HistoryTransactionNFTContent, + HistoryTransactionNFTInfo, HistoryTransactionNFTInfoFlags, + HistoryTransactionTransfer, HistoryTransactionTransferQuantity, + HistoryTransactionURLItem, HistoryTransactionURLandContentTypeItem, }, portfolio::{PortfolioPosition, PortfolioQueryParams, PortfolioResponseBody}, }, diff --git a/src/providers/zora.rs b/src/providers/zora.rs index ea1648c27..bd668b06b 100644 --- a/src/providers/zora.rs +++ b/src/providers/zora.rs @@ -1,13 +1,7 @@ use { super::{ - Provider, - ProviderKind, - RateLimited, - RpcProvider, - RpcProviderFactory, - RpcQueryParams, - RpcWsProvider, - WS_PROXY_TASK_METRICS, + Provider, ProviderKind, RateLimited, RpcProvider, RpcProviderFactory, RpcQueryParams, + RpcWsProvider, WS_PROXY_TASK_METRICS, }, crate::{ env::ZoraConfig, diff --git a/src/storage/redis/mod.rs b/src/storage/redis/mod.rs index 6da787c17..21370fa7b 100644 --- a/src/storage/redis/mod.rs +++ b/src/storage/redis/mod.rs @@ -3,8 +3,7 @@ use { async_trait::async_trait, deadpool_redis::{ redis::{AsyncCommands, Value}, - Config, - Pool, + Config, Pool, }, serde::{de::DeserializeOwned, Serialize}, std::{fmt::Debug, time::Duration}, diff --git a/tests/functional/database.rs b/tests/functional/database.rs index c0b976df9..5eb8fa3b2 100644 --- a/tests/functional/database.rs +++ b/tests/functional/database.rs @@ -2,15 +2,9 @@ use { crate::utils::{generate_random_string, get_postgres_pool}, rpc_proxy::database::{ helpers::{ - delete_address, - delete_name, - get_addresses_by_name, - get_name, - get_name_and_addresses_by_name, - get_names_by_address, - get_names_by_address_and_namespace, - insert_name, - insert_or_update_address, + delete_address, delete_name, get_addresses_by_name, get_name, + get_name_and_addresses_by_name, get_names_by_address, + get_names_by_address_and_namespace, insert_name, insert_or_update_address, update_name_attributes, }, types, @@ -25,10 +19,13 @@ async fn insert_and_get_name_by_name() { let name = format!("{}.connect.id", generate_random_string(10)); let address = format!("0x{}", generate_random_string(16)); let chain_id = 1; - let addresses = HashMap::from([(chain_id, types::Address { - address, - created_at: None, - })]); + let addresses = HashMap::from([( + chain_id, + types::Address { + address, + created_at: None, + }, + )]); // create a new hashmap with attributes let attributes: HashMap = HashMap::from_iter([ @@ -77,10 +74,13 @@ async fn insert_and_get_names_by_address() { let name = format!("{}.connect.id", generate_random_string(10)); let address = format!("0x{}", generate_random_string(16)); let chain_id = 1; - let addresses = HashMap::from([(chain_id, types::Address { - address: address.clone(), - created_at: None, - })]); + let addresses = HashMap::from([( + chain_id, + types::Address { + address: address.clone(), + created_at: None, + }, + )]); let insert_result = insert_name( name.clone(), @@ -114,10 +114,13 @@ async fn insert_and_get_names_by_address_and_namespace() { let address = format!("0x{}", generate_random_string(16)); let namespace = types::SupportedNamespaces::Eip155; let chain_id = 1; - let addresses = HashMap::from([(chain_id, types::Address { - address: address.clone(), - created_at: None, - })]); + let addresses = HashMap::from([( + chain_id, + types::Address { + address: address.clone(), + created_at: None, + }, + )]); let insert_result = insert_name( name.clone(), @@ -151,10 +154,13 @@ async fn insert_and_get_name_and_addresses() { let address = format!("0x{}", generate_random_string(16)); let namespace = types::SupportedNamespaces::Eip155; let expected_ensip11_coin_type = 60; - let addresses = HashMap::from([(expected_ensip11_coin_type, types::Address { - address: address.clone(), - created_at: None, - })]); + let addresses = HashMap::from([( + expected_ensip11_coin_type, + types::Address { + address: address.clone(), + created_at: None, + }, + )]); let attributes: HashMap = HashMap::from_iter([( "avatar".to_string(), @@ -201,10 +207,13 @@ async fn insert_and_update_name_attributes() { let name = format!("{}.connect.id", generate_random_string(10)); let address = format!("0x{}", generate_random_string(16)); let chain_id = 1; - let addresses = HashMap::from([(chain_id, types::Address { - address, - created_at: None, - })]); + let addresses = HashMap::from([( + chain_id, + types::Address { + address, + created_at: None, + }, + )]); // create a new hashmap with attributes let attributes: HashMap = HashMap::from_iter([ @@ -264,10 +273,13 @@ async fn insert_delete_two_addresses() { let name = format!("{}.connect.id", generate_random_string(10)); let address = format!("0x{}", generate_random_string(16)); let mut chain_id = 1; - let addresses = HashMap::from([(chain_id, types::Address { - address: address.clone(), - created_at: None, - })]); + let addresses = HashMap::from([( + chain_id, + types::Address { + address: address.clone(), + created_at: None, + }, + )]); let insert_result = insert_name( name.clone(), diff --git a/tests/functional/http/aurora.rs b/tests/functional/http/aurora.rs index 9b813c71d..087ed3a76 100644 --- a/tests/functional/http/aurora.rs +++ b/tests/functional/http/aurora.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/base.rs b/tests/functional/http/base.rs index 3293109e7..1e4c5ead5 100644 --- a/tests/functional/http/base.rs +++ b/tests/functional/http/base.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/binance.rs b/tests/functional/http/binance.rs index 84387cc02..d517d7bf3 100644 --- a/tests/functional/http/binance.rs +++ b/tests/functional/http/binance.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/infura.rs b/tests/functional/http/infura.rs index 118522391..283d5a1ad 100644 --- a/tests/functional/http/infura.rs +++ b/tests/functional/http/infura.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/mantle.rs b/tests/functional/http/mantle.rs index 68aa250e3..df464b1f8 100644 --- a/tests/functional/http/mantle.rs +++ b/tests/functional/http/mantle.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/near.rs b/tests/functional/http/near.rs index 2cef51e90..76cdc0625 100644 --- a/tests/functional/http/near.rs +++ b/tests/functional/http/near.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_near_protocol, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_near_protocol, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/publicnode.rs b/tests/functional/http/publicnode.rs index 5173e6fc6..8e79990d0 100644 --- a/tests/functional/http/publicnode.rs +++ b/tests/functional/http/publicnode.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/quicknode.rs b/tests/functional/http/quicknode.rs index e83e90c28..f33833988 100644 --- a/tests/functional/http/quicknode.rs +++ b/tests/functional/http/quicknode.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/zksync.rs b/tests/functional/http/zksync.rs index 8d41a203e..8657c1515 100644 --- a/tests/functional/http/zksync.rs +++ b/tests/functional/http/zksync.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/http/zora.rs b/tests/functional/http/zora.rs index 9c5f7efdd..a980c1de2 100644 --- a/tests/functional/http/zora.rs +++ b/tests/functional/http/zora.rs @@ -1,8 +1,6 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, - rpc_proxy::providers::ProviderKind, - test_context::test_context, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, + rpc_proxy::providers::ProviderKind, test_context::test_context, }; #[test_context(ServerContext)] diff --git a/tests/functional/websocket/infura.rs b/tests/functional/websocket/infura.rs index 92e80e664..379881fef 100644 --- a/tests/functional/websocket/infura.rs +++ b/tests/functional/websocket/infura.rs @@ -1,6 +1,5 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, test_context::test_context, }; diff --git a/tests/functional/websocket/zora.rs b/tests/functional/websocket/zora.rs index 6c5127f9f..cc0d1eb36 100644 --- a/tests/functional/websocket/zora.rs +++ b/tests/functional/websocket/zora.rs @@ -1,6 +1,5 @@ use { - super::check_if_rpc_is_responding_correctly_for_supported_chain, - crate::context::ServerContext, + super::check_if_rpc_is_responding_correctly_for_supported_chain, crate::context::ServerContext, test_context::test_context, }; From e0a703341984583baaa3b42966abfa314fa70d7a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 14:31:33 -0400 Subject: [PATCH 07/10] fix: fmt --- src/handlers/fungible_price.rs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/handlers/fungible_price.rs b/src/handlers/fungible_price.rs index 58b78604d..2aa2b275c 100644 --- a/src/handlers/fungible_price.rs +++ b/src/handlers/fungible_price.rs @@ -29,17 +29,21 @@ pub enum PriceCurrencies { impl Display for PriceCurrencies { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", match self { - PriceCurrencies::BTC => "btc", - PriceCurrencies::ETH => "eth", - PriceCurrencies::USD => "usd", - PriceCurrencies::EUR => "eur", - PriceCurrencies::GBP => "gbp", - PriceCurrencies::AUD => "aud", - PriceCurrencies::CAD => "cad", - PriceCurrencies::INR => "inr", - PriceCurrencies::JPY => "jpy", - }) + write!( + f, + "{}", + match self { + PriceCurrencies::BTC => "btc", + PriceCurrencies::ETH => "eth", + PriceCurrencies::USD => "usd", + PriceCurrencies::EUR => "eur", + PriceCurrencies::GBP => "gbp", + PriceCurrencies::AUD => "aud", + PriceCurrencies::CAD => "cad", + PriceCurrencies::INR => "inr", + PriceCurrencies::JPY => "jpy", + } + ) } } From 854dd957c6e3e143724772501702c15edd2dc201 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 5 Apr 2024 15:15:07 -0400 Subject: [PATCH 08/10] fix: use central http client --- src/handlers/balance.rs | 2 +- src/handlers/fungible_price.rs | 7 +------ src/handlers/history.rs | 4 ++-- src/handlers/onramp/options.rs | 2 +- src/handlers/onramp/quotes.rs | 2 +- src/lib.rs | 3 --- src/providers/aurora.rs | 12 +++++++++--- src/providers/base.rs | 12 +++++++++--- src/providers/binance.rs | 12 +++++++++--- src/providers/coinbase.rs | 17 ++++++++++------- src/providers/getblock.rs | 8 ++++++-- src/providers/infura.rs | 10 +++++++--- src/providers/mantle.rs | 12 +++++++++--- src/providers/mod.rs | 22 ++++++++++++---------- src/providers/near.rs | 12 +++++++++--- src/providers/one_inch.rs | 16 ++++++++-------- src/providers/pokt.rs | 8 ++++++-- src/providers/publicnode.rs | 12 +++++++++--- src/providers/quicknode.rs | 8 ++++++-- src/providers/zerion.rs | 23 +++++++++++++---------- src/providers/zksync.rs | 12 +++++++++--- src/providers/zora.rs | 14 ++++++++++---- src/state.rs | 4 ---- 23 files changed, 147 insertions(+), 87 deletions(-) diff --git a/src/handlers/balance.rs b/src/handlers/balance.rs index 550bedb6f..efd21d5b3 100644 --- a/src/handlers/balance.rs +++ b/src/handlers/balance.rs @@ -111,7 +111,7 @@ async fn handler_internal( let response = state .providers .balance_provider - .get_balance(address, query.0, state.http_client.clone()) + .get_balance(address, query.0) .await .tap_err(|e| { error!("Failed to call balance with {}", e); diff --git a/src/handlers/fungible_price.rs b/src/handlers/fungible_price.rs index 2aa2b275c..1eb6dc253 100644 --- a/src/handlers/fungible_price.rs +++ b/src/handlers/fungible_price.rs @@ -101,12 +101,7 @@ async fn handler_internal( let response = state .providers .fungible_price_provider - .get_price( - &chain_id, - &address, - &query.currency, - state.http_client.clone(), - ) + .get_price(&chain_id, &address, &query.currency) .await .tap_err(|e| { error!("Failed to call fungible price with {}", e); diff --git a/src/handlers/history.rs b/src/handlers/history.rs index c4ec636a2..0c67e4dcb 100644 --- a/src/handlers/history.rs +++ b/src/handlers/history.rs @@ -154,7 +154,7 @@ async fn handler_internal( state .providers .coinbase_pay_provider - .get_transactions(address.clone(), query.clone().0, state.http_client.clone()) + .get_transactions(address.clone(), query.clone().0) .await .tap_err(|e| { error!("Failed to call coinbase transactions history with {}", e); @@ -168,7 +168,7 @@ async fn handler_internal( state .providers .history_provider - .get_transactions(address.clone(), query.0.clone(), state.http_client.clone()) + .get_transactions(address.clone(), query.0.clone()) .await .tap_err(|e| { error!("Failed to call transactions history with {}", e); diff --git a/src/handlers/onramp/options.rs b/src/handlers/onramp/options.rs index b507764a4..5a0135073 100644 --- a/src/handlers/onramp/options.rs +++ b/src/handlers/onramp/options.rs @@ -89,7 +89,7 @@ async fn handler_internal( let buy_options = state .providers .onramp_provider - .get_buy_options(query.0, state.http_client.clone()) + .get_buy_options(query.0) .await .tap_err(|e| { error!("Failed to call coinbase buy options with {}", e); diff --git a/src/handlers/onramp/quotes.rs b/src/handlers/onramp/quotes.rs index e5a8a2642..be6cb0a5c 100644 --- a/src/handlers/onramp/quotes.rs +++ b/src/handlers/onramp/quotes.rs @@ -85,7 +85,7 @@ async fn handler_internal( let buy_quotes = state .providers .onramp_provider - .get_buy_quotes(query.0, state.http_client.clone()) + .get_buy_quotes(query.0) .await .tap_err(|e| { error!("Failed to call coinbase buy quotes with {}", e); diff --git a/src/lib.rs b/src/lib.rs index 34c100920..72963b039 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,8 +158,6 @@ pub async fn bootstrap(config: Config) -> RpcResult<()> { .await?; sqlx::migrate!("./migrations").run(&postgres).await?; - let http_client = reqwest::Client::new(); - let state = state::new_state( config.clone(), postgres.clone(), @@ -168,7 +166,6 @@ pub async fn bootstrap(config: Config) -> RpcResult<()> { registry, identity_cache, analytics, - http_client, rate_limiting, ); diff --git a/src/providers/aurora.rs b/src/providers/aurora.rs index 161d4dcbb..81c7a1290 100644 --- a/src/providers/aurora.rs +++ b/src/providers/aurora.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct AuroraProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -52,7 +54,8 @@ impl RpcProvider for AuroraProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -81,13 +84,16 @@ impl RpcProvider for AuroraProvider { impl RpcProviderFactory for AuroraProvider { #[tracing::instrument] - fn new(provider_config: &AuroraConfig) -> Self { + fn new(client: Client, provider_config: &AuroraConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - AuroraProvider { supported_chains } + AuroraProvider { + client, + supported_chains, + } } } diff --git a/src/providers/base.rs b/src/providers/base.rs index 8e3012cb9..ef0ec6e7e 100644 --- a/src/providers/base.rs +++ b/src/providers/base.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct BaseProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -52,7 +54,8 @@ impl RpcProvider for BaseProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -81,13 +84,16 @@ impl RpcProvider for BaseProvider { impl RpcProviderFactory for BaseProvider { #[tracing::instrument] - fn new(provider_config: &BaseConfig) -> Self { + fn new(client: Client, provider_config: &BaseConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - BaseProvider { supported_chains } + BaseProvider { + client, + supported_chains, + } } } diff --git a/src/providers/binance.rs b/src/providers/binance.rs index 4587a5cb8..7742cbb74 100644 --- a/src/providers/binance.rs +++ b/src/providers/binance.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct BinanceProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -52,7 +54,8 @@ impl RpcProvider for BinanceProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -81,13 +84,16 @@ impl RpcProvider for BinanceProvider { impl RpcProviderFactory for BinanceProvider { #[tracing::instrument] - fn new(provider_config: &BinanceConfig) -> Self { + fn new(client: Client, provider_config: &BinanceConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - BinanceProvider { supported_chains } + BinanceProvider { + client, + supported_chains, + } } } diff --git a/src/providers/coinbase.rs b/src/providers/coinbase.rs index 880d8680a..da6b4b5bf 100644 --- a/src/providers/coinbase.rs +++ b/src/providers/coinbase.rs @@ -16,6 +16,7 @@ use { utils::crypto::ChainId, }, async_trait::async_trait, + reqwest::Client, serde::{Deserialize, Serialize}, tracing::log::error, url::Url, @@ -23,14 +24,16 @@ use { #[derive(Debug)] pub struct CoinbaseProvider { + pub client: Client, pub api_key: String, pub app_id: String, pub base_api_url: String, } impl CoinbaseProvider { - pub fn new(api_key: String, app_id: String, base_api_url: String) -> Self { + pub fn new(client: Client, api_key: String, app_id: String, base_api_url: String) -> Self { Self { + client, api_key, app_id, base_api_url, @@ -68,7 +71,6 @@ impl HistoryProvider for CoinbaseProvider { &self, address: String, params: HistoryQueryParams, - http_client: reqwest::Client, ) -> RpcResult { let base = format!("{}/buy/user/{}/transactions", &self.base_api_url, &address); @@ -79,7 +81,8 @@ impl HistoryProvider for CoinbaseProvider { url.query_pairs_mut().append_pair("page_key", &cursor); } - let response = http_client + let response = self + .client .get(url) .header("Content-Type", "application/json") .header("CBPAY-APP-ID", self.app_id.clone()) @@ -143,7 +146,6 @@ impl OnRampProvider for CoinbaseProvider { async fn get_buy_options( &self, params: OnRampBuyOptionsParams, - http_client: reqwest::Client, ) -> RpcResult { let base = format!("{}/buy/options", &self.base_api_url); let mut url = Url::parse(&base).map_err(|_| RpcError::OnRampParseURLError)?; @@ -154,7 +156,8 @@ impl OnRampProvider for CoinbaseProvider { .append_pair("subdivision", &subdivision); } - let response = http_client + let response = self + .client .get(url) .header("Content-Type", "application/json") .header("CBPAY-APP-ID", self.app_id.clone()) @@ -176,12 +179,12 @@ impl OnRampProvider for CoinbaseProvider { async fn get_buy_quotes( &self, params: OnRampBuyQuotesParams, - http_client: reqwest::Client, ) -> RpcResult { let base = format!("{}/buy/quote", &self.base_api_url); let url = Url::parse(&base).map_err(|_| RpcError::OnRampParseURLError)?; - let response = http_client + let response = self + .client .post(url) .json(¶ms) .header("Content-Type", "application/json") diff --git a/src/providers/getblock.rs b/src/providers/getblock.rs index 1ebe57fc7..8956978f3 100644 --- a/src/providers/getblock.rs +++ b/src/providers/getblock.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct GetBlockProvider { + pub client: Client, base_api_url: String, supported_chains: HashMap, } @@ -52,7 +54,8 @@ impl RpcProvider for GetBlockProvider { let uri = format!("{}/{}", self.base_api_url, access_token_api); - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -81,7 +84,7 @@ impl RpcProvider for GetBlockProvider { impl RpcProviderFactory for GetBlockProvider { #[tracing::instrument] - fn new(provider_config: &GetBlockConfig) -> Self { + fn new(client: Client, provider_config: &GetBlockConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -90,6 +93,7 @@ impl RpcProviderFactory for GetBlockProvider { let base_api_url = "https://go.getblock.io".to_string(); GetBlockProvider { + client, base_api_url, supported_chains, } diff --git a/src/providers/infura.rs b/src/providers/infura.rs index 79a9bacf2..23e59b2bb 100644 --- a/src/providers/infura.rs +++ b/src/providers/infura.rs @@ -15,6 +15,7 @@ use { }, axum_tungstenite::WebSocketUpgrade, hyper::{http, StatusCode}, + reqwest::Client, std::collections::HashMap, tracing::info, wc::future::FutureExt, @@ -22,6 +23,7 @@ use { #[derive(Debug)] pub struct InfuraProvider { + pub client: Client, pub project_id: String, pub supported_chains: HashMap, } @@ -117,7 +119,8 @@ impl RpcProvider for InfuraProvider { let uri = format!("https://{}.infura.io/v3/{}", chain, self.project_id); - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -151,7 +154,7 @@ impl RpcProvider for InfuraProvider { impl RpcProviderFactory for InfuraProvider { #[tracing::instrument] - fn new(provider_config: &InfuraConfig) -> Self { + fn new(client: Client, provider_config: &InfuraConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -159,6 +162,7 @@ impl RpcProviderFactory for InfuraProvider { .collect(); InfuraProvider { + client, supported_chains, project_id: provider_config.project_id.clone(), } @@ -167,7 +171,7 @@ impl RpcProviderFactory for InfuraProvider { impl RpcProviderFactory for InfuraWsProvider { #[tracing::instrument] - fn new(provider_config: &InfuraConfig) -> Self { + fn new(_client: Client, provider_config: &InfuraConfig) -> Self { let supported_chains: HashMap = provider_config .supported_ws_chains .iter() diff --git a/src/providers/mantle.rs b/src/providers/mantle.rs index f8db1835d..1a42a68aa 100644 --- a/src/providers/mantle.rs +++ b/src/providers/mantle.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct MantleProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -49,7 +51,8 @@ impl RpcProvider for MantleProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -78,13 +81,16 @@ impl RpcProvider for MantleProvider { impl RpcProviderFactory for MantleProvider { #[tracing::instrument] - fn new(provider_config: &MantleConfig) -> Self { + fn new(client: Client, provider_config: &MantleConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - MantleProvider { supported_chains } + MantleProvider { + client, + supported_chains, + } } } diff --git a/src/providers/mod.rs b/src/providers/mod.rs index 25b71f05c..66e9c3521 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -26,6 +26,7 @@ use { axum_tungstenite::WebSocketUpgrade, hyper::http::HeaderValue, rand::{distributions::WeightedIndex, prelude::Distribution, rngs::OsRng}, + reqwest::Client, serde::{Deserialize, Serialize}, std::{ collections::{HashMap, HashSet}, @@ -98,6 +99,8 @@ pub struct SupportedChains { } pub struct ProviderRepository { + pub client: Client, + pub supported_chains: SupportedChains, providers: HashMap>, @@ -164,20 +167,24 @@ impl ProviderRepository { .clone() .unwrap_or("ONE_INCH_API_KEY".into()); - let zerion_provider = Arc::new(ZerionProvider::new(zerion_api_key)); + let client = Client::new(); + + let zerion_provider = Arc::new(ZerionProvider::new(client.clone(), zerion_api_key)); let history_provider = zerion_provider.clone(); let portfolio_provider = zerion_provider.clone(); let balance_provider = zerion_provider.clone(); let fungible_price_provider = zerion_provider; - let conversion_provider = Arc::new(OneInchProvider::new(one_inch_api_key)); + let conversion_provider = Arc::new(OneInchProvider::new(client.clone(), one_inch_api_key)); let coinbase_pay_provider = Arc::new(CoinbaseProvider::new( + client.clone(), coinbase_api_key, coinbase_app_id, "https://pay.coinbase.com/api/v1".into(), )); Self { + client, supported_chains: SupportedChains { http: HashSet::new(), ws: HashSet::new(), @@ -270,7 +277,7 @@ impl ProviderRepository { &mut self, provider_config: C, ) { - let ws_provider = T::new(&provider_config); + let ws_provider = T::new(self.client.clone(), &provider_config); let arc_ws_provider = Arc::new(ws_provider); self.ws_providers @@ -294,7 +301,7 @@ impl ProviderRepository { &mut self, provider_config: C, ) { - let provider = T::new(&provider_config); + let provider = T::new(self.client.clone(), &provider_config); let arc_provider = Arc::new(provider); self.providers @@ -425,7 +432,7 @@ pub trait RpcProvider: Provider { } pub trait RpcProviderFactory: Provider { - fn new(provider_config: &T) -> Self; + fn new(client: Client, provider_config: &T) -> Self; } #[async_trait] @@ -540,7 +547,6 @@ pub trait HistoryProvider: Send + Sync + Debug { &self, address: String, params: HistoryQueryParams, - http_client: reqwest::Client, ) -> RpcResult; } @@ -559,13 +565,11 @@ pub trait OnRampProvider: Send + Sync + Debug { async fn get_buy_options( &self, params: OnRampBuyOptionsParams, - http_client: reqwest::Client, ) -> RpcResult; async fn get_buy_quotes( &self, params: OnRampBuyQuotesParams, - http_client: reqwest::Client, ) -> RpcResult; } @@ -575,7 +579,6 @@ pub trait BalanceProvider: Send + Sync + Debug { &self, address: String, params: BalanceQueryParams, - http_client: reqwest::Client, ) -> RpcResult; } @@ -586,7 +589,6 @@ pub trait FungiblePriceProvider: Send + Sync + Debug { chain_id: &str, address: &str, currency: &PriceCurrencies, - http_client: reqwest::Client, ) -> RpcResult; } diff --git a/src/providers/near.rs b/src/providers/near.rs index 0e3e9a3ad..ce569df4f 100644 --- a/src/providers/near.rs +++ b/src/providers/near.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct NearProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -49,7 +51,8 @@ impl RpcProvider for NearProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -78,13 +81,16 @@ impl RpcProvider for NearProvider { impl RpcProviderFactory for NearProvider { #[tracing::instrument] - fn new(provider_config: &NearConfig) -> Self { + fn new(client: Client, provider_config: &NearConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - NearProvider { supported_chains } + NearProvider { + client, + supported_chains, + } } } diff --git a/src/providers/one_inch.rs b/src/providers/one_inch.rs index 88ebe562c..a2e2077d8 100644 --- a/src/providers/one_inch.rs +++ b/src/providers/one_inch.rs @@ -17,6 +17,7 @@ use { utils::crypto, }, async_trait::async_trait, + reqwest::Client, serde::Deserialize, std::collections::HashMap, tracing::log::error, @@ -25,19 +26,18 @@ use { #[derive(Debug)] pub struct OneInchProvider { + pub client: Client, pub api_key: String, pub base_api_url: String, - pub http_client: reqwest::Client, } impl OneInchProvider { - pub fn new(api_key: String) -> Self { + pub fn new(client: Client, api_key: String) -> Self { let base_api_url = "https://api.1inch.dev/swap/v6.0".to_string(); - let http_client = reqwest::Client::new(); Self { + client, api_key, base_api_url, - http_client, } } @@ -114,7 +114,7 @@ impl ConversionProvider for OneInchProvider { let base = format!("{}/{}/tokens", &self.base_api_url, evm_chain_id.clone()); let url = Url::parse(&base).map_err(|_| RpcError::ConversionParseURLError)?; - let response = self.send_request(url, &self.http_client.clone()).await?; + let response = self.send_request(url, &self.client.clone()).await?; if !response.status().is_success() { error!( @@ -175,7 +175,7 @@ impl ConversionProvider for OneInchProvider { url.query_pairs_mut() .append_pair("amount", ¶ms.amount.to_string()); - let response = self.send_request(url, &self.http_client.clone()).await?; + let response = self.send_request(url, &self.client.clone()).await?; if !response.status().is_success() { error!( @@ -223,7 +223,7 @@ impl ConversionProvider for OneInchProvider { url.query_pairs_mut() .append_pair("amount", ¶ms.amount.to_string()); - let response = self.send_request(url, &self.http_client.clone()).await?; + let response = self.send_request(url, &self.client.clone()).await?; if !response.status().is_success() { error!( @@ -287,7 +287,7 @@ impl ConversionProvider for OneInchProvider { )); } - let response = self.send_request(url, &self.http_client.clone()).await?; + let response = self.send_request(url, &self.client.clone()).await?; if !response.status().is_success() { error!( diff --git a/src/providers/pokt.rs b/src/providers/pokt.rs index a01eb1102..d94518f0a 100644 --- a/src/providers/pokt.rs +++ b/src/providers/pokt.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::StatusCode, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct PoktProvider { + pub client: Client, pub project_id: String, pub supported_chains: HashMap, } @@ -76,7 +78,8 @@ impl RpcProvider for PoktProvider { let uri = format!("https://{}.rpc.grove.city/v1/{}", chain, self.project_id); - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -113,7 +116,7 @@ impl RpcProvider for PoktProvider { impl RpcProviderFactory for PoktProvider { #[tracing::instrument] - fn new(provider_config: &PoktConfig) -> Self { + fn new(client: Client, provider_config: &PoktConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -121,6 +124,7 @@ impl RpcProviderFactory for PoktProvider { .collect(); PoktProvider { + client, supported_chains, project_id: provider_config.project_id.clone(), } diff --git a/src/providers/publicnode.rs b/src/providers/publicnode.rs index 085b305eb..137269c16 100644 --- a/src/providers/publicnode.rs +++ b/src/providers/publicnode.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct PublicnodeProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -51,7 +53,8 @@ impl RpcProvider for PublicnodeProvider { let uri = format!("https://{}.publicnode.com", chain); - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -80,13 +83,16 @@ impl RpcProvider for PublicnodeProvider { impl RpcProviderFactory for PublicnodeProvider { #[tracing::instrument] - fn new(provider_config: &PublicnodeConfig) -> Self { + fn new(client: Client, provider_config: &PublicnodeConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - PublicnodeProvider { supported_chains } + PublicnodeProvider { + client, + supported_chains, + } } } diff --git a/src/providers/quicknode.rs b/src/providers/quicknode.rs index 05eb4d0d7..8261f4dd0 100644 --- a/src/providers/quicknode.rs +++ b/src/providers/quicknode.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct QuicknodeProvider { + pub client: Client, pub api_token: String, pub supported_chains: HashMap, } @@ -55,7 +57,8 @@ impl RpcProvider for QuicknodeProvider { let uri = format!("https://{}.quiknode.pro/{}", chain, self.api_token); - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -84,7 +87,7 @@ impl RpcProvider for QuicknodeProvider { impl RpcProviderFactory for QuicknodeProvider { #[tracing::instrument] - fn new(provider_config: &QuicknodeConfig) -> Self { + fn new(client: Client, provider_config: &QuicknodeConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() @@ -92,6 +95,7 @@ impl RpcProviderFactory for QuicknodeProvider { .collect(); QuicknodeProvider { + client, supported_chains, api_token: provider_config.api_token.clone(), } diff --git a/src/providers/zerion.rs b/src/providers/zerion.rs index 439f6dc7d..32d9e587c 100644 --- a/src/providers/zerion.rs +++ b/src/providers/zerion.rs @@ -20,6 +20,7 @@ use { }, async_trait::async_trait, axum::body::Bytes, + reqwest::Client, serde::{Deserialize, Serialize}, tracing::log::error, url::Url, @@ -27,12 +28,13 @@ use { #[derive(Debug)] pub struct ZerionProvider { + pub client: Client, pub api_key: String, } impl ZerionProvider { - pub fn new(api_key: String) -> Self { - Self { api_key } + pub fn new(client: Client, api_key: String) -> Self { + Self { client, api_key } } } @@ -214,7 +216,6 @@ impl HistoryProvider for ZerionProvider { &self, address: String, params: HistoryQueryParams, - http_client: reqwest::Client, ) -> RpcResult { let base = format!( "https://api.zerion.io/v1/wallets/{}/transactions/?", @@ -228,7 +229,8 @@ impl HistoryProvider for ZerionProvider { url.query_pairs_mut().append_pair("page[after]", &cursor); } - let response = http_client + let response = self + .client .get(url) .header("Content-Type", "application/json") .header("authorization", format!("Basic {}", self.api_key)) @@ -351,7 +353,8 @@ impl PortfolioProvider for ZerionProvider { url.query_pairs_mut() .append_pair("currency", ¶ms.currency.unwrap_or("usd".to_string())); - let response = reqwest::Client::new() + let response = self + .client .get(url.as_str()) .header("Content-Type", "application/json") .header("authorization", format!("Basic {}", self.api_key)) @@ -398,7 +401,6 @@ impl BalanceProvider for ZerionProvider { &self, address: String, params: BalanceQueryParams, - http_client: reqwest::Client, ) -> RpcResult { let base = format!("https://api.zerion.io/v1/wallets/{}/positions/?", &address); let mut url = Url::parse(&base).map_err(|_| RpcError::BalanceParseURLError)?; @@ -414,7 +416,8 @@ impl BalanceProvider for ZerionProvider { .append_pair("filter[chain_ids]", &chain_name); } - let response = http_client + let response = self + .client .get(url) .header("Content-Type", "application/json") .header("authorization", format!("Basic {}", self.api_key)) @@ -490,13 +493,12 @@ impl BalanceProvider for ZerionProvider { #[async_trait] impl FungiblePriceProvider for ZerionProvider { - #[tracing::instrument(skip(self, http_client), fields(provider = "Zerion"))] + #[tracing::instrument(skip(self), fields(provider = "Zerion"))] async fn get_price( &self, chain_id: &str, address: &str, currency: &PriceCurrencies, - http_client: reqwest::Client, ) -> RpcResult { let base = "https://api.zerion.io/v1/fungibles/?".to_string(); let mut url = Url::parse(&base).map_err(|_| RpcError::FungiblePriceParseURLError)?; @@ -508,7 +510,8 @@ impl FungiblePriceProvider for ZerionProvider { url.query_pairs_mut() .append_pair("filter[implementation_address]", address); - let response = http_client + let response = self + .client .get(url) .header("Content-Type", "application/json") .header("authorization", format!("Basic {}", self.api_key)) diff --git a/src/providers/zksync.rs b/src/providers/zksync.rs index 98d0e7ea7..9ccbd290c 100644 --- a/src/providers/zksync.rs +++ b/src/providers/zksync.rs @@ -10,12 +10,14 @@ use { response::{IntoResponse, Response}, }, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, }; #[derive(Debug)] pub struct ZKSyncProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -49,7 +51,8 @@ impl RpcProvider for ZKSyncProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -78,13 +81,16 @@ impl RpcProvider for ZKSyncProvider { impl RpcProviderFactory for ZKSyncProvider { #[tracing::instrument] - fn new(provider_config: &ZKSyncConfig) -> Self { + fn new(client: Client, provider_config: &ZKSyncConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - ZKSyncProvider { supported_chains } + ZKSyncProvider { + client, + supported_chains, + } } } diff --git a/src/providers/zora.rs b/src/providers/zora.rs index bd668b06b..ed0870278 100644 --- a/src/providers/zora.rs +++ b/src/providers/zora.rs @@ -15,6 +15,7 @@ use { }, axum_tungstenite::WebSocketUpgrade, hyper::http, + reqwest::Client, std::collections::HashMap, tracing::info, wc::future::FutureExt, @@ -22,6 +23,7 @@ use { #[derive(Debug)] pub struct ZoraProvider { + pub client: Client, pub supported_chains: HashMap, } @@ -111,7 +113,8 @@ impl RpcProvider for ZoraProvider { .get(chain_id) .ok_or(RpcError::ChainNotFound)?; - let response = reqwest::Client::new() + let response = self + .client .post(uri) .header("Content-Type", "application/json") .body(body) @@ -140,20 +143,23 @@ impl RpcProvider for ZoraProvider { impl RpcProviderFactory for ZoraProvider { #[tracing::instrument] - fn new(provider_config: &ZoraConfig) -> Self { + fn new(client: Client, provider_config: &ZoraConfig) -> Self { let supported_chains: HashMap = provider_config .supported_chains .iter() .map(|(k, v)| (k.clone(), v.0.clone())) .collect(); - ZoraProvider { supported_chains } + ZoraProvider { + client, + supported_chains, + } } } impl RpcProviderFactory for ZoraWsProvider { #[tracing::instrument] - fn new(provider_config: &ZoraConfig) -> Self { + fn new(_client: Client, provider_config: &ZoraConfig) -> Self { let supported_chains: HashMap = provider_config .supported_ws_chains .iter() diff --git a/src/state.rs b/src/state.rs index af86f933e..1b77f2796 100644 --- a/src/state.rs +++ b/src/state.rs @@ -28,8 +28,6 @@ pub struct AppState { pub compile_info: CompileInfo, /// Service instance uptime measurement pub uptime: std::time::Instant, - /// Shared http client - pub http_client: reqwest::Client, // Rate limiting checks pub rate_limit: Option, } @@ -43,7 +41,6 @@ pub fn new_state( registry: Registry, identity_cache: Option>>, analytics: RPCAnalytics, - http_client: reqwest::Client, rate_limit: Option, ) -> AppState { AppState { @@ -56,7 +53,6 @@ pub fn new_state( analytics, compile_info: CompileInfo {}, uptime: std::time::Instant::now(), - http_client, rate_limit, } } From 40adbf80d2d9975cb9cb50d6c4e54897932cb60a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 8 Apr 2024 16:03:16 -0400 Subject: [PATCH 09/10] chore: use released version --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54207255f..9883a8fff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3941,8 +3941,9 @@ dependencies = [ [[package]] name = "prometheus-http-query" -version = "0.8.2" -source = "git+https://github.com/WalletConnect/prometheus-http-query?branch=feat/reqwest-v12#82fa7b4d6df30adf39cb9826081cffbca8374bb5" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcebfa99f03ae51220778316b37d24981e36322c82c24848f48c5bd0f64cbdb" dependencies = [ "enum-as-inner", "mime", diff --git a/Cargo.toml b/Cargo.toml index 2da17fb79..0cea5635f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ tokio-stream = "0.1.12" axum-tungstenite = { git = "https://github.com/Astralchroma/axum-tungstenite", rev = "0906fea" } # https://github.com/davidpdrsn/axum-tungstenite/pull/13 rand = "0.8.4" -prometheus-http-query = { git = "https://github.com/WalletConnect/prometheus-http-query", branch = "feat/reqwest-v12" } # https://github.com/puetzp/prometheus-http-query/pull/13 +prometheus-http-query = "0.8.3" ethers = { version = "2.0.11", git = "https://github.com/gakonst/ethers-rs" } # using Git version because crates.io version fails clippy bytes = "1.4.0" From e7171e52dff0cc5af8a255b627a301d34249c6f5 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 15 Apr 2024 16:24:39 -0400 Subject: [PATCH 10/10] chore: use tagged versions --- .github/workflows/dispatch_deploy.yml | 2 +- .github/workflows/dispatch_publish.yml | 4 ++-- .github/workflows/dispatch_validate.yml | 2 +- .github/workflows/event_pr.yml | 2 +- .github/workflows/event_release.yml | 2 +- .github/workflows/sub-cd.yml | 4 ++-- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/dispatch_deploy.yml b/.github/workflows/dispatch_deploy.yml index 51feb351c..c027e3123 100644 --- a/.github/workflows/dispatch_deploy.yml +++ b/.github/workflows/dispatch_deploy.yml @@ -49,7 +49,7 @@ jobs: name: Lookup deployed version if: ${{ inputs.version-type == 'current' }} secrets: inherit - uses: WalletConnect/ci_workflows/.github/workflows/release-get_deployed_version.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/release-get_deployed_version.yml@0.2.9 with: task-name-stage: prod task-name: ${{ vars.TASK_NAME }} diff --git a/.github/workflows/dispatch_publish.yml b/.github/workflows/dispatch_publish.yml index 7bf2ae914..988708b8f 100644 --- a/.github/workflows/dispatch_publish.yml +++ b/.github/workflows/dispatch_publish.yml @@ -25,7 +25,7 @@ permissions: jobs: ci: name: CI - uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@0.2.9 secrets: inherit with: check-infra: false @@ -33,7 +33,7 @@ jobs: release: name: Release - uses: WalletConnect/ci_workflows/.github/workflows/release.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/release.yml@0.2.9 secrets: inherit with: infra-changed: false diff --git a/.github/workflows/dispatch_validate.yml b/.github/workflows/dispatch_validate.yml index 51f810097..2f2ead8d2 100644 --- a/.github/workflows/dispatch_validate.yml +++ b/.github/workflows/dispatch_validate.yml @@ -32,7 +32,7 @@ permissions: jobs: ci: name: CI - uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@0.2.9 secrets: inherit with: check-infra: ${{ inputs.check-infra }} diff --git a/.github/workflows/event_pr.yml b/.github/workflows/event_pr.yml index ea009c21c..33e03d44a 100644 --- a/.github/workflows/event_pr.yml +++ b/.github/workflows/event_pr.yml @@ -46,7 +46,7 @@ jobs: ci: name: CI needs: [ paths-filter ] - uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/ci.yml@0.2.9 secrets: inherit with: check-app: ${{ needs.paths-filter.outputs.app == 'true' }} diff --git a/.github/workflows/event_release.yml b/.github/workflows/event_release.yml index 9fe6e9abd..628f05fa3 100644 --- a/.github/workflows/event_release.yml +++ b/.github/workflows/event_release.yml @@ -44,7 +44,7 @@ jobs: release: name: Release needs: [ paths_filter ] - uses: WalletConnect/ci_workflows/.github/workflows/release.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/release.yml@0.2.9 secrets: inherit with: task-name: ${{ vars.TASK_NAME }} diff --git a/.github/workflows/sub-cd.yml b/.github/workflows/sub-cd.yml index 57a9d2476..2b7774e14 100644 --- a/.github/workflows/sub-cd.yml +++ b/.github/workflows/sub-cd.yml @@ -31,7 +31,7 @@ jobs: cd-staging: name: Staging secrets: inherit - uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@0.2.9 with: deploy-infra: ${{ inputs.deploy-infra }} deploy-app: ${{ inputs.deploy-app && !inputs.deploy-infra }} @@ -57,7 +57,7 @@ jobs: needs: [ validate-staging ] if: ${{ inputs.deploy-prod }} secrets: inherit - uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@fix/udeps-build + uses: WalletConnect/ci_workflows/.github/workflows/cd.yml@0.2.9 with: deploy-infra: ${{ inputs.deploy-infra }} deploy-app: ${{ inputs.deploy-app && !inputs.deploy-infra }} diff --git a/Cargo.lock b/Cargo.lock index 9883a8fff..5e82584ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "alloc" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "metrics", "serde", @@ -98,7 +98,7 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "analytics" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "anyhow", "async-trait", @@ -2079,7 +2079,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "future" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "metrics", "pin-project", @@ -2231,7 +2231,7 @@ dependencies = [ [[package]] name = "geoip" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "aws-sdk-s3", "axum-client-ip", @@ -2452,7 +2452,7 @@ dependencies = [ [[package]] name = "http" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "future", "hyper 1.2.0", @@ -3053,7 +3053,7 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "metrics" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "once_cell", "opentelemetry", @@ -4067,7 +4067,7 @@ dependencies = [ [[package]] name = "rate_limit" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "chrono", "deadpool-redis", @@ -6229,7 +6229,7 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wc" version = "0.1.0" -source = "git+https://github.com/WalletConnect/utils-rs.git?branch=feat/axum-0.7#05eab9f9baa88fa5da22c02e79aba44a537e8004" +source = "git+https://github.com/WalletConnect/utils-rs.git?tag=v0.10.0#dfb9d5902271e4f27027f78948ea4f9b7e0e9072" dependencies = [ "alloc", "analytics", diff --git a/Cargo.toml b/Cargo.toml index 0cea5635f..3d66d53b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ authors = [ build = "build.rs" [dependencies] -wc = { git = "https://github.com/WalletConnect/utils-rs.git", branch = "feat/axum-0.7", features = ["alloc", "analytics", "future", "http", "metrics", "geoip", "geoblock", "rate_limit"] } +wc = { git = "https://github.com/WalletConnect/utils-rs.git", tag = "v0.10.0", features = ["alloc", "analytics", "future", "http", "metrics", "geoip", "geoblock", "rate_limit"] } # Async async-trait = "0.1.57"