Skip to content

Commit

Permalink
Merge branch 'master' into pablo/test/smoke/improve-decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
pLabarta committed Sep 23, 2024
2 parents bb6eceb + 850be55 commit be5002d
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 50 deletions.
52 changes: 26 additions & 26 deletions Cargo.lock

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

48 changes: 41 additions & 7 deletions client/rpc/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,30 @@ where
// The block is initialized inside "trace_block"
api.trace_block(parent_block_hash, exts, eth_tx_hashes, &header)
} else {
// Pre pallet-message-queue
// Get core runtime api version
let core_api_version = if let Ok(Some(api_version)) =
api.api_version::<dyn Core<B>>(parent_block_hash)
{
api_version
} else {
return Err(internal_err(
"Runtime api version call failed (core)".to_string(),
));
};

// Initialize block: calls the "on_initialize" hook on every pallet
// in AllPalletsWithSystem
// This was fine before pallet-message-queue because the XCM messages
// were processed by the "setValidationData" inherent call and not on an
// "on_initialize" hook, which runs before enabling XCM tracing
api.initialize_block(parent_block_hash, &header)
.map_err(|e| internal_err(format!("Runtime api access error: {:?}", e)))?;
if core_api_version >= 5 {
api.initialize_block(parent_block_hash, &header)
.map_err(|e| internal_err(format!("Runtime api access error: {:?}", e)))?;
} else {
#[allow(deprecated)]
api.initialize_block_before_version_5(parent_block_hash, &header)
.map_err(|e| internal_err(format!("Runtime api access error: {:?}", e)))?;
}

#[allow(deprecated)]
api.trace_block_before_version_5(parent_block_hash, exts, eth_tx_hashes)
Expand Down Expand Up @@ -583,15 +598,34 @@ where
// The block is initialized inside "trace_transaction"
api.trace_transaction(parent_block_hash, exts, &transaction, &header)
} else {
// Get core runtime api version
let core_api_version = if let Ok(Some(api_version)) =
api.api_version::<dyn Core<B>>(parent_block_hash)
{
api_version
} else {
return Err(internal_err(
"Runtime api version call failed (core)".to_string(),
));
};

// Initialize block: calls the "on_initialize" hook on every pallet
// in AllPalletsWithSystem
// This was fine before pallet-message-queue because the XCM messages
// were processed by the "setValidationData" inherent call and not on an
// "on_initialize" hook, which runs before enabling XCM tracing
api.initialize_block(parent_block_hash, &header)
.map_err(|e| {
internal_err(format!("Runtime api access error: {:?}", e))
})?;
if core_api_version >= 5 {
api.initialize_block(parent_block_hash, &header)
.map_err(|e| {
internal_err(format!("Runtime api access error: {:?}", e))
})?;
} else {
#[allow(deprecated)]
api.initialize_block_before_version_5(parent_block_hash, &header)
.map_err(|e| {
internal_err(format!("Runtime api access error: {:?}", e))
})?;
}

if trace_api_version == 4 {
// Pre pallet-message-queue
Expand Down
19 changes: 16 additions & 3 deletions client/rpc/trace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,15 +859,28 @@ where
&block_header,
)
} else {
// Pre pallet-message-queue
// Get core runtime api version
let core_api_version = if let Ok(Some(api_version)) =
api.api_version::<dyn Core<B>>(substrate_parent_hash)
{
api_version
} else {
return Err("Runtime api version call failed (core)".to_string());
};

// Initialize block: calls the "on_initialize" hook on every pallet
// in AllPalletsWithSystem
// This was fine before pallet-message-queue because the XCM messages
// were processed by the "setValidationData" inherent call and not on an
// "on_initialize" hook, which runs before enabling XCM tracing
api.initialize_block(substrate_parent_hash, &block_header)
.map_err(|e| format!("Runtime api access error: {:?}", e))?;
if core_api_version >= 5 {
api.initialize_block(substrate_parent_hash, &block_header)
.map_err(|e| format!("Runtime api access error: {:?}", e))?;
} else {
#[allow(deprecated)]
api.initialize_block_before_version_5(substrate_parent_hash, &block_header)
.map_err(|e| format!("Runtime api access error: {:?}", e))?;
}

#[allow(deprecated)]
api.trace_block_before_version_5(substrate_parent_hash, extrinsics, eth_tx_hashes)
Expand Down
4 changes: 2 additions & 2 deletions test/helpers/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function assetContractAddress(assetId: bigint | string): `0x${string}` {
return `0xffffffff${BigInt(assetId).toString(16)}`;
}

const patchLocationV4recursively = (value: any) => {
export const patchLocationV4recursively = (value: any) => {
// e.g. Convert this: { X1: { Parachain: 1000 } } to { X1: [ { Parachain: 1000 } ] }
if (value && typeof value == "object") {
if (Array.isArray(value)) {
Expand All @@ -61,7 +61,7 @@ const patchLocationV4recursively = (value: any) => {
if (k === "Concrete" || k === "Abstract") {
return patchLocationV4recursively(value[k]);
}
if (k.match(/^X\d$/g) && !Array.isArray(value[k])) {
if (k.match(/^[Xx]\d$/g) && !Array.isArray(value[k])) {
value[k] = Object.entries(value[k]).map(([k, v]) => ({
[k]: patchLocationV4recursively(v),
}));
Expand Down
Loading

0 comments on commit be5002d

Please sign in to comment.