Skip to content
Open
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
718 changes: 506 additions & 212 deletions Cargo.lock

Large diffs are not rendered by default.

180 changes: 110 additions & 70 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
async-trait = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-codec = { workspace = true }
# Substrate
sp-core = { workspace = true, features = ["default"] }
sp-runtime = { workspace = true, features = ["default"] }
Expand Down
21 changes: 21 additions & 0 deletions client/bifrost/evm-tracing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "fc-evm-tracing"
authors = ["bifrost-platform"]
edition = "2021"
homepage = "https://www.bifrostnetwork.com"
license = "Apache-2.0"
repository = "https://github.com/bifrost-platform/bifrost-frontier"
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 }

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

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