From 36bca56f9b70aeda87e1021cbeb34a2b88f24fab Mon Sep 17 00:00:00 2001 From: Dima Zhornyk <55756184+dimazhornyk@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:27:02 +0100 Subject: [PATCH] feat: Avail gas relay upgrade (#3601) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ This PR upgrades Avail Turbo DA from v0.1 to v1 with significant API changes and improvements to the authentication system. The upgrade includes a complete overhaul of the API endpoints structure, authentication mechanism (moving from JWT to API keys), and internal architecture improvements. ## Why ❔ Improve security through better API key management and support for multiple keys per user Enhance performance with better latency and higher throughput capabilities Create a more maintainable and extensible codebase through modular design Establish proper API versioning to better manage future updates and backwards compatibility Standardize endpoint structures by removing redundant path segments ## Is this a breaking change? - [ ] Yes - [x] No ## Operational changes ## Checklist - [ ] 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 `zkstack dev fmt` and `zkstack dev lint`. --- core/node/da_clients/src/avail/sdk.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/node/da_clients/src/avail/sdk.rs b/core/node/da_clients/src/avail/sdk.rs index 9aaab0c3ae54..d1de2b1b9925 100644 --- a/core/node/da_clients/src/avail/sdk.rs +++ b/core/node/da_clients/src/avail/sdk.rs @@ -443,14 +443,14 @@ impl GasRelayClient { } pub(crate) async fn post_data(&self, data: Vec) -> anyhow::Result<(H256, u64)> { - let submit_url = format!("{}/user/submit_raw_data?token=ethereum", &self.api_url); + let submit_url = format!("{}/v1/submit_raw_data", &self.api_url); // send the data to the gas relay let submit_response = self .api_client .post(&submit_url) .body(Bytes::from(data)) - .header("Content-Type", "text/plain") - .header("Authorization", format!("Bearer {}", self.api_key)) + .header("Content-Type", "application/octet-stream") + .header("x-api-key", &self.api_key) .send() .await .context("Failed to submit data to the gas relay")?; @@ -472,7 +472,7 @@ impl GasRelayClient { }; let status_url = format!( - "{}/user/get_submission_info?submission_id={}", + "{}/v1/get_submission_info?submission_id={}", self.api_url, submit_response.submission_id ); @@ -480,7 +480,7 @@ impl GasRelayClient { let status_response = (|| async { self.api_client .get(&status_url) - .header("Authorization", format!("Bearer {}", self.api_key)) + .header("x-api-key", &self.api_key) .send() .await })