forked from kkrt-labs/kakarot-rpc
-
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/debug transaction (kkrt-labs#867)
* add debug api debug transaction * fix docker compose bug * hail move * boyscout commit to solve estimate gas if kakarot.basefee > 0 * add tests for debug api
- Loading branch information
Showing
19 changed files
with
629 additions
and
34 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Validating CODEOWNERS rules …
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 +1 @@ | ||
* @clementwalter @eikix | ||
* @clementwalter @eikix @greged93 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use jsonrpsee::core::RpcResult as Result; | ||
use jsonrpsee::proc_macros::rpc; | ||
use reth_primitives::{Bytes, B256}; | ||
use reth_rpc_types::BlockId; | ||
|
||
/// Debug API | ||
/// Taken from Reth's DebugApi trait: | ||
/// <https://github.com/paradigmxyz/reth/blob/5d6ac4c815c562677d7ae6ad6b422b55ef4ed8e2/crates/rpc/rpc-api/src/debug.rs#L14> | ||
#[rpc(server, namespace = "debug")] | ||
#[async_trait] | ||
pub trait DebugApi { | ||
/// Returns an RLP-encoded header. | ||
#[method(name = "getRawHeader")] | ||
async fn raw_header(&self, block_id: BlockId) -> Result<Bytes>; | ||
|
||
/// Returns an RLP-encoded block. | ||
#[method(name = "getRawBlock")] | ||
async fn raw_block(&self, block_id: BlockId) -> Result<Bytes>; | ||
|
||
/// Returns a EIP-2718 binary-encoded transaction. | ||
/// | ||
/// If this is a pooled EIP-4844 transaction, the blob sidecar is included. | ||
#[method(name = "getRawTransaction")] | ||
async fn raw_transaction(&self, hash: B256) -> Result<Option<Bytes>>; | ||
|
||
/// Returns an array of EIP-2718 binary-encoded transactions for the given [BlockId]. | ||
#[method(name = "getRawTransactions")] | ||
async fn raw_transactions(&self, block_id: BlockId) -> Result<Vec<Bytes>>; | ||
|
||
/// Returns an array of EIP-2718 binary-encoded receipts. | ||
#[method(name = "getRawReceipts")] | ||
async fn raw_receipts(&self, block_id: BlockId) -> Result<Vec<Bytes>>; | ||
} |
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,4 +1,5 @@ | ||
pub mod alchemy_api; | ||
pub mod debug_api; | ||
pub mod eth_api; | ||
pub mod net_api; | ||
pub mod web3_api; |
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,66 @@ | ||
use crate::eth_provider::error::EthProviderError; | ||
use crate::eth_rpc::api::debug_api::DebugApiServer; | ||
use crate::{eth_provider::provider::EthereumProvider, models::transaction::rpc_transaction_to_primitive}; | ||
// use alloy_rlp::Encodable; | ||
use jsonrpsee::core::{async_trait, RpcResult as Result}; | ||
use reth_primitives::{Bytes, TransactionSigned, B256}; | ||
use reth_rpc_types::BlockId; | ||
|
||
/// The RPC module for the implementing Net api | ||
pub struct DebugRpc<P: EthereumProvider> { | ||
eth_provider: P, | ||
} | ||
|
||
impl<P: EthereumProvider> DebugRpc<P> { | ||
pub const fn new(eth_provider: P) -> Self { | ||
Self { eth_provider } | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl<P: EthereumProvider + Send + Sync + 'static> DebugApiServer for DebugRpc<P> { | ||
/// Returns an RLP-encoded header. | ||
async fn raw_header(&self, _block_id: BlockId) -> Result<Bytes> { | ||
Err(EthProviderError::MethodNotSupported("debug_rawHeader".to_string()).into()) | ||
} | ||
|
||
/// Returns an RLP-encoded block. | ||
async fn raw_block(&self, _block_id: BlockId) -> Result<Bytes> { | ||
Err(EthProviderError::MethodNotSupported("debug_rawBlock".to_string()).into()) | ||
} | ||
|
||
/// Returns a EIP-2718 binary-encoded transaction. | ||
/// | ||
/// If this is a pooled EIP-4844 transaction, the blob sidecar is included. | ||
async fn raw_transaction(&self, hash: B256) -> Result<Option<Bytes>> { | ||
let transaction = self.eth_provider.transaction_by_hash(hash).await?; | ||
|
||
if let Some(tx) = transaction { | ||
let mut raw_transaction = Vec::new(); | ||
let signature = tx.signature.ok_or(EthProviderError::ValueNotFound("signature".to_string()))?; | ||
let tx = rpc_transaction_to_primitive(tx).map_err(EthProviderError::from)?; | ||
TransactionSigned::from_transaction_and_signature( | ||
tx, | ||
reth_primitives::Signature { | ||
r: signature.r, | ||
s: signature.s, | ||
odd_y_parity: signature.y_parity.unwrap_or(reth_rpc_types::Parity(false)).0, | ||
}, | ||
) | ||
.encode_enveloped(&mut raw_transaction); | ||
Ok(Some(Bytes::from(raw_transaction))) | ||
} else { | ||
Ok(None) | ||
} | ||
} | ||
|
||
/// Returns an array of EIP-2718 binary-encoded transactions for the given [BlockId]. | ||
async fn raw_transactions(&self, _block_id: BlockId) -> Result<Vec<Bytes>> { | ||
Err(EthProviderError::MethodNotSupported("debug_rawTransactions".to_string()).into()) | ||
} | ||
|
||
/// Returns an array of EIP-2718 binary-encoded receipts. | ||
async fn raw_receipts(&self, _block_id: BlockId) -> Result<Vec<Bytes>> { | ||
Err(EthProviderError::MethodNotSupported("debug_rawReceipts".to_string()).into()) | ||
} | ||
} |
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,4 +1,5 @@ | ||
pub mod alchemy_rpc; | ||
pub mod debug_rpc; | ||
pub mod eth_rpc; | ||
pub mod net_rpc; | ||
pub mod web3_rpc; |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod balance; | |
pub mod block; | ||
pub mod errors; | ||
pub mod felt; | ||
pub mod transaction; |
Oops, something went wrong.