Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug_traceCall draft implementation #1

Draft
wants to merge 3 commits into
base: atleta-polkadot-v1.11.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,207 changes: 2,422 additions & 1,785 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ members = [
"client/db",
"client/storage",
"client/mapping-sync",
"client/evm-tracing",
"primitives/account",
"primitives/consensus",
"primitives/dynamic-fee",
"primitives/evm",
"primitives/rpc",
"primitives/self-contained",
"primitives/debug",
"primitives/evm-tracing-events",
"template/node",
"template/runtime",
"precompiles",
Expand All @@ -53,6 +56,7 @@ environmental = { version = "1.1.4", default-features = false }
ethereum = { version = "0.15.0", default-features = false }
ethereum-types = { version = "0.14.1", default-features = false }
evm = { version = "0.41.1", default-features = false }
evm-runtime = { git = "https://github.com/moonbeam-foundation/evm", branch = "moonbeam-polkadot-stable2407", default-features = false }
futures = "0.3.30"
hash-db = { version = "0.16.0", default-features = false }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
Expand All @@ -68,6 +72,7 @@ parity-db = "0.4.13"
parking_lot = "0.12.2"
rlp = { version = "0.5.2", default-features = false }
scale-codec = { package = "parity-scale-codec", version = "3.6.4", default-features = false, features = ["derive"] }
parity-scale-codec = { package = "parity-scale-codec", version = "3.6.4", default-features = false, features = ["derive"] }
scale-info = { version = "2.11.2", default-features = false, features = ["derive"] }
serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
serde_json = "1.0"
Expand Down Expand Up @@ -170,6 +175,7 @@ fc-mapping-sync = { path = "client/mapping-sync", default-features = false }
fc-rpc = { path = "client/rpc", default-features = false }
fc-rpc-core = { path = "client/rpc-core" }
fc-storage = { path = "client/storage" }
client-evm-tracing = { path = "client/evm-tracing" }
# Frontier Primitive
fp-account = { path = "primitives/account", default-features = false }
fp-consensus = { path = "primitives/consensus", default-features = false }
Expand All @@ -179,6 +185,8 @@ fp-evm = { path = "primitives/evm", default-features = false }
fp-rpc = { path = "primitives/rpc", default-features = false }
fp-self-contained = { path = "primitives/self-contained", default-features = false }
fp-storage = { path = "primitives/storage", default-features = false }
rpc-primitives-debug = { path = "primitives/debug", default-features = false }
evm-tracing-events = { path = "primitives/evm-tracing-events", default-features = false }
# Frontier FRAME
pallet-base-fee = { path = "frame/base-fee", default-features = false }
pallet-dynamic-fee = { path = "frame/dynamic-fee", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/frontier_db_cmd/mapping_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ where
}
}

impl<'a, B: BlockT, C: HeaderBackend<B>> FrontierDbMessage for MappingDb<'a, B, C> {}
impl<B: BlockT, C: HeaderBackend<B>> FrontierDbMessage for MappingDb<'_, B, C> {}
2 changes: 1 addition & 1 deletion client/cli/src/frontier_db_cmd/meta_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ impl<'a, B: BlockT, C: HeaderBackend<B>> MetaDb<'a, B, C> {
}
}

impl<'a, B: BlockT, C: HeaderBackend<B>> FrontierDbMessage for MetaDb<'a, B, C> {}
impl<B: BlockT, C: HeaderBackend<B>> FrontierDbMessage for MetaDb<'_, B, C> {}
20 changes: 20 additions & 0 deletions client/evm-tracing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "client-evm-tracing"
authors = { workspace = true }
license = "GPL-3.0-only"
repository = { workspace = true }
version = "0.1.0"

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

evm-tracing-events = { workspace = true, features = [ "std" ] }
rpc-primitives-debug = { workspace = true, features = [ "std" ] }

# Substrate
parity-scale-codec = { workspace = true, features = [ "std" ] }
sp-std = { workspace = true, features = [ "std" ] }
sp-runtime = { workspace = true, features = [ "std" ] }
93 changes: 93 additions & 0 deletions client/evm-tracing/src/formatters/blockscout.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// 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::listeners::call_list::Listener;
use crate::types::serialization::*;
use crate::types::{
single::{Call, TransactionTrace},
CallResult, CallType, CreateResult,
};
use ethereum_types::{H160, U256};
use parity_scale_codec::{Decode, Encode};
use serde::Serialize;

pub struct Formatter;

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

fn format(listener: Listener) -> Option<TransactionTrace> {
if let Some(entry) = listener.entries.last() {
return Some(TransactionTrace::CallList(
entry
.into_iter()
.map(|(_, value)| Call::Blockscout(value.clone()))
.collect(),
));
}
None
}
}

#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, Serialize)]
#[serde(rename_all = "lowercase", tag = "type")]
pub enum BlockscoutCallInner {
Call {
#[serde(rename(serialize = "callType"))]
/// Type of call.
call_type: CallType,
to: H160,
#[serde(serialize_with = "bytes_0x_serialize")]
input: Vec<u8>,
/// "output" or "error" field
#[serde(flatten)]
res: CallResult,
},
Create {
#[serde(serialize_with = "bytes_0x_serialize")]
init: Vec<u8>,
#[serde(flatten)]
res: CreateResult,
},
SelfDestruct {
#[serde(skip)]
balance: U256,
to: H160,
},
}

#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BlockscoutCall {
pub from: H160,
/// Indices of parent calls.
pub trace_address: Vec<u32>,
/// Number of children calls.
/// Not needed for Blockscout, but needed for `crate::block`
/// types that are build from this type.
#[serde(skip)]
pub subtraces: u32,
/// Sends funds to the (payable) function
pub value: U256,
/// Remaining gas in the runtime.
pub gas: U256,
/// Gas used by this context.
pub gas_used: U256,
#[serde(flatten)]
pub inner: BlockscoutCallInner,
pub logs: Vec<crate::types::single::Log>,
}
Loading