-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add Registrar proxy type #358
Conversation
Coverage Report@@ Coverage Diff @@
## master jeremy-registar-proxy-type +/- ##
==============================================================
+ Coverage 73.94% 74.06% +0.12%
Files 91 91
+ Lines 20536 20637 +101
==============================================================
+ Hits 15184 15283 +99
+ Misses 5352 5354 +2
|
Let's add a typescript test, I guess it will be a combination of these 2: test/suites/common/proxy/test-proxy-balances.ts |
null, | ||
polkadotJs.tx.registrar.register(2002, containerChainGenesisData) | ||
); | ||
const tx3 = polkadotJs.tx.registrar.markValidForCollating(2002); |
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.
Isnt it sufficient for the test that we test only that the genesis data gets set? the rest is made with sudo
@@ -940,6 +942,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |||
ProxyType::Balances => { | |||
matches!(c, RuntimeCall::Balances(..) | RuntimeCall::Utility(..)) | |||
} | |||
ProxyType::Registrar => { |
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 we also add a proxy type called SUdoRegistrar that is sable to call with sudo any of the registrar calls? similar to https://github.com/paritytech/polkadot-sdk/blob/e7651cf41b2d775dedcc897e17ead16e200a4fff/polkadot/runtime/westend/src/lib.rs#L1064
const onChainBootnodes = await polkadotJs.query.registrar.bootNodes(2002); | ||
// TODO: fix once we have types | ||
expect(onChainBootnodes.toHuman()).to.deep.equal(["dummy"]); | ||
}, |
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.
This test could also check that the registrar deposit is set to alice when charlie registers the chain using proxy. And also add a test for sudoRegistrar, it should be easy, try calling sudo(markValidForCollating) through the proxy.
runtime/dancebox/src/lib.rs
Outdated
RuntimeCall::Sudo(pallet_sudo::Call::sudo {call: ref x}) | ||
if matches!(x.as_ref(), RuntimeCall::Registrar(..)) |
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.
Compared to SudoBalances this is missing RuntimeCall::Utility, but I guess that's good, we don't want the proxy to be able to call sudo(utility.dispatchAs)... But what about allowing utility.batch*, that should be ok?
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 am actually not entirely sure what would happen if we enable utility here, but I see that parity has it enabled in a similar proxy type: https://github.com/paritytech/polkadot-sdk/blob/4c4407a8930267e139db93019c01444acf49e1ce/polkadot/runtime/westend/src/lib.rs#L1066
@nanocryk can you try it out?
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 was wrong, it depends on how you define the proxy:
Sudo(Registrar) || Utility
this is fine
Sudo(Registrar || Utility)
this is bad
The current way of always allowing utility should be ok as well
Cargo.lock
Outdated
@@ -853,7 +853,7 @@ dependencies = [ | |||
[[package]] | |||
name = "binary-merkle-tree" | |||
version = "4.0.0-dev" | |||
source = "git+https://github.com/moondance-labs/polkadot-sdk?branch=tanssi-polkadot-v1.3.0#c3d18c8c2f4c5462b752b98eb2908dc32b5ec985" |
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 merge master? It should remove the changes in Cargo.lock
ProxyType::Balances, | ||
ProxyType::Registrar, | ||
ProxyType::SudoRegistrar, | ||
]; |
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.
There are some external crates that allow iterating over enums, not sure if we already have one, but as a nice hack we could use the Decode trait (not tested but should work):
for x in 0u8.. {
if let Ok(x) = x.decode::<ProxyType>() {
proxy_types.push(x);
} else {
break;
}
}
const tx3 = polkadotJs.tx.proxy.proxy( | ||
bob.address, | ||
null, | ||
polkadotJs.tx.registrar.setBootNodes(2002, ["dummy"]) |
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.
Sorry, in #341 we moved the setBootNodes to a different pallet, pallet_data_preservers. I guess we want that to be included in the SudoRegistrar proxy as well. So this should work:
polkadotJs.tx.registrar.setBootNodes(2002, ["dummy"]) | |
polkadotJs.tx.dataPreservers.setBootNodes(2002, ["dummy"]) |
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.
yes exactly
Please put a description in the PR and let's merge master back in |
Co-authored-by: tmpolaczyk <[email protected]>
Co-authored-by: tmpolaczyk <[email protected]>
None, | ||
Box::new( | ||
pallet_utility::Call::batch { | ||
calls: vec![pallet_balances::Call::force_set_balance { |
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.
force_set_balance will always fail because it needs root origin, maybe this test is missing a call to sudo first?
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.
yes the test needs to be batch->sudo.>force_set_balacne
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.
But ProxyType::Any
should allow this, right? Then why doesn't the test fail?
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.
hmm that's a good question
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.
its probably becaues we are still not going through the sudo pallet right?
Adds new
Registrar
andSudoRegistrar
proxy types.