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

Implement fees in outbound router since it is not supported #941

Closed
wants to merge 8 commits into from

Conversation

claravanstaden
Copy link
Contributor

@claravanstaden claravanstaden commented Aug 29, 2023

Remove support for target chain fees in the XCM message, since they are not handled in the target chain at all. In any case, target chain fees will be added in: #924

Resolves: SNO-645
Cumulus companion: Snowfork/cumulus#62

@@ -103,16 +103,11 @@ where
})?;

let mut converter = XcmConverter::new(&message, &gateway_network, &gateway_address);
let (agent_execute_command, max_target_fee) = converter.convert().map_err(|err|{
let (agent_execute_command, _max_target_fee) = converter.convert().map_err(|err|{
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 guess _max_target_fee can be removed in its entirety here.

if fee_asset.len() == 1 && fee_asset.contains(execution_fee) =>
Some(execution_fee),
_ => return Err(BuyExecutionExpected),
},
UnpaidExecution { check_origin: None, weight_limit: Unlimited } => None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only allow unpaid execution here since we don't handle fees on the target platform.

TBC: I am not sure this is acceptable for going live on Kusama, we might have to implement it before then.

Copy link
Contributor

@yrong yrong Aug 30, 2023

Choose a reason for hiding this comment

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

For implementing fee charge mechanism there are several xcm conponents related.

Firstly In source chain it requires a properly configured SovereignPaidRemoteExporter like what we did for template runtime(not the unpaid currently in assetHub).

Secondly we need to make sure from whom to charge the fee, I would assume a soverign account derivated from that particular agent_id, could be relevant to we're discussing in #940 (comment)

Lastly a properly configured FeeManager in bridgeHub which still missing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if removing this code resolves the audit issue. The audit report suggests handling both scenarios. This PR makes no change to the observable behavior of this code. Both the old code and the new code will return SendError::Unroutable when target fees are specified. The only change is what error gets logged out to the log file. The new code will log TargetFeesExpected as the error. The old code will log TargetFeesNotSupported as the error, which I think is more self documenting.

So maybe this should be solved in the way Ron suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback.

@yrong I understood these fees as fees on the target chain, right? So the fees also need to be paid on the Ethereum side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alistair-singh Ok sure! I thought we would just remove the fee XCM instructions and only allow UnpaidExecution for now (I know it doesn't really make a change to the functionality, but neither does some of the other refactor issues), but if you think it's better to implement the fees now I will get on it.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the end all incurred costs(including gas cost on the Ethereum side) should be covered by the original sender(i.e. a signed origin like Alice or Bob in assetHub).

Though we have some fee_info logic prepared to extract fee from the original xcm, we don't support it as you can see the check here actually only unpaid is allowed.

For fully implementing the fee charge mechanism it requires several other xcm components as I mentioned above which still missing(considerable change required both in assetHub and bridgeHub).

I think the current implementation should be fine for demo purposes or the launch on Rococo testnet. But definitely not for production usage as you mentioned before the kusama or polkadot.

I don't know if we would implement it right now or later, leave to the team for the final decision.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mostly agree with Ron. In general there are some missing pieces in BridgeHub, and we are on a very old version of Polkadot/Substrate/Cumulus/. So it is hard to make sense of where we need to be.

The big difference is that in the newer versions, AssetHub will not be configured with a SovereignRemoteExporter or a UnpaidRemoteExporter. Instead AssetHub will directly send an XCM message to BridgeHub containing an ExportMessage instruction.

So I think we should consider this PR BLOCKED for the time being.

Copy link
Contributor

@yrong yrong Sep 11, 2023

Choose a reason for hiding this comment

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

Seems they're just trying to reuse the previous reserve_transfer_assets without introducing a new pallet for this?

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Patch coverage: 80.00% and no project coverage change.

Comparison is base (1201e1d) 74.23% compared to head (0cd5645) 74.23%.
Report is 6 commits behind head on main.

❗ Current head 0cd5645 differs from pull request most recent head 227f5a3. Consider uploading reports for the commit 227f5a3 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #941   +/-   ##
=======================================
  Coverage   74.23%   74.23%           
=======================================
  Files          41       41           
  Lines        1836     1836           
  Branches       77       77           
=======================================
  Hits         1363     1363           
  Misses        451      451           
  Partials       22       22           
Flag Coverage Δ
rust 74.76% <80.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
parachain/primitives/router/src/outbound/mod.rs 87.96% <80.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@claravanstaden claravanstaden changed the title Oak fix: issue 18 Removes XCM target chain fees in outbound router since it is not supported Aug 30, 2023
@claravanstaden claravanstaden changed the title Removes XCM target chain fees in outbound router since it is not supported Implement fees in outbound router since it is not supported Aug 31, 2023
@claravanstaden
Copy link
Contributor Author

Closing this PR since #940 (review) covers this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants