Skip to content

Commit

Permalink
fix: git rebase
Browse files Browse the repository at this point in the history
commit-id:ddf37cb7
  • Loading branch information
lambda-0x committed Nov 14, 2024
1 parent d4daef3 commit e263f2f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 119 deletions.
28 changes: 28 additions & 0 deletions Cargo.lock

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

117 changes: 1 addition & 116 deletions bin/torii/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;

use anyhow::Context;
use camino::Utf8PathBuf;
use clap::Parser;
use clap::{ArgAction, Parser};
use dojo_metrics::exporters::prometheus::PrometheusRecorder;
use dojo_world::contracts::world::WorldContractReader;
use sqlx::sqlite::{
Expand Down Expand Up @@ -48,111 +46,6 @@ use url::{form_urlencoded, Url};

pub(crate) const LOG_TARGET: &str = "torii::cli";

/// Dojo World Indexer
#[derive(Parser, Debug)]
#[command(name = "torii", author, version, about, long_about = None)]
struct Args {
/// The world to index
#[arg(short, long = "world", env = "DOJO_WORLD_ADDRESS")]
world_address: Option<Felt>,

/// The sequencer rpc endpoint to index.
#[arg(long, value_name = "URL", default_value = ":5050", value_parser = parse_url)]
rpc: Url,

/// Database filepath (ex: indexer.db). If specified file doesn't exist, it will be
/// created. Defaults to in-memory database
#[arg(short, long, default_value = "")]
database: String,

/// Address to serve api endpoints at.
#[arg(long, value_name = "SOCKET", default_value = "0.0.0.0:8080", value_parser = parse_socket_address)]
addr: SocketAddr,

/// Port to serve Libp2p TCP & UDP Quic transports
#[arg(long, value_name = "PORT", default_value = "9090")]
relay_port: u16,

/// Port to serve Libp2p WebRTC transport
#[arg(long, value_name = "PORT", default_value = "9091")]
relay_webrtc_port: u16,

/// Port to serve Libp2p WebRTC transport
#[arg(long, value_name = "PORT", default_value = "9092")]
relay_websocket_port: u16,

/// Path to a local identity key file. If not specified, a new identity will be generated
#[arg(long, value_name = "PATH")]
relay_local_key_path: Option<String>,

/// Path to a local certificate file. If not specified, a new certificate will be generated
/// for WebRTC connections
#[arg(long, value_name = "PATH")]
relay_cert_path: Option<String>,

/// Specify allowed origins for api endpoints (comma-separated list of allowed origins, or "*"
/// for all)
#[arg(long)]
#[arg(value_delimiter = ',')]
allowed_origins: Option<Vec<String>>,

/// The external url of the server, used for configuring the GraphQL Playground in a hosted
/// environment
#[arg(long, value_parser = parse_url)]
external_url: Option<Url>,

/// Enable Prometheus metrics.
///
/// The metrics will be served at the given interface and port.
#[arg(long, value_name = "SOCKET", value_parser = parse_socket_address, help_heading = "Metrics")]
metrics: Option<SocketAddr>,

/// Open World Explorer on the browser.
#[arg(long)]
explorer: bool,

/// Chunk size of the events page when indexing using events
#[arg(long, default_value = "1024")]
events_chunk_size: u64,

/// Number of blocks to process before commiting to DB
#[arg(long, default_value = "10240")]
blocks_chunk_size: u64,

/// Enable indexing pending blocks
#[arg(long, action = ArgAction::Set, default_value_t = true)]
index_pending: bool,

/// Polling interval in ms
#[arg(long, default_value = "500")]
polling_interval: u64,

/// Max concurrent tasks
#[arg(long, default_value = "100")]
max_concurrent_tasks: usize,

/// Whether or not to index world transactions
#[arg(long, action = ArgAction::Set, default_value_t = false)]
index_transactions: bool,

/// Whether or not to index raw events
#[arg(long, action = ArgAction::Set, default_value_t = true)]
index_raw_events: bool,

/// ERC contract addresses to index
#[arg(long, value_parser = parse_erc_contracts)]
#[arg(conflicts_with = "config")]
contracts: Option<std::vec::Vec<Contract>>,

/// Configuration file
#[arg(long)]
config: Option<PathBuf>,

/// Path to a directory to store ERC artifacts
#[arg(long)]
artifacts_path: Option<Utf8PathBuf>,
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut args = ToriiArgs::parse().with_config_file()?;
Expand Down Expand Up @@ -217,19 +110,11 @@ async fn main() -> anyhow::Result<()> {
// Get world address
let world = WorldContractReader::new(world_address, provider.clone());

// let (mut executor, sender) = Executor::new(pool.clone(), shutdown_tx.clone()).await?;
let contracts = args
.indexing
.contracts
.iter()
.map(|contract| (contract.address, contract.r#type))
.collect();

let (mut executor, sender) = Executor::new(
pool.clone(),
shutdown_tx.clone(),
provider.clone(),
args.max_concurrent_tasks,
args.indexing.max_concurrent_tasks,
)
.await?;
let executor_handle = tokio::spawn(async move { executor.run().await });
Expand Down
5 changes: 3 additions & 2 deletions crates/torii/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ version.workspace = true

[dependencies]
anyhow.workspace = true
camino.workspace = true
clap.workspace = true
dojo-utils.workspace = true
serde.workspace = true
starknet.workspace = true
torii-core.workspace = true
toml.workspace = true
torii-core.workspace = true
url.workspace = true

[dev-dependencies]
Expand All @@ -21,4 +22,4 @@ camino.workspace = true

[features]
default = [ "server" ]
server = [ ]
server = [ ]
5 changes: 5 additions & 0 deletions crates/torii/cli/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

use anyhow::Result;
use camino::Utf8PathBuf;
use clap::Parser;
use dojo_utils::parse::parse_url;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -47,6 +48,10 @@ pub struct ToriiArgs {
#[arg(long, help = "Configuration file to setup Torii.")]
pub config: Option<PathBuf>,

/// Path to a directory to store ERC artifacts
#[arg(long)]
pub artifacts_path: Option<Utf8PathBuf>,

#[command(flatten)]
pub indexing: IndexingOptions,

Expand Down
1 change: 0 additions & 1 deletion crates/torii/graphql/src/tests/subscription_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ mod tests {
use torii_core::sql::cache::ModelCache;
use torii_core::sql::utils::felts_to_sql_string;
use torii_core::sql::Sql;
use torii_core::types::ContractType;
use torii_core::types::{Contract, ContractType};
use url::Url;

Expand Down

0 comments on commit e263f2f

Please sign in to comment.