-
Notifications
You must be signed in to change notification settings - Fork 39
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
Optional parties and party/signer/role validation overhaul #1453
Conversation
…TestGetMsgTypeURLs to be table driven.
…terfaces, and implement them on all the entries and specs and msgs.
…the Msg Type URL, and update the call chains to it as well.
…nfo from the msg we're now passing in.
…it's something to include in the overhaul.
…ing, but output exactly what's needed for a copy/paste into msg.go.
…wn since it's now a thing in there.
…red anymore and not used. Do type checking on nil values instead of empty structs. Use the sdk for MustAccAddressFromBech32. Add or update a bunch of comments.
…rs is just converting a string to AccAddress which NewEventTxCompleted was then converting right back to a string.
…HasAccess except takes in a string since the comparison is done using strings anyway.
…ng, and get the proposed from the message.
…n address just so they can be converted back for comparison.
…o) since it's more related to that stuff.
…since those were only needed for p8e stuff.
…equest.parties field since it's already ignored anyway.
… fail when a new entry is added.
# Conflicts: # CHANGELOG.md
…unction and clean up some code.
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.
High level review of changes complete. Overall this looks good!
…me unit tests on some stuff that didn't have any.
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.
With the recent updates all tests/checks are passing.
…ateWrite... funcs.
Massive code coverage now... nice work. |
Description
closes: #1381
closes: #1437
closes: #1438
Primarily, this PR:
require_party_rollup
boolean field to the scope, and anoptional
boolean field to theParty
messagerequire_party_rollup = true
, new signer validation is used (see spec docs for full details) andoptional = true
parties are allowed in the scope and it's sessions. Otherwise,optional = true
parties are not allowed and existing signer logic is applied.require_party_rollup
andoptional
change.PROVENANCE
MUST be for a smart contract account. And any parties that have a smart contract account address must MUST have thePROVENANCE
role. In other words, smart contracts MUST use thePROVENANCE
role, and only smart contracts can use thePROVENANCE
role.AddScopeOwner
endpoint no longer updates the role of an existing entry with the same address as the one provided. It now simply adds the provided owner.Secondarily, this PR:
make proto-format
.keeper.go
andsignatures.go
stuff intosigners.go
andsigners_utils.go
and refactors some more of that stuff.auth
andauthz
keepers and creates mocks for those so that unit testing can be a little easier in there..String()
funcs for the metadataMsg
s..MsgTypeURL()
funcs from theMsg
s.Validate...Update
functions toValidate<endpoint>
, e.g.ValidateWriteScope
instead ofValidateScopeUpdate
.Overview of new signer validation
New signer validation is used for scopes, sessions, and records where the scope has
require_party_rollup = true
. For such scopes, all parties in any of its sessions must also be included in the scope'sowners
.optional=false
are required to sign for any scope updates including its sessions and records.optional=false
are required to sign for updates to that session as well as the records being written under that session.optional=false
in the scope andoptional=true
in a session, and vice versa.owners
once. It can also have differentoptional
values in each session.Then, coordination is done with the specification, parties, and signers to possibly require additional signatures (beyond the
optional=false
ones). The roles defined in the specification dictate which parties need to sign. For each required role, there needs to be a unique party that is also a signer.For example:
SERVICER
.A
, Role:OWNER
, Optional:false
B
, Role:SERVICER
, Optional:true
C
, Role:SERVICER
, Optional:true
In order to write that record, address
A
must be a signer because it isoptional=false
in the session.Then, EITHER address
B
orC
must be a signer because the specification requires aSERVICER
(and addressA
is not one).In that above example, if the record spec instead requires
SERVICER
,SERVICER
, then bothB
andC
would need to sign since they are the onlySERVICER
entries, and two different ones are required.Then, if, there were a forth party in the session: Address :
D
, Role:SERVICER
, Optional:true
(and twoSERVICER
s are required), any two ofB
,C
, andD
must sign.In all of this, consideration is still made for
x/authz
authorizations. It's possible for a single signer to fulfill all signing requirements if other parties have granted them authorization. They can even fulfill the signing requirements for multiple of the same role as long as there are enough different parties that have given them authorizations.For example:
VALIDATOR
,VALIDATOR
,OWNER
.A
, Role:OWNER
, Optional:true
B
, Role:OWNER
, Optional:true
C
, Role:VALIDATOR
, Optional:true
D
, Role:VALIDATOR
, Optional:true
E
, Role:VALIDATOR
, Optional:true
F
, andG
.C
, Grantee:B
D
, Grantee:B
A
, Grantee:F
D
, Grantee:F
E
, Grantee:F
A
, Grantee:C
A
, Grantee:G
C
, Grantee:G
The session can be written with any of these collections of signers (not an exhaustive list):
B
- They fulfill theOWNER
spec requirement themselves. Because of grants 1 and 2, their signature can fulfill two differentVALIDATOR
roles fromC
andD
.F
- AnOWNER
and two differentVALIDATOR
s have granted them the ability to sign on their behalf (grants 3, 4, and 5). So all three requirements are satisfied.C
andD
- BothC
andD
can individually fulfill the twoVALIDATOR
requirements. Then because of grant 6,C
is allowed to sign forA
, andA
is anOWNER
. SoC
's signature also covers theOWNER
requirement.G
andE
- The signature fromE
covers one of the twoVALIDATOR
requirements. ThenG
, because of grants 7 and 8, can sign forC
(anotherVALIDATOR
), andA
(anOWNER
).Authorizations are not transitive though. Grant 1 says that
B
can sign on behalf ofC
, and grant 6 says thatC
can sign on behalf ofA
. That does not mean thatB
can sign on behalf ofA
.One problem all of this solves is when a scope owner wants to give someone (e.g. a
SERVICER
) permission to write sessions/records in a certain subset of scopes.The owner would list themselves as
optional=false
in the scope, probably with the roleOWNER
(really, anything butSERVICER
). Then, they'd list the servicer asoptional=true
in the applicable scopes. The contract specs and record specs would then need to require aSERVICER
. Lastly, the owner would issue anauthz
grant allowing them to write sessions and records on their behalf.Now, the servicer can write their sessions records to those scopes using only their signature. However, they wouldn't be allowed to write those sessions and records to other scopes because a
SERVICER
signature is required, and they are not listed as such in those scopes.Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes