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

Handle burn rate in extensions #834

Merged
merged 8 commits into from
May 20, 2024

Conversation

masihyeganeh
Copy link
Contributor

@masihyeganeh masihyeganeh commented May 13, 2024

Description

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

@masihyeganeh masihyeganeh marked this pull request as ready for review May 15, 2024 05:11
@masihyeganeh masihyeganeh requested a review from a team as a code owner May 15, 2024 05:11
@masihyeganeh masihyeganeh requested review from dzmitryhil, miladz68, ysv and wojtek-coreum and removed request for a team May 15, 2024 05:11
Copy link
Contributor

@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.

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @dzmitryhil, @masihyeganeh, @wojtek-coreum, and @ysv)


integration-tests/modules/assetft_extension_test.go line 1484 at r1 (raw file):

	denom := tokenIssuedEvents[0].Denom

	// send from issuer to recipient1 (burn must not apply)

I am not seeing the check on the contract ! that the issuer (actually the admin) is exempted from the burn rate. then why is it working ? I assume the calculate rate function is not working as intended. I assume it will be fixed in the other PR that you have.


integration-tests/modules/assetft_extension_test.go line 1499 at r1 (raw file):

	requireT.NoError(err)
	// assert that we don't receive events with empty amounts
	requireT.NotContains(txRes.RawLog, `{"key":"amount"}`)

you should filter the events by event type, this is not the correct way to do it. look at other tests to see how events are looked up.


integration-tests/modules/assetft_extension_test.go line 1546 at r1 (raw file):

	})

	// send from recipient2 to issuer (burn must not apply)

change issuer to admin, we now work with admins from now on.


x/asset/ft/keeper/keeper_extension_test.go line 754 at r1 (raw file):

}

func TestKeeper_Extension_BurnRate_BankMultiSend(t *testing.T) {

I assume this is the exact copy from the other test right ?


x/asset/ft/keeper/test-contracts/asset-extension/src/contract.rs line 267 at r1 (raw file):

        };

        burn_amount = Uint128::zero();

why are you changing burn_amount to zero ? should you just return here ?

Copy link
Contributor Author

@masihyeganeh masihyeganeh 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, 5 unresolved discussions (waiting on @dzmitryhil, @miladz68, @wojtek-coreum, and @ysv)


integration-tests/modules/assetft_extension_test.go line 1484 at r1 (raw file):

Previously, miladz68 (milad) wrote…

I am not seeing the check on the contract ! that the issuer (actually the admin) is exempted from the burn rate. then why is it working ? I assume the calculate rate function is not working as intended. I assume it will be fixed in the other PR that you have.

Done. Yes, it is fixed after rebasing the branch


integration-tests/modules/assetft_extension_test.go line 1499 at r1 (raw file):

Previously, miladz68 (milad) wrote…

you should filter the events by event type, this is not the correct way to do it. look at other tests to see how events are looked up.

This test is copied from the assetft integration test. I'm not sure why it is decided to keep it this way, but there should be a reason


integration-tests/modules/assetft_extension_test.go line 1546 at r1 (raw file):

Previously, miladz68 (milad) wrote…

change issuer to admin, we now work with admins from now on.

Done.


x/asset/ft/keeper/keeper_extension_test.go line 754 at r1 (raw file):

Previously, miladz68 (milad) wrote…

I assume this is the exact copy from the other test right ?

This test is copied from the assetft integration test but the extension is added


x/asset/ft/keeper/test-contracts/asset-extension/src/contract.rs line 267 at r1 (raw file):

Previously, miladz68 (milad) wrote…

why are you changing burn_amount to zero ? should you just return here ?

Done.

@masihyeganeh masihyeganeh force-pushed the masih/handle-burn-rate-in-extensions branch from ba46a87 to d9227e6 Compare May 15, 2024 10:36
Copy link
Contributor

@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.

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

Copy link
Contributor

@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, 1 unresolved discussion (waiting on @dzmitryhil, @masihyeganeh, @wojtek-coreum, and @ysv)

a discussion (no related file):
Wait for my PR for sudo to be merged and make this PR against master.


@masihyeganeh masihyeganeh force-pushed the masih/handle-burn-rate-in-extensions branch from d9227e6 to 6835af7 Compare May 16, 2024 08:24
Base automatically changed from milad/sudo-extension-entry to master May 16, 2024 10:02
@masihyeganeh masihyeganeh force-pushed the masih/handle-burn-rate-in-extensions branch from 6835af7 to cbd34df Compare May 16, 2024 11:16
Copy link
Contributor Author

@masihyeganeh masihyeganeh 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 (commit messages unreviewed), 1 unresolved discussion (waiting on @dzmitryhil, @miladz68, @wojtek-coreum, and @ysv)

a discussion (no related file):

Previously, miladz68 (milad) wrote…

Wait for my PR for sudo to be merged and make this PR against master.

Done.


Copy link

codecov bot commented May 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.06%. Comparing base (5a7ab26) to head (1fd10f4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #834   +/-   ##
=======================================
  Coverage   37.06%   37.06%           
=======================================
  Files         182      182           
  Lines       52722    52722           
=======================================
  Hits        19544    19544           
  Misses      29640    29640           
  Partials     3538     3538           
Flag Coverage Δ
coreum 32.95% <ø> (ø)
coreum-integration-tests-modules 23.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 (commit messages unreviewed), 1 unresolved discussion (waiting on @miladz68, @wojtek-coreum, and @ysv)


x/asset/ft/keeper/keeper_extension_test.go line 725 at r3 (raw file):

	ba.assertCoinDistribution(denom, map[*sdk.AccAddress]int64{
		&recipient:  392,

Could you please use AmountIgnoreBurnRateTrigger in the assertions when the extensions uses the rate as initial - AmountIgnoreBurnRateTrigger. In this way it is easier to validate (in both tests ).


x/asset/ft/keeper/keeper_extension_test.go line 820 at r3 (raw file):

	// create 2 recipient for every admin to allow for complex test cases
	recipients = append(recipients, sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()))
	recipients = append(recipients, sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()))

You can simply use and call it once.

	recipients := lo.RepeatBy(4, func(index int) sdk.AccAddress {
		return sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
	})

miladz68
miladz68 previously approved these changes May 17, 2024
Copy link
Contributor

@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.

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

Copy link
Contributor Author

@masihyeganeh masihyeganeh 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: 2 of 3 files reviewed, all discussions resolved (waiting on @miladz68, @wojtek-coreum, and @ysv)


x/asset/ft/keeper/keeper_extension_test.go line 725 at r3 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Could you please use AmountIgnoreBurnRateTrigger in the assertions when the extensions uses the rate as initial - AmountIgnoreBurnRateTrigger. In this way it is easier to validate (in both tests ).

I prefer to add comments to each line and keep the calculated number there. Comments added


x/asset/ft/keeper/keeper_extension_test.go line 820 at r3 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

You can simply use and call it once.

	recipients := lo.RepeatBy(4, func(index int) sdk.AccAddress {
		return sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
	})

Thank you. Yeah, it's better

Copy link
Contributor Author

@masihyeganeh masihyeganeh 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 3 files at r2, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @wojtek-coreum and @ysv)

wojtek-coreum
wojtek-coreum previously approved these changes May 17, 2024
Copy link
Collaborator

@wojtek-coreum wojtek-coreum 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 3 files at r2, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)


x/asset/ft/keeper/keeper_extension_test.go line 725 at r3 (raw file):

Previously, masihyeganeh (Masih Yeganeh) wrote…

I prefer to add comments to each line and keep the calculated number there. Comments added

But why? If you already have those constants?

Copy link
Contributor Author

@masihyeganeh masihyeganeh 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)


x/asset/ft/keeper/keeper_extension_test.go line 725 at r3 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

But why? If you already have those constants?

Because there are more than one transfer in each test and it helps for each transfer to know the exact balance of accounts after previous transfer to check if the calculations are right

@masihyeganeh masihyeganeh force-pushed the masih/handle-burn-rate-in-extensions branch from 23f2198 to 16d1c2b Compare May 17, 2024 11:30
Copy link
Contributor Author

@masihyeganeh masihyeganeh left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

wojtek-coreum
wojtek-coreum previously approved these changes May 20, 2024
Copy link
Collaborator

@wojtek-coreum wojtek-coreum left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

miladz68
miladz68 previously approved these changes May 20, 2024
Copy link
Contributor

@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.

Reviewed 1 of 1 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

* Add commission rate to extension

* Better naming

* Add integration test

* Fix comment

* Add comments for calculations

* Remove checks for events with empty amount
@masihyeganeh masihyeganeh dismissed stale reviews from wojtek-coreum and miladz68 via 1fd10f4 May 20, 2024 07:30
Copy link
Contributor

@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.

Reviewed 3 of 3 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

Copy link
Collaborator

@wojtek-coreum wojtek-coreum left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

Copy link
Contributor Author

@masihyeganeh masihyeganeh left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

@masihyeganeh masihyeganeh merged commit ef18924 into master May 20, 2024
9 checks passed
@masihyeganeh masihyeganeh deleted the masih/handle-burn-rate-in-extensions branch May 20, 2024 08:12
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