Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bootstrap/proxy/deployment.tf
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ resource "kubernetes_deployment_v1" "blockfrost_proxy" {
value = var.dolos_endpoints
}

env {
name = "SUBMITAPI_ENABLED"
value = var.submitapi_enabled
}

env {
name = "SUBMITAPI_PORT"
value = var.submitapi_port
}

env {
name = "SUBMITAPI_DNS"
value = var.submitapi_dns
}

volume_mount {
mount_path = "/certs"
name = "certs"
Expand Down
15 changes: 15 additions & 0 deletions bootstrap/proxy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ variable "dolos_endpoints" {
default = "\\/blocks\\/[A-z0-9]+\\/txs\\/?$,\\/blocks\\/[A-z0-9]+\\/?$,\\/addresses\\/[A-z0-9]+\\/utxos(\\?.*)?$"
}

variable "submitapi_enabled" {
type = bool
default = true
}

variable "submitapi_port" {
type = number
default = 8090
}

variable "submitapi_dns" {
type = string
default = "ext-submitapi-m1.svc.cluster.local"
}

variable "tolerations" {
type = list(object({
effect = string
Expand Down
1 change: 1 addition & 0 deletions operator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ mod test {
network: "preview".to_string(),
throughput_tier: "0".to_string(),
blockfrost_version: Some("v1".to_string()),
auth_token: None,
},
);
crd.metadata.namespace = Some("namespace".to_string());
Expand Down
14 changes: 14 additions & 0 deletions proxy/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ pub struct Config {
pub dolos_dns: String,
pub dolos_endpoints: Vec<Endpoint>,

// Submit API settings
pub submitapi_enabled: bool,
pub submitapi_port: u16,
pub submitapi_dns: String,

// Cache settings
pub cache_rules_path: PathBuf,
pub cache_db_path: String,
Expand Down Expand Up @@ -85,6 +90,12 @@ impl Config {
.split(',')
.map(|endpoint| Endpoint::new(endpoint).expect("Invalid dolos endpoint regex"))
.collect(),
submitapi_enabled: env::var("SUBMITAPI_ENABLED").unwrap_or("false".to_string()) == "true",
submitapi_port: env::var("SUBMITAPI_PORT")
.expect("SUBMITAPI_PORT must be set")
.parse()
.expect("SUBMITAPI_PORT must be a number"),
submitapi_dns: env::var("SUBMITAPI_DNS").expect("SUBMITAPI_DNS must be set"),
health_endpoint: "/dmtr_health".to_string(),
}
}
Expand Down Expand Up @@ -118,6 +129,9 @@ mod tests {
env::set_var("FORBIDDEN_ENDPOINTS", r"/network,/pools/\w+$");
env::set_var("DOLOS_PORT", "50051");
env::set_var("DOLOS_DNS", "ext-utxorpc-m1");
env::set_var("DOLOS_ENDPOINTS", r"/blocks/,/epochs/");
env::set_var("SUBMITAPI_PORT", "8090");
env::set_var("SUBMITAPI_DNS", "ext-submitapi-m1");

let config = Config::new();
assert!(config.forbidden_endpoints[0].matches("/network"));
Expand Down
17 changes: 16 additions & 1 deletion proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ impl BlockfrostProxy {
fn should_use_dolos(&self, network: &str, path: &str) -> bool {
network != "vector-testnet" && self.config.dolos_enabled && self.is_dolos_path(path)
}

fn is_submit_api_path(&self, path: &str) -> bool {
path == "/tx/submit"
}

fn should_use_submit_api(&self, path: &str) -> bool {
self.config.submitapi_enabled && self.is_submit_api_path(path)
}
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -220,7 +228,14 @@ impl ProxyHttp for BlockfrostProxy {

ctx.consumer = consumer.unwrap();

if self.should_use_dolos(&ctx.consumer.network, path) {
if self.should_use_submit_api(path) {
ctx.instance = format!(
//eg: submitapi-cardano-mainnet.ext-submitapi-m1.svc.cluster.local:8090
"submitapi-{}.{}:{}",
ctx.consumer.network, self.config.submitapi_dns, self.config.submitapi_port
);
ctx.resolved_by = "submitapi".to_string();
} else if self.should_use_dolos(&ctx.consumer.network, path) {
ctx.instance = format!(
//eg: internal-cardano-mainnet-minibf.ext-utxorpc-m1.svc.cluster.local:3001
"internal-{}-minibf.{}:{}",
Expand Down