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

feat(bank): add MintCoinsToAddress #9620

Closed
wants to merge 1 commit into from
Closed

Conversation

robert-zaremba
Copy link
Collaborator

Description

Closes: #9619

todo:

  • mint
  • burn
  • tests

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Jul 1, 2021

Codecov Report

Merging #9620 (8f51a72) into master (d9fb4cf) will decrease coverage by 0.00%.
The diff coverage is 68.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9620      +/-   ##
==========================================
- Coverage   60.54%   60.54%   -0.01%     
==========================================
  Files         588      588              
  Lines       37447    37460      +13     
==========================================
+ Hits        22674    22679       +5     
- Misses      12781    12789       +8     
  Partials     1992     1992              
Impacted Files Coverage Δ
x/bank/types/events.go 0.00% <0.00%> (ø)
x/bank/keeper/keeper.go 71.69% <94.44%> (+0.33%) ⬆️

sdk.NewAttribute(AttributeKeyMinter, minter.String()),
sdk.NewAttribute(sdk.AttributeKeyAmount, amount.String()),
sdk.NewAttribute(AttributeKeyReceiver, receiver.String()),
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do you think it make sense to have variable list of attributes for the same event type?

Copy link
Contributor

Choose a reason for hiding this comment

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

why can the receiver be empty? a module has to mint coins somewhere, either to itself or to an address?

Copy link
Member

@aaronc aaronc Jul 1, 2021

Choose a reason for hiding this comment

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

Let's not diverge from the existing event definitions. For minting and sending let's just have two events and not add receiver to the mint event. Better to be consistent with existing usage where possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fdymylja - receiver is empty to be compatible with the current behavior when minting to a module.
@aaronc - the idea was to not send and have a functionality and event to mint to an account.

Re event: maybe we can add a third argument in both cases? Will it break any client? Do we know how this events are parsed?

Copy link
Contributor

Choose a reason for hiding this comment

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

receiver is empty to be compatible with the current behavior when minting to a module.

What does this mean exactly? In what cases is it empty?

the idea was to not send and have a functionality and event to mint to an account.

I don't follow this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@robert-zaremba, if the current events are mantained as they are then there's no need.

The current implementation uses the mint event to signal a coinbase
Then the addCoins function creates a CoinReceived event. This combo allows rosetta to be aware of balance changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fdymylja - my question was rather related to the changes proposed here: keeping same event with one extra argument. I guess, currently Rosetta assumes that all minting is done to a module only, right?

Copy link
Contributor

@fdymylja fdymylja Jul 9, 2021

Choose a reason for hiding this comment

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

I guess, currently Rosetta assumes that all minting is done to a module only, right?

Nope, when there's a mint, a coinbase event is produced, which identifies how much the supply was inflated, and who is the minter. This event does not make rosetta add coins to the balance of the minter.
What adds coins to the balance of an address is the event produced by addCoins bank keeper function which is called in the Mint function alongside SendCoins etc...

Copy link
Member

Choose a reason for hiding this comment

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

I think for consistency we should stick with the current events for now and MintCoinsToAddress would then emit two events - one for minting, one for sending. Does that seem workable @robert-zaremba ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, so let's do this:

  1. We don't create a new event nor extend the current one.
  2. All mint events will not have recipient.
  3. For Rosetta, to account a new balance, we will use CoinReceivedEvent -- triggered in addCoins

@github-actions
Copy link
Contributor

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.

@robert-zaremba
Copy link
Collaborator Author

if we get back to this PR then we should update according to: #10771

@alexanderbez alexanderbez deleted the robert/bank-mint branch April 22, 2022 13:41
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.

feat(bank): extend bank keeper by providing a convinient funtion to mint tokens to an account.
4 participants