diff --git a/Cargo.lock b/Cargo.lock index b3d21c41..aae5fea9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-primitives" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0628ec0ba5b98b3370bb6be17b12f23bfce8ee4ad83823325a20546d9b03b78" +checksum = "08ca2c09d5911548a5cb620382ea0e1af99d3c898ce0efecbbd274a4676cf53e" dependencies = [ "alloy-rlp", "bytes", @@ -109,13 +109,14 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a98ad1696a2e17f010ae8e43e9f2a1e930ed176a8e3ff77acfeff6dfb07b42c" +checksum = "e40cea54ac58080a1b88ea6556866eac1902b321186c77d53ad2b5ebbbf0e038" dependencies = [ "const-hex", "dunce", "heck", + "indexmap 2.0.2", "proc-macro-error", "proc-macro2", "quote", @@ -126,9 +127,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98d7107bed88e8f09f0ddcc3335622d87bfb6821f3e0c7473329fb1cfad5e015" +checksum = "f81aa34725607be118c395d62c1d8d97c8a343dd1ada5370ed508ed5232eab6a" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -341,12 +342,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "ascii" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" - [[package]] name = "ascii-canvas" version = "3.0.0" @@ -417,13 +412,13 @@ dependencies = [ [[package]] name = "async-graphql" -version = "6.0.7" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1addb0b551c59640e15de99e7566a4e3a1186cf42269e160c485ba6d8b43fe30" +checksum = "298a5d587d6e6fdb271bf56af2dc325a80eb291fd0fc979146584b9a05494a8c" dependencies = [ - "async-graphql-derive 6.0.7", - "async-graphql-parser 6.0.7", - "async-graphql-value 6.0.7", + "async-graphql-derive 6.0.11", + "async-graphql-parser 6.0.11", + "async-graphql-value 6.0.11", "async-stream", "async-trait", "base64 0.13.1", @@ -483,12 +478,12 @@ dependencies = [ [[package]] name = "async-graphql-derive" -version = "6.0.7" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1121ff0be2feea705c24f6940162c4f14a077e50a217b16e091e6534a8c08a" +checksum = "c7f329c7eb9b646a72f70c9c4b516c70867d356ec46cb00dcac8ad343fd006b0" dependencies = [ "Inflector", - "async-graphql-parser 6.0.7", + "async-graphql-parser 6.0.11", "darling 0.20.3", "proc-macro-crate 1.3.1", "proc-macro2", @@ -512,11 +507,11 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "6.0.7" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b6713fd4ffd610b8b6f6e911bf31277cbb84b7c2a9cdeeb39d1b3eed3b88e4" +checksum = "6139181845757fd6a73fbb8839f3d036d7150b798db0e9bb3c6e83cdd65bd53b" dependencies = [ - "async-graphql-value 6.0.7", + "async-graphql-value 6.0.11", "pest", "serde", "serde_json", @@ -536,9 +531,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "6.0.7" +version = "6.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d74240f9daa8c1e8f73e9cfcc338d20a88d00bbeb83ded49ce8e5b4dcec0f5" +checksum = "323a5143f5bdd2030f45e3f2e0c821c9b1d36e79cf382129c64299c50a7f3750" dependencies = [ "bytes", "indexmap 2.0.2", @@ -1062,9 +1057,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -1211,19 +1206,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "combine" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" -dependencies = [ - "ascii", - "byteorder", - "either", - "memchr", - "unreachable", -] - [[package]] name = "concurrent-queue" version = "2.3.0" @@ -1906,9 +1888,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", @@ -1925,9 +1907,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", @@ -1943,15 +1925,15 @@ dependencies = [ "serde", "serde_json", "syn 2.0.38", - "toml 0.7.8", + "toml 0.8.2", "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", @@ -1965,9 +1947,9 @@ 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", @@ -1995,10 +1977,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.20", @@ -2037,9 +2020,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", @@ -2074,9 +2057,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", @@ -2225,12 +2208,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" -[[package]] -name = "firestorm" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c5f6c2c942da57e2aaaa84b8a521489486f14e75e7fa91dab70aba913975f98" - [[package]] name = "fixed-hash" version = "0.8.0" @@ -2531,22 +2508,13 @@ dependencies = [ ] [[package]] -name = "graphql" -version = "0.1.0" -source = "git+https://github.com/edgeandnode/toolshed?branch=main#e9f344633ef0d78a3209fac295de57c6397bd009" +name = "graphql-http" +version = "0.1.1" +source = "git+https://github.com/edgeandnode/toolshed?branch=main#f113025319cde85b03706f80d6be5711dcb31678" dependencies = [ - "firestorm", - "graphql-parser", + "anyhow", "serde", -] - -[[package]] -name = "graphql-parser" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ebc8013b4426d5b81a4364c419a95ed0b404af2b82e2457de52d9348f0e474" -dependencies = [ - "combine", + "serde_json", "thiserror", ] @@ -2946,7 +2914,7 @@ dependencies = [ "ethers-core", "eventuals", "faux", - "graphql", + "graphql-http", "keccak-hash", "lazy_static", "lru", @@ -2958,10 +2926,10 @@ dependencies = [ "serde", "serde_json", "sqlx", - "tap_core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tap_core", "test-log", + "thegraph", "tokio", - "toolshed", "tracing", "wiremock", ] @@ -2990,11 +2958,11 @@ dependencies = [ "serde_yaml", "sqlx", "tap_aggregator", - "tap_core 0.6.0 (git+https://github.com/semiotic-ai/timeline-aggregation-protocol.git?rev=882ca394444b451538908b9996bf7d45869a1bb9)", + "tap_core", "tempfile", + "thegraph", "thiserror", "tokio", - "toolshed", "tracing", "tracing-subscriber", "wiremock", @@ -4236,7 +4204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", ] [[package]] @@ -4759,9 +4727,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95294d6e3a6192f3aabf91c38f56505a625aa495533442744185a36d75a790c4" +checksum = "608a5726529f2f0ef81b8fde9873c4bb829d6b5b5ca6be4d97345ddf0749c825" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -4769,6 +4737,7 @@ dependencies = [ "bytes", "fastrlp", "num-bigint", + "num-traits", "parity-scale-codec", "primitive-types", "proptest", @@ -5099,18 +5068,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -5245,12 +5214,12 @@ dependencies = [ "serde_json", "sha3", "sqlx", - "tap_core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tap_core", "test-log", + "thegraph", "thiserror", "tokio", "toml 0.7.8", - "toolshed", "tower", "tower-http 0.4.4", "tracing", @@ -5818,9 +5787,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.4.2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b837ef12ab88835251726eb12237655e61ec8dc8a280085d1961cdc3dfd047" +checksum = "e2c7ad08db24862d5b787a94714ff6b047935c3e3f60af944ac969404debd7ff" dependencies = [ "paste", "proc-macro2", @@ -5863,9 +5832,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tap_aggregator" -version = "0.1.6" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e29a877040a076bcc3c3a442d2bef48456d9840b5db7c82512d65d249284a71" +checksum = "3344e835a276a75d94a5e63db7786e4deb5e0d82748182a826e7ff62c0a0c8f2" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -5884,40 +5853,16 @@ dependencies = [ "serde", "serde_json", "strum 0.24.1", - "tap_core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tap_core", "tokio", "tracing-subscriber", ] [[package]] name = "tap_core" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6de9bc4538c13ca369b1ff35d31be8eaeb955bed3805ce64d8fd2aee4f0ec0c7" -dependencies = [ - "alloy-primitives", - "alloy-sol-types", - "anyhow", - "async-trait", - "ethereum-types", - "ethers", - "ethers-contract", - "ethers-contract-derive", - "ethers-core", - "rand 0.8.5", - "rand_core 0.6.4", - "rstest", - "serde", - "strum 0.24.1", - "strum_macros 0.24.3", - "thiserror", - "tokio", -] - -[[package]] -name = "tap_core" -version = "0.6.0" -source = "git+https://github.com/semiotic-ai/timeline-aggregation-protocol.git?rev=882ca394444b451538908b9996bf7d45869a1bb9#882ca394444b451538908b9996bf7d45869a1bb9" +checksum = "b684316a94bf1ab08d6c32c578b5efec441278594d066f27d619edb478d926c6" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -5982,6 +5927,22 @@ dependencies = [ "syn 2.0.38", ] +[[package]] +name = "thegraph" +version = "0.1.1" +source = "git+https://github.com/edgeandnode/toolshed?branch=main#f113025319cde85b03706f80d6be5711dcb31678" +dependencies = [ + "alloy-primitives", + "alloy-sol-types", + "async-graphql 6.0.11", + "bs58", + "ethers-core", + "serde", + "serde_with", + "sha3", + "thiserror", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -6186,7 +6147,19 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.2", ] [[package]] @@ -6212,22 +6185,16 @@ dependencies = [ ] [[package]] -name = "toolshed" -version = "0.2.2" -source = "git+https://github.com/edgeandnode/toolshed?branch=main#e9f344633ef0d78a3209fac295de57c6397bd009" +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "alloy-primitives", - "alloy-sol-types", - "async-graphql 6.0.7", - "bs58", - "ethers-core", - "firestorm", - "graphql-parser", + "indexmap 2.0.2", "serde", - "serde_with", - "sha3", - "thiserror", - "url", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] @@ -6496,15 +6463,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - [[package]] name = "unsafe-libyaml" version = "0.2.9" @@ -6578,12 +6536,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/common/Cargo.toml b/common/Cargo.toml index 768e25c5..56a88267 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -4,8 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = { version = "0.4.2", features = ["serde"] } -alloy-sol-types = "0.4.2" +alloy-primitives = { version = "0.5.2", features = ["serde"] } +alloy-sol-types = "0.5.2" anyhow = "1.0.75" arc-swap = "1.6.0" ethers = "2.0.10" @@ -30,12 +30,10 @@ sqlx = { version = "0.7.1", features = [ "time", ] } tokio = { version = "1.32.0", features = ["full", "macros", "rt"] } -toolshed = { git = "https://github.com/edgeandnode/toolshed", branch = "main", features = [ - "graphql", -] } +thegraph = { git = "https://github.com/edgeandnode/toolshed", branch = "main" } tracing = "0.1.34" -graphql = { git = "https://github.com/edgeandnode/toolshed", branch = "main" } -tap_core = "0.6.0" +graphql-http = { git = "https://github.com/edgeandnode/toolshed", branch = "main" } +tap_core = "0.7.0" [dev-dependencies] env_logger = "0.9.0" diff --git a/common/src/allocations/mod.rs b/common/src/allocations/mod.rs index 1a3b56f1..d52c9de2 100644 --- a/common/src/allocations/mod.rs +++ b/common/src/allocations/mod.rs @@ -4,7 +4,7 @@ use alloy_primitives::Address; use ethers_core::types::U256; use serde::{Deserialize, Deserializer}; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; pub mod monitor; diff --git a/common/src/allocations/monitor.rs b/common/src/allocations/monitor.rs index eddb0b73..4ea1dc57 100644 --- a/common/src/allocations/monitor.rs +++ b/common/src/allocations/monitor.rs @@ -42,11 +42,12 @@ async fn current_epoch( })) .await?; - if let Some(errors) = response.errors { + if !response.errors.is_empty() { warn!( "Errors encountered identifying current epoch for network {}: {}", graph_network_id, - errors + response + .errors .into_iter() .map(|e| e.message) .collect::>() @@ -147,11 +148,11 @@ pub fn indexer_allocations( .map_err(|e| e.to_string())?; // If there are any GraphQL errors returned, we'll log them for debugging - if let Some(errors) = response.errors { + if !response.errors.is_empty() { warn!( "Errors encountered fetching active or recently closed allocations for indexer {:?}: {}", indexer_address, - errors.into_iter().map(|e| e.message).collect::>().join(", ") + response.errors.into_iter().map(|e| e.message).collect::>().join(", ") ); } diff --git a/common/src/attestations/dispute_manager.rs b/common/src/attestations/dispute_manager.rs index 0a19075e..b473345b 100644 --- a/common/src/attestations/dispute_manager.rs +++ b/common/src/attestations/dispute_manager.rs @@ -47,11 +47,12 @@ pub fn dispute_manager( .await .map_err(|e| e.to_string())?; - if let Some(errors) = response.errors { + if !response.errors.is_empty() { warn!( "Errors encountered querying the dispute manager for network {}: {}", graph_network_id, - errors + response + .errors .into_iter() .map(|e| e.message) .collect::>() diff --git a/common/src/attestations/signer.rs b/common/src/attestations/signer.rs index ff13f347..1480bfe2 100644 --- a/common/src/attestations/signer.rs +++ b/common/src/attestations/signer.rs @@ -6,8 +6,7 @@ use alloy_sol_types::Eip712Domain; use ethers::signers::coins_bip39::English; use ethers::signers::{MnemonicBuilder, Signer, Wallet}; use ethers_core::k256::ecdsa::SigningKey; -use toolshed::thegraph::attestation::{self, Attestation}; -use toolshed::thegraph::DeploymentId; +use thegraph::types::{attestation, Attestation, DeploymentId}; use crate::prelude::Allocation; diff --git a/common/src/escrow_accounts.rs b/common/src/escrow_accounts.rs index 7ebdcc0f..7584762d 100644 --- a/common/src/escrow_accounts.rs +++ b/common/src/escrow_accounts.rs @@ -65,11 +65,12 @@ pub fn escrow_accounts( .map_err(|e| e.to_string())?; // If there are any GraphQL errors returned, we'll log them for debugging - if let Some(errors) = response.errors { + if !response.errors.is_empty() { error!( "Errors encountered fetching escrow accounts for indexer {:?}: {}", indexer_address, - errors + response + .errors .into_iter() .map(|e| e.message) .collect::>() diff --git a/common/src/subgraph_client/client.rs b/common/src/subgraph_client/client.rs index d811ebd2..297ce5a5 100644 --- a/common/src/subgraph_client/client.rs +++ b/common/src/subgraph_client/client.rs @@ -3,11 +3,11 @@ use anyhow::anyhow; use eventuals::Eventual; -use graphql::http::Response; +use graphql_http::http::response::ResponseBody; use reqwest::{header, Url}; use serde::de::Deserialize; use serde_json::Value; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; use tracing::warn; use super::monitor::{monitor_deployment_status, DeploymentStatus}; @@ -62,7 +62,7 @@ impl DeploymentClient { pub async fn query Deserialize<'de>>( &self, body: &Value, - ) -> Result, anyhow::Error> { + ) -> Result, anyhow::Error> { if let Some(ref status) = self.status { let deployment_status = status.value().await.expect("reading deployment status"); @@ -83,7 +83,7 @@ impl DeploymentClient { .send() .await .and_then(|response| response.error_for_status())? - .json::>() + .json::>() .await?) } } @@ -109,7 +109,7 @@ impl SubgraphClient { pub async fn query Deserialize<'de>>( &self, body: &Value, - ) -> Result, anyhow::Error> { + ) -> Result, anyhow::Error> { // Try the local client first; if that fails, log the error and move on // to the remote client if let Some(ref local_client) = self.local_client { @@ -273,7 +273,7 @@ mod test { ); // Query the subgraph - let response: Response = client + let response: ResponseBody = client .query(&json!({ "query": "{ user(id: 1} { name } }"})) .await .unwrap(); @@ -352,7 +352,7 @@ mod test { ); // Query the subgraph - let response: Response = client + let response: ResponseBody = client .query(&json!({ "query": "{ user(id: 1} { name } }"})) .await .unwrap(); @@ -431,7 +431,7 @@ mod test { ); // Query the subgraph - let response: Response = client + let response: ResponseBody = client .query(&json!({ "query": "{ user(id: 1} { name } }"})) .await .unwrap(); diff --git a/common/src/subgraph_client/monitor.rs b/common/src/subgraph_client/monitor.rs index c638fddd..aeeed05c 100644 --- a/common/src/subgraph_client/monitor.rs +++ b/common/src/subgraph_client/monitor.rs @@ -4,12 +4,12 @@ use std::time::Duration; use eventuals::{timer, Eventual, EventualExt}; -use graphql::http::Response; +use graphql_http::http::response::ResponseBody; use reqwest::{header, Url}; use serde::Deserialize; use serde_json::{json, Value}; +use thegraph::types::DeploymentId; use tokio::time::sleep; -use toolshed::thegraph::DeploymentId; use tracing::warn; #[derive(Deserialize)] @@ -27,7 +27,7 @@ pub struct DeploymentStatus { async fn query Deserialize<'de>>( url: Url, body: &Value, -) -> Result, reqwest::Error> { +) -> Result, reqwest::Error> { reqwest::Client::new() .post(url) .json(body) @@ -35,7 +35,7 @@ async fn query Deserialize<'de>>( .send() .await .and_then(|response| response.error_for_status())? - .json::>() + .json::>() .await } @@ -68,11 +68,12 @@ pub fn monitor_deployment_status( format!("Failed to query status of deployment `{deployment}`: {e}") })?; - if let Some(errors) = response.errors { + if !response.errors.is_empty() { warn!( "Errors encountered querying the deployment status for `{}`: {}", deployment, - errors + response + .errors .into_iter() .map(|e| e.message) .collect::>() diff --git a/common/src/test_vectors.rs b/common/src/test_vectors.rs index 19890680..019b16b7 100644 --- a/common/src/test_vectors.rs +++ b/common/src/test_vectors.rs @@ -6,7 +6,7 @@ use std::{collections::HashMap, str::FromStr}; use alloy_primitives::Address; use ethers_core::types::U256; use lazy_static::lazy_static; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; use crate::prelude::{Allocation, AllocationStatus, SubgraphDeployment}; diff --git a/service/Cargo.toml b/service/Cargo.toml index d9e9c0d9..ce264f17 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -2,7 +2,7 @@ name = "service" version = "0.1.0" edition = "2021" -description="Could not find crate on crates.io and could not import with git and path at the same time, so copied a version directly at https://github.com/graphprotocol/indexer/blob/972658b3ce8c512ad7b4dc575d29cd9d5377e3fe/packages/indexer-native/native" +description = "Could not find crate on crates.io and could not import with git and path at the same time, so copied a version directly at https://github.com/graphprotocol/indexer/blob/972658b3ce8c512ad7b4dc575d29cd9d5377e3fe/packages/indexer-native/native" license = "Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -25,7 +25,11 @@ serde_json = "1" axum = "0.5" hyper = "0.14.27" tower = { version = "0.4", features = ["util", "timeout", "limit"] } -tower-http = { version = "0.4.0", features = ["add-extension", "trace", "cors"] } +tower-http = { version = "0.4.0", features = [ + "add-extension", + "trace", + "cors", +] } toml = "0.7.4" once_cell = "1.17" async-graphql = "4.0.16" @@ -42,13 +46,19 @@ autometrics = { version = "0.3.3", features = ["prometheus-exporter"] } clap = { version = "4.3.1", features = ["derive", "env"] } prometheus = "0.13.3" hex = "0.4.3" -tap_core = "0.6.0" +tap_core = "0.7.0" ethereum-types = "0.14.1" -sqlx = { version = "0.7.1", features = ["postgres", "runtime-tokio", "bigdecimal", "rust_decimal", "time"] } -alloy-primitives = { version = "0.4.2", features = ["serde"] } -alloy-sol-types = "0.4.2" +sqlx = { version = "0.7.1", features = [ + "postgres", + "runtime-tokio", + "bigdecimal", + "rust_decimal", + "time", +] } +alloy-primitives = { version = "0.5.2", features = ["serde"] } +alloy-sol-types = "0.5.2" lazy_static = "1.4.0" -toolshed = { git = "https://github.com/edgeandnode/toolshed", branch = "main", features = ["graphql"] } +thegraph = { git = "https://github.com/edgeandnode/toolshed", branch = "main" } [dev-dependencies] faux = "0.1.10" @@ -65,4 +75,4 @@ wiremock = "0.5.19" version = "1" default-features = false # Disable features which are enabled by default -features = ["precommit-hook", "run-cargo-fmt", "run-cargo-clippy"] \ No newline at end of file +features = ["precommit-hook", "run-cargo-fmt", "run-cargo-clippy"] diff --git a/service/src/common/address.rs b/service/src/common/address.rs index 4e2232c7..9172f33d 100644 --- a/service/src/common/address.rs +++ b/service/src/common/address.rs @@ -4,18 +4,7 @@ use ethers::signers::{ coins_bip39::English, LocalWallet, MnemonicBuilder, Signer, Wallet, WalletError, }; -use ethers_core::{k256::ecdsa::SigningKey, utils::hex}; -use sha3::{Digest, Keccak256}; - -/// A normalized address in checksum format. -pub type Address = String; - -/// Converts an address to checksum format and returns a typed instance. -pub fn to_address(s: impl AsRef) -> Address { - let address = s.as_ref().to_ascii_lowercase(); - let hash = &Keccak256::digest(address); - hex::encode(hash) -} +use ethers_core::k256::ecdsa::SigningKey; /// Build Wallet from Private key or Mnemonic pub fn build_wallet(value: &str) -> Result, WalletError> { diff --git a/service/src/common/indexer_management/mod.rs b/service/src/common/indexer_management/mod.rs index 32a19e12..f32002b4 100644 --- a/service/src/common/indexer_management/mod.rs +++ b/service/src/common/indexer_management/mod.rs @@ -6,7 +6,7 @@ use std::{collections::HashSet, str::FromStr}; use serde::{Deserialize, Serialize}; use serde_json::Value; use sqlx::PgPool; -use toolshed::thegraph::{DeploymentId, DeploymentIdError}; +use thegraph::types::{DeploymentId, DeploymentIdError}; /// Internal cost model representation as stored in the database. /// diff --git a/service/src/config.rs b/service/src/config.rs index c131a4f6..017ad4a2 100644 --- a/service/src/config.rs +++ b/service/src/config.rs @@ -5,7 +5,7 @@ use clap::{command, Args, Parser, ValueEnum}; use alloy_primitives::Address; use serde::{Deserialize, Serialize}; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; use crate::util::init_tracing; diff --git a/service/src/graph_node.rs b/service/src/graph_node.rs index 7c875764..b1bafb2d 100644 --- a/service/src/graph_node.rs +++ b/service/src/graph_node.rs @@ -4,7 +4,7 @@ use anyhow::anyhow; use reqwest::{header, Client, Url}; use std::sync::Arc; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; use crate::query_processor::{QueryError, UnattestedQueryResult}; diff --git a/service/src/query_processor.rs b/service/src/query_processor.rs index b4e99120..e494ff52 100644 --- a/service/src/query_processor.rs +++ b/service/src/query_processor.rs @@ -9,8 +9,7 @@ use indexer_common::tap_manager::TapManager; use log::error; use serde::{Deserialize, Serialize}; use tap_core::tap_manager::SignedReceipt; -use toolshed::thegraph::attestation::Attestation; -use toolshed::thegraph::DeploymentId; +use thegraph::types::{attestation::Attestation, DeploymentId}; use indexer_common::indexer_errors::{IndexerError, IndexerErrorCause, IndexerErrorCode}; use indexer_common::prelude::AttestationSigner; diff --git a/service/src/server/routes/cost.rs b/service/src/server/routes/cost.rs index caeb39ad..c1c30c89 100644 --- a/service/src/server/routes/cost.rs +++ b/service/src/server/routes/cost.rs @@ -8,7 +8,7 @@ use async_graphql_axum::{GraphQLRequest, GraphQLResponse}; use axum::extract::Extension; use serde::{Deserialize, Serialize}; use serde_json::Value; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; use crate::{ common::indexer_management::{self, CostModel}, diff --git a/service/src/server/routes/network.rs b/service/src/server/routes/network.rs index ce330c93..852a12ff 100644 --- a/service/src/server/routes/network.rs +++ b/service/src/server/routes/network.rs @@ -36,12 +36,10 @@ pub async fn network_queries( match server.network_subgraph.query::(&body).await { Ok(result) => Json(json!({ "data": result.data, - "errors": result.errors.map(|errors| { - errors + "errors": result.errors .into_iter() .map(|e| json!({ "message": e.message })) - .collect::>() - }), + .collect::>(), })) .into_response(), Err(e) => bad_request_response(&e.to_string()), diff --git a/service/src/server/routes/subgraphs.rs b/service/src/server/routes/subgraphs.rs index ec471964..2591e9aa 100644 --- a/service/src/server/routes/subgraphs.rs +++ b/service/src/server/routes/subgraphs.rs @@ -8,7 +8,7 @@ use axum::{ Json, }; use std::str::FromStr; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; use tracing::trace; use crate::{ diff --git a/tap-agent/Cargo.toml b/tap-agent/Cargo.toml index 2eb3d4a1..e2f220f4 100644 --- a/tap-agent/Cargo.toml +++ b/tap-agent/Cargo.toml @@ -9,8 +9,8 @@ name = "indexer-tap-agent" path = "src/main.rs" [dependencies] -alloy-primitives = "0.4.2" -alloy-sol-types = "0.4.2" +alloy-primitives = "0.5.2" +alloy-sol-types = "0.5.2" anyhow = "1.0.72" async-trait = "0.1.72" bigdecimal = { version = "0.4.2", features = ["serde"] } @@ -26,12 +26,17 @@ reqwest = "0.11.20" serde = "1.0.188" serde_json = "1.0.104" serde_yaml = "0.9.25" -sqlx = { version = "0.7.2", features = ["postgres", "runtime-tokio", "bigdecimal", "rust_decimal"] } -tap_aggregator = "0.1.6" -tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol.git", rev = "882ca394444b451538908b9996bf7d45869a1bb9" } +sqlx = { version = "0.7.2", features = [ + "postgres", + "runtime-tokio", + "bigdecimal", + "rust_decimal", +] } +tap_aggregator = "0.2.0" +tap_core = "0.7.0" thiserror = "1.0.44" tokio = { version = "1.33.0" } -toolshed = { git = "https://github.com/edgeandnode/toolshed", branch = "main", features = ["graphql"] } +thegraph = { git = "https://github.com/edgeandnode/toolshed", branch = "main" } tracing = "0.1.37" tracing-subscriber = { version = "0.3", features = [ "env-filter", diff --git a/tap-agent/src/config.rs b/tap-agent/src/config.rs index b292ce0c..975583fb 100644 --- a/tap-agent/src/config.rs +++ b/tap-agent/src/config.rs @@ -8,7 +8,7 @@ use bigdecimal::{BigDecimal, ToPrimitive}; use clap::{command, Args, Parser, ValueEnum}; use dotenvy::dotenv; use serde::{Deserialize, Serialize}; -use toolshed::thegraph::DeploymentId; +use thegraph::types::DeploymentId; use tracing::subscriber::{set_global_default, SetGlobalDefaultError}; use tracing_subscriber::{EnvFilter, FmtSubscriber}; diff --git a/tap-agent/src/tap/receipt_checks_adapter.rs b/tap-agent/src/tap/receipt_checks_adapter.rs index 0c0b0966..5df552dd 100644 --- a/tap-agent/src/tap/receipt_checks_adapter.rs +++ b/tap-agent/src/tap/receipt_checks_adapter.rs @@ -116,7 +116,7 @@ impl ReceiptChecksAdapterTrait for ReceiptChecksAdapter { Ok(true) } - async fn is_valid_gateway_id(&self, gateway_id: Address) -> Result { + async fn is_valid_sender_id(&self, sender_id: Address) -> Result { let escrow_accounts = self.escrow_accounts .value() @@ -126,7 +126,7 @@ impl ReceiptChecksAdapterTrait for ReceiptChecksAdapter { })?; Ok(escrow_accounts - .get(&gateway_id) + .get(&sender_id) .map_or(false, |balance| *balance > U256::from(0))) } } diff --git a/tap-agent/src/tap/receipt_storage_adapter.rs b/tap-agent/src/tap/receipt_storage_adapter.rs index 3586592c..2b144a03 100644 --- a/tap-agent/src/tap/receipt_storage_adapter.rs +++ b/tap-agent/src/tap/receipt_storage_adapter.rs @@ -97,6 +97,8 @@ impl ReceiptStorageAdapterTrait for ReceiptStorageAdapter { async fn retrieve_receipts_in_timestamp_range + Send>( &self, timestamp_range_ns: R, + // TODO: Make use of this limit in this function + _receipts_limit: Option, ) -> Result, Self::AdapterError> { let records = sqlx::query!( r#" @@ -210,7 +212,8 @@ mod test { // Retrieving receipts in timestamp range from the database, convert to json Value let recovered_received_receipt_vec = storage_adapter - .retrieve_receipts_in_timestamp_range(range) + // TODO: Make use of the receipt limit if it makes sense here + .retrieve_receipts_in_timestamp_range(range, None) .await? .iter() .map(|(id, received_receipt)| { diff --git a/tap-agent/src/tap/sender_allocation_relationship.rs b/tap-agent/src/tap/sender_allocation_relationship.rs index ad940aa5..22a929cb 100644 --- a/tap-agent/src/tap/sender_allocation_relationship.rs +++ b/tap-agent/src/tap/sender_allocation_relationship.rs @@ -283,7 +283,6 @@ impl SenderAllocationRelationship { async fn rav_requester_try(inner: &Arc) -> anyhow::Result<()> { loop { - // TODO: limit the number of receipts to aggregate per request. let RAVRequest { valid_receipts, previous_rav, @@ -291,7 +290,11 @@ impl SenderAllocationRelationship { expected_rav, } = inner .tap_manager - .create_rav_request(inner.config.tap.rav_request_timestamp_buffer_ms * 1_000_000) + .create_rav_request( + inner.config.tap.rav_request_timestamp_buffer_ms * 1_000_000, + // TODO: limit the number of receipts to aggregate per request. + None, + ) .await?; // TODO: Request compression and response decompression. Also a fancy user agent? diff --git a/tap-agent/src/tap/sender_allocation_relationships_manager.rs b/tap-agent/src/tap/sender_allocation_relationships_manager.rs index 5b71cf4e..6832a0fb 100644 --- a/tap-agent/src/tap/sender_allocation_relationships_manager.rs +++ b/tap-agent/src/tap/sender_allocation_relationships_manager.rs @@ -308,7 +308,7 @@ mod tests { subgraph_client::DeploymentDetails, }; use serde_json::json; - use toolshed::thegraph::DeploymentId; + use thegraph::types::DeploymentId; use wiremock::{ matchers::{body_string_contains, method}, Mock, MockServer, ResponseTemplate,