forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(da-clients): add Celestia client (matter-labs#2983)
## What ❔ This PR adds a Celestia DA client. The main complexity of this PR comes from our goal to lower the operational load and not run the Celestia light node (which is a default way of interacting with Celestia blockchain). This was done by adapting Astria's Celestia client implementation to our codebase and removing unneeded logical components. Note that Celestia's main communication protocol is gRPC, which means we have to import or maintain the proto definitions. I decided to reuse the generated `.rs` files from Astria's repo to remove the need to maintain the `.proto` files in our repo (not the cleanest way, but consider it a rather temporary solution). There is a [celestia-proto](https://github.com/eigerco/lumina/tree/main/proto) crate that has all the codegen that we need, but they don't generate the gRPC client definitions, only the types, so we can't use them atm. I will try to ask the team maintaining it to add such an option, then we would be able to remove all the codegen from our repo, and simply import it from celestia-proto. Example config: ``` da_client: celestia: api_node_url: http://grpc-mocha.pops.one:9090 namespace: 000000000000000000000000000000000000ca1de12a5e2d5beb9ba9 chain_id: mocha-4 timeout_ms: 10000 ``` secrets: ``` da: celestia: private_key: PRIVATE_KEY_WITHOUT_0x_PREFIX ``` ## Why ❔ To enable Celestia DA in ZK stack ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`.
- Loading branch information
1 parent
6c034f6
commit d88b875
Showing
44 changed files
with
4,004 additions
and
592 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 was deleted.
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,54 @@ | ||
use std::str::FromStr; | ||
|
||
use secrecy::{ExposeSecret, Secret}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct SeedPhrase(pub Secret<String>); | ||
|
||
impl PartialEq for SeedPhrase { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.0.expose_secret().eq(other.0.expose_secret()) | ||
} | ||
} | ||
|
||
impl FromStr for SeedPhrase { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(SeedPhrase(s.parse()?)) | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct PrivateKey(pub Secret<String>); | ||
|
||
impl PartialEq for PrivateKey { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.0.expose_secret().eq(other.0.expose_secret()) | ||
} | ||
} | ||
|
||
impl FromStr for PrivateKey { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(PrivateKey(s.parse()?)) | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct APIKey(pub Secret<String>); | ||
|
||
impl PartialEq for APIKey { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.0.expose_secret().eq(other.0.expose_secret()) | ||
} | ||
} | ||
|
||
impl FromStr for APIKey { | ||
type Err = anyhow::Error; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(APIKey(s.parse()?)) | ||
} | ||
} |
This file was deleted.
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,15 @@ | ||
use serde::Deserialize; | ||
use zksync_basic_types::secrets::PrivateKey; | ||
|
||
#[derive(Clone, Debug, Default, PartialEq, Deserialize)] | ||
pub struct CelestiaConfig { | ||
pub api_node_url: String, | ||
pub namespace: String, | ||
pub chain_id: String, | ||
pub timeout_ms: u64, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct CelestiaSecrets { | ||
pub private_key: PrivateKey, | ||
} |
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,12 +1,15 @@ | ||
use crate::{AvailConfig, ObjectStoreConfig}; | ||
use crate::{AvailConfig, CelestiaConfig, ObjectStoreConfig}; | ||
|
||
pub mod avail; | ||
pub mod celestia; | ||
|
||
pub const AVAIL_CLIENT_CONFIG_NAME: &str = "Avail"; | ||
pub const CELESTIA_CLIENT_CONFIG_NAME: &str = "Celestia"; | ||
pub const OBJECT_STORE_CLIENT_CONFIG_NAME: &str = "ObjectStore"; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub enum DAClientConfig { | ||
Avail(AvailConfig), | ||
Celestia(CelestiaConfig), | ||
ObjectStore(ObjectStoreConfig), | ||
} |
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
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.