Skip to content

Commit

Permalink
feat: emergency indexer blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Jan 15, 2024
1 parent dc638d0 commit 2054aba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub struct Context {
pub network: GraphNetwork,
pub indexing_statuses: Eventual<Ptr<HashMap<Indexing, indexing::Status>>>,
pub attestation_domain: &'static Eip712Domain,
pub bad_indexers: &'static HashSet<Address>,
pub indexings_blocklist: Eventual<Ptr<HashSet<Indexing>>>,
pub isa_state: DoubleBufferReader<indexer_selection::State>,
pub observations: QueueWriter<Update>,
Expand Down Expand Up @@ -383,7 +384,7 @@ async fn handle_client_query_inner(
.value_immediate()
.unwrap_or_default();
candidates.retain(|candidate| {
if blocklist.contains(candidate) {
if blocklist.contains(candidate) || ctx.bad_indexers.contains(&candidate.indexer) {
indexer_errors.insert(candidate.indexer, IndexerError::Unavailable(NoStatus));
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions graph-gateway/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub struct Config {
/// Respect the payment state of API keys (disable for testnets)
pub api_key_payment_required: bool,
pub attestations: AttestationConfig,
/// List of indexer addresses to block. This should only be used temprorarily, to compensate for
/// indexer-selection imperfections.
pub bad_indexers: Vec<Address>,
pub chains: Vec<Chain>,
/// Ethereum RPC provider, or fixed exchange rate for testing
pub exchange_rate_provider: ExchangeRateProvider,
Expand Down
4 changes: 4 additions & 0 deletions graph-gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ async fn main() {
Eventual::from_value(Ptr::default())
};

let bad_indexers: &'static HashSet<Address> =
Box::leak(Box::new(config.bad_indexers.into_iter().collect()));

let indexing_statuses = indexing::statuses(
network.deployments.clone(),
http_client.clone(),
Expand Down Expand Up @@ -285,6 +288,7 @@ async fn main() {
network,
indexing_statuses,
attestation_domain,
bad_indexers,
indexings_blocklist,
block_caches,
observations: update_writer,
Expand Down

0 comments on commit 2054aba

Please sign in to comment.