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

R4R: Bank Denom Metadata Spec #2072

Merged
merged 3 commits into from
Sep 25, 2018
Merged

R4R: Bank Denom Metadata Spec #2072

merged 3 commits into from
Sep 25, 2018

Conversation

sunnya97
Copy link
Member

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
  • Updated all relevant documentation (docs/)
  • Updated all relevant code comments
  • Wrote tests
  • Added entries in PENDING.md that include links to the relevant issue or PR that most accurately describes the change.
  • Updated cmd/gaia and examples/

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented Aug 17, 2018

Codecov Report

Merging #2072 into develop will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop    #2072   +/-   ##
========================================
  Coverage    64.86%   64.86%           
========================================
  Files          115      115           
  Lines         6863     6863           
========================================
  Hits          4452     4452           
  Misses        2127     2127           
  Partials       284      284

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 @sunnya97 -- I left some general feedback.


## 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.
Copy link
Contributor

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.

Copy link
Contributor

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

@@ -0,0 +1,22 @@
# Keeper
Copy link
Contributor

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 👍


## 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.
Copy link
Contributor

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 */*?

@@ -0,0 +1,22 @@
# Keeper

Copy link
Contributor

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.

cwgoes
cwgoes previously requested changes Aug 20, 2018
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

See comments.


## 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.
Copy link
Contributor

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


## 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.
Copy link
Contributor

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.


`1 [Base Unit] = 10^(N) [Smallest Unit]`

### TotalSupply `sdk.Integer`
Copy link
Contributor

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?

Copy link
Member Author

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.


### 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.
Copy link
Contributor

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?

Copy link
Member Author

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.


### Decimals `int8`

- `Base Unit` = The common standard for the default "standard" size of a token. Examples: 1 Bitcoin or 1 Ether.
Copy link
Contributor

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?

- `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.
Copy link
Contributor

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"


### 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.
Copy link
Contributor

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


### 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).
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

@cwgoes
Copy link
Contributor

cwgoes commented Aug 24, 2018

Should #1277 be in scope for this PR?

@rigelrozanski
Copy link
Contributor

Should be merged as WIP in filename

@rigelrozanski rigelrozanski self-assigned this Sep 11, 2018
Copy link
Contributor

@rigelrozanski rigelrozanski left a 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)

@rigelrozanski rigelrozanski dismissed stale reviews from cwgoes and alexanderbez September 25, 2018 17:53

approved as WIP merge

@rigelrozanski rigelrozanski merged commit a04d5cf into develop Sep 25, 2018
@rigelrozanski rigelrozanski deleted the sunny/bank-denoms-spec branch September 25, 2018 18:18
@alexanderbez alexanderbez mentioned this pull request Aug 15, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants