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

Validate that FT and NFT features are in the defined set #530

Merged
merged 16 commits into from
Jun 28, 2023

Conversation

wojtek-coreum
Copy link
Collaborator

@wojtek-coreum wojtek-coreum commented Jun 21, 2023

This change is Reviewable

@wojtek-coreum wojtek-coreum requested a review from a team as a code owner June 21, 2023 12:27
@wojtek-coreum wojtek-coreum requested review from dzmitryhil, vertex451, miladz68 and ysv and removed request for a team June 21, 2023 12:27
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: 0 of 22 files reviewed, 5 unresolved discussions (waiting on @miladz68, @silverspase, @wojtek-coreum, and @ysv)


integration-tests/upgrade/ft.go line 581 at r2 (raw file):

		Description:   "AAA Description",
		InitialAmount: sdk.NewInt(1000),
		Features: []assetfttypes.Feature{

What about testing the duplicated features, they should be removed as well? Same comment for the NFT.


x/asset/ft/keeper/keeper.go line 97 at r2 (raw file):

// IterateAllDefinitions iterates over all token definitions and applies the provided callback.
// If true is returned from the callback, iteration is halted.
func (k Keeper) IterateAllDefinitions(ctx sdk.Context, cb func(types.Definition) (bool, error)) error {

Why do you need to update the interface of the method, you can achieve what you need with the previous version as well. (same for the NFT)


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

// MigrateFeatures migrates asset ft features state from v1 to v2.
// It removes features which are outside the allowed scope.
func MigrateFeatures(ctx sdk.Context, keeper FTKeeper, allowedFeatures map[int32]string) error {

As far as I remember we wanted to remove duplicated features as well, since it was possible to do it before.


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

// MigrateFeatures migrates asset ft features state from v1 to v2.
// It removes features which are outside the allowed scope.
func MigrateFeatures(ctx sdk.Context, keeper FTKeeper, allowedFeatures map[int32]string) error {

The input is allowedFeatures map[int32]string but that isn't true since you filter the IBC later. IMO better to define the list here without using it as a function param. (same for the NFT)


x/asset/ft/types/token.go line 186 at r2 (raw file):

// ValidateFeatures verifies that provided features belong to the defined set.
func ValidateFeatures(features []Feature) error {

Unit tests? (same for the NFT)

Copy link
Collaborator Author

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

Reviewable status: 0 of 22 files reviewed, 5 unresolved discussions (waiting on @dzmitryhil, @miladz68, @silverspase, and @ysv)


x/asset/ft/keeper/keeper.go line 97 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Why do you need to update the interface of the method, you can achieve what you need with the previous version as well. (same for the NFT)

I need to be able to return the error from the cb


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

As far as I remember we wanted to remove duplicated features as well, since it was possible to do it before.

Good point, completely missed that!


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

The input is allowedFeatures map[int32]string but that isn't true since you filter the IBC later. IMO better to define the list here without using it as a function param. (same for the NFT)

I need to define it as a param to be able to write unit test. After the fix, I'm able to create the token only with the valid set of features. So to test that invalid features are filtered out, I trick the list of allowed features passed to the MigrateFeatures.

Copy link
Collaborator Author

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

Reviewable status: 0 of 24 files reviewed, 5 unresolved discussions (waiting on @dzmitryhil, @miladz68, @silverspase, and @ysv)


integration-tests/upgrade/ft.go line 581 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

What about testing the duplicated features, they should be removed as well? Same comment for the NFT.

Done.


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, wojtek-coreum (Wojtek) wrote…

Good point, completely missed that!

Done


x/asset/ft/types/token.go line 186 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Unit tests? (same for the NFT)

Done.

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: 0 of 25 files reviewed, 2 unresolved discussions (waiting on @miladz68, @silverspase, @wojtek-coreum, and @ysv)


x/asset/ft/keeper/keeper.go line 97 at r2 (raw file):

Previously, wojtek-coreum (Wojtek) wrote…

I need to be able to return the error from the cb

Why do you need this? You can do VIA error assigning, but in general I don't see a reason to return it.


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, wojtek-coreum (Wojtek) wrote…

I need to define it as a param to be able to write unit test. After the fix, I'm able to create the token only with the valid set of features. So to test that invalid features are filtered out, I trick the list of allowed features passed to the MigrateFeatures.

In that case list all allowed feature as inmut without the filtration of the IBC in the func.

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 11 of 22 files at r1, 13 of 14 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @miladz68, @silverspase, @wojtek-coreum, and @ysv)

Copy link
Collaborator Author

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dzmitryhil, @miladz68, @silverspase, and @ysv)


x/asset/ft/keeper/keeper.go line 97 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

Why do you need this? You can do VIA error assigning, but in general I don't see a reason to return it.

doing it via assigning is a weird hack when no proper interface is available


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

In that case list all allowed feature as inmut without the filtration of the IBC in the func.

I've redone it

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


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, wojtek-coreum (Wojtek) wrote…

I've redone it

The if f == types.Feature_ibc { still looks redundant. If you know that you support only the list of features, better to define that list, instead of filtering the ibc;

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, 1 unresolved discussion (waiting on @miladz68, @silverspase, and @ysv)


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

The if f == types.Feature_ibc { still looks redundant. If you know that you support only the list of features, better to define that list, instead of filtering the ibc;

@ysv @miladz68 WDYT ?

Copy link
Collaborator Author

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @miladz68, @silverspase, and @ysv)


x/asset/ft/legacy/v1/features.go line 17 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

@ysv @miladz68 WDYT ?

Done.

dzmitryhil
dzmitryhil previously approved these changes Jun 26, 2023
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: 23 of 25 files reviewed, all discussions resolved (waiting on @miladz68, @silverspase, and @ysv)

miladz68
miladz68 previously approved these changes Jun 27, 2023
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 10 of 22 files at r1, 12 of 14 files at r3, 1 of 1 files at r4, 2 of 2 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @silverspase and @ysv)

@wojtek-coreum wojtek-coreum dismissed stale reviews from miladz68 and dzmitryhil via 7d19c5a June 28, 2023 06:57
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 r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @silverspase and @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.

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

@wojtek-coreum wojtek-coreum merged commit d4abf14 into master Jun 28, 2023
@wojtek-coreum wojtek-coreum deleted the wojtek/feature-enum branch June 28, 2023 11:37
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.

3 participants