Skip to content

Commit e154fd3

Browse files
authored
Gusinacio/uniform config (#199)
* refactor!(common,service): rename scalar to tap Signed-off-by: Gustavo Inacio <[email protected]> * refactor!(tap-agent): inline sender endpoints Signed-off-by: Gustavo Inacio <[email protected]> * refactor(common): remove id from graph, use 1 Signed-off-by: Gustavo Inacio <[email protected]> * refactor!: use unified config Signed-off-by: Gustavo Inacio <[email protected]> * refactor: add warnings and use single value for buffer and timestamp error Signed-off-by: Gustavo Inacio <[email protected]> * test(config): add maximal config test Signed-off-by: Gustavo Inacio <[email protected]> * revert: use Scalar-Receipt again Signed-off-by: Gustavo Inacio <[email protected]> * style(config,tap-agent): clippy Signed-off-by: Gustavo Inacio <[email protected]> * refactor(config): add unit and comments Signed-off-by: Gustavo Inacio <[email protected]> * docs: remove outdated example service config Signed-off-by: Gustavo Inacio <[email protected]> * refactor(config): update checks for warnings Signed-off-by: Gustavo Inacio <[email protected]> * refactor: remove serde-inline-default Signed-off-by: Gustavo Inacio <[email protected]> * fix(config): use default values in grt Signed-off-by: Gustavo Inacio <[email protected]> * style(config): keep ethereum chains together Signed-off-by: Gustavo Inacio <[email protected]> --------- Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 41108d7 commit e154fd3

29 files changed

+927
-684
lines changed

Cargo.lock

Lines changed: 59 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["common", "service", "tap-agent"]
2+
members = ["common", "config", "service", "tap-agent"]
33
resolver = "2"
44

55
[profile.dev.package."*"]

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ We follow conventional semantics for package versioning. An indexer may set a mi
3737
1. **Review Release Notes**: Before upgrading, check the release notes for the new version to understand what changes, fixes, or new features are included.
3838
2. **Review Documentation**: Check the up-to-date documentation for an accurate reflection of the changes made during the upgrade.
3939
3. **Backup Configuration**: Save your current configuration files and any local modifications you've made to the existing codebase.
40-
4. **Deploy**: Replace the old executable or docker image with the new one and restart the service to apply the upgrade.
40+
4. **Deploy**: Replace the old executable or docker image with the new one and restart the service to apply the upgrade.
4141
5. **Monitor and Validate**: After the upgrade, monitor system behavior and performance metrics to validate that the service is running as expected.
4242

4343
These steps should ensure a smooth transition to the latest version of `indexer-service-rs`, harnessing new capabilities while maintaining system integrity.
@@ -46,13 +46,11 @@ These steps should ensure a smooth transition to the latest version of `indexer-
4646

4747
[Contributions guide](/contributing.md)
4848

49-
5049
### Supported request and response format examples
5150

52-
5351
```
5452
✗ curl http://localhost:7300/
55-
Ready to roll!
53+
Ready to roll!
5654
5755
✗ curl http://localhost:7300/health
5856
{"healthy":true}
@@ -78,27 +76,27 @@ Ready to roll!
7876
7977
# Subgraph health check
8078
✗ curl http://localhost:7300/subgraphs/health/QmVhiE4nax9i86UBnBmQCYDzvjWuwHShYh7aspGPQhU5Sj
81-
"Subgraph deployment is up to date"%
79+
"Subgraph deployment is up to date"%
8280
## Unfound subgraph
8381
✗ curl http://localhost:7300/subgraphs/health/QmacQnSgia4iDPWHpeY6aWxesRFdb8o5DKZUx96zZqEWrB
84-
"Invalid indexing status"%
82+
"Invalid indexing status"%
8583
8684
# Network queries
8785
# Checks for auth and configuration to serve-network-subgraph
88-
✗ curl -X POST -H 'Content-Type: application/json' -H 'Authorization: token-for-network-subgraph' --data '{"query": "{_meta{block{number}}}"}' http://localhost:7300/network
86+
✗ curl -X POST -H 'Content-Type: application/json' -H 'Authorization: token-for-network-subgraph' --data '{"query": "{_meta{block{number}}}"}' http://localhost:7300/network
8987
"Not enabled or authorized query"
9088
9189
# Indexing status resolver - Route supported root field queries to graph node status endpoint
92-
✗ curl -X POST -H 'Content-Type: application/json' --data '{"query": "{blockHashFromNumber(network:\"goerli\", blockNumber: 9069120)}"}' http://localhost:7300/status
93-
{"data":{"blockHashFromNumber":"e1e5472636db73ba5496aee098dc21310683c95eb30fc46f9ba6c36d8b28d58e"}}%
90+
✗ curl -X POST -H 'Content-Type: application/json' --data '{"query": "{blockHashFromNumber(network:\"goerli\", blockNumber: 9069120)}"}' http://localhost:7300/status
91+
{"data":{"blockHashFromNumber":"e1e5472636db73ba5496aee098dc21310683c95eb30fc46f9ba6c36d8b28d58e"}}%
9492
95-
# Indexing status resolver -
96-
✗ curl -X POST -H 'Content-Type: application/json' --data '{"query": "{indexingStatuses {subgraph health} }"}' http://localhost:7300/status
93+
# Indexing status resolver -
94+
✗ curl -X POST -H 'Content-Type: application/json' --data '{"query": "{indexingStatuses {subgraph health} }"}' http://localhost:7300/status
9795
{"data":{"indexingStatuses":[{"subgraph":"QmVhiE4nax9i86UBnBmQCYDzvjWuwHShYh7aspGPQhU5Sj","health":"healthy"},{"subgraph":"QmWVtsWk8Pqn3zY3czDjyoVreshRLmoz9jko3mQ4uvxQDj","health":"healthy"},{"subgraph":"QmacQnSgia4iDPWHpeY6aWxesRFdb8o5DKZUx96zZqEWrB","health":"healthy"}]}}
9896
9997
# Indexing status resolver - Filter out the unsupported queries
100-
✗ curl -X POST -H 'Content-Type: application/json' --data '{"query": "{_meta{block{number}}}"}' http://localhost:7300/status
101-
{"errors":[{"locations":[{"line":1,"column":2}],"message":"Type `Query` has no field `_meta`"}]}%
98+
✗ curl -X POST -H 'Content-Type: application/json' --data '{"query": "{_meta{block{number}}}"}' http://localhost:7300/status
99+
{"errors":[{"locations":[{"line":1,"column":2}],"message":"Type `Query` has no field `_meta`"}]}%
102100
103101
######## Cost server - read-only graphql query
104102
curl -X GET -H 'Content-Type: application/json' --data '{"query": "{ costModel(deployment: \"Qmb5Ysp5oCUXhLA8NmxmYKDAX2nCMnh7Vvb5uffb9n5vss\") { deployment model variables }} "}' http://localhost:7300/cost
@@ -109,8 +107,8 @@ curl -X GET -H 'Content-Type: application/json' --data '{"query": "{ costModel(d
109107
curl -X GET -H 'Content-Type: application/json' --data '{"query": "{ costModel(deployment: \"Qmb5Ysp5oCUXhLA8NmxmYKDAX2nCMnh7Vvb5uffb9n5vas\") { deployment model variables }} "}' http://localhost:7300/cost
110108
{"data":{"costModel":null}}%
111109
112-
curl -X GET -H 'Content-Type: application/json' --data '{"query": "{ costModel(deployment: \"Qmb5Ysp5oCUXhLA8NmxmYKDAX2nCMnh7Vvb5uffb9n5vss\") { deployment odel variables }} "}' http://localhost:7300/cost
113-
{"errors":[{"message":"Cannot query field \"odel\" on type \"CostModel\". Did you mean \"model\"?","locations":[{"line":1,"column":88}]}]}%
110+
curl -X GET -H 'Content-Type: application/json' --data '{"query": "{ costModel(deployment: \"Qmb5Ysp5oCUXhLA8NmxmYKDAX2nCMnh7Vvb5uffb9n5vss\") { deployment odel variables }} "}' http://localhost:7300/cost
111+
{"errors":[{"message":"Cannot query field \"odel\" on type \"CostModel\". Did you mean \"model\"?","locations":[{"line":1,"column":88}]}]}%
114112
115113
curl -X GET -H 'Content-Type: application/json' --data '{"query": "{ costModels(deployments: [\"Qmb5Ysp5oCUXhLA8NmxmYKDAX2nCMnh7Vvb5uffb9n5vss\"]) { deployment model variables }} "}' http://localhost:7300/cost
116114
{"data":{"costModels":[{"deployment":"0xbd499f7673ca32ef4a642207a8bebdd0fb03888cf2678b298438e3a1ae5206ea","model":"default => 0.00025;","variables":null}]}}%
@@ -125,13 +123,13 @@ curl -X GET -H 'Content-Type: application/json' --data '{"query": "{ costModels(
125123
- `postgres` database connection required to indexer management server database, shared with the indexer agent
126124
- No migration in indexer service as it might introduce conflicts to the database; indexer agent is solely responsible for database management.
127125

128-
129126
### Indexer common components
130127

131128
Temporarily live inside the indexer-service package under `src/common`.
132129

133130
Simple indexer management client to track NetworkSubgraph and postgres connection.
134-
- NetworkSubgraph instance track both remote API endpoint and local deployment query endpoint.
131+
132+
- NetworkSubgraph instance track both remote API endpoint and local deployment query endpoint.
135133
- TODO: query indexing status of local deployment, only use remote API as fallback.
136134
- Keeps cost model schema and resolvers with postgres and graphQL types: `costModel(deployment)` and `costModels(deployments)`. If deployments is empty, all cost models are returned.
137135
- Global cost model fallback used when specific deployments are queried
@@ -141,7 +139,7 @@ Simple indexer management client to track NetworkSubgraph and postgres connectio
141139

142140
Linked dependency could not be linked directly with git url "https://github.com/graphprotocol/indexer" and path "packages/indexer-native/native" at the same time, and could not access it on crates.io. So copid the folder to local repo with the version at https://github.com/graphprotocol/indexer/blob/972658b3ce8c512ad7b4dc575d29cd9d5377e3fe/packages/indexer-native/native.
143141

144-
Since indexer-service will be written in Rust and no need for typescript, indexer-native's neon build and util has been removed.
142+
Since indexer-service will be written in Rust and no need for typescript, indexer-native's neon build and util has been removed.
145143

146144
Component `NativeSignatureVerifier` renamed to `SignatureVerifier`.
147145

@@ -194,7 +192,7 @@ Temporarily live inside the indexer-service package under `src/types`
194192
- [ ] query timing logs
195193
- [x] Deployment health server
196194
- [x] query status endpoint and process result
197-
- [ ] Status server
195+
- [ ] Status server
198196
- [x] indexing status resolver - to query indexingStatuses
199197
- [ ] Filter for unsupported queries
200198
- [x] Cost server
@@ -211,7 +209,7 @@ Temporarily live inside the indexer-service package under `src/types`
211209
- [ ] Metrics
212210
- [x] Metrics setup
213211
- [x] serve basic indexer service metrics
214-
- [ ] Add cost model metrics
212+
- [ ] Add cost model metrics
215213
- [x] CLI args
216214
- [ ] App profiling
217215
- [ ] No gcloud profiling, can use `perf` to collect performance data.

common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ tower_governor = "0.3.2"
4343
tower-http = { version = "0.5.2", features = ["trace", "cors"] }
4444
tokio-util = "0.7.10"
4545
bigdecimal = "0.4.2"
46-
serde-inline-default = "0.2.0"
4746
thegraph-core = { version = "0.4.1", features = ["subgraph-client"] }
4847

4948
[dev-dependencies]

common/src/attestations/dispute_manager.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::subgraph_client::{Query, SubgraphClient};
1313

1414
pub fn dispute_manager(
1515
network_subgraph: &'static SubgraphClient,
16-
graph_network_id: u64,
1716
interval: Duration,
1817
) -> Eventual<Address> {
1918
#[derive(Deserialize)]
@@ -31,32 +30,26 @@ pub fn dispute_manager(
3130
timer(interval).map_with_retry(
3231
move |_| async move {
3332
let response = network_subgraph
34-
.query::<DisputeManagerResponse>(Query::new_with_variables(
33+
.query::<DisputeManagerResponse>(Query::new(
3534
r#"
36-
query network($id: ID!) {
37-
graphNetwork(id: $id) {
35+
query network {
36+
graphNetwork(id: 1) {
3837
disputeManager
3938
}
4039
}
4140
"#,
42-
[("id", graph_network_id.into())],
4341
))
4442
.await
4543
.map_err(|e| e.to_string())?;
4644

4745
response.map_err(|e| e.to_string()).and_then(|data| {
4846
data.graph_network
4947
.map(|network| network.dispute_manager)
50-
.ok_or_else(|| {
51-
format!("Network {} not found in network subgraph", graph_network_id)
52-
})
48+
.ok_or_else(|| "Network 1 not found in network subgraph".to_string())
5349
})
5450
},
5551
move |err: String| {
56-
warn!(
57-
"Failed to query dispute manager for network {}: {}",
58-
graph_network_id, err,
59-
);
52+
warn!("Failed to query dispute manager for network: {}", err,);
6053

6154
// Sleep for a bit before we retry
6255
sleep(interval.div_f32(2.0))
@@ -115,7 +108,7 @@ mod test {
115108
async fn test_parses_dispute_manager_from_network_subgraph_correctly() {
116109
let (network_subgraph, _mock_server) = setup_mock_network_subgraph().await;
117110

118-
let dispute_manager = dispute_manager(network_subgraph, 1, Duration::from_secs(60));
111+
let dispute_manager = dispute_manager(network_subgraph, Duration::from_secs(60));
119112

120113
assert_eq!(
121114
dispute_manager.value().await.unwrap(),

0 commit comments

Comments
 (0)