Skip to content

Commit

Permalink
Add support for Saya deployments
Browse files Browse the repository at this point in the history
Integrated Saya deployment commands and configuration across CLI, GraphQL, and schema files. This allows users to create, update, delete, and describe Saya deployments, with detailed configurations and options specific to the Saya service.
  • Loading branch information
steebchen committed Sep 6, 2024
1 parent 55cf3eb commit e4c927e
Show file tree
Hide file tree
Showing 11 changed files with 611 additions and 98 deletions.
34 changes: 33 additions & 1 deletion cli/src/command/deployments/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clap::Args;
use slot::api::Client;
use slot::credential::Credentials;
use slot::graphql::deployments::create_deployment::CreateDeploymentCreateDeployment::{
KatanaConfig, MadaraConfig, ToriiConfig,
KatanaConfig, MadaraConfig, SayaConfig, ToriiConfig,
};
use slot::graphql::deployments::create_deployment::*;
use slot::graphql::deployments::CreateDeployment;
Expand Down Expand Up @@ -58,6 +58,7 @@ impl CreateArgs {
}),
torii: None,
madara: None,
saya: None,
}),
},
CreateServiceCommands::Torii(config) => CreateServiceInput {
Expand All @@ -73,6 +74,7 @@ impl CreateArgs {
index_pending: config.index_pending,
polling_interval: config.polling_interval,
}),
saya: None,
}),
},
CreateServiceCommands::Madara(config) => CreateServiceInput {
Expand All @@ -90,6 +92,31 @@ impl CreateArgs {
sealing: config.sealing.clone().map(|s| s.to_string()),
chain: config.chain.clone().map(|c| c.to_string()),
}),
saya: None,
}),
},
CreateServiceCommands::Saya(config) => CreateServiceInput {
type_: DeploymentService::saya,
version: config.version.clone(),
config: Some(CreateServiceConfigInput {
katana: None,
torii: None,
madara: None,
saya: Some(CreateSayaConfigInput {
mode: config.mode.clone(),
rpc_url: config.rpc_url.clone(),
registry: config.registry.clone(),
settlement_contract: config.settlement_contract.clone(),
world: config.world.clone().to_string(),
prover_url: config.prover_url.clone(),
store_proofs: config.store_proofs.unwrap_or(false),
starknet_url: config.starknet_url.clone(),
signer_key: config.signer_key.clone(),
signer_address: config.signer_address.clone(),
private_key: config.private_key.clone(),
batch_size: config.batch_size.unwrap_or(1),
start_block: config.start_block.unwrap_or(0),
}),
}),
},
};
Expand Down Expand Up @@ -124,6 +151,10 @@ impl CreateArgs {
if let Some(data) = res.data {
println!("Deployment success 🚀");
match data.create_deployment {
SayaConfig(config) => {
println!("\nConfiguration:");
println!(" RPC URL: {}", config.rpc_url);
}
ToriiConfig(config) => {
println!("\nConfiguration:");
println!(" World: {}", config.world);
Expand All @@ -149,6 +180,7 @@ impl CreateArgs {
CreateServiceCommands::Katana(_) => "katana",
CreateServiceCommands::Torii(_) => "torii",
CreateServiceCommands::Madara(_) => "madara",
CreateServiceCommands::Saya(_) => "saya",
};

println!(
Expand Down
2 changes: 2 additions & 0 deletions cli/src/command/deployments/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub enum Service {
Katana,
Torii,
Madara,
Saya,
}

#[derive(Debug, Args)]
Expand Down Expand Up @@ -49,6 +50,7 @@ impl DeleteArgs {
Service::Katana => DeploymentService::katana,
Service::Torii => DeploymentService::torii,
Service::Madara => DeploymentService::madara,
Service::Saya => DeploymentService::saya,
};

let request_body = DeleteDeployment::build_query(Variables {
Expand Down
7 changes: 6 additions & 1 deletion cli/src/command/deployments/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::services::Service;
use anyhow::Result;
use clap::Args;
use slot::graphql::deployments::describe_deployment::DescribeDeploymentDeploymentConfig::{
KatanaConfig, MadaraConfig, ToriiConfig,
KatanaConfig, MadaraConfig, SayaConfig, ToriiConfig,
};
use slot::graphql::deployments::{describe_deployment::*, DescribeDeployment};
use slot::graphql::{GraphQLQuery, Response};
Expand All @@ -26,6 +26,7 @@ impl DescribeArgs {
Service::Torii => DeploymentService::torii,
Service::Katana => DeploymentService::katana,
Service::Madara => DeploymentService::madara,
Service::Saya => DeploymentService::saya,
};

let request_body = DescribeDeployment::build_query(Variables {
Expand Down Expand Up @@ -77,6 +78,10 @@ impl DescribeArgs {
println!(" Version: {}", config.version);
println!(" RPC: {}", config.rpc);
}
SayaConfig(config) => {
println!("\nEndpoints:");
println!(" RPC URL: {}", config.rpc_url);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions cli/src/command/deployments/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl LogReader {
Service::Katana => DeploymentService::katana,
Service::Torii => DeploymentService::torii,
Service::Madara => DeploymentService::madara,
Service::Saya => DeploymentService::saya,
};

let request_body = DeploymentLogs::build_query(Variables {
Expand Down
7 changes: 7 additions & 0 deletions cli/src/command/deployments/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ use clap::{Subcommand, ValueEnum};
use self::{
katana::{KatanaAccountArgs, KatanaCreateArgs, KatanaForkArgs, KatanaUpdateArgs},
madara::MadaraCreateArgs,
saya::{SayaCreateArgs, SayaUpdateArgs},
torii::{ToriiCreateArgs, ToriiUpdateArgs},
};

mod katana;
mod madara;
mod saya;
mod torii;

#[derive(Debug, Subcommand, serde::Serialize)]
Expand All @@ -19,6 +21,8 @@ pub enum CreateServiceCommands {
Torii(ToriiCreateArgs),
#[command(about = "Madara deployment.")]
Madara(MadaraCreateArgs),
#[command(about = "Saya deployment.")]
Saya(SayaCreateArgs),
}

#[derive(Debug, Subcommand, serde::Serialize)]
Expand All @@ -28,6 +32,8 @@ pub enum UpdateServiceCommands {
Katana(KatanaUpdateArgs),
#[command(about = "Torii deployment.")]
Torii(ToriiUpdateArgs),
#[command(about = "Saya deployment.")]
Saya(SayaUpdateArgs),
}

#[derive(Debug, Subcommand, serde::Serialize)]
Expand All @@ -51,4 +57,5 @@ pub enum Service {
Katana,
Torii,
Madara,
Saya,
}
83 changes: 83 additions & 0 deletions cli/src/command/deployments/services/saya.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
use clap::Args;
use starknet::core::types::Felt;

#[derive(Clone, Debug, Args, serde::Serialize)]
#[command(next_help_heading = "Saya create options")]
pub struct SayaCreateArgs {
#[arg(long, short, value_name = "version")]
#[arg(help = "Service version to use.")]
pub version: Option<String>,

#[arg(long)]
#[arg(value_name = "mode")]
#[arg(help = "The mode to use for the deployment.")]
pub mode: String,

#[arg(long)]
#[arg(value_name = "rpc_url")]
#[arg(help = "The Katana RPC endpoint.")]
pub rpc_url: String,

#[arg(long)]
#[arg(value_name = "registry")]
#[arg(help = "Registry address.")]
pub registry: String,

#[arg(long)]
#[arg(value_name = "settlement_contract")]
#[arg(help = "Settlement contract address.")]
pub settlement_contract: String,

#[arg(long)]
#[arg(value_name = "world")]
#[arg(help = "World address.")]
pub world: Felt,

#[arg(long)]
#[arg(value_name = "start_block")]
#[arg(help = "Specify a block to start indexing from.")]
pub start_block: Option<i64>,

#[arg(long)]
#[arg(value_name = "prover_url")]
#[arg(help = "Prover URL.")]
pub prover_url: String,

#[arg(long)]
#[arg(value_name = "prover_key")]
#[arg(help = "Store proofs.")]
pub store_proofs: Option<bool>,

#[arg(long)]
#[arg(value_name = "starknet_url")]
#[arg(help = "Starknet URL.")]
pub starknet_url: String,

#[arg(long)]
#[arg(value_name = "signer_key")]
#[arg(help = "Signer key.")]
pub signer_key: String,

#[arg(long)]
#[arg(value_name = "signer_address")]
#[arg(help = "Signer address.")]
pub signer_address: String,

#[arg(long)]
#[arg(value_name = "private_key")]
#[arg(help = "Private key.")]
pub private_key: String,

#[arg(long)]
#[arg(value_name = "batch_size")]
#[arg(help = "Batch size.")]
pub batch_size: Option<i64>,
}

#[derive(Clone, Debug, Args, serde::Serialize)]
#[command(next_help_heading = "Saya update options")]
pub struct SayaUpdateArgs {
#[arg(long, short, value_name = "version")]
#[arg(help = "Service version to use.")]
pub version: Option<String>,
}
12 changes: 11 additions & 1 deletion cli/src/command/deployments/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use clap::Args;
use slot::api::Client;
use slot::credential::Credentials;
use slot::graphql::deployments::update_deployment::UpdateDeploymentUpdateDeployment::{
KatanaConfig, MadaraConfig, ToriiConfig,
KatanaConfig, MadaraConfig, SayaConfig, ToriiConfig,
};
use slot::graphql::deployments::update_deployment::{
self, UpdateKatanaConfigInput, UpdateServiceConfigInput, UpdateServiceInput,
Expand Down Expand Up @@ -50,6 +50,11 @@ impl UpdateArgs {
version: config.version.clone(),
config: Some(UpdateServiceConfigInput { katana: None }),
},
UpdateServiceCommands::Saya(config) => UpdateServiceInput {
type_: DeploymentService::saya,
version: config.version.clone(),
config: Some(UpdateServiceConfigInput { katana: None }),
},
};

let tier = match &self.tier {
Expand Down Expand Up @@ -96,12 +101,17 @@ impl UpdateArgs {
println!(" RPC: {}", config.rpc);
}
MadaraConfig => {} // TODO: implement
SayaConfig(config) => {
println!("\nConfiguration:");
println!(" RPC URL: {}", config.rpc_url);
}
}
}

let service = match &self.update_commands {
UpdateServiceCommands::Katana(_) => "katana",
UpdateServiceCommands::Torii(_) => "torii",
UpdateServiceCommands::Saya(_) => "saya",
};

println!(
Expand Down
Loading

0 comments on commit e4c927e

Please sign in to comment.