From c86bdc20f79e0670b9c4713b882260ade32d8bf9 Mon Sep 17 00:00:00 2001 From: Jannis Pohlmann Date: Fri, 24 Nov 2023 13:58:45 +0100 Subject: [PATCH] WIP --- Cargo.lock | 460 ++++++++++----------------------- service/Cargo.toml | 14 +- service/src/config.rs | 15 +- service/src/main.rs | 51 +++- service/src/routes/mod.rs | 4 +- service/src/routes/operator.rs | 19 -- 6 files changed, 202 insertions(+), 361 deletions(-) delete mode 100644 service/src/routes/operator.rs diff --git a/Cargo.lock b/Cargo.lock index bfa1577d..8249b31e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -395,45 +395,13 @@ dependencies = [ [[package]] name = "async-graphql" -version = "4.0.16" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9ed522678d412d77effe47b3c82314ac36952a35e6e852093dd48287c421f80" +checksum = "298a5d587d6e6fdb271bf56af2dc325a80eb291fd0fc979146584b9a05494a8c" dependencies = [ - "async-graphql-derive 4.0.16", - "async-graphql-parser 4.0.16", - "async-graphql-value 4.0.16", - "async-stream", - "async-trait", - "base64 0.13.1", - "bytes", - "fast_chemail", - "fnv", - "futures-util", - "http", - "indexmap 1.9.3", - "mime", - "multer", - "num-traits", - "once_cell", - "pin-project-lite", - "regex", - "serde", - "serde_json", - "serde_urlencoded", - "static_assertions", - "tempfile", - "thiserror", -] - -[[package]] -name = "async-graphql" -version = "6.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1addb0b551c59640e15de99e7566a4e3a1186cf42269e160c485ba6d8b43fe30" -dependencies = [ - "async-graphql-derive 6.0.7", - "async-graphql-parser 6.0.7", - "async-graphql-value 6.0.7", + "async-graphql-derive", + "async-graphql-parser", + "async-graphql-value", "async-stream", "async-trait", "base64 0.13.1", @@ -460,46 +428,31 @@ dependencies = [ [[package]] name = "async-graphql-axum" -version = "4.0.16" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91ac174c05670edffb720bc376b9d4c274c3d127ac08ed3d38144c9415502cd" +checksum = "01a1c20a2059bffbc95130715b23435a05168c518fba9709c81fa2a38eed990c" dependencies = [ - "async-graphql 4.0.16", + "async-graphql", "async-trait", - "axum 0.5.17", + "axum", "bytes", "futures-util", - "http-body", "serde_json", + "tokio", + "tokio-stream", "tokio-util", "tower-service", ] [[package]] name = "async-graphql-derive" -version = "4.0.16" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c121a894495d7d3fc3d4e15e0a9843e422e4d1d9e3c514d8062a1c94b35b005d" +checksum = "c7f329c7eb9b646a72f70c9c4b516c70867d356ec46cb00dcac8ad343fd006b0" dependencies = [ "Inflector", - "async-graphql-parser 4.0.16", - "darling 0.14.4", - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", - "thiserror", -] - -[[package]] -name = "async-graphql-derive" -version = "6.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1121ff0be2feea705c24f6940162c4f14a077e50a217b16e091e6534a8c08a" -dependencies = [ - "Inflector", - "async-graphql-parser 6.0.7", - "darling 0.20.3", + "async-graphql-parser", + "darling", "proc-macro-crate 1.3.1", "proc-macro2", "quote", @@ -510,23 +463,11 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "4.0.16" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b6c386f398145c6180206c1869c2279f5a3d45db5be4e0266148c6ac5c6ad68" +checksum = "6139181845757fd6a73fbb8839f3d036d7150b798db0e9bb3c6e83cdd65bd53b" dependencies = [ - "async-graphql-value 4.0.16", - "pest", - "serde", - "serde_json", -] - -[[package]] -name = "async-graphql-parser" -version = "6.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b6713fd4ffd610b8b6f6e911bf31277cbb84b7c2a9cdeeb39d1b3eed3b88e4" -dependencies = [ - "async-graphql-value 6.0.7", + "async-graphql-value", "pest", "serde", "serde_json", @@ -534,21 +475,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "4.0.16" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a941b499fead4a3fb5392cabf42446566d18c86313f69f2deab69560394d65f" -dependencies = [ - "bytes", - "indexmap 1.9.3", - "serde", - "serde_json", -] - -[[package]] -name = "async-graphql-value" -version = "6.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d74240f9daa8c1e8f73e9cfcc338d20a88d00bbeb83ded49ce8e5b4dcec0f5" +checksum = "323a5143f5bdd2030f45e3f2e0c821c9b1d36e79cf382129c64299c50a7f3750" dependencies = [ "bytes", "indexmap 2.0.0", @@ -704,41 +633,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "axum" -version = "0.5.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acee9fd5073ab6b045a275b3e709c163dd36c90685219cb21804a147b58dba43" -dependencies = [ - "async-trait", - "axum-core 0.2.9", - "base64 0.13.1", - "bitflags 1.3.2", - "bytes", - "futures-util", - "headers", - "http", - "http-body", - "hyper", - "itoa", - "matchit 0.5.0", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "sha-1", - "sync_wrapper", - "tokio", - "tokio-tungstenite 0.17.2", - "tower", - "tower-http 0.3.5", - "tower-layer", - "tower-service", -] - [[package]] name = "axum" version = "0.6.20" @@ -746,7 +640,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core 0.3.4", + "axum-core", + "base64 0.21.4", "bitflags 1.3.2", "bytes", "futures-util", @@ -755,7 +650,7 @@ dependencies = [ "http-body", "hyper", "itoa", - "matchit 0.7.3", + "matchit", "memchr", "mime", "percent-encoding", @@ -765,29 +660,15 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", + "sha1", "sync_wrapper", "tokio", + "tokio-tungstenite", "tower", "tower-layer", "tower-service", ] -[[package]] -name = "axum-core" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e5939e02c56fecd5c017c37df4238c0a839fa76b7f97acdd7efb804fd181cc" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http", - "http-body", - "mime", - "tower-layer", - "tower-service", -] - [[package]] name = "axum-core" version = "0.3.4" @@ -1023,7 +904,7 @@ dependencies = [ "base64 0.21.4", "bincode", "build-info-common", - "cargo_metadata 0.18.1", + "cargo_metadata", "chrono", "git2", "glob", @@ -1166,20 +1047,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cargo_metadata" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.17", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "cargo_metadata" version = "0.18.1" @@ -1565,38 +1432,14 @@ dependencies = [ "cipher", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core 0.14.4", - "darling_macro 0.14.4", -] - [[package]] name = "darling" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ - "darling_core 0.20.3", - "darling_macro 0.20.3", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", + "darling_core", + "darling_macro", ] [[package]] @@ -1613,24 +1456,13 @@ dependencies = [ "syn 2.0.28", ] -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core 0.14.4", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling_macro" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ - "darling_core 0.20.3", + "darling_core", "quote", "syn 2.0.28", ] @@ -2017,9 +1849,9 @@ dependencies = [ [[package]] name = "ethers" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad13497f6e0a24292fc7b408e30d22fe9dc262da1f40d7b542c3a44e7fc0476" +checksum = "1a5344eea9b20effb5efeaad29418215c4d27017639fd1f908260f59cbbd226e" dependencies = [ "ethers-addressbook", "ethers-contract", @@ -2033,9 +1865,9 @@ dependencies = [ [[package]] name = "ethers-addressbook" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e9e8acd0ed348403cc73a670c24daba3226c40b98dc1a41903766b3ab6240a" +checksum = "8c405f24ea3a517899ba7985385c43dc4a7eb1209af3b1e0a1a32d7dcc7f8d09" dependencies = [ "ethers-core", "once_cell", @@ -2045,9 +1877,9 @@ dependencies = [ [[package]] name = "ethers-contract" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d79269278125006bb0552349c03593ffa9702112ca88bc7046cc669f148fb47c" +checksum = "0111ead599d17a7bff6985fd5756f39ca7033edc79a31b23026a8d5d64fa95cd" dependencies = [ "const-hex", "ethers-contract-abigen", @@ -2064,9 +1896,9 @@ dependencies = [ [[package]] name = "ethers-contract-abigen" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce95a43c939b2e4e2f3191c5ad4a1f279780b8a39139c9905b43a7433531e2ab" +checksum = "51258120c6b47ea9d9bec0d90f9e8af71c977fbefbef8213c91bfed385fe45eb" dependencies = [ "Inflector", "const-hex", @@ -2082,15 +1914,15 @@ dependencies = [ "serde", "serde_json", "syn 2.0.28", - "toml 0.7.4", + "toml 0.8.8", "walkdir", ] [[package]] name = "ethers-contract-derive" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9ce44906fc871b3ee8c69a695ca7ec7f70e50cb379c9b9cb5e532269e492f6" +checksum = "936e7a0f1197cee2b62dc89f63eff3201dbf87c283ff7e18d86d38f83b845483" dependencies = [ "Inflector", "const-hex", @@ -2104,13 +1936,13 @@ dependencies = [ [[package]] name = "ethers-core" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0a17f0708692024db9956b31d7a20163607d2745953f5ae8125ab368ba280ad" +checksum = "2f03e0bdc216eeb9e355b90cf610ef6c5bb8aca631f97b5ae9980ce34ea7878d" dependencies = [ "arrayvec", "bytes", - "cargo_metadata 0.17.0", + "cargo_metadata", "chrono", "const-hex", "elliptic-curve", @@ -2134,10 +1966,11 @@ dependencies = [ [[package]] name = "ethers-etherscan" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e53451ea4a8128fbce33966da71132cf9e1040dcfd2a2084fd7733ada7b2045" +checksum = "abbac2c890bdbe0f1b8e549a53b00e2c4c1de86bb077c1094d1f38cdf9381a56" dependencies = [ + "chrono", "ethers-core", "reqwest", "semver 1.0.17", @@ -2149,9 +1982,9 @@ dependencies = [ [[package]] name = "ethers-middleware" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473f1ccd0c793871bbc248729fa8df7e6d2981d6226e4343e3bbaa9281074d5d" +checksum = "681ece6eb1d10f7cf4f873059a77c04ff1de4f35c63dd7bccde8f438374fcb93" dependencies = [ "async-trait", "auto_impl", @@ -2176,9 +2009,9 @@ dependencies = [ [[package]] name = "ethers-providers" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6838fa110e57d572336178b7c79e94ff88ef976306852d8cb87d9e5b1fc7c0b5" +checksum = "25d6c0c9455d93d4990c06e049abf9b30daf148cf461ee939c11d88907c60816" dependencies = [ "async-trait", "auto_impl", @@ -2201,7 +2034,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-tungstenite 0.20.0", + "tokio-tungstenite", "tracing", "tracing-futures", "url", @@ -2213,9 +2046,9 @@ dependencies = [ [[package]] name = "ethers-signers" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea44bec930f12292866166f9ddbea6aa76304850e4d8dcd66dc492b43d00ff1" +checksum = "0cb1b714e227bbd2d8c53528adb580b203009728b17d0d0e4119353aa9bc5532" dependencies = [ "async-trait", "coins-bip32", @@ -2232,9 +2065,9 @@ dependencies = [ [[package]] name = "ethers-solc" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de34e484e7ae3cab99fbfd013d6c5dc7f9013676a4e0e414d8b12e1213e8b3ba" +checksum = "a64f710586d147864cff66540a6d64518b9ff37d73ef827fee430538265b595f" dependencies = [ "cfg-if", "const-hex", @@ -2341,7 +2174,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d15473d7f83b54a44826907af16ae5727eaacaf6e53b51474016d3efd9aa35d5" dependencies = [ - "darling 0.20.3", + "darling", "proc-macro2", "quote", "syn 2.0.28", @@ -2716,13 +2549,26 @@ dependencies = [ [[package]] name = "graphql" version = "0.1.0" -source = "git+https://github.com/edgeandnode/toolshed?branch=main#82313926248990a9c823efe4c9e6b6a7890c7678" +source = "git+https://github.com/edgeandnode/toolshed?branch=main#5c55a5707b7d91cdeeaeb090e27f036e11062cfe" dependencies = [ "firestorm", "graphql-parser", "serde", ] +[[package]] +name = "graphql-http" +version = "0.1.0" +source = "git+https://github.com/edgeandnode/toolshed?branch=main#5c55a5707b7d91cdeeaeb090e27f036e11062cfe" +dependencies = [ + "anyhow", + "async-trait", + "reqwest", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "graphql-parser" version = "0.4.0" @@ -3134,7 +2980,7 @@ dependencies = [ "arc-swap", "async-trait", "autometrics 0.6.0", - "axum 0.6.20", + "axum", "build-info", "env_logger", "ethers", @@ -3504,12 +3350,6 @@ dependencies = [ "regex-automata 0.1.10", ] -[[package]] -name = "matchit" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" - [[package]] name = "matchit" version = "0.7.3" @@ -4228,10 +4068,11 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.6.0" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] @@ -4477,7 +4318,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.10", ] [[package]] @@ -5390,9 +5231,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -5410,9 +5251,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -5474,9 +5315,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" +checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ "base64 0.21.4", "chrono", @@ -5491,11 +5332,11 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e6be15c453eb305019bfa438b1593c731f36a289a7853f7707ee29e870b3b3c" +checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" dependencies = [ - "darling 0.20.3", + "darling", "proc-macro2", "quote", "syn 2.0.28", @@ -5508,10 +5349,10 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "anyhow", - "async-graphql 4.0.16", + "async-graphql", "async-graphql-axum", "autometrics 0.3.3", - "axum 0.6.20", + "axum", "build-info", "build-info-build", "cargo-husky", @@ -5524,6 +5365,8 @@ dependencies = [ "eventuals", "faux", "figment", + "graphql", + "graphql-http", "hex", "hex-literal", "hyper", @@ -5544,23 +5387,12 @@ dependencies = [ "tokio", "toolshed", "tower", - "tower-http 0.4.4", + "tower-http", "tracing", "tracing-subscriber", "wiremock", ] -[[package]] -name = "sha-1" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - [[package]] name = "sha1" version = "0.10.5" @@ -5719,9 +5551,9 @@ dependencies = [ [[package]] name = "solang-parser" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb9fa2fa2fa6837be8a2495486ff92e3ffe68a99b6eeba288e139efdd842457" +checksum = "c425ce1c59f4b154717592f0bdf4715c3a1d55058883622d3157e1f0908a5b26" dependencies = [ "itertools 0.11.0", "lalrpop", @@ -6204,18 +6036,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -6344,18 +6176,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "tokio-tungstenite" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.17.3", -] - [[package]] name = "tokio-tungstenite" version = "0.20.0" @@ -6367,7 +6187,7 @@ dependencies = [ "rustls", "tokio", "tokio-rustls", - "tungstenite 0.20.0", + "tungstenite", "webpki-roots 0.23.1", ] @@ -6404,14 +6224,26 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.10", +] + +[[package]] +name = "toml" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.21.0", ] [[package]] name = "toml_datetime" -version = "0.6.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a76a9312f5ba4c2dec6b9161fdf25d87ad8a09256ccea5a556fef03c706a10f" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -6426,17 +6258,30 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.4.6", +] + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.5.19", ] [[package]] name = "toolshed" -version = "0.2.2" -source = "git+https://github.com/edgeandnode/toolshed?branch=main#82313926248990a9c823efe4c9e6b6a7890c7678" +version = "0.2.3" +source = "git+https://github.com/edgeandnode/toolshed?branch=main#5c55a5707b7d91cdeeaeb090e27f036e11062cfe" dependencies = [ "alloy-primitives", "alloy-sol-types", - "async-graphql 6.0.7", + "async-graphql", "bs58 0.5.0", "ethers-core", "firestorm", @@ -6465,25 +6310,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tower-http" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" -dependencies = [ - "bitflags 1.3.2", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "tower-http" version = "0.4.4" @@ -6521,7 +6347,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db81d9313372d714152194f3f2b66badda23a783fb6a97462e35f632814f4cff" dependencies = [ - "axum 0.6.20", + "axum", "forwarded-header-value", "futures", "futures-core", @@ -6626,25 +6452,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "tungstenite" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27992fd6a8c29ee7eef28fc78349aa244134e10ad447ce3b9f0ac0ed0fa4ce0" -dependencies = [ - "base64 0.13.1", - "byteorder", - "bytes", - "http", - "httparse", - "log", - "rand 0.8.5", - "sha-1", - "thiserror", - "url", - "utf-8", -] - [[package]] name = "tungstenite" version = "0.20.0" @@ -7177,6 +6984,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" diff --git a/service/Cargo.toml b/service/Cargo.toml index d5df369e..2c0f1253 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -10,8 +10,8 @@ license = "Apache-2.0" [dependencies] indexer-common = { path = "../common" } confy = "0.5.1" -ethers-core = "2.0.10" -ethers = "2.0.10" +ethers-core = "2.0.11" +ethers = "2.0.11" eventuals = "0.6.7" dotenvy = "0.15" log = "0.4.17" @@ -31,8 +31,8 @@ tower-http = { version = "0.4.0", features = [ "cors", ] } once_cell = "1.17" -async-graphql = "4.0.16" -async-graphql-axum = "4.0.16" +async-graphql = "6.0.11" +async-graphql-axum = "6.0.11" sha3 = "0.10.6" tracing-subscriber = { version = "0.3", features = [ "env-filter", @@ -57,8 +57,10 @@ sqlx = { version = "0.7.1", features = [ alloy-primitives = { version = "0.4.2", features = ["serde"] } alloy-sol-types = "0.4.2" lazy_static = "1.4.0" -toolshed = { git = "https://github.com/edgeandnode/toolshed", branch = "main", features = [ - "graphql", +toolshed = { git = "https://github.com/edgeandnode/toolshed", branch = "main" } +graphql = { git = "https://github.com/edgeandnode/toolshed", branch = "main" } +graphql-http = { git = "https://github.com/edgeandnode/toolshed", branch = "main", features = [ + "http-reqwest", ] } build-info = "0.0.34" figment = { version = "0.10", features = ["toml", "env"] } diff --git a/service/src/config.rs b/service/src/config.rs index 1f7203e4..f8c61fb6 100644 --- a/service/src/config.rs +++ b/service/src/config.rs @@ -12,15 +12,14 @@ use indexer_common::indexer_service::http::IndexerServiceConfig; use serde::{Deserialize, Serialize}; use toolshed::thegraph::DeploymentId; -#[derive(Clone, Deserialize)] +#[derive(Clone, Debug, Deserialize)] pub struct Config { - pub ethereum: Ethereum, - pub receipts: Receipts, - pub indexer_infrastructure: IndexerInfrastructure, - pub postgres: Postgres, - pub network_subgraph: NetworkSubgraph, - pub escrow_subgraph: EscrowSubgraph, - + // pub ethereum: Ethereum, + // pub receipts: Receipts, + // pub indexer_infrastructure: IndexerInfrastructure, + // pub postgres: Postgres, + // pub network_subgraph: NetworkSubgraph, + // pub escrow_subgraph: EscrowSubgraph, pub common: IndexerServiceConfig, } diff --git a/service/src/main.rs b/service/src/main.rs index e928e1dd..e39740d8 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -2,18 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 use std::sync::Arc; +use std::time::Duration; use anyhow::Error; use axum::{ async_trait, response::{IntoResponse, Response}, - routing::get, + routing::post, Json, Router, }; use clap::Parser; use indexer_common::indexer_service::http::{ IndexerService, IndexerServiceImpl, IndexerServiceOptions, IndexerServiceRelease, IsAttestable, }; +use reqwest::StatusCode; use serde::Serialize; use serde_json::{json, Value}; use thiserror::Error; @@ -28,7 +30,32 @@ use cli::Cli; use config::Config; #[derive(Debug, Error)] -pub enum SubgraphServiceError {} +pub enum SubgraphServiceError { + #[error("Invalid status query: {0}")] + InvalidStatusQuery(Error), + #[error("Unsupported status query fields: {0:?}")] + UnsupportedStatusQueryFields(Vec), + #[error("Internal server error: {0}")] + StatusQueryError(Error), +} + +impl From<&SubgraphServiceError> for StatusCode { + fn from(err: &SubgraphServiceError) -> Self { + use SubgraphServiceError::*; + match err { + InvalidStatusQuery(_) => StatusCode::BAD_REQUEST, + UnsupportedStatusQueryFields(_) => StatusCode::BAD_REQUEST, + StatusQueryError(_) => StatusCode::INTERNAL_SERVER_ERROR, + } + } +} + +// Tell axum how to convert `SubgraphServiceError` into a response. +impl IntoResponse for SubgraphServiceError { + fn into_response(self) -> Response { + (StatusCode::from(&self), self.to_string()).into_response() + } +} #[derive(Serialize)] #[serde(transparent)] @@ -57,7 +84,9 @@ impl IsAttestable for SubgraphResponse { } pub struct SubgraphServiceState { - config: Config, + pub config: Config, + pub graph_node_client: reqwest::Client, + pub graph_node_status_url: String, } struct SubgraphService { @@ -100,6 +129,8 @@ impl IndexerServiceImpl for SubgraphService { /// Return response from Query Processor #[tokio::main] async fn main() -> Result<(), Error> { + tracing_subscriber::fmt::init(); + // Parse command line and environment arguments let cli = Cli::parse(); @@ -127,6 +158,18 @@ async fn main() -> Result<(), Error> { // that is involved in serving requests let state = Arc::new(SubgraphServiceState { config: config.clone(), + graph_node_client: reqwest::ClientBuilder::new() + .tcp_nodelay(true) + .timeout(Duration::from_secs(30)) + .build() + .expect("Failed to init HTTP client for Graph Node"), + graph_node_status_url: config + .common + .graph_node + .as_ref() + .expect("Config must have `common.graph_node.status_url` set") + .status_url + .clone(), }); IndexerService::run(IndexerServiceOptions { @@ -136,7 +179,7 @@ async fn main() -> Result<(), Error> { metrics_prefix: "subgraph", service_impl: SubgraphService::new(config), extra_routes: Router::new() - .route("/operator", get(routes::operator)) + .route("/status", post(routes::status)) .with_state(state), }) .await diff --git a/service/src/routes/mod.rs b/service/src/routes/mod.rs index 27f5dbaf..f3566544 100644 --- a/service/src/routes/mod.rs +++ b/service/src/routes/mod.rs @@ -1,3 +1,3 @@ -mod operator; +mod status; -pub use operator::operator; +pub use status::status; diff --git a/service/src/routes/operator.rs b/service/src/routes/operator.rs deleted file mode 100644 index 9b8be16f..00000000 --- a/service/src/routes/operator.rs +++ /dev/null @@ -1,19 +0,0 @@ -use std::sync::Arc; - -use axum::{extract::State, response::Json}; -use ethers::signers::{coins_bip39::English, MnemonicBuilder, Signer}; -use serde_json::{json, Value}; - -use crate::SubgraphServiceState; - -// Define a handler function for the `/info` route -pub async fn operator(State(state): State>) -> Json { - let mnemonic = &state.config.common.indexer.operator_mnemonic; - let address = MnemonicBuilder::::default() - .phrase(mnemonic.as_str()) - .build() - .expect("operator mnemonic must be valid") - .address() - .to_string(); - Json(json!({ "publicKey": address })) -}