Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[In Progress] Feat : added l3 appchain functions #199

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
54 changes: 52 additions & 2 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"crates/orchestrator",
"crates/da-clients/da-client-interface",
"crates/da-clients/ethereum",
"crates/da-clients/starknet",
"crates/prover-clients/prover-client-interface",
"crates/prover-clients/gps-fact-checker",
"crates/prover-clients/sharp-service",
Expand Down Expand Up @@ -95,13 +96,13 @@ hyper = { version = "0.14", features = ["full"] }
mockall = "0.13.0"
testcontainers = "0.18.0"
once_cell = "1.8"
appchain-core-contract-client = { git = "https://github.com/byteZorvin/zaun", branch = "type-update" }
appchain-core-contract-client = { git = "https://github.com/Mohiiit/zaun", rev="878cf6fac215c260858b070f72fb52a70bf5e460" }
crypto-bigint = { version = "0.5.5" }
env_logger = "0.11.5"
strum_macros = "0.26.4"
strum = "0.26.3"
async-std = { version = "1.13.0", features = ["attributes"] }

swiftness_proof_parser = "0.1.0"

# Instrumentation
opentelemetry = { version = "0.25.0", features = ["metrics", "logs"] }
Expand Down Expand Up @@ -147,6 +148,7 @@ majin-blob-types = { git = "https://github.com/AbdelStark/majin-blob", branch =
# Project
da-client-interface = { path = "crates/da-clients/da-client-interface" }
ethereum-da-client = { path = "crates/da-clients/ethereum" }
starknet-da-client = { path = "crates/da-clients/starknet" }

settlement-client-interface = { path = "crates/settlement-clients/settlement-client-interface" }
ethereum-settlement-client = { path = "crates/settlement-clients/ethereum" }
Expand Down
49 changes: 49 additions & 0 deletions crates/da-clients/starknet/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
name = "starknet-da-client"
version.workspace = true
edition.workspace = true

[dependencies]
# TODO: update this to the workspace
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "68952c0", features = [
"consensus",
"providers",
"rpc-client",
"transport-http",
"network",
"eips",
"signers",
"signer-wallet",
] }
async-trait = { workspace = true }
c-kzg = { workspace = true }
color-eyre = { workspace = true }
da-client-interface = { workspace = true }
dotenvy.workspace = true
mockall = { workspace = true }
reqwest = { workspace = true }
rstest = { workspace = true }
serde = { workspace = true, features = ["derive"] }
starknet = { workspace = true }
tokio = { workspace = true }
url = { workspace = true }
utils = { workspace = true }

#Instrumentation
opentelemetry = { workspace = true, features = ["metrics", "logs"] }
opentelemetry-appender-tracing = { workspace = true, default-features = false }
opentelemetry-otlp = { workspace = true, features = [
"tonic",
"metrics",
"logs",
] }
opentelemetry-semantic-conventions = { workspace = true }
opentelemetry_sdk = { workspace = true, features = ["rt-tokio", "logs"] }
tracing = { workspace = true }
tracing-core = { workspace = true, default-features = false }
tracing-opentelemetry = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }


[dev-dependencies]
tokio-test = "*"
56 changes: 56 additions & 0 deletions crates/da-clients/starknet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#![allow(missing_docs)]
#![allow(clippy::missing_docs_in_private_items)]

use std::str::FromStr;
use std::sync::Arc;

use async_trait::async_trait;
use color_eyre::Result;
use da_client_interface::{DaClient, DaVerificationStatus};
use mockall::automock;
use mockall::predicate::*;
use serde::{Deserialize, Serialize};
use starknet::providers::jsonrpc::HttpTransport;
use starknet::providers::JsonRpcClient;
use url::Url;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct StarknetDaValidatedArgs {
pub starknet_da_rpc_url: Url,
}

pub struct StarknetDaClient {
#[allow(dead_code)]
provider: Arc<JsonRpcClient<HttpTransport>>,
}

impl StarknetDaClient {
pub async fn new_with_args(starknet_da_params: &StarknetDaValidatedArgs) -> Self {
let client = JsonRpcClient::new(HttpTransport::new(
Url::from_str(starknet_da_params.starknet_da_rpc_url.as_str()).expect("invalid url provided"),
));
Self { provider: Arc::new(client) }
}
}

#[automock]
#[async_trait]
impl DaClient for StarknetDaClient {
async fn publish_state_diff(&self, _state_diff: Vec<Vec<u8>>, _to: &[u8; 32]) -> Result<String> {
// Here in case of starknet we are not publishing the state diff because we are doing it all
// together in proving and update_state job. So we don't need to send anything here.
Ok("NA".to_string())
}

async fn verify_inclusion(&self, _external_id: &str) -> Result<DaVerificationStatus> {
Ok(DaVerificationStatus::Verified)
}

async fn max_blob_per_txn(&self) -> u64 {
6
}

async fn max_bytes_per_blob(&self) -> u64 {
131072
}
}
5 changes: 4 additions & 1 deletion crates/orchestrator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ color-eyre = { workspace = true }
da-client-interface = { workspace = true }
dotenvy = { workspace = true }
ethereum-da-client = { workspace = true, optional = true }
starknet-da-client = { workspace = true, optional = true }
ethereum-settlement-client = { workspace = true }
futures = { workspace = true }
hex = { workspace = true }
Expand Down Expand Up @@ -69,6 +70,7 @@ strum_macros = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["sync", "macros", "rt-multi-thread"] }
swiftness_proof_parser = { workspace = true }

url = { workspace = true }
utils = { workspace = true }
Expand All @@ -94,8 +96,9 @@ tracing-opentelemetry = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[features]
default = ["ethereum", "with_mongodb", "with_sqs"]
default = ["ethereum", "with_mongodb", "with_sqs", "starknet"]
ethereum = ["ethereum-da-client"]
starknet = ["starknet-da-client"]
with_mongodb = ["mongodb"]
with_sqs = ["omniqueue"]
testing = []
Expand Down
3 changes: 3 additions & 0 deletions crates/orchestrator/src/cli/da/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use ethereum_da_client::EthereumDaValidatedArgs;
use starknet_da_client::StarknetDaValidatedArgs;

pub mod ethereum;
pub mod starknet;

#[derive(Debug, Clone)]
pub enum DaValidatedArgs {
Ethereum(EthereumDaValidatedArgs),
Starknet(StarknetDaValidatedArgs),
}
15 changes: 15 additions & 0 deletions crates/orchestrator/src/cli/da/starknet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use clap::Args;
use url::Url;

/// Parameters used to config Starknet.
#[derive(Debug, Clone, Args)]
#[group(requires_all = ["starknet_da_rpc_url"])]
pub struct StarknetDaCliArgs {
/// Use the Starknet DA layer.
#[arg(long)]
pub da_on_starknet: bool,

/// The RPC URL of the Ethereum node.
#[arg(env = "MADARA_ORCHESTRATOR_STARKNET_DA_RPC_URL", long)]
pub starknet_da_rpc_url: Option<Url>,
}
Loading