From d07b28d2bfff668b56a2f53bb24d331ee2c63329 Mon Sep 17 00:00:00 2001 From: Daniel Wedul Date: Tue, 30 Aug 2022 13:10:41 -0600 Subject: [PATCH] docs(x/authz): Fix the GrantQueue key documentation. (#13078) --- x/authz/keeper/keys.go | 2 +- x/authz/spec/02_state.md | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index c4343d1892..27aec0b5e0 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -78,7 +78,7 @@ func parseGrantQueueKey(key []byte) (time.Time, sdk.AccAddress, sdk.AccAddress, // expiration, then it should not be used in the pruning queue. // Key format is: // -// 0x02: GrantQueueItem +// 0x02: GrantQueueItem func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte { exp := sdk.FormatTimeBytes(expiration) granter = address.MustLengthPrefix(granter) diff --git a/x/authz/spec/02_state.md b/x/authz/spec/02_state.md index fb4a9f1bcb..d4725b62c7 100644 --- a/x/authz/spec/02_state.md +++ b/x/authz/spec/02_state.md @@ -8,7 +8,7 @@ order: 2 Grants are identified by combining granter address (the address bytes of the granter), grantee address (the address bytes of the grantee) and Authorization type (its type URL). Hence we only allow one grant for the (granter, grantee, Authorization) triple. -* Grant: `0x01 | granter_address_len (1 byte) | granter_address_bytes | grantee_address_len (1 byte) | grantee_address_bytes | msgType_bytes-> ProtocolBuffer(AuthorizationGrant)` +* Grant: `0x01 | granter_address_len (1 byte) | granter_address_bytes | grantee_address_len (1 byte) | grantee_address_bytes | msgType_bytes -> ProtocolBuffer(AuthorizationGrant)` The grant object encapsulates an `Authorization` type and an expiration timestamp: @@ -16,8 +16,12 @@ The grant object encapsulates an `Authorization` type and an expiration timestam ## GrantQueue -We are maintaining a queue for authz pruning, whenever a grant created an item will be added to `GrantQueue` with a key of granter, grantee, expiration and value added as array of msg type urls. +We are maintaining a queue for authz pruning. Whenever a grant is created, an item will be added to `GrantQueue` with a key of expiration, granter, grantee. -* GrantQueue: `0x02 | granter_address_len (1 byte) | granter_address_bytes | grantee_address_len (1 byte) | grantee_address_bytes | expiration_bytes -> ProtocalBuffer([]string{msgTypeUrls})` +* GrantQueue: `0x02 | expiration_bytes | granter_address_len (1 byte) | granter_address_bytes | grantee_address_len (1 byte) | grantee_address_bytes -> ProtocalBuffer(GrantQueueItem)` + +The `expiration_bytes` are the expiration date in UTC with the format `"2006-01-02T15:04:05.000000000"`. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0/x/authz/keeper/keys.go#L78-L93 + +The `GrantQueueItem` object contains the list of type urls between granter and grantee that expire at the time indicated in the key.