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

Msg Authorization ADR #5235

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Oct 23, 2019

@alexanderbez @jackzampolin this PR points to our latest spec on this "generic msg delegation/authorization" functionality so that we have a place to discuss the architectural details in preparation for next time we meet. This supersedes the previous spec although this module doesn't really have any substantive differences from that spec. I know we want something different from msg_delegation. Once I've got a clear idea, I'll rename it and update the PR.

@codecov
Copy link

codecov bot commented Oct 23, 2019

Codecov Report

Merging #5235 into master will increase coverage by 0.04%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5235      +/-   ##
==========================================
+ Coverage   53.51%   53.55%   +0.04%     
==========================================
  Files         290      290              
  Lines       17770    17719      -51     
==========================================
- Hits         9509     9489      -20     
+ Misses       7511     7489      -22     
+ Partials      750      741       -9

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Concept ACK. Left some minor feedback.

Also, I'm not sure what merging this PR signifies as it's not a true spec but more of a proposal? Perhaps turn this into an ADR and we can then merge it and begin implementation.

Grantee sdk.AccAddress `json:"grantee"`
Capability Capability `json:"capability"`
// Expiration specifies the expiration time of the grant
Expiration time.Time `json:"expiration"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should piggy back off of what fee delegation provides in that you can expire at a height or time. We could use the concrete type defined in that PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fine using the existing struct but I do question the utility of both height and time. It seems like adding height introduces other complexities when exporting to genesis. I commented about this in the fee delegation PR as well. Basically why is it desired to support both @alexanderbez or would just time be sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO time is sufficient and simpler. In that case, we should just use int64

}
```

### MsgRevoke
Copy link
Contributor

Choose a reason for hiding this comment

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

The UX is a bit confusing here IMHO. Capabilities are granted, but messages are revoked? What if I wanted to revoke an entire capability instead of doing it message by message?

Copy link
Member Author

@aaronc aaronc Nov 6, 2019

Choose a reason for hiding this comment

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

So the reason for this is because capabilities are stored based on the sdk.Msg type they refer to. That is the key that needs to be revoked. Would it make it clearer if MsgRevoke had a field CapabilityMsgType like this?

type MsgRevoke struct {
	Granter sdk.AccAddress `json:"granter"`
	Grantee sdk.AccAddress `json:"grantee"`
        // CapabilityMsgType is the type of sdk.Msg that the revoked Capability refers to.
        // i.e. this is what `Capability.MsgType()` returns
	CapabilityMsgType sdk.Msg `json:"capability_msg_type"`
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes!

`DispatchActions attempts to execute the provided messages via capability
grants from the message signer to the grantee.

### `Grant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccAddress, capability Capability, expiration time.Time)`
Copy link
Contributor

Choose a reason for hiding this comment

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

markdown linting is needed here.

// MsgExecDelegated attempts to execute the provided messages using
// capabilities granted to the grantee. Each message should have only
// one signer corresponding to the granter of the capability.
type MsgExecDelegated struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

What this pseudo-spec fails to mention, yet should, is how this is wired together. It should be noted that when a client wishes to send a tx with a delegated message(s), they need to wrap it with this message type and that the client logic (CLI and REST) should do this automatically for the client via some flags/params.

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding a --send-as flag to the docs

@aaronc aaronc changed the title Msg delegation/authorization spec Msg Authorization ADR Nov 6, 2019
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Thanks @aaronc. Left some feedback. The ADR also needs to be added in the TOC section in docs/architecture/README.MD.

Comment on lines +17 to +19
We will create a module named `msg_authorization`

The `msg_authorization` module provides support for granting arbitrary capabilities
Copy link
Contributor

Choose a reason for hiding this comment

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

We will create a module named msg_authorization. The msg_authorization module provides ...


- 2019-11-06: Initial ADR

## Context
Copy link
Contributor

Choose a reason for hiding this comment

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

The context should state the (concise) motivation for why we believe this is needed.

```go
type Capability interface {
// MsgType returns the type of Msg's that this capability can accept
MsgType() sdk.Msg
Copy link
Contributor

Choose a reason for hiding this comment

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

The more I look at this contract in the interface, the more is kinda bugs me. I feel like this should be MsgType() string. Since the sdk.Msg interface already has a Type() string method. This way we can directly compare against const values and not type match.

}

func (cap SendCapability) MsgType() sdk.Msg {
return bank.MsgSend{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return bank.MsgSend{}
return bank.TypeMsgSend

}

func (cap SendCapability) Accept(msg sdk.Msg, block abci.Header) (allow bool, updated Capability, delete bool) {
switch msg := msg.(type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

see above. just switch on the string value and use const.

```
#### `tx grant <grantee> <capability> --from <granter>`

This CLI command will send a `MsgGrant` tx. `capability` should be encoded as
Copy link
Contributor

Choose a reason for hiding this comment

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

We can expand a bit upon this I think. Just add a bit more detail.


#### `tx revoke <grantee> <capability-msg-type> --from <granter>`

This CLI command will send a `MsgRevoke` tx. `capability-msg-type` should be encoded as
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@stale
Copy link

stale bot commented Dec 7, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 7, 2019
@stale stale bot closed this Dec 11, 2019
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.

2 participants