Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Rename original_origin and origin in XcmExecutor #7136

Closed
wants to merge 10 commits into from

Conversation

tonyalaribe
Copy link
Contributor

These are semantic changes for the variables to have clearer meanings.
original_origin was renamed to physical_origin since it should point to the actual chain.
origin was renamed to computed_origin in some cases since those origins could be more conceptual and might point to Accounts, or Pallets or other entities. And not necessary the chain executing the XCM instructions.

@tonyalaribe tonyalaribe added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. labels Apr 26, 2023
@xlc
Copy link
Contributor

xlc commented Apr 26, 2023

I like the name. Some in code comments explain them will be better.

pub fn new(origin: impl Into<MultiLocation>, message_hash: XcmHash) -> Self {
let origin = origin.into();
pub fn new(computed_origin: impl Into<MultiLocation>, message_hash: XcmHash) -> Self {
let computed_origin = computed_origin.into();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the computed origin -- whatever that gets sent in is definitely the physical origin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. I've updated it

@@ -340,7 +340,9 @@ impl TryFrom<OldWeightLimit> for WeightLimit {
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug)]
pub struct XcmContext {
/// The `MultiLocation` origin of the corresponding XCM.
pub origin: Option<MultiLocation>,
/// The origin is could point to physical locations (Chains, etc),
/// but also conceptual locations such as Accounts or Pallet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what a computed origin is: check the docs here for info:

/// This effectively allows for the possibility of distinguishing an origin which is acting as a
/// router for its derivative locations (or as a bridge for a remote location) and an origin which
/// is actually trying to send a message for itself. In the former case, the message will be
/// prefixed with origin-mutating instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to put it in words as a definition. Do you have any suggestions?

@@ -191,21 +192,21 @@ impl<Config: config::Config> ExecuteXcm<Config::RuntimeCall> for XcmExecutor<Con
}
}
fn execute(
origin: impl Into<MultiLocation>,
computed_origin: impl Into<MultiLocation>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, this surely isn't a computed origin that gets sent in. You can only get a computed origin as a result of an XCM execution, not when it is set up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it back to origin

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's correct either -- this is the physical origin that gets sent in. Calling it just origin naturally makes people question whether it's computed or physical, and in this case, we know it's physical for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it to physical_origin, but I also renamed origin to physical_origin in execute_xcm and execute_xcm_in_credit. Is that ok?

xcm/src/v3/mod.rs Outdated Show resolved Hide resolved
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable
Logs: https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/2748572

@gavofyork
Copy link
Member

I'm not sure the new names are actually accurate.

The origin with which the executor is initialised is obviously the Original Origin. The value in the Origin register may get mutated but I don't see why this wouldn't still be called the Origin.

I think unfortunately people are not realising that the XCVM operates at a different abstraction level to that of the *MP routing system. The XCVM does not know or care about transport systems or the difference between "physical" and "computed" origins.

@tonyalaribe
Copy link
Contributor Author

I'm not sure the new names are actually accurate.

The origin with which the executor is initialised is obviously the Original Origin. The value in the Origin register may get mutated but I don't see why this wouldn't still be called the Origin.

I think unfortunately people are not realising that the XCVM operates at a different abstraction level to that of the *MP routing system. The XCVM does not know or care about transport systems or the difference between "physical" and "computed" origins.

Following I would close this PR, since the renamings don't make thinks as clear as we imagined, and muddles XCM and XCMP concepts.

@tonyalaribe tonyalaribe closed this May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants