Skip to content

Commit

Permalink
Merge branch 'pg/add-tracing-support-2' into pg/evm-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Jan 17, 2025
2 parents c484137 + 175585c commit 0641eeb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions substrate/frame/revive/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,8 @@ impl Client {
log::error!(target: LOG_TARGET, "state_debugBlock failed with: {err:?}");
})?;

let traces = CallTrace::decode(&mut &bytes.0[..])?;
Ok(traces)
let trace = Option::<CallTrace>::decode(&mut &bytes.0[..])?;
Ok(trace.ok_or(ClientError::EthExtrinsicNotFound)?)
}

/// Get the EVM block for the given hash.
Expand Down
11 changes: 10 additions & 1 deletion substrate/frame/revive/src/evm/api/debug_rpc_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::evm::Bytes;
use crate::evm::{Bytes, CallTracer};
use alloc::{fmt, string::String, vec::Vec};
use codec::{Decode, Encode};
use scale_info::TypeInfo;
Expand All @@ -38,6 +38,15 @@ pub enum TracerConfig {
},
}

impl TracerConfig {
/// Build the tracer associated to this config.
pub fn build<G>(self, gas_mapper: G) -> CallTracer<U256, G> {
match self {
Self::CallTracer { with_logs } => CallTracer::new(with_logs, gas_mapper),
}
}
}

/// Custom deserializer to support the following JSON format:
///
/// ```json
Expand Down
5 changes: 2 additions & 3 deletions substrate/frame/revive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ sp_api::decl_runtime_apis! {
fn trace_block(
block: Block,
config: TracerConfig
) -> Vec<(u32, Vec<CallTrace>)>;
) -> Vec<(u32, CallTrace)>;

/// Replay the block with the given hash.
/// This is intended to called through `state_debugBlock` RPC. Using [`using_tracer`]
Expand All @@ -1490,7 +1490,6 @@ sp_api::decl_runtime_apis! {
block: Block,
tx_index: u32,
config: TracerConfig
) -> CallTrace;

) -> Option<CallTrace>;
}
}

0 comments on commit 0641eeb

Please sign in to comment.