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

Refactor MultiSend interceptor to work only with 1 input #660

Merged
merged 4 commits into from
Sep 26, 2023

Conversation

miladz68
Copy link
Contributor

@miladz68 miladz68 commented Sep 21, 2023

Description

With a change introduced to bank Multisend in Cosmos SDK v0.47, only a single sender can be specified in Multisend. In this PR we take advantage of this change to make the logic of our interceptor much simpler.

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@miladz68 miladz68 requested a review from a team as a code owner September 21, 2023 12:27
@miladz68 miladz68 requested review from dzmitryhil, ysv and wojtek-coreum and removed request for a team September 21, 2023 12:27
ysv
ysv previously approved these changes Sep 22, 2023
Copy link
Contributor

@ysv ysv left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dzmitryhil and @wojtek-coreum)

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @miladz68 and @wojtek-coreum)

a discussion (no related file):
Check the tests please they are failed



x/asset/ft/keeper/before_send.go line 86 at r1 (raw file):

		burnAmount := k.ApplyRate(ctx, def.BurnRate, issuer, sender, outOps)
		if err := k.burnIfSpendable(ctx, sender, def, burnAmount); err != nil {

You burn twice. Why does the unit tests don't show it?


x/asset/ft/keeper/before_send.go line 100 at r1 (raw file):

		}

		if err := k.isCoinSpendable(ctx, sender, def, coin.Amount); err != nil {

Does it make send to check it before burning and commision?


x/asset/ft/keeper/before_send.go line 104 at r1 (raw file):

		}

		return iterateMapDeterministic(outOps, func(account string, amount sdkmath.Int) error {

The same quesion here, does it make send to check it before burning and commision?

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @miladz68 and @wojtek-coreum)

Copy link
Contributor Author

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dzmitryhil and @wojtek-coreum)

a discussion (no related file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Check the tests please they are failed

Done.



x/asset/ft/keeper/before_send.go line 86 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

You burn twice. Why does the unit tests don't show it?

well they actually show it. integration and unit tests are failing.
removed.


x/asset/ft/keeper/before_send.go line 100 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Does it make send to check it before burning and commision?

no, because if want to make sure the sender has enough balance after the rates are applied.


x/asset/ft/keeper/before_send.go line 104 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

The same quesion here, does it make send to check it before burning and commision?

Right now we are not modifying the received amount, but any of our features in future might touch it. for the same reason stated above. it makes sense to perform the checks at the end of function.

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @miladz68, @wojtek-coreum, and @ysv)


x/asset/ft/keeper/before_send.go line 86 at r1 (raw file):

Previously, miladz68 (milad) wrote…

well they actually show it. integration and unit tests are failing.
removed.

But unit tests should show it as well. Add the test case to the unit tests please.

Copy link
Contributor Author

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, 1 unresolved discussion (waiting on @dzmitryhil, @wojtek-coreum, and @ysv)


x/asset/ft/keeper/before_send.go line 86 at r1 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

But unit tests should show it as well. Add the test case to the unit tests please.

the unit tests did show it before i fixed them. perhaps you refer to one unit test that tested the rate caculations ? that test is not supposed to show the problem since it only concerns the calculation of the rates not their applicaiton.

Copy link
Contributor

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, all discussions resolved (waiting on @wojtek-coreum and @ysv)

@miladz68 miladz68 requested a review from keyleu September 26, 2023 08:37
Copy link
Collaborator

@keyleu keyleu left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @wojtek-coreum)

@miladz68 miladz68 merged commit 52c8d17 into master Sep 26, 2023
8 checks passed
@miladz68 miladz68 deleted the milad/refactor_send_interceptor_single_input branch September 26, 2023 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants