Skip to content

Commit

Permalink
update debug api to version 5
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ committed Mar 14, 2024
1 parent 7ae4a7b commit 48b864a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
22 changes: 14 additions & 8 deletions scripts/migrate-imported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use {
clap::Parser,
std::path::{Path, PathBuf},
std::{borrow::{Borrow, BorrowMut}, ops::DerefMut, path::{Path, PathBuf}},
toml_edit::{Array, Document, Formatted, Item, Value},
};

Expand Down Expand Up @@ -93,8 +93,8 @@ fn update_root_toml(args: &Args) -> Vec<String> {
.enumerate()
.filter_map(|(i, member)| {
let Value::String(member) = member else {
return None;
};
return None;
};

let member = member.value();

Expand Down Expand Up @@ -122,20 +122,26 @@ fn update_root_toml(args: &Args) -> Vec<String> {

for (dep_name, dep_table) in dependencies.iter_mut() {
let Item::Value(Value::InlineTable(dep_table)) = dep_table else {
continue
continue;
};

// Add feature "runtime-1600" to "evm-tracing-event"
if dep_name == "evm-tracing-events" {
let Value::Array(features) = dep_table.get_or_insert("features", Array::new()) else {
let Value::Array(ref mut features) = dep_table.get_or_insert("features", Array::new()) else {
panic!("expected features of `{dep_name}` to be an array or missing");
};
features.push("runtime-1600");
}
if dep_name == "moonbeam-rpc-primitives-debug" {
let Value::Array(ref mut features) = dep_table.get_or_insert("features", Array::new()) else {
panic!("expected features of `{dep_name}` to be an array or missing");
};
features.push("runtime-2900");
}

// No path => not moonbeam crate.
let Some(Value::String(ref mut path)) = dep_table.get_mut("path") else {
continue
continue;
};

// If this is a shared crate, update the path and stop there.
Expand Down Expand Up @@ -170,8 +176,8 @@ fn update_root_toml(args: &Args) -> Vec<String> {
fn update_runtime_toml(path: &Path) {
let toml = std::fs::read_to_string(&path).expect("cannot open runtime toml file");
let mut toml = toml.parse::<Document>().expect("invalid runtime toml file");
println!("- Enabling evm-tracing feature in {}", path.display());

println!("- Enabling X feature in {}", path.display());
let Some(Item::Table(features)) = toml.get_mut("features") else {
panic!("cannot get features table");
};
Expand Down
1 change: 1 addition & 0 deletions tracing/shared/primitives/rpc/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ default = [ "std" ]

before_700 = []
_700_to_1200 = []
runtime-2900 = []

std = [
"parity-scale-codec/std",
Expand Down
20 changes: 19 additions & 1 deletion tracing/shared/primitives/rpc/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,25 @@ use ethereum::TransactionV2 as Transaction;
use ethereum_types::{H160, H256, U256};
use sp_std::vec::Vec;

#[cfg(all(not(feature = "before_700"), not(feature = "_700_to_1200")))]
#[cfg(feature = "runtime-2900")]
sp_api::decl_runtime_apis! {
#[api_version(5)]
pub trait DebugRuntimeApi {
fn trace_transaction(
extrinsics: Vec<Block::Extrinsic>,
transaction: &Transaction,
transaction: &Block::Header,
) -> Result<(), sp_runtime::DispatchError>;

fn trace_block(
extrinsics: Vec<Block::Extrinsic>,
known_transactions: Vec<H256>,
transaction: &Block::Header,
) -> Result<(), sp_runtime::DispatchError>;
}
}

#[cfg(all(not(feature = "before_700"), not(feature = "_700_to_1200"), not(feature = "runtime-2900")))]
sp_api::decl_runtime_apis! {
#[api_version(4)]
pub trait DebugRuntimeApi {
Expand Down

0 comments on commit 48b864a

Please sign in to comment.