Refactoring create asset and add CI tests to cover#1112
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1112 +/- ##
==========================================
+ Coverage 75.08% 75.09% +0.01%
==========================================
Files 58 58
Lines 2464 2465 +1
Branches 72 72
==========================================
+ Hits 1850 1851 +1
Misses 597 597
Partials 17 17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
claravanstaden
left a comment
There was a problem hiding this comment.
I had a quick look, I think the polkadot-sdk companion PR should still be opened right? 😄
| #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] | ||
| pub enum Call { | ||
| /// Call create_asset on foreign assets pallet. | ||
| #[codec(index = 53)] |
There was a problem hiding this comment.
I think the pallet index should stay configured in the runtime config. What happens if the ForeignAssets pallet indexes are different per runtime? I think they are the same and that is the convention, but I still think this is runtime related and shouldn't live in the snowbridge crates.
There was a problem hiding this comment.
What happens if the ForeignAssets pallet indexes are different per runtime? I think they are the same and that is the convention.
Yeah, that's the precondition, checked that all the same in multiple runtimes(e.g. polkadot/kusama). I do not see a reason why they need to break this rule in the future so prefer to make things simple at this moment.
But I'm open if you all think that's a problem and will make some changes accordingly.
There was a problem hiding this comment.
Maybe we can add a test to make sure they are in line?
There was a problem hiding this comment.
Ah I see a test is added. Ignore this.
There was a problem hiding this comment.
I agree with Clara here, I am a bit uncomfortable with baking runtime configuration inside our pallets & primitives crate.
Secondly, I am sensitive about changing code unnecessarily at this point. Our next audit is scheduled for Feb 8, and this change will increase the scope of the audit.
I want to reserve any scope increases to accommodate for the second round of code review that the Parity bridges team is going to perform soon.
There was a problem hiding this comment.
The initial intention of this PR is for the comment to add the call index to some primitives which can be referenced/checked in the AH runtime tests.
So @vgeddes do we still need this PR? I think we already have the emulated test register token to cover this use case so maybe the refactoring here and the unit test added in AH may not be necessary at all?
There was a problem hiding this comment.
I think Slava wanted us to move those constants here: polkadot-sdk/bridges/primitives/chain-asset-hub-rococo. I think it is fine to move the pallet index, but not to our crates. It should still be in the polkadot-sdk, and it should be configured per testnet. I think it can actually go here too: polkadot-sdk/cumulus/parachains/common/src/rococo.rs
There was a problem hiding this comment.
Thanks Clara and that makes sense! So do you think also better to move the hard-coded weight to some common runtime config?
Also noticed that Vincent mentioned to reserve any scope increases to accommodate for the second round of code review then not sure if it's the right time to do the refactoring.
So I'll convert the PR as draft and let the team decide whether to continue with the change or not.
There was a problem hiding this comment.
@claravanstaden Some refactoring in 37aa97e as you suggested.
| /// CallInfo required to create the foreign asset | ||
| #[derive(Clone, Encode, Decode, RuntimeDebug)] | ||
| pub struct CreateAssetCallInfo { | ||
| /// Index of the create call | ||
| pub call_index: CallIndex, | ||
| /// Deposit required to create the asset | ||
| pub asset_deposit: u128, | ||
| /// Minimal balance of the asset | ||
| pub min_balance: u128, | ||
| /// Weight required for the xcm transact | ||
| pub transact_weight_at_most: Weight, | ||
| } |
There was a problem hiding this comment.
So we add a CallInfo structure for the create asset and make it runtime config(without any hard coded params anymore), meanwhile we add runtime tests in asset-hub to check the call_index and transact_weight_at_most all as expected.
vgeddes
left a comment
There was a problem hiding this comment.
Hey Ron this is a very nice improvement. However we have an audit in 2-3 weeks and I want us to have some sort of code freeze for relatively non-important changes.
So lets wait till after the next audit to merge this in.
Resolves: SNO-817
Requires: Snowfork/polkadot-sdk#99