Skip to content

feat: reduce budget on recurring requests #498

Open
@Theodus

Description

@Theodus

Since indexers do caching on their end, the gateway should detect recurring request hashes (potentially using requestCID in attestation) and reduce the budget on those queries once they meet some threshold.

Most queries will not meet this threshold. However, for the ones that do this will mitigate desires to cache query responses in the gateway. Rough pseudocode proposal:

pub struct Budgeter {
  // This must match the hashes of deterministic requests, including variables.
  // This can be cleared periodically, since nearly all entries will be short-lived.
  recurring_requests: RwLock<Set<Hash>>,
  ...
}
impl Budgeter {
  ...
  pub async fn budget(&self, hash: Hash) -> GRT {
    let mut budget = ...;
    if self.recurring_requests.read().await.contains(&hash) {
     budget *= 0.1;
    }
    budget
  }
  pub fn add_request(&mut self, hash: Hash) {
    self.recurring_requests.try_lock.insert(hash);
  }
}

open questions

  • How might this interact with auto-agora?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions