-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement gas relay mode and inclusion data for data attestation (
#3070) ## What ❔ This PR adds gas relay API support for gasless submission to the Avail network, it also provides the attestation implementation necessary for data attestation. ## Why ❔ Gas relay API support is required for Avail partners that choose to pay in a different token. Data attestation ensures that arbitrary tx data cannot be used for rollup finality and that no data withholding attack can occur. ## Checklist - [X] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [X] Documentation comments have been added / updated. - [X] Code has been formatted via `zk fmt` and `zk lint`. Supersedes #2987 --------- Co-authored-by: vibhurajeev <[email protected]> Co-authored-by: dimazhornyk <[email protected]> Co-authored-by: Dima Zhornyk <[email protected]>
- Loading branch information
1 parent
4629450
commit 561fc1b
Showing
15 changed files
with
512 additions
and
97 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
use std::str::FromStr; | ||
|
||
use secrecy::{ExposeSecret, Secret}; | ||
|
||
#[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 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,16 +1,38 @@ | ||
use serde::Deserialize; | ||
use zksync_basic_types::seed_phrase::SeedPhrase; | ||
use zksync_basic_types::{api_key::APIKey, seed_phrase::SeedPhrase}; | ||
|
||
pub const AVAIL_GAS_RELAY_CLIENT_NAME: &str = "GasRelay"; | ||
pub const AVAIL_FULL_CLIENT_NAME: &str = "FullClient"; | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize)] | ||
#[serde(tag = "avail_client")] | ||
pub enum AvailClientConfig { | ||
FullClient(AvailDefaultConfig), | ||
GasRelay(AvailGasRelayConfig), | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize)] | ||
pub struct AvailConfig { | ||
pub api_node_url: String, | ||
pub bridge_api_url: String, | ||
pub app_id: u32, | ||
pub timeout: usize, | ||
#[serde(flatten)] | ||
pub config: AvailClientConfig, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize)] | ||
pub struct AvailDefaultConfig { | ||
pub api_node_url: String, | ||
pub app_id: u32, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize)] | ||
pub struct AvailGasRelayConfig { | ||
pub gas_relay_api_url: String, | ||
pub max_retries: usize, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct AvailSecrets { | ||
pub seed_phrase: Option<SeedPhrase>, | ||
pub gas_relay_api_key: Option<APIKey>, | ||
} |
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.