Skip to content

Commit

Permalink
add sentioTracer, sentioPrestateTracer and debug_storageRange api
Browse files Browse the repository at this point in the history
disable storage range for now
  • Loading branch information
zfy0701 committed Aug 30, 2024
1 parent 77a50ac commit 52a3ed3
Show file tree
Hide file tree
Showing 19 changed files with 2,328 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,18 @@ impl_runtime_apis! {
pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))
}

// fn storage_range_at(address: H160, start_key: H256, limit: u64) -> (Vec<(H256, H256)>, Option<H256>) {
// let iter = pallet_evm::AccountStorages::<Runtime>::iter_prefix_from(address, start_key.as_bytes().to_vec());
// let mut res: Vec<(H256, H256)> = vec![];
// for (key, value) in iter {
// if res.len() == limit as usize {
// return (res, Some(key));
// }
// res.push((key, value));
// }
// return (res, None);
// }

fn call(
from: H160,
to: H160,
Expand Down
12 changes: 12 additions & 0 deletions runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,18 @@ impl_runtime_apis! {
pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))
}

// fn storage_range_at(address: H160, start_key: H256, limit: u64) -> (Vec<(H256, H256)>, Option<H256>) {
// let iter = pallet_evm::AccountStorages::<Runtime>::iter_prefix_from(address, start_key.as_bytes().to_vec());
// let mut res: Vec<(H256, H256)> = vec![];
// for (key, value) in iter {
// if res.len() == limit as usize {
// return (res, Some(key));
// }
// res.push((key, value));
// }
// return (res, None);
// }

fn call(
from: H160,
to: H160,
Expand Down
12 changes: 12 additions & 0 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,18 @@ impl_runtime_apis! {
pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))
}

// fn storage_range_at(address: H160, start_key: H256, limit: u64) -> (Vec<(H256, H256)>, Option<H256>) {
// let iter = pallet_evm::AccountStorages::<Runtime>::iter_prefix_from(address, start_key.as_bytes().to_vec());
// let mut res: Vec<(H256, H256)> = vec![];
// for (key, value) in iter {
// if res.len() == limit as usize {
// return (res, Some(key));
// }
// res.push((key, value));
// }
// return (res, None);
// }

fn call(
from: H160,
to: H160,
Expand Down
12 changes: 12 additions & 0 deletions runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,18 @@ impl_runtime_apis! {
pallet_evm::AccountStorages::<Runtime>::get(address, H256::from_slice(&tmp[..]))
}

// fn storage_range_at(address: H160, start_key: H256, limit: u64) -> (Vec<(H256, H256)>, Option<H256>) {
// let iter = pallet_evm::AccountStorages::<Runtime>::iter_prefix_from(address, start_key.as_bytes().to_vec());
// let mut res: Vec<(H256, H256)> = vec![];
// for (key, value) in iter {
// if res.len() == limit as usize {
// return (res, Some(key));
// }
// res.push((key, value));
// }
// return (res, None);
// }

fn call(
from: H160,
to: H160,
Expand Down
8 changes: 8 additions & 0 deletions vendor/evm-tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ version = "0.1.0"

[dependencies]
ethereum-types = { workspace = true, features = ["std"] }
log = { workspace = true }
hex = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["std"] }
serde_json = { workspace = true }
sha3 = { workspace = true }
rlp = { workspace = true }

# Moonbeam
evm-tracing-events = { workspace = true, features = ["std"] }
Expand All @@ -21,3 +24,8 @@ moonbeam-rpc-primitives-debug = { workspace = true, features = ["std"] }
parity-scale-codec = { workspace = true, features = ["std"] }
sp-runtime = { workspace = true, features = ["std"] }
sp-std = { workspace = true, features = ["std"] }
sp-api = { workspace = true, features = [ "std" ] }
sp-block-builder = { workspace = true, features = [ "std" ] }

# Frontier
fp-rpc = { workspace = true, features = [ "std" ] }
5 changes: 5 additions & 0 deletions vendor/evm-tracing/src/formatters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ pub mod call_tracer;
pub mod raw;
pub mod trace_filter;

pub mod sentio_call_tracer;
pub mod sentio_prestate_tracer;

pub use blockscout::Formatter as Blockscout;
pub use call_tracer::Formatter as CallTracer;
pub use raw::Formatter as Raw;
pub use trace_filter::Formatter as TraceFilter;
pub use sentio_call_tracer::Formatter as SentioTracer;
pub use sentio_prestate_tracer::Formatter as SentioPrestateTracer;

use evm_tracing_events::Listener;
use serde::Serialize;
Expand Down
34 changes: 34 additions & 0 deletions vendor/evm-tracing/src/formatters/sentio_call_tracer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2019-2022 PureStake Inc.
// This file is part of Moonbeam.

// Moonbeam is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Moonbeam is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

use crate::types::single::TransactionTrace;

use crate::listeners::sentio_call_list::Listener;

pub struct Formatter;

impl super::ResponseFormatter for Formatter {
type Listener = Listener;
type Response = Vec<TransactionTrace>;

fn format(listener: Listener) -> Option<Vec<TransactionTrace>> {
if listener.results.is_empty() {
None
} else {
Some(listener.results.into_iter().map(|call| TransactionTrace::SentioCallTrace(call)).collect())
}
}
}
53 changes: 53 additions & 0 deletions vendor/evm-tracing/src/formatters/sentio_prestate_tracer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2019-2022 PureStake Inc.
// This file is part of Moonbeam.

// Moonbeam is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Moonbeam is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.

use std::marker::PhantomData;
use fp_rpc::EthereumRuntimeRPCApi;
use sp_api::ProvideRuntimeApi;
use sp_runtime::traits::Block as BlockT;
use sp_block_builder::BlockBuilder;
use crate::types::single::TransactionTrace;

use crate::listeners::sentio_prestate::Listener;

pub struct Formatter<B, C>
where
B: BlockT,
C:ProvideRuntimeApi<B>,
C::Api: EthereumRuntimeRPCApi<B>,
C::Api: BlockBuilder<B> {
_b: PhantomData<B>,
_c: PhantomData<C>
}

impl<B, C> super::ResponseFormatter for Formatter<B, C>
where
B: BlockT,
C:ProvideRuntimeApi<B> + 'static,
C::Api: EthereumRuntimeRPCApi<B>,
C::Api: BlockBuilder<B>
{
type Listener = Listener<B, C>;
type Response = Vec<TransactionTrace>;

fn format(listener: Listener<B, C>) -> Option<Vec<TransactionTrace>> {
if listener.results.is_empty() {
None
} else {
Some(listener.results.into_iter().map(|trace| TransactionTrace::SentioPrestateTrace(trace)).collect())
}
}
}
6 changes: 6 additions & 0 deletions vendor/evm-tracing/src/listeners/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
pub mod call_list;
pub mod raw;

pub mod sentio_call_list;
pub mod sentio_prestate;
mod sentio_util;

pub use call_list::Listener as CallList;
pub use raw::Listener as Raw;
pub use sentio_call_list::Listener as SentioCallList;
pub use sentio_prestate::Listener as SentioPrestate;
Loading

0 comments on commit 52a3ed3

Please sign in to comment.