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

Fix evm tracing for native ERC20 foreign asset registrations #3194

Merged
merged 5 commits into from
Feb 19, 2025
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions client/rpc/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repository = { workspace = true }
version = "0.1.0"

[dependencies]
log = { workspace = true }
futures = { workspace = true, features = [ "compat" ] }
hex-literal = { workspace = true }
jsonrpsee = { workspace = true, features = [ "macros", "server" ] }
Expand Down
11 changes: 11 additions & 0 deletions client/rpc/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,17 @@ where
})
.collect::<Vec<BlockTransactionTrace>>();

let n_txs = eth_transactions_by_index.len();
let n_traces = result.len();
if n_txs != n_traces {
log::warn!(
"The traces in block {:?} don't match with the number of ethereum transactions. (txs: {}, traces: {})",
request_block_id,
n_txs,
n_traces
);
}

Ok(result)
}
_ => Err(internal_err(
Expand Down
27 changes: 16 additions & 11 deletions runtime/common/src/impl_moonbeam_xcm_call_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ macro_rules! impl_moonbeam_xcm_call_tracing {
origin: RuntimeOrigin,
) -> CallResult {
if let Ok(raw_origin) = TryInto::<RawOrigin<AccountId>>::try_into(origin.clone().caller) {
match (call.clone(), raw_origin) {
(
RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::transact { xcm_transaction }) |
RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::transact_through_proxy {
xcm_transaction, ..
}),
RawOrigin::Signed(account_id)
) => {
match call.clone() {
RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::transact { xcm_transaction }) |
RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::transact_through_proxy {
xcm_transaction, ..
}) |
RuntimeCall::EthereumXcm(pallet_ethereum_xcm::Call::force_transact_as {
xcm_transaction, ..
}) => {
use crate::EthereumXcm;
use moonbeam_evm_tracer::tracer::EvmTracer;
use xcm_primitives::{
Expand All @@ -52,9 +52,14 @@ macro_rules! impl_moonbeam_xcm_call_tracing {
let dispatch_call = || {
RuntimeCall::dispatch(
call,
pallet_ethereum_xcm::Origin::XcmEthereumTransaction(
account_id.into()
).into()
match raw_origin {
RawOrigin::Signed(account_id) => {
pallet_ethereum_xcm::Origin::XcmEthereumTransaction(
account_id.into()
).into()
},
origin => origin.into()
}
)
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { customDevRpcRequest, describeSuite, expect } from "@moonwall/cli";
import {
ARBITRARY_ASSET_ID,
registerForeignAsset,
RELAY_SOURCE_LOCATION_V4,
relayAssetMetadata,
} from "../../helpers";

describeSuite({
id: "T17",
title: "Trace ERC20 Foreign asset creation",
foundationMethods: "dev",
testCases: ({ context, it }) => {
it({
id: "T01",
title: "Ensure native ERC20 foreign asset creation is traceable",
timeout: 50000,
test: async function () {
const assetLocation = RELAY_SOURCE_LOCATION_V4;
const assetId = ARBITRARY_ASSET_ID;

// Register the asset
await registerForeignAsset(context, assetId, assetLocation, relayAssetMetadata);

const number = await context.viem().getBlockNumber();
const traces = await customDevRpcRequest("debug_traceBlockByNumber", [
number.toString(),
{ tracer: "callTracer" },
]);

expect(traces).to.toMatchObject([
{
result: {
to: "0xffffffff1fcacbd218edc0eba20fc2308c778080",
type: "CREATE",
},
},
]);
},
});
},
});
Loading