From 24b18d989e9b8d10fa3273b545c28211e5224253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erce=20Can=20Bekt=C3=BCre?= Date: Fri, 20 Dec 2024 23:16:44 +0300 Subject: [PATCH] Also add derive rpc macro pr --- bin/citrea/src/test_rpc.rs | 3 +- bin/citrea/tests/test_client/mod.rs | 4 +- crates/ethereum-rpc/src/lib.rs | 2 +- crates/fullnode/src/runner.rs | 6 +- crates/prover/src/runner.rs | 6 +- .../full-node/db/sov-db/src/ledger_db/rpc.rs | 6 +- .../full-node/sov-ledger-rpc/src/lib.rs | 124 ++++++++- .../full-node/sov-ledger-rpc/src/server.rs | 258 ++++++++---------- .../sov-ledger-rpc/tests/empty_ledger.rs | 8 +- .../src/runtime_rpc.rs | 10 +- .../rollup-interface/src/node/rpc/mod.rs | 5 +- 11 files changed, 261 insertions(+), 171 deletions(-) diff --git a/bin/citrea/src/test_rpc.rs b/bin/citrea/src/test_rpc.rs index 8e274001a..d622100db 100644 --- a/bin/citrea/src/test_rpc.rs +++ b/bin/citrea/src/test_rpc.rs @@ -74,8 +74,7 @@ fn test_helper( .await .unwrap(); let addr = server.local_addr().unwrap(); - let server_rpc_module = - sov_ledger_rpc::server::rpc_module::(ledger_db).unwrap(); + let server_rpc_module = sov_ledger_rpc::server::create_rpc_module(ledger_db); let _server_handle = server.start(server_rpc_module); let rpc_config = RpcConfig { diff --git a/bin/citrea/tests/test_client/mod.rs b/bin/citrea/tests/test_client/mod.rs index e31ab7561..c940c1a6d 100644 --- a/bin/citrea/tests/test_client/mod.rs +++ b/bin/citrea/tests/test_client/mod.rs @@ -18,8 +18,8 @@ use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, TxHash, TxKind, // use reth_rpc_types::TransactionReceipt; use reth_rpc_types::trace::geth::{GethDebugTracingOptions, GethTrace}; use reth_rpc_types::RichBlock; -use sov_ledger_rpc::client::RpcClient; use sov_ledger_rpc::HexHash; +use sov_ledger_rpc::LedgerRpcClient; use sov_rollup_interface::rpc::{ LastVerifiedProofResponse, ProofResponse, SequencerCommitmentResponse, SoftConfirmationResponse, SoftConfirmationStatus, VerifiedProofResponse, @@ -519,7 +519,7 @@ impl TestClient { pub(crate) async fn ledger_get_last_scanned_l1_height(&self) -> u64 { self.http_client - .request("ledger_getLastScannedL1Hieght", rpc_params![]) + .request("ledger_getLastScannedL1Height", rpc_params![]) .await .unwrap() } diff --git a/crates/ethereum-rpc/src/lib.rs b/crates/ethereum-rpc/src/lib.rs index e6dac6f5e..313a9f662 100644 --- a/crates/ethereum-rpc/src/lib.rs +++ b/crates/ethereum-rpc/src/lib.rs @@ -21,7 +21,7 @@ use reth_rpc_types::trace::geth::{GethDebugTracingOptions, GethTrace}; use reth_rpc_types::{FeeHistory, Index}; use serde_json::json; use sov_db::ledger_db::{LedgerDB, SharedLedgerOps}; -use sov_ledger_rpc::client::RpcClient; +use sov_ledger_rpc::LedgerRpcClient; use sov_modules_api::da::BlockHeaderTrait; use sov_modules_api::utils::to_jsonrpsee_error_object; use sov_modules_api::WorkingSet; diff --git a/crates/fullnode/src/runner.rs b/crates/fullnode/src/runner.rs index 9dc266b57..d8b99a96d 100644 --- a/crates/fullnode/src/runner.rs +++ b/crates/fullnode/src/runner.rs @@ -18,7 +18,7 @@ use jsonrpsee::RpcModule; use reth_primitives::U64; use sov_db::ledger_db::NodeLedgerOps; use sov_db::schema::types::{BatchNumber, SlotNumber}; -use sov_ledger_rpc::client::RpcClient; +use sov_ledger_rpc::LedgerRpcClient; use sov_modules_api::Context; use sov_modules_stf_blueprint::StfBlueprintTrait; use sov_rollup_interface::da::{BlockHeaderTrait, DaSpec}; @@ -451,10 +451,10 @@ async fn sync_l2( let inner_client = &sequencer_client; let soft_confirmations = match retry_backoff(exponential_backoff.clone(), || async move { match inner_client - .get_soft_confirmation_range(( + .get_soft_confirmation_range( U64::from(l2_height), U64::from(l2_height + sync_blocks_count - 1), - )) + ) .await { Ok(soft_confirmations) => { diff --git a/crates/prover/src/runner.rs b/crates/prover/src/runner.rs index 5bcb3e99b..3926b90c7 100644 --- a/crates/prover/src/runner.rs +++ b/crates/prover/src/runner.rs @@ -19,7 +19,7 @@ use jsonrpsee::RpcModule; use reth_primitives::U64; use sov_db::ledger_db::ProverLedgerOps; use sov_db::schema::types::{BatchNumber, SlotNumber}; -use sov_ledger_rpc::client::RpcClient; +use sov_ledger_rpc::LedgerRpcClient; use sov_modules_api::storage::HierarchicalStorageManager; use sov_modules_api::{Context, SlotData}; use sov_modules_stf_blueprint::StfBlueprintTrait; @@ -475,10 +475,10 @@ async fn sync_l2( let inner_client = &sequencer_client; let soft_confirmations = match retry_backoff(exponential_backoff.clone(), || async move { let soft_confirmations = inner_client - .get_soft_confirmation_range(( + .get_soft_confirmation_range( U64::from(l2_height), U64::from(l2_height + sync_blocks_count - 1), - )) + ) .await; match soft_confirmations { diff --git a/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/rpc.rs b/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/rpc.rs index 5864db50f..e12fe8756 100644 --- a/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/rpc.rs +++ b/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/rpc.rs @@ -1,4 +1,3 @@ -use serde::de::DeserializeOwned; use sov_rollup_interface::rpc::{ sequencer_commitment_to_response, LastVerifiedProofResponse, LedgerRpcProvider, ProofResponse, SequencerCommitmentResponse, SoftConfirmationIdentifier, SoftConfirmationResponse, @@ -115,6 +114,7 @@ impl LedgerRpcProvider for LedgerDB { None => Ok(sov_rollup_interface::rpc::SoftConfirmationStatus::Trusted), } } + fn get_slot_number_by_hash(&self, hash: [u8; 32]) -> Result, anyhow::Error> { self.db.get::(&hash).map(|v| v.map(|a| a.0)) } @@ -201,6 +201,10 @@ impl LedgerRpcProvider for LedgerDB { let next_ids = self.get_next_items_numbers(); Ok(next_ids.soft_confirmation_number.saturating_sub(1)) } + + fn get_l2_genesis_state_root(&self) -> Result>, anyhow::Error> { + self.get_l2_state_root(0) + } } impl LedgerDB { diff --git a/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/lib.rs b/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/lib.rs index d75704b82..d76e6f26a 100644 --- a/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/lib.rs +++ b/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/lib.rs @@ -1,11 +1,16 @@ #![forbid(unsafe_code)] +use jsonrpsee::core::RpcResult; +use jsonrpsee::proc_macros::rpc; +use reth_primitives::U64; +use sov_rollup_interface::rpc::{ + LastVerifiedProofResponse, ProofResponse, SequencerCommitmentResponse, + SoftConfirmationResponse, SoftConfirmationStatus, VerifiedProofResponse, +}; + #[cfg(feature = "server")] pub mod server; -#[cfg(feature = "client")] -pub mod client; - /// A 32-byte hash [`serde`]-encoded as a hex string optionally prefixed with /// `0x`. See [`sov_rollup_interface::rpc::utils::rpc_hex`]. #[derive(Debug, Copy, Clone, serde::Serialize, serde::Deserialize)] @@ -16,3 +21,116 @@ impl From<[u8; 32]> for HexHash { Self(v) } } + +/// A [`jsonrpsee`] trait for interacting with the ledger JSON-RPC API. +/// +/// Client and server implementations are automatically generated by +/// [`jsonrpsee`], see [`LedgerRpcClient`] and [`LedgerRpcServer`]. +/// +/// For more information about the specific methods, see the +/// [`sov_rollup_interface::rpc`] module. +#[cfg_attr( + all(feature = "server", feature = "client"), + rpc(server, client, namespace = "ledger") +)] +#[cfg_attr( + all(feature = "server", not(feature = "client")), + rpc(server, namespace = "ledger") +)] +#[cfg_attr( + all(not(feature = "server"), feature = "client"), + rpc(client, namespace = "ledger") +)] +pub trait LedgerRpc { + /// Gets a single soft confirmation by number. + #[method(name = "getSoftConfirmationByNumber")] + #[blocking] + fn get_soft_confirmation_by_number( + &self, + number: U64, + ) -> RpcResult>; + + /// Gets a single soft confirmation by hash. + #[method(name = "getSoftConfirmationByHash")] + #[blocking] + fn get_soft_confirmation_by_hash( + &self, + hash: HexHash, + ) -> RpcResult>; + + /// Gets all soft confirmations with numbers `range.start` to `range.end`. + #[method(name = "getSoftConfirmationRange")] + #[blocking] + fn get_soft_confirmation_range( + &self, + start: U64, + end: U64, + ) -> RpcResult>>; + + /// Gets a single event by number. + #[method(name = "getSoftConfirmationStatus")] + #[blocking] + fn get_soft_confirmation_status( + &self, + soft_confirmation_receipt: U64, + ) -> RpcResult; + + /// Gets the L2 genesis state root. + #[method(name = "getL2GenesisStateRoot")] + #[blocking] + fn get_l2_genesis_state_root(&self) -> RpcResult>>; + + /// Gets the commitments in the DA slot with the given height. + #[method(name = "getSequencerCommitmentsOnSlotByNumber")] + #[blocking] + fn get_sequencer_commitments_on_slot_by_number( + &self, + height: U64, + ) -> RpcResult>>; + + /// Gets the commitments in the DA slot with the given hash. + #[method(name = "getSequencerCommitmentsOnSlotByHash")] + #[blocking] + fn get_sequencer_commitments_on_slot_by_hash( + &self, + hash: HexHash, + ) -> RpcResult>>; + + /// Gets proof by slot height. + #[method(name = "getProofsBySlotHeight")] + #[blocking] + fn get_proofs_by_slot_height(&self, height: U64) -> RpcResult>>; + + /// Gets proof by slot hash. + #[method(name = "getProofsBySlotHash")] + #[blocking] + fn get_proofs_by_slot_hash(&self, hash: HexHash) -> RpcResult>>; + + /// Gets the height pf most recent committed soft confirmation. + #[method(name = "getHeadSoftConfirmation")] + #[blocking] + fn get_head_soft_confirmation(&self) -> RpcResult>; + + /// Gets the height pf most recent committed soft confirmation. + #[method(name = "getHeadSoftConfirmationHeight")] + #[blocking] + fn get_head_soft_confirmation_height(&self) -> RpcResult; + + /// Gets verified proofs by slot height + #[method(name = "getVerifiedProofsBySlotHeight")] + #[blocking] + fn get_verified_proofs_by_slot_height( + &self, + height: U64, + ) -> RpcResult>>; + + /// Gets last verified proog + #[method(name = "getLastVerifiedProof")] + #[blocking] + fn get_last_verified_proof(&self) -> RpcResult>; + + /// Get last scanned l1 height + #[method(name = "getLastScannedL1Height")] + #[blocking] + fn get_last_scanned_l1_height(&self) -> RpcResult; +} diff --git a/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/server.rs b/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/server.rs index 549ac34d9..9d2efee20 100644 --- a/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/server.rs +++ b/crates/sovereign-sdk/full-node/sov-ledger-rpc/src/server.rs @@ -1,175 +1,145 @@ -//! A JSON-RPC server implementation for any [`LedgerRpcProvider`]. - +use jsonrpsee::core::RpcResult; use jsonrpsee::types::ErrorObjectOwned; use jsonrpsee::RpcModule; use reth_primitives::U64; -use serde::de::DeserializeOwned; use sov_modules_api::utils::to_jsonrpsee_error_object; -use sov_rollup_interface::rpc::LedgerRpcProvider; +use sov_rollup_interface::rpc::{ + LastVerifiedProofResponse, LedgerRpcProvider, ProofResponse, SequencerCommitmentResponse, + SoftConfirmationResponse, SoftConfirmationStatus, VerifiedProofResponse, +}; -use crate::HexHash; +use crate::{HexHash, LedgerRpcServer}; const LEDGER_RPC_ERROR: &str = "LEDGER_RPC_ERROR"; fn to_ledger_rpc_error(err: impl ToString) -> ErrorObjectOwned { to_jsonrpsee_error_object(LEDGER_RPC_ERROR, err) } +pub struct LedgerRpcServerImpl { + ledger: T, +} +impl LedgerRpcServerImpl { + pub fn new(ledger: T) -> Self { + Self { ledger } + } +} -/// Creates a new [`jsonrpsee::RpcModule`] that exposes all JSON-RPC methods -/// necessary to interface with the [`LedgerRpcProvider`]. -/// -/// # Example -/// ``` -/// use sov_ledger_rpc::server::rpc_module; -/// use tempfile::tempdir; -/// use sov_db::ledger_db::LedgerDB; -/// -/// /// Creates a new [`LedgerDB`] and starts serving JSON-RPC requests. -/// async fn rpc_server() -> jsonrpsee::server::ServerHandle { -/// let dir = tempdir().unwrap(); -/// let db = LedgerDB::with_path(dir).unwrap(); -/// let rpc_module = rpc_module::(db).unwrap(); -/// -/// let server = jsonrpsee::server::ServerBuilder::default() -/// .build("127.0.0.1:0") -/// .await -/// .unwrap(); -/// server.start(rpc_module) -/// } -/// ``` -pub fn rpc_module(ledger: T) -> anyhow::Result> +impl LedgerRpcServer for LedgerRpcServerImpl where T: LedgerRpcProvider + Send + Sync + 'static, - B: serde::Serialize + DeserializeOwned + Clone + 'static, - Tx: serde::Serialize + DeserializeOwned + Clone + 'static, { - let mut rpc = RpcModule::new(ledger); - - rpc.register_blocking_method( - "ledger_getSoftConfirmationByHash", - move |params, ledger, _| { - let args: HexHash = params.one()?; - ledger - .get_soft_confirmation_by_hash::(&args.0) - .map_err(to_ledger_rpc_error) - }, - )?; - rpc.register_blocking_method( - "ledger_getSoftConfirmationByNumber", - move |params, ledger, _| { - let args: U64 = params.one()?; - ledger - .get_soft_confirmation_by_number::(args.to()) - .map_err(to_ledger_rpc_error) - }, - )?; - rpc.register_blocking_method( - "ledger_getSoftConfirmationRange", - move |params, ledger, _| { - let args: (U64, U64) = params.parse()?; - ledger - .get_soft_confirmations_range(args.0.to(), args.1.to()) - .map_err(to_ledger_rpc_error) - }, - )?; - rpc.register_blocking_method( - "ledger_getSoftConfirmationStatus", - move |params, ledger, _| { - let args: U64 = params.one()?; - ledger - .get_soft_confirmation_status(args.to()) - .map_err(to_ledger_rpc_error) - }, - )?; - rpc.register_blocking_method("ledger_getLastScannedL1Hieght", move |_, ledger, _| { - ledger + fn get_soft_confirmation_by_number( + &self, + number: U64, + ) -> RpcResult> { + self.ledger + .get_soft_confirmation_by_number(number.to()) + .map_err(to_ledger_rpc_error) + } + fn get_soft_confirmation_by_hash( + &self, + hash: HexHash, + ) -> RpcResult> { + self.ledger + .get_soft_confirmation_by_hash(&hash.0) + .map_err(to_ledger_rpc_error) + } + fn get_soft_confirmation_range( + &self, + start: U64, + end: U64, + ) -> RpcResult>> { + self.ledger + .get_soft_confirmations_range(start.to(), end.to()) + .map_err(to_ledger_rpc_error) + } + fn get_soft_confirmation_status( + &self, + soft_confirmation_receipt: U64, + ) -> RpcResult { + self.ledger + .get_soft_confirmation_status(soft_confirmation_receipt.to()) + .map_err(to_ledger_rpc_error) + } + fn get_l2_genesis_state_root(&self) -> RpcResult>> { + self.ledger + .get_l2_genesis_state_root() + .map_err(to_ledger_rpc_error) + } + fn get_last_scanned_l1_height(&self) -> RpcResult { + self.ledger .get_last_scanned_l1_height() .map_err(to_ledger_rpc_error) - })?; - - rpc.register_blocking_method( - "ledger_getSequencerCommitmentsOnSlotByNumber", - move |params, ledger, _| { - // Returns commitments on DA slot with given height. - let height: U64 = params.one()?; - - ledger - .get_sequencer_commitments_on_slot_by_number(height.to()) - .map_err(to_ledger_rpc_error) - }, - )?; - - rpc.register_blocking_method( - "ledger_getSequencerCommitmentsOnSlotByHash", - move |params, ledger, _| { - // Returns commitments on DA slot with given hash. - let hash: HexHash = params.one()?; - let Some(height) = ledger - .get_slot_number_by_hash(hash.0) - .map_err(to_ledger_rpc_error)? - else { - return Ok(None); - }; - ledger - .get_sequencer_commitments_on_slot_by_number(height) - .map_err(to_ledger_rpc_error) - }, - )?; - - rpc.register_blocking_method("ledger_getProofsBySlotHeight", move |params, ledger, _| { - // Returns proof on DA slot with given height - let height: U64 = params.one()?; - ledger + } + fn get_sequencer_commitments_on_slot_by_number( + &self, + height: U64, + ) -> RpcResult>> { + self.ledger + .get_sequencer_commitments_on_slot_by_number(height.to()) + .map_err(to_ledger_rpc_error) + } + fn get_sequencer_commitments_on_slot_by_hash( + &self, + hash: HexHash, + ) -> RpcResult>> { + let Some(height) = self + .ledger + .get_slot_number_by_hash(hash.0) + .map_err(to_ledger_rpc_error)? + else { + return Ok(None); + }; + self.ledger + .get_sequencer_commitments_on_slot_by_number(height) + .map_err(to_ledger_rpc_error) + } + fn get_proofs_by_slot_height(&self, height: U64) -> RpcResult>> { + self.ledger .get_proof_data_by_l1_height(height.to()) .map_err(to_ledger_rpc_error) - })?; - - rpc.register_blocking_method("ledger_getProofsBySlotHash", move |params, ledger, _| { - // Returns proof on DA slot with given height - let hash: HexHash = params.one()?; - let Some(height) = ledger + } + fn get_proofs_by_slot_hash(&self, hash: HexHash) -> RpcResult>> { + let Some(height) = self + .ledger .get_slot_number_by_hash(hash.0) .map_err(to_ledger_rpc_error)? else { return Ok(None); }; - ledger + self.ledger .get_proof_data_by_l1_height(height) .map_err(to_ledger_rpc_error) - })?; - - rpc.register_blocking_method( - "ledger_getVerifiedProofsBySlotHeight", - move |params, ledger, _| { - // Returns proof on DA slot with given height - let height: U64 = params.one()?; - ledger - .get_verified_proof_data_by_l1_height(height.to()) - .map_err(to_ledger_rpc_error) - }, - )?; - - rpc.register_blocking_method("ledger_getLastVerifiedProof", move |_, ledger, _| { - // Returns latest proof data - ledger + } + fn get_verified_proofs_by_slot_height( + &self, + height: U64, + ) -> RpcResult>> { + self.ledger + .get_verified_proof_data_by_l1_height(height.to()) + .map_err(to_ledger_rpc_error) + } + fn get_last_verified_proof(&self) -> RpcResult> { + self.ledger .get_last_verified_proof() .map_err(to_ledger_rpc_error) - })?; + } - rpc.register_blocking_method("ledger_getHeadSoftConfirmation", move |_, ledger, _| { - ledger + fn get_head_soft_confirmation(&self) -> RpcResult> { + self.ledger .get_head_soft_confirmation() - .map_err(|e: anyhow::Error| to_jsonrpsee_error_object(LEDGER_RPC_ERROR, e)) - })?; - - rpc.register_blocking_method( - "ledger_getHeadSoftConfirmationHeight", - move |_, ledger, _| { - ledger - .get_head_soft_confirmation_height() - .map_err(to_ledger_rpc_error) - }, - )?; - - Ok(rpc) + .map_err(to_ledger_rpc_error) + } + fn get_head_soft_confirmation_height(&self) -> RpcResult { + self.ledger + .get_head_soft_confirmation_height() + .map_err(to_ledger_rpc_error) + } +} +pub fn create_rpc_module(ledger: T) -> RpcModule> +where + T: LedgerRpcProvider + Send + Sync + 'static, +{ + let server = LedgerRpcServerImpl::new(ledger); + LedgerRpcServer::into_rpc(server) } diff --git a/crates/sovereign-sdk/full-node/sov-ledger-rpc/tests/empty_ledger.rs b/crates/sovereign-sdk/full-node/sov-ledger-rpc/tests/empty_ledger.rs index cc83d91a8..8ec0a71e4 100644 --- a/crates/sovereign-sdk/full-node/sov-ledger-rpc/tests/empty_ledger.rs +++ b/crates/sovereign-sdk/full-node/sov-ledger-rpc/tests/empty_ledger.rs @@ -4,15 +4,15 @@ use std::sync::Arc; use reth_primitives::U64; use sov_db::ledger_db::LedgerDB; use sov_db::rocks_db_config::RocksdbConfig; -use sov_ledger_rpc::client::RpcClient; -use sov_ledger_rpc::server::rpc_module; +use sov_ledger_rpc::server::create_rpc_module; use sov_ledger_rpc::HexHash; +use sov_ledger_rpc::LedgerRpcClient; use tempfile::tempdir; async fn rpc_server() -> (jsonrpsee::server::ServerHandle, SocketAddr) { let dir = tempdir().unwrap(); let db = LedgerDB::with_config(&RocksdbConfig::new(dir.path(), None)).unwrap(); - let rpc_module = rpc_module::(db).unwrap(); + let rpc_module = create_rpc_module(db); let server = jsonrpsee::server::ServerBuilder::default() .build("127.0.0.1:0") @@ -22,7 +22,7 @@ async fn rpc_server() -> (jsonrpsee::server::ServerHandle, SocketAddr) { (server.start(rpc_module), addr) } -async fn rpc_client(addr: SocketAddr) -> Arc { +async fn rpc_client(addr: SocketAddr) -> Arc { Arc::new( jsonrpsee::ws_client::WsClientBuilder::new() .build(format!("ws://{}", addr)) diff --git a/crates/sovereign-sdk/module-system/sov-modules-rollup-blueprint/src/runtime_rpc.rs b/crates/sovereign-sdk/module-system/sov-modules-rollup-blueprint/src/runtime_rpc.rs index 5f62cc36b..0a6c24e0e 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-rollup-blueprint/src/runtime_rpc.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-rollup-blueprint/src/runtime_rpc.rs @@ -1,6 +1,6 @@ use sov_db::ledger_db::LedgerDB; use sov_modules_api::{Context, Spec}; -use sov_modules_stf_blueprint::{Runtime as RuntimeTrait, SequencerOutcome, TxEffect}; +use sov_modules_stf_blueprint::Runtime as RuntimeTrait; use sov_rollup_interface::services::da::DaService; /// Register rollup's default rpc methods. @@ -20,11 +20,9 @@ where // ledger rpc. { - rpc_methods.merge(sov_ledger_rpc::server::rpc_module::< - LedgerDB, - SequencerOutcome<::Address>, - TxEffect, - >(ledger_db.clone())?)?; + rpc_methods.merge(sov_ledger_rpc::server::create_rpc_module::( + ledger_db.clone(), + ))?; } Ok(rpc_methods) diff --git a/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs b/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs index 31f62ceb5..63b92fabe 100644 --- a/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs +++ b/crates/sovereign-sdk/rollup-interface/src/node/rpc/mod.rs @@ -9,8 +9,6 @@ use alloc::vec::Vec; use core::marker::PhantomData; use borsh::{BorshDeserialize, BorshSerialize}; -#[cfg(feature = "native")] -use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use crate::da::SequencerCommitment; @@ -465,6 +463,9 @@ pub trait LedgerRpcProvider { soft_confirmation_receipt: u64, ) -> Result; + /// Returns the L2 genesis state root + fn get_l2_genesis_state_root(&self) -> Result>, anyhow::Error>; + /// Returns the last scanned L1 height (for sequencer commitments) fn get_last_scanned_l1_height(&self) -> Result;