-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
R4R: Bank Denom Metadata Spec #2072
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2072 +/- ##
========================================
Coverage 64.86% 64.86%
========================================
Files 115 115
Lines 6863 6863
========================================
Hits 4452 4452
Misses 2127 2127
Partials 284 284 |
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.
Thanks @sunnya97 -- I left some general feedback.
docs/spec/bank/keeper.md
Outdated
|
||
## Denom Metadata | ||
|
||
The BankKeeper contains a store that stores the metadata of different token denoms. Denoms are referred to by their name, same as the `denom` field in sdk.Coin. The different attributes of a denom are stored in the denom metadata store under the key `[denom name]:[attribute name]`. The default attributes in the store are explained below. However, this can be extended by the developer or through SoftwareUpgrade proposals. |
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 don't think we need to abbreviate denom/denoms in this spec for brevity, unless referring to code snippets.
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.
We have a standard way of writing key formats in specs - see e.g. https://github.com/cosmos/cosmos-sdk/blob/develop/docs/spec/staking/state.md
docs/spec/bank/keeper.md
Outdated
@@ -0,0 +1,22 @@ | |||
# Keeper |
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.
A bunch of sentences start with an extra space 👍
docs/spec/bank/keeper.md
Outdated
|
||
## Denom Metadata | ||
|
||
The BankKeeper contains a store that stores the metadata of different token denoms. Denoms are referred to by their name, same as the `denom` field in sdk.Coin. The different attributes of a denom are stored in the denom metadata store under the key `[denom name]:[attribute name]`. The default attributes in the store are explained below. However, this can be extended by the developer or through SoftwareUpgrade proposals. |
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.
Do we have a convention in the rest of the SDK for composite keys using */*
?
docs/spec/bank/keeper.md
Outdated
@@ -0,0 +1,22 @@ | |||
# Keeper | |||
|
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 also think it would help to add an example here for a token with the default metadata.
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.
See comments.
docs/spec/bank/keeper.md
Outdated
|
||
## Denom Metadata | ||
|
||
The BankKeeper contains a store that stores the metadata of different token denoms. Denoms are referred to by their name, same as the `denom` field in sdk.Coin. The different attributes of a denom are stored in the denom metadata store under the key `[denom name]:[attribute name]`. The default attributes in the store are explained below. However, this can be extended by the developer or through SoftwareUpgrade proposals. |
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.
We have a standard way of writing key formats in specs - see e.g. https://github.com/cosmos/cosmos-sdk/blob/develop/docs/spec/staking/state.md
docs/spec/bank/keeper.md
Outdated
|
||
## Denom Metadata | ||
|
||
The BankKeeper contains a store that stores the metadata of different token denoms. Denoms are referred to by their name, same as the `denom` field in sdk.Coin. The different attributes of a denom are stored in the denom metadata store under the key `[denom name]:[attribute name]`. The default attributes in the store are explained below. However, this can be extended by the developer or through SoftwareUpgrade proposals. |
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.
Anything can be extended through software upgrade proposals, not sure it's necessary to mention unless you had particular upgrades in mind.
docs/spec/bank/keeper.md
Outdated
|
||
`1 [Base Unit] = 10^(N) [Smallest Unit]` | ||
|
||
### TotalSupply `sdk.Integer` |
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.
Is this intended to be a duplicate of the data kept in the stake Pool
structure (total supply, including unclaimed inflation) or a different number (circulating supply, in accounts but not bonded)?
In either case, it seems a little expensive to track this explicitly, do we really need to?
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.
No, we stop tracking it in the Pool.
docs/spec/bank/keeper.md
Outdated
|
||
### Aliases `[]string` | ||
|
||
Aliases is an array of strings that are "alternative names" for a token. As an example, while the Ether's denom name might be `ether`, a possible alias could be `ETH`. This field can be useful for UIs and clients. It is intended that this field can be modified by a governance mechanism. |
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.
So this is read-only in the state machine? What's the advantage of doing this on-chain?
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.
It can be changed by governance. Also, it provides a standard source of truth for wallets to use.
docs/spec/bank/keeper.md
Outdated
|
||
### Decimals `int8` | ||
|
||
- `Base Unit` = The common standard for the default "standard" size of a token. Examples: 1 Bitcoin or 1 Ether. |
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.
These are amounts, denominated in integers (of the smallest unit), right?
e.g. for Ether:
- Base Unit: 1e18
- Smallest Unit: 1
Or are you suggesting we store the names of the sizes?
docs/spec/bank/keeper.md
Outdated
- `Base Unit` = The common standard for the default "standard" size of a token. Examples: 1 Bitcoin or 1 Ether. | ||
- `Smallest Unit` = The smallest possible denomination of a token. A fraction of the base unit. Examples: 1 satoshi or 1 wei. | ||
|
||
All amounts throughout the SDK are denominated in the smallest unit of a token, so that all amounts can be expressed as integers. However, UIs typically want to display token values in the base unit, so the Decimals metadata field standardizes the number of digits that come after the decimal place in the base unit. |
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.
Not entirely true. Inflation stores amounts as decimal not integer. Perhaps rephrase "all amounts" to "all account holdings"
docs/spec/bank/keeper.md
Outdated
|
||
### Aliases `[]string` | ||
|
||
Aliases is an array of strings that are "alternative names" for a token. As an example, while the Ether's denom name might be `ether`, a possible alias could be `ETH`. This field can be useful for UIs and clients. It is intended that this field can be modified by a governance mechanism. |
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.
Should we standardize on having uis accept case insensitive aliases, and therefore two aliases shouldn't be equal in a case insensitive manner
docs/spec/bank/keeper.md
Outdated
|
||
### TotalSupply `sdk.Integer` | ||
|
||
The TotalSupply of a denom is the total amount of a token that exists (known to the chain) across all accounts and modules. It is denominated in the `smallest unit` of a denom. It can be changed by the Keeper functions `MintCoins` and `BurnCoins`. `AddCoins` and `SubtractCoins` are used when adding or subtracting coins for an account, but not removing them from total supply (for example, when moving the coins to the control of the staking module). |
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.
Are chains then expected to update this on every IBC tx? (I.e. is sending tokens from chain 1 to 2 a mint on chain 2 since they now know about this token for the first time)
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
Should #1277 be in scope for this PR? |
Should be merged as WIP in filename |
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.
approved for merge as WIP (as per recent team discussions)
approved as WIP merge
docs/
)PENDING.md
that include links to the relevant issue or PR that most accurately describes the change.cmd/gaia
andexamples/
For Admin Use: