[Documentation]: Group Policy delegation example #17561
Open
Description
opened on Aug 28, 2023
Summary
In the x/group
documentation 1, it is written
Managing group membership separately from decision policies results in the
least overhead and keeps membership consistent across different policies.
The pattern that is recommended is to have a single master group policy
for a given group, and then to create separate group policies with different
decision policies and delegate the desired permissions from the master
account to those "sub-accounts" using the x/authz module.
I would like to see an example of how to achieve such delegation as I failed to make it work on my own.
My attempt
- Use
create-group-with-policy
to create a new group and a new (master) policy, where the policy address is used as the owner of the group policy
- admin: tc31c799jddmlz7segvg6jrw6w2k6svwafganjdznard3tc74n7td7rq656kvp
created_at: "2023-08-25T16:59:41.034297658Z"
id: "2"
metadata: ""
total_weight: "2"
version: "2"
members:
- group_id: "2"
member:
added_at: "2023-08-25T16:59:41.034297658Z"
address: tc31wquv2y58ljkqjw5a90amlk0vc00mu45v3mhq30
metadata: Bob
weight: "1"
- group_id: "2"
member:
added_at: "2023-08-25T16:59:41.034297658Z"
address: tc3109u66fqlkyvtxuy2n9js35zlhqhml8dncuva77
metadata: Alice
weight: "1"
- address: tc31c799jddmlz7segvg6jrw6w2k6svwafganjdznard3tc74n7td7rq656kvp
admin: tc31c799jddmlz7segvg6jrw6w2k6svwafganjdznard3tc74n7td7rq656kvp
created_at: "2023-08-25T16:59:41.034297658Z"
decision_policy:
'@type': /cosmos.group.v1.ThresholdDecisionPolicy
threshold: "2"
windows:
min_execution_period: 0s
voting_period: 600s
group_id: "2"
metadata: ""
version: "2"
- Submit a new proposal to create a new (send token) group policy, where the master policy address is used as the owner of the send token policy. Vote and execute the proposal.
- address: tc31f6fyc0ptxh7padqr3hnrw6sm8wjfr93w6cgv39jwm00nd6kh08esyrnyes
admin: tc31c799jddmlz7segvg6jrw6w2k6svwafganjdznard3tc74n7td7rq656kvp
created_at: "2023-08-25T17:15:20.452943414Z"
decision_policy:
'@type': /cosmos.group.v1.ThresholdDecisionPolicy
threshold: "1"
windows:
min_execution_period: 0s
voting_period: 600s
group_id: "2"
metadata: ""
version: "1"
- Submit a new proposal to grant
SendAuthorization
to the send token policy on behalf of the master policy. Vote and execute the proposal.
grants:
- authorization:
'@type': /cosmos.bank.v1beta1.SendAuthorization
allow_list: []
spend_limit:
- amount: "10"
denom: token
expiration: null
grantee: tc31f6fyc0ptxh7padqr3hnrw6sm8wjfr93w6cgv39jwm00nd6kh08esyrnyes
granter: tc31c799jddmlz7segvg6jrw6w2k6svwafganjdznard3tc74n7td7rq656kvp
- Submit a proposal to send some tokens from the master policy account to some user
{
"group_policy_address": "tc31f6fyc0ptxh7padqr3hnrw6sm8wjfr93w6cgv39jwm00nd6kh08esyrnyes",
"messages": [
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from_address": "tc31c799jddmlz7segvg6jrw6w2k6svwafganjdznard3tc74n7td7rq656kvp",
"to_address": "tc31wquv2y58ljkqjw5a90amlk0vc00mu45v3mhq30",
"amount": [
{
"denom": "token",
"amount": "10"
}
]
}
],
"metadata": "",
"title": "Pay Bob for stuff",
"summary": "This is a proposal to pay 10token to Bob for stuff",
"proposers": [ "tc31wquv2y58ljkqjw5a90amlk0vc00mu45v3mhq30" ]
}
This fails with
raw_log: 'failed to execute message; message index: 0: msg does not have group policy
authorization; expected tc31f6fyc0ptxh7padqr3hnrw6sm8wjfr93w6cgv39jwm00nd6kh08esyrnyes,
got tc31c799jddmlz7segvg6jrw6w2k6svwafganjdznard3tc74n7td7rq656kvp: unauthorized'
Thanks!
Activity