-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
339 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.