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

xcm: fix for DenyThenTry Barrier #7169

Open
wants to merge 48 commits into
base: master
Choose a base branch
from

Conversation

yrong
Copy link
Contributor

@yrong yrong commented Jan 15, 2025

Resolves (partially): #7148 (see Problem 1 - ShouldExecute tuple implementation and Deny filter tuple)

This PR changes the behavior of DenyThenTry from the pattern DenyIfAllMatch to DenyIfAnyMatch for the tuple.

I would expect the latter is the right behavior so make the fix in place, but we can also add a dedicated Impl with the legacy one untouched.

TODO

  • add unit-test for DenyReserveTransferToRelayChain
  • add test and investigate/check DenyThenTry as discussed here and update documentation if needed

@yrong yrong requested a review from a team as a code owner January 15, 2025 02:43
@yrong yrong changed the title Fix for DenyThenTry xcm: fix for DenyThenTry Barrier Jan 15, 2025
@yrong yrong marked this pull request as draft January 15, 2025 03:36
polkadot/xcm/xcm-executor/src/traits/should_execute.rs Outdated Show resolved Hide resolved
polkadot/xcm/xcm-executor/src/traits/should_execute.rs Outdated Show resolved Hide resolved
polkadot/xcm/xcm-builder/src/barriers.rs Outdated Show resolved Hide resolved
polkadot/xcm/xcm-builder/src/barriers.rs Outdated Show resolved Hide resolved
polkadot/xcm/xcm-builder/src/barriers.rs Outdated Show resolved Hide resolved
polkadot/xcm/xcm-executor/src/traits/should_execute.rs Outdated Show resolved Hide resolved
@bkontur
Copy link
Contributor

bkontur commented Jan 15, 2025

@yrong overall looks good so far, I was also thinking about another trait for that like this

@bkontur bkontur requested a review from x3c41a January 15, 2025 09:46
@yrong yrong marked this pull request as ready for review January 15, 2025 12:38
@franciscoaguirre franciscoaguirre added the T6-XCM This PR/Issue is related to XCM. label Jan 15, 2025
polkadot/xcm/xcm-executor/src/traits/should_execute.rs Outdated Show resolved Hide resolved
prdoc/pr_7169.prdoc Outdated Show resolved Hide resolved
@yrong yrong requested a review from bkontur January 15, 2025 16:06
Copy link
Contributor

@bkontur bkontur left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

Thank you @yrong !

New barrier is much better. Just have a few punctual impl comments:

polkadot/xcm/xcm-executor/src/traits/should_execute.rs Outdated Show resolved Hide resolved
instructions: &mut [Instruction<RuntimeCall>],
max_weight: Weight,
properties: &mut Properties,
) -> Option<ProcessMessageError>;
Copy link
Contributor

Choose a reason for hiding this comment

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

nitish: using Result instead of Option would be idiomatic here.

Suggested change
) -> Option<ProcessMessageError>;
) -> Result<(), ProcessMessageError>;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original version is something like that. @bkontur left some concerns in
#7169 (comment) which make sense to me, so we made the change accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand it better with the Option because seeing Some(_) makes me guess it will be denied but seeing Ok(_) makes me doubt whether or not it's okay to deny or okay to pass.

To clear up all possible misunderstanding we could use a custom enum:

enum DenyResult {
  Deny,
  DontDeny,
}

Might be overkill though.

Copy link
Contributor Author

@yrong yrong Jan 25, 2025

Choose a reason for hiding this comment

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

Miss the comment in another thread #7169 (comment)

@franciscoaguirre seems others prefer more to Result<(), ProcessMessageError>, but thanks for the comment here anyway.

polkadot/xcm/xcm-executor/src/traits/should_execute.rs Outdated Show resolved Hide resolved
polkadot/xcm/xcm-executor/src/traits/should_execute.rs Outdated Show resolved Hide resolved
instructions: &mut [Instruction<RuntimeCall>],
max_weight: Weight,
properties: &mut Properties,
) -> Option<ProcessMessageError>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand it better with the Option because seeing Some(_) makes me guess it will be denied but seeing Ok(_) makes me doubt whether or not it's okay to deny or okay to pass.

To clear up all possible misunderstanding we could use a custom enum:

enum DenyResult {
  Deny,
  DontDeny,
}

Might be overkill though.

polkadot/xcm/xcm-builder/src/tests/barriers.rs Outdated Show resolved Hide resolved
polkadot/xcm/xcm-builder/src/tests/barriers.rs Outdated Show resolved Hide resolved
@franciscoaguirre
Copy link
Contributor

/cmd fmt

@yrong
Copy link
Contributor Author

yrong commented Jan 26, 2025

@acatangiu Please check if there is anything important that I should address for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T6-XCM This PR/Issue is related to XCM.
Projects
Status: In-Review
Development

Successfully merging this pull request may close these issues.

[XCM] Investigate better support for filtering XCM programs with Barrier
6 participants