Skip to content

Commit

Permalink
refactor: move fee selection out of indexer selection (#419)
Browse files Browse the repository at this point in the history
This removes Agora (and therefore GraphQL-specific) cost models from
indexer-selection. The fee negotiation step now happens before indexer
selections (and no longer requires a retry). For now, the interaction
between budgeting & candidate fees is simple, but that's acceptable for
now since we are paying indexers more than they are requesting. Volume
discounting has been removed entirely.
  • Loading branch information
Theodus authored Nov 20, 2023
1 parent 936a7ad commit 3105fdf
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 615 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ debug = true
[workspace.dependencies]
anyhow = "1.0"
alloy-primitives = { version = "0.4.2", features = ["serde"] }
eventuals = "0.6.7"
rand = { version = "0.8", features = ["small_rng"] }
reqwest = { version = "0.11", default-features = false, features = [
"json",
Expand Down
7 changes: 5 additions & 2 deletions graph-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ axum = { version = "0.6.15", default-features = false, features = [
"original-uri",
] }
chrono = { version = "0.4", default-features = false, features = ["clock"] }
cost-model = { git = "https://github.com/graphprotocol/agora", rev = "9984f9e" }
ethers = { version = "2.0.10", default-features = false, features = ["abigen"] }
eventuals.workspace = true
eventuals = "0.6.7"
faster-hex = "0.8.0"
futures = "0.3"
graph-subscriptions = { git = "https://github.com/edgeandnode/subscription-payments", rev = "334d18b" }
graphql = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-v0.1.0" }
graphql-http = { git = "https://github.com/edgeandnode/toolshed.git", tag = "graphql-http-v0.1.0", features = ["http-reqwest"] }
graphql-http = { git = "https://github.com/edgeandnode/toolshed.git", tag = "graphql-http-v0.1.0", features = [
"http-reqwest",
] }
hex = "0.4"
indexer-selection = { path = "../indexer-selection" }
indoc = "2.0.3"
Expand Down
10 changes: 6 additions & 4 deletions graph-gateway/src/block_constraints.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::collections::{BTreeMap, BTreeSet};

use alloy_primitives::{BlockHash, BlockNumber};
use cost_model::Context;
use graphql::graphql_parser::query::{
Definition, Document, OperationDefinition, Selection, Text, Value,
};
use graphql::{IntoStaticValue as _, QueryVariables, StaticValue};
use indexer_selection::UnresolvedBlock;
use itertools::Itertools as _;
use serde_json::{self, json};
use toolshed::thegraph::BlockPointer;

use indexer_selection::{Context, UnresolvedBlock};

#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum BlockConstraint {
Unconstrained,
Expand All @@ -29,7 +29,9 @@ impl BlockConstraint {
}
}

pub fn block_constraints<'c>(context: &'c Context<'c>) -> Option<BTreeSet<BlockConstraint>> {
pub fn block_constraints<'c>(
context: &'c Context<'c, String>,
) -> Option<BTreeSet<BlockConstraint>> {
let mut constraints = BTreeSet::new();
let vars = &context.variables;
// ba6c90f1-3baf-45be-ac1c-f60733404436
Expand Down Expand Up @@ -72,7 +74,7 @@ pub fn block_constraints<'c>(context: &'c Context<'c>) -> Option<BTreeSet<BlockC
}

pub fn make_query_deterministic(
mut ctx: Context<'_>,
mut ctx: Context<'_, String>,
resolved: &BTreeSet<BlockPointer>,
latest: &BlockPointer,
) -> Option<String> {
Expand Down
Loading

0 comments on commit 3105fdf

Please sign in to comment.