-
Notifications
You must be signed in to change notification settings - Fork 91
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
Feat/restricted transfers closure #1621
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The restricted-xtokens
pallet looks good 🥳
I left a couple of comments, suggestions or just questions as a first scan but will give it another look either later or tomorrow morning 👍
fn para_a_rreceiver_para_a() -> MultiLocation { | ||
MultiLocation::new( | ||
0, | ||
X1(Junction::AccountId32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't include the parachain "a" in the multilocation. I guess it doesn't affect functionality but it would be nice to have this in sync with para_a_rreceiver_para_b
and generally having it looking like what one would expect it to be (the principle of least surprise)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would I do that? The location is generated from the point of view of para_a
, right?
let mut a: Vec<u8> = "A".into(); | ||
a.resize(32, 0); | ||
let mut a1: Vec<u8> = "A1".into(); | ||
a1.resize(32, 0); | ||
let mut b: Vec<u8> = "B".into(); | ||
b.resize(32, 0); | ||
let mut b1: Vec<u8> = "B1".into(); | ||
b1.resize(32, 0); | ||
if l == MultiLocation::parent() { | ||
return Some(CurrencyId::R); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unnecessarily clutter-y. If we would use a GeneralIndex
(u128
) that we map for each currency, then it's a lot simpler and we could even define that map at the enum definition level (i.e, pub enum CurrencyId { R = 0, A = 1, etc
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copy pasta that one from acala. While I agree I think for the given 5 enum variants this logic is fine and I do not expect to change it often in the futre. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of comments, but looks good to me! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current extrinsic weights are underestimated. Given that this is a common attack vector, this needs to be fixed.
Apart from that, I also believe that we cannot simply overwrite the OrmlXTokens
pallet index with XTokens
because we drop the storage.
There a few more nit comments which you can ignore. I have to admit that I only skimmed through the mocks and unit tests.
@@ -1994,6 +2015,7 @@ mod __runtime_api_use { | |||
|
|||
#[cfg(not(feature = "disable-runtime-api"))] | |||
use __runtime_api_use::*; | |||
use cfg_types::locations::Location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on this addition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clion. will see if can remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I switched to RustRover, I am running into similar issues. Still incredible time saving with the auto imports.
There is no storage, or am I missing something? |
You are right. Then I suppose we can keep your change. Will close the requests. |
b8ca31e
to
455cd00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minus nits from william I think it is good to go. We should address these and then get this in.
Needs: - tests - clean up of warnings
* integration-tests: Add relay chain storage to env, update restricted token tests * restricted-xtokens: Remove xcm-simulator tests * deps: Update restricted-xtokens deps * transfer-allowlist: Use different trait for increasing an account balance in benchmarking setup * integration-tests: Add default constructor for generic envs * integration-test: Add LP eth usdc test via LP pallet * integration-tests: Check for allowance in LP eth usdc test * transfer-allowlist: Use non-default currency ID in benchmarks * clippy: Obey * transfer-allowlist: Drop custom currency ID in mock runtime * transfer-allowlist: Add non-default currency ID for tests
51152d7
to
ab7528a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adhering to all my nits and fixing the weight! Looks really good, great work @mustermeiszer and @cdamian!
runtime/altair/src/lib.rs
Outdated
ProxyType::Transfer => { | ||
matches!( | ||
c, | ||
RuntimeCall::XTokens(..) | RuntimeCall::Balances(..) | RuntimeCall::Tokens(..) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdamian sit, I forgot something. We should add two more here
RuntimeCall::LiquidityPools(pallet_liquidituy_pool::Call::Transfer{..} | pallet_liquidituy_pool::Call::TransferTrancheTokens{..})
runtime/development/src/lib.rs
Outdated
ProxyType::Transfer => { | ||
matches!( | ||
c, | ||
RuntimeCall::XTokens(..) | RuntimeCall::Balances(..) | RuntimeCall::Tokens(..) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in altair and Centrifuge
/benchmark centrifuge |
/benchmark altair |
/benchmark development |
5535ee6
to
df59f6a
Compare
Description
This changes closes the restricted transfers features. This will allow accounts to set allowances for their accounts and currencies to where funds are allowed to be sent to (not for CFG though, as we can not restrict
pallet-balances
).This is an opt-in restriction meaning
NOTE:
orml-xtokens
has NO storage andpallet-restricted-xtokens
mimics the API 1-to-1, hence we can replace the location oforml-xtokens
withpallet-restricted-xtokens
in theconstruct_runtime!
-macroChanges and Descriptions
orml-xtokens
inpallet-restricted-xtokens
pallet-transfer-allowlist
to reject native currency allowancespallet-transfer-allowlist
to devpallet-transfer-allowlist
to altairpallet-transfer-allowlist
to centrifugepallet-restricted-xtokens
to devpallet-restricted-xtokens
to altairpallet-restricted-xtokens
to centrifugepallet-restricted-xtokens
andpallet-restricted-tokens
ProxyType::Transfer
that can be used to extend otherwise non-transfer proxies with this ability.Checklist: