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(x/bank): introduce msg burn to bank keeper #17569

Merged
merged 14 commits into from
Sep 8, 2023
Merged

feat(x/bank): introduce msg burn to bank keeper #17569

merged 14 commits into from
Sep 8, 2023

Conversation

tac0turtle
Copy link
Member

Description

Closes: #11020

introduce msgBurn to bank module


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
  • run make lint and make test
  • 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)

@julienrbrt julienrbrt changed the title feature: introduce msg burn to bank keeper feat(x/bank): introduce msg burn to bank keeper Aug 29, 2023
@tac0turtle tac0turtle marked this pull request as ready for review August 29, 2023 13:53
@tac0turtle tac0turtle requested a review from a team as a code owner August 29, 2023 13:53
CHANGELOG.md Outdated Show resolved Hide resolved
x/bank/keeper/keeper.go Outdated Show resolved Hide resolved
Comment on lines 191 to 194
var coins sdk.Coins
for _, coin := range msg.Amount {
coins = append(coins, sdk.NewCoin(coin.Denom, coin.Amount))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to recreate the coins slice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mainly tried to avoid using gogo annotations. The cast repeated is one of them

Copy link
Contributor

@alexanderbez alexanderbez Aug 29, 2023

Choose a reason for hiding this comment

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

Mainly tried to avoid using gogo annotations

Asking to learn, is this a thing we're generally striving towards? Or is this just preference?

Copy link
Member Author

Choose a reason for hiding this comment

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

mainly in prep for protov2/pulsar but we dot really have a plan for how to get there today

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

lgtm

x/bank/keeper/msg_server.go Show resolved Hide resolved
x/bank/keeper/keeper.go Outdated Show resolved Hide resolved
x/bank/keeper/keeper_test.go Show resolved Hide resolved
x/bank/keeper/msg_server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

could you also add msg server tests ?

proto/cosmos/bank/v1beta1/tx.proto Outdated Show resolved Hide resolved
x/bank/keeper/keeper.go Outdated Show resolved Hide resolved
x/bank/keeper/keeper_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@likhita-809 likhita-809 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@facundomedica facundomedica left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@atheeshp atheeshp left a comment

Choose a reason for hiding this comment

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

lgtm, how about adding simulation checks/tests?
also there is a failing test.

x/bank/keeper/keeper.go Show resolved Hide resolved
acc := k.ak.GetModuleAccount(ctx, moduleName)
func (k BaseKeeper) BurnCoins(ctx context.Context, address []byte, amounts sdk.Coins) error {
acc := k.ak.GetAccount(ctx, address)
fmt.Println("acc", acc)
Copy link
Member

Choose a reason for hiding this comment

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

let's make sure we remove this before merging

Copy link
Collaborator

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Nice work and thank you @tac0turtle! Just a drive-by review, cheers!

Comment on lines 192 to 194
for _, coin := range msg.Amount {
coins = append(coins, sdk.NewCoin(coin.Denom, coin.Amount))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tac0turtle I believe there is a method inside Coins.Add which handles deduplication https://pkg.go.dev/github.com/cosmos/cosmos-sdk/types#Coins.Add otherwise currently are we sure that msg.Amount will have unique coins?

Comment on lines +196 to +203
if base, ok := k.Keeper.(BaseKeeper); ok {
from, err = base.ak.AddressCodec().StringToBytes(msg.FromAddress)
if err != nil {
return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid from address: %s", err)
}
} else {
return nil, sdkerrors.ErrInvalidRequest.Wrapf("invalid keeper type: %T", k.Keeper)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that this code is independent of coins adding and validity, I'd recommend we move it upfront then bring the coins related code below it where it is closer to home.

@tac0turtle tac0turtle added this pull request to the merge queue Sep 8, 2023
Merged via the queue into main with commit 81d9ce9 Sep 8, 2023
51 checks passed
@tac0turtle tac0turtle deleted the marko/11020 branch September 8, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to burn tokens to zero address
7 participants