From b6b9dcd781770854942c63bece492b78ba7c5912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 20 Dec 2024 22:35:57 +0300 Subject: [PATCH] Remove sequencer client --- crates/sequencer-client/Cargo.toml | 40 -------- crates/sequencer-client/src/lib.rs | 151 ----------------------------- 2 files changed, 191 deletions(-) delete mode 100644 crates/sequencer-client/Cargo.toml delete mode 100644 crates/sequencer-client/src/lib.rs diff --git a/crates/sequencer-client/Cargo.toml b/crates/sequencer-client/Cargo.toml deleted file mode 100644 index 17b3a973e..000000000 --- a/crates/sequencer-client/Cargo.toml +++ /dev/null @@ -1,40 +0,0 @@ -[package] -name = "sequencer-client" -authors = { workspace = true } -edition = { workspace = true } -homepage = { workspace = true } -license = { workspace = true } -repository = { workspace = true } - -version = { workspace = true } -publish = false -readme = "README.md" -resolver = "2" - -[dependencies] -# 3rd-party dependencies -anyhow = { workspace = true } -hex = { workspace = true } -jsonrpsee = { workspace = true, features = ["http-client"] } -serde = { workspace = true } -serde_json = { workspace = true } -tokio = { workspace = true } -tracing = { workspace = true } - -# Reth Deps -reth-primitives = { workspace = true } -reth-rpc-types = { workspace = true } - -# Sovereign-SDK deps -sov-rollup-interface = { path = "../sovereign-sdk/rollup-interface" } - -# Citrea Deps -citrea-primitives = { path = "../primitives" } - -[dev-dependencies] -tokio = { workspace = true } - -[features] -default = [] -local = [] -native = ["sov-rollup-interface/native"] diff --git a/crates/sequencer-client/src/lib.rs b/crates/sequencer-client/src/lib.rs deleted file mode 100644 index f65317647..000000000 --- a/crates/sequencer-client/src/lib.rs +++ /dev/null @@ -1,151 +0,0 @@ -use std::ops::RangeInclusive; - -use citrea_primitives::types::SoftConfirmationHash; -use jsonrpsee::core::client::{ClientT, Error}; -use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; -use jsonrpsee::rpc_params; -use reth_primitives::{Bytes, B256}; -use serde::Deserialize; -use sov_rollup_interface::rpc::HexTx; -use sov_rollup_interface::soft_confirmation::SignedSoftConfirmation; -use tracing::instrument; - -/// Configuration for SequencerClient. -#[derive(Debug, Clone)] -pub struct SequencerClient { - /// Host config for soft confirmation - pub rpc_url: String, - /// Client object for soft confirmation - pub client: HttpClient, -} - -impl SequencerClient { - /// Creates the sequencer client - #[instrument(level = "trace")] - pub fn new(rpc_url: String) -> Self { - let client = HttpClientBuilder::default().build(&rpc_url).unwrap(); - Self { rpc_url, client } - } - - /// Gets l2 block given l2 height - #[instrument(level = "trace", skip(self), ret)] - pub async fn get_soft_confirmation( - &self, - num: u64, - ) -> anyhow::Result> { - let res: Result, Error> = self - .client - .request("ledger_getSoftConfirmationByNumber", rpc_params![num]) - .await; - - match res { - Ok(res) => Ok(res), - Err(e) => match e { - Error::Transport(e) => anyhow::Result::Err(Error::Transport(e).into()), - _ => Err(anyhow::anyhow!(e)), - }, - } - } - - /// Gets l2 blocks given a range - #[instrument(level = "trace", skip(self), ret)] - pub async fn get_soft_confirmation_range( - &self, - range: RangeInclusive, - ) -> anyhow::Result>> { - let res: Result>, Error> = self - .client - .request( - "ledger_getSoftConfirmationRange", - rpc_params![range.start(), range.end()], - ) - .await; - - match res { - Ok(res) => Ok(res), - Err(e) => match e { - Error::Transport(e) => anyhow::Result::Err(Error::Transport(e).into()), - _ => Err(anyhow::anyhow!(e)), - }, - } - } - - /// Gets l2 block height - #[instrument(level = "trace", skip(self), ret)] - pub async fn block_number(&self) -> Result { - self.client - .request("ledger_getHeadSoftConfirmationHeight", rpc_params![]) - .await - } - - /// Sends raw tx to sequencer - #[instrument(level = "trace", skip_all, ret)] - pub async fn send_raw_tx(&self, tx: Bytes) -> Result { - self.client - .request("eth_sendRawTransaction", rpc_params![tx]) - .await - } - - #[instrument(level = "trace", skip(self), ret)] - pub async fn get_tx_by_hash( - &self, - tx_hash: B256, - mempool_only: Option, - ) -> Result, Error> { - self.client - .request( - "eth_getTransactionByHash", - rpc_params![tx_hash, mempool_only], - ) - .await - } -} - -#[derive(Deserialize, Debug, Clone)] -#[serde(rename_all = "camelCase")] -pub struct GetSoftConfirmationResponse { - pub l2_height: u64, - #[serde(with = "hex::serde")] - pub hash: SoftConfirmationHash, - #[serde(with = "hex::serde")] - pub prev_hash: SoftConfirmationHash, - pub da_slot_height: u64, - #[serde(with = "hex::serde")] - pub da_slot_hash: [u8; 32], - #[serde(with = "hex::serde")] - pub da_slot_txs_commitment: [u8; 32], - #[serde(skip_serializing_if = "Option::is_none")] - pub txs: Option>, - #[serde(with = "hex::serde")] - pub state_root: Vec, - #[serde(with = "hex::serde")] - pub soft_confirmation_signature: Vec, - pub deposit_data: Vec, // Vec wrapper around deposit data - #[serde(with = "hex::serde")] - pub pub_key: Vec, - pub l1_fee_rate: u128, - pub timestamp: u64, -} - -impl From for SignedSoftConfirmation { - fn from(val: GetSoftConfirmationResponse) -> Self { - SignedSoftConfirmation::new( - val.l2_height, - val.hash, - val.prev_hash, - val.da_slot_height, - val.da_slot_hash, - val.da_slot_txs_commitment, - val.l1_fee_rate, - val.txs - .unwrap_or_default() - .into_iter() - .map(|tx| tx.tx) - .collect(), - val.deposit_data.into_iter().map(|tx| tx.tx).collect(), - val.soft_confirmation_signature, - val.pub_key, - val.timestamp, - ) - } -}