This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
forked from matter-labs/zksync-era
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding unstable RPC endpoint to return the execution_info (matt…
…er-labs#2332) ## What ❔ * Execution info shows some details from the VM execution (like circutits used, pubdata etc) * This data was only stored in DB and not accessible outside - after this PR, it is available under `nstable_getTransactionExecutionInfo` ## Why ❔ * This allows us to do more advanced debugging of issues - especially for cases where we might not have access to the underlying database. * In the future, some parts of this might be migrated into a 'stable' RPC. ## Evidence ![image](https://github.com/matter-labs/zksync-era/assets/128217157/20da9e80-f7b3-4614-89f3-b09a774ffcf9)
- Loading branch information
Showing
11 changed files
with
171 additions
and
9 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...lib/dal/.sqlx/query-53ab91ac4daebeb7d9d38018f31a9a184779646a16537df5b7cc54d0b4175d24.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
pub use self::{ | ||
debug::DebugNamespaceClient, en::EnNamespaceClient, eth::EthNamespaceClient, | ||
net::NetNamespaceClient, snapshots::SnapshotsNamespaceClient, web3::Web3NamespaceClient, | ||
zks::ZksNamespaceClient, | ||
net::NetNamespaceClient, snapshots::SnapshotsNamespaceClient, | ||
unstable::UnstableNamespaceClient, web3::Web3NamespaceClient, zks::ZksNamespaceClient, | ||
}; | ||
#[cfg(feature = "server")] | ||
pub use self::{ | ||
debug::DebugNamespaceServer, en::EnNamespaceServer, eth::EthNamespaceServer, | ||
eth::EthPubSubServer, net::NetNamespaceServer, snapshots::SnapshotsNamespaceServer, | ||
web3::Web3NamespaceServer, zks::ZksNamespaceServer, | ||
unstable::UnstableNamespaceServer, web3::Web3NamespaceServer, zks::ZksNamespaceServer, | ||
}; | ||
|
||
mod debug; | ||
mod en; | ||
mod eth; | ||
mod net; | ||
mod snapshots; | ||
mod unstable; | ||
mod web3; | ||
mod zks; |
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,23 @@ | ||
#[cfg_attr(not(feature = "server"), allow(unused_imports))] | ||
use jsonrpsee::core::RpcResult; | ||
use jsonrpsee::proc_macros::rpc; | ||
use zksync_types::{api::TransactionExecutionInfo, H256}; | ||
|
||
use crate::client::{ForNetwork, L2}; | ||
|
||
/// RPCs in this namespace are experimental, and their interface is unstable, and it WILL change. | ||
#[cfg_attr( | ||
feature = "server", | ||
rpc(server, client, namespace = "unstable", client_bounds(Self: ForNetwork<Net = L2>)) | ||
)] | ||
#[cfg_attr( | ||
not(feature = "server"), | ||
rpc(client, namespace = "unstable", client_bounds(Self: ForNetwork<Net = L2>)) | ||
)] | ||
pub trait UnstableNamespace { | ||
#[method(name = "getTransactionExecutionInfo")] | ||
async fn transaction_execution_info( | ||
&self, | ||
hash: H256, | ||
) -> RpcResult<Option<TransactionExecutionInfo>>; | ||
} |
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 |
---|---|---|
|
@@ -3,5 +3,6 @@ pub mod en; | |
pub mod eth; | ||
pub mod net; | ||
pub mod snapshots; | ||
pub mod unstable; | ||
pub mod web3; | ||
pub mod zks; |
19 changes: 19 additions & 0 deletions
19
core/node/api_server/src/web3/backend_jsonrpsee/namespaces/unstable.rs
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,19 @@ | ||
use zksync_types::{api::TransactionExecutionInfo, H256}; | ||
use zksync_web3_decl::{ | ||
jsonrpsee::core::{async_trait, RpcResult}, | ||
namespaces::UnstableNamespaceServer, | ||
}; | ||
|
||
use crate::web3::namespaces::UnstableNamespace; | ||
|
||
#[async_trait] | ||
impl UnstableNamespaceServer for UnstableNamespace { | ||
async fn transaction_execution_info( | ||
&self, | ||
hash: H256, | ||
) -> RpcResult<Option<TransactionExecutionInfo>> { | ||
self.transaction_execution_info_impl(hash) | ||
.await | ||
.map_err(|err| self.current_method().map_err(err)) | ||
} | ||
} |
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 zksync_dal::{CoreDal, DalError}; | ||
use zksync_types::api::TransactionExecutionInfo; | ||
use zksync_web3_decl::{error::Web3Error, types::H256}; | ||
|
||
use crate::web3::{backend_jsonrpsee::MethodTracer, RpcState}; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct UnstableNamespace { | ||
state: RpcState, | ||
} | ||
|
||
impl UnstableNamespace { | ||
pub fn new(state: RpcState) -> Self { | ||
Self { state } | ||
} | ||
|
||
pub(crate) fn current_method(&self) -> &MethodTracer { | ||
&self.state.current_method | ||
} | ||
|
||
pub async fn transaction_execution_info_impl( | ||
&self, | ||
hash: H256, | ||
) -> Result<Option<TransactionExecutionInfo>, Web3Error> { | ||
let mut storage = self.state.acquire_connection().await?; | ||
Ok(storage | ||
.transactions_web3_dal() | ||
.get_unstable_transaction_execution_info(hash) | ||
.await | ||
.map_err(DalError::generalize)? | ||
.map(|execution_info| TransactionExecutionInfo { execution_info })) | ||
} | ||
} |