Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Conversation

@vstam1
Copy link
Contributor

@vstam1 vstam1 commented Sep 5, 2023

No description provided.

# Barrier
Before any XCMs are executed in the XCM executor, they must pass the Barrier.
The Barrier type implements the `ShouldExecute`
[trait](https://paritytech.github.io/polkadot/doc/xcm_executor/traits/trait.ShouldExecute.html)

Choose a reason for hiding this comment

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

Given all these links being so long, it might be useful to list them at the bottom of the file. Something like:

some [`link`] foo


[`link`]: https://paritytech.github.io/polkadot/doc/xcm_executor/traits/trait.ShouldExecute.html

This works in rust-docs, I think it is a native markdown feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did not know this! Really nice feature.



### `TakeWeightCredit`
The `TakeWeightCredit`` barrier checks if the calculated weight of the XCM does not exceed a set weight limit.
Copy link

@kianenigma kianenigma Sep 6, 2023

Choose a reason for hiding this comment

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

For each of these barriers, can these explanations be just part of the rust-docs? Remember, "what can be documented in rust-docs (or generally a lower level documentation) should be documented in there".

I am not familiar enough to make the call, but it seems to me that these should just be rust-docs, and the high level concepts, possibly how you compose and use barriers in the broad scope should be mentioned here.

Choose a reason for hiding this comment

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

Or possibly, if this is paraphrasing what is already in the rust-docs, I also think there is less added value in it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with putting this explanations in rust-docs. I also think some amount of the top-level explanations and examples should be in rust-docs too.

Each time the xcm-executor receives an XCM, it checks with the barrier to determine if the XCM should be executed.

We can also define multiple barriers for our Barrier type using a tuple.
During execution, each barrier is checked, and if any of them succeed, the XCM is executed.

Choose a reason for hiding this comment

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

question for me: how can you express an && operator with these barriers then? is there a way to say: Execute if all of my barriers pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I know we do not support && operator in any way as I am not sure if it makes sense with the current barrier implementations. Most of these implementations are used for specific XCMs. We of course already have nested barriers like the WithComputedOrigin. We could make something similar that takes other implementations and only passes if all the implementations pass.

@@ -0,0 +1,89 @@
-TODO: All Barriers Explained
-TODO: Security Note about misconfigured barriers
-TODO: Example

Choose a reason for hiding this comment

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

Examples would be both nice here, but also as a part of the rust-docs.

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 created an comprehensive example that uses most of the Barriers in the list together, showing how barriers can be combined.

Copy link
Collaborator

@franciscoaguirre franciscoaguirre left a comment

Choose a reason for hiding this comment

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

We should port this to the polkadot wiki, see: #47

Multiple barriers can be defined for the Barrier type using a tuple. During execution, each barrier is checked, and if any succeed, the XCM is executed. The combination of barriers is crucial as it can either block or allow specific XCM functionalities. An example of how barriers can be combined will be provided in the [example section](#example).

## Security
Barriers are vital for the security of the xcm-executor, acting as its firewall. Their main role is to decide whether a given XCM should be executed. Barriers can operate in various ways, such as checking if certain origins are authorized to execute an XCM, verifying if the XCM contains specific instructions, or a combination of both. Incorrectly configuring a barrier can lead to vulnerabilities, such as allowing attackers to flood the system with XCMs, potentially causing a Denial of Service.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd add that it's important to note the barrier will run for each message received in order to know if it should be executed, so it should be cheap to compute.

Comment on lines +73 to +75



Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

@@ -0,0 +1,75 @@
# Barrier
Before any XCMs are executed in the XCM executor, they must pass through the Barrier. The Barrier type implements the [`ShouldExecute`] trait and serves as the firewall for the xcm-executor. Each time the xcm-executor receives an XCM, it consults the Barrier to determine if the XCM should be executed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd add in a new paragraph that barriers can also modify the message, like adding a new instruction or whatnot.

- [`DenyReserveTransferToRelayChain`]


### Example
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a good example, but I would add some smaller examples before it to build up to it. Makes it easier to understand.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants