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(fungible): implement MsgUpdateZRC20Name #3541

Merged
merged 9 commits into from
Feb 18, 2025

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Feb 17, 2025

Description

Closes #3540

Allow to update then name and symbol of a ZRC20 with admin policy group

Summary by CodeRabbit

  • New Features
    • Added functionality to update the name and symbol of ZRC20 tokens.
    • Enabled SOL withdrawal and call operations.
    • Introduced a setting update for improved transaction confirmations.
    • Provided an option to remove inbound trackers.
  • Bug Fixes
    • Resolved issues with transaction validations and prevented spam in Bitcoin key-signing.
  • Documentation
    • Updated public documentation and API specifications to reflect the new token update features and confirmation parameter enhancements.

@lumtis lumtis added the ADMIN_TESTS Run make start-admin-tests label Feb 17, 2025
Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This pull request introduces a new message type, MsgUpdateZRC20Name, enabling updates to the name and symbol of ZRC20 tokens. The changes span updates to the changelog, documentation, and OpenAPI specification; the addition of RPC and keeper methods; and new end-to-end and unit tests. Furthermore, the authorization system has been updated to include the new message in both migration and admin policies, along with the necessary codec registrations and interface implementations.

Changes

File(s) Change Summary
changelog.md, docs/openapi/…swagger.yaml, docs/spec/fungible/messages.md, proto/…/fungible/tx.proto Updated changelog and documentation; added new message type (MsgUpdateZRC20Name), response types, and RPC method.
cmd/zetae2e/local/local.go, e2e/e2etests/e2etests.go, e2e/…/test_update_zrc20_name.go Introduced new end-to-end tests for updating the ZRC20 token name and symbol.
x/authority/migrations/v3/migrate.go, x/authority/migrations/v3/migrate_test.go, x/authority/types/authorization_list.go, x/authority/types/authorization_list_test.go Modified authorization entries and tests to include/remove MsgUpdateZRC20Name from the admin policy.
x/fungible/keeper/msg_server_update_zrc20_name.go, x/fungible/keeper/msg_server_update_zrc20_name_test.go, x/fungible/keeper/zrc20_methods.go, x/fungible/keeper/zrc20_methods_test.go, x/fungible/types/codec.go, x/fungible/types/message_update_zrc20_name.go, x/fungible/types/message_update_zrc20_name_test.go Added keeper methods for updating and retrieving ZRC20 name and symbol, registered the new message type, and implemented unit tests for message, codec, and keeper functionality.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ZetaTxServer
  participant MsgServer
  participant AuthorityKeeper
  participant Keeper

  Client->>ZetaTxServer: Submit MsgUpdateZRC20Name\n(creator, token address, new name, symbol)
  ZetaTxServer->>MsgServer: Route MsgUpdateZRC20Name request
  MsgServer->>AuthorityKeeper: CheckAuthorization(creator)
  AuthorityKeeper-->>MsgServer: Authorization validated (or error)
  MsgServer->>Keeper: Call UpdateZRC20Name
  Keeper->>Keeper: Validate ZRC20 address and existence
  Keeper->>Keeper: Execute ZRC20SetName (if name provided)
  Keeper->>Keeper: Execute ZRC20SetSymbol (if symbol provided)
  Keeper-->>MsgServer: Return MsgUpdateZRC20NameResponse
  MsgServer-->>ZetaTxServer: Relay response
  ZetaTxServer-->>Client: Return transaction result (tx hash)
Loading

Possibly related PRs

Suggested labels

UPGRADE_TESTS

Suggested reviewers

  • fbac
  • kingpinXD
  • ws4charlie
  • skosito
  • brewmaster012

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

Attention: Patch coverage is 67.74194% with 60 lines in your changes missing coverage. Please review.

Project coverage is 64.69%. Comparing base (d9b7aa0) to head (6d7f42f).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
x/fungible/keeper/zrc20_methods.go 53.44% 36 Missing and 18 partials ⚠️
x/fungible/keeper/msg_server_update_zrc20_name.go 81.81% 4 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3541      +/-   ##
===========================================
+ Coverage    64.68%   64.69%   +0.01%     
===========================================
  Files          453      455       +2     
  Lines        31310    31495     +185     
===========================================
+ Hits         20252    20377     +125     
- Misses       10189    10229      +40     
- Partials       869      889      +20     
Files with missing lines Coverage Δ
x/authority/migrations/v3/migrate.go 100.00% <100.00%> (ø)
x/authority/types/authorization_list.go 100.00% <ø> (ø)
x/fungible/types/message_update_zrc20_name.go 100.00% <100.00%> (ø)
x/fungible/keeper/msg_server_update_zrc20_name.go 81.81% <81.81%> (ø)
x/fungible/keeper/zrc20_methods.go 55.93% <53.44%> (-1.42%) ⬇️

@lumtis lumtis marked this pull request as ready for review February 18, 2025 11:24
@lumtis lumtis requested a review from a team as a code owner February 18, 2025 11:24
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (8)
e2e/e2etests/test_update_zrc20_name.go (1)

12-54: Enhance test coverage with negative test cases.

While the happy path is well tested, consider adding tests for:

  • Unauthorized access attempts
  • Invalid ZRC20 addresses
  • Empty name and symbol
  • Special characters in name/symbol
x/fungible/types/message_update_zrc20_name_test.go (1)

14-89: LGTM with a minor suggestion for test readability.

The test suite provides comprehensive coverage of the message type's functionality.

Consider making the test case descriptions more descriptive. For example:

-			name: "valid message",
+			name: "should accept valid message with both name and symbol",
-			name: "valid message with empty name",
+			name: "should accept valid message with only symbol update",
x/fungible/keeper/zrc20_methods_test.go (2)

15-41: Consider adding error test cases for ZRC20SetName.

While the happy path is tested, consider adding test cases for:

  • Invalid ZRC20 address
  • Empty name
  • Error scenarios from EVM calls

29-41: Consider adding error test cases for ZRC20SetSymbol.

Similar to the name tests, consider adding test cases for:

  • Invalid ZRC20 address
  • Empty symbol
  • Error scenarios from EVM calls
e2e/e2etests/e2etests.go (1)

133-136: Consider adding a comment to document the test's purpose.

The admin tests section has a comment block explaining its purpose. Consider adding documentation for this new test to maintain consistency.

 /*
  Admin tests
  Test admin functionalities
  */
+// TestUpdateZRC20Name tests the ability to update the name and symbol of ZRC20 tokens
+// through admin policy group governance.
 runner.NewE2ETest(
   TestUpdateZRC20NameName,
   "update ZRC20 name and symbol",

Also applies to: 975-981

docs/openapi/openapi.swagger.yaml (1)

59565-59566: Review the New OpenAPI Definition for fungibleMsgUpdateZRC20NameResponse

The new response object is defined cleanly and follows the expected structure by simply specifying the type as an object. Please verify that this minimal definition aligns with the API documentation and your intended behavior. If future enhancements (such as including status codes, error messages, or additional metadata) are expected, consider incorporating those fields or adding a descriptive comment for clarity.

docs/spec/fungible/messages.md (1)

155-166: Documentation Consistency Suggestion
The new MsgUpdateZRC20Name message is clearly documented and its proto block is well formatted. For consistency with other message descriptions, consider adding an explicit note regarding the required admin authorization (e.g. “Authorized: admin policy group 2”) similar to the other messages in this file.

proto/zetachain/zetacore/fungible/tx.proto (1)

142-149: Proto Message Definition Assessment
The newly introduced MsgUpdateZRC20Name message is structured correctly with all required fields (creator, zrc20_address, name, symbol) and the appropriate field numbering. Consider, as an optional enhancement, adding inline comments or field options if future validations or custom types become necessary.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9b7aa0 and 634de91.

⛔ Files ignored due to path filters (2)
  • typescript/zetachain/zetacore/fungible/tx_pb.d.ts is excluded by !**/*_pb.d.ts
  • x/fungible/types/tx.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
📒 Files selected for processing (18)
  • changelog.md (1 hunks)
  • cmd/zetae2e/local/local.go (1 hunks)
  • docs/openapi/openapi.swagger.yaml (1 hunks)
  • docs/spec/fungible/messages.md (1 hunks)
  • e2e/e2etests/e2etests.go (2 hunks)
  • e2e/e2etests/test_update_zrc20_name.go (1 hunks)
  • proto/zetachain/zetacore/fungible/tx.proto (2 hunks)
  • x/authority/migrations/v3/migrate.go (2 hunks)
  • x/authority/migrations/v3/migrate_test.go (1 hunks)
  • x/authority/types/authorization_list.go (1 hunks)
  • x/authority/types/authorization_list_test.go (1 hunks)
  • x/fungible/keeper/msg_server_update_zrc20_name.go (1 hunks)
  • x/fungible/keeper/msg_server_update_zrc20_name_test.go (1 hunks)
  • x/fungible/keeper/zrc20_methods.go (1 hunks)
  • x/fungible/keeper/zrc20_methods_test.go (5 hunks)
  • x/fungible/types/codec.go (2 hunks)
  • x/fungible/types/message_update_zrc20_name.go (1 hunks)
  • x/fungible/types/message_update_zrc20_name_test.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • x/authority/types/authorization_list_test.go
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.go`: Review the Go code, point out issues relative to ...

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • cmd/zetae2e/local/local.go
  • x/fungible/types/codec.go
  • x/authority/types/authorization_list.go
  • e2e/e2etests/test_update_zrc20_name.go
  • x/authority/migrations/v3/migrate_test.go
  • x/authority/migrations/v3/migrate.go
  • x/fungible/keeper/msg_server_update_zrc20_name_test.go
  • x/fungible/keeper/msg_server_update_zrc20_name.go
  • x/fungible/keeper/zrc20_methods_test.go
  • e2e/e2etests/e2etests.go
  • x/fungible/keeper/zrc20_methods.go
  • x/fungible/types/message_update_zrc20_name_test.go
  • x/fungible/types/message_update_zrc20_name.go
`**/*.proto`: Review the Protobuf definitions, point out iss...

**/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.

  • proto/zetachain/zetacore/fungible/tx.proto
🪛 GitHub Check: codecov/patch
x/fungible/keeper/msg_server_update_zrc20_name.go

[warning] 51-52: x/fungible/keeper/msg_server_update_zrc20_name.go#L51-L52
Added lines #L51 - L52 were not covered by tests


[warning] 57-58: x/fungible/keeper/msg_server_update_zrc20_name.go#L57-L58
Added lines #L57 - L58 were not covered by tests

x/fungible/keeper/zrc20_methods.go

[warning] 36-37: x/fungible/keeper/zrc20_methods.go#L36-L37
Added lines #L36 - L37 were not covered by tests


[warning] 53-54: x/fungible/keeper/zrc20_methods.go#L53-L54
Added lines #L53 - L54 were not covered by tests


[warning] 56-57: x/fungible/keeper/zrc20_methods.go#L56-L57
Added lines #L56 - L57 were not covered by tests


[warning] 70-71: x/fungible/keeper/zrc20_methods.go#L70-L71
Added lines #L70 - L71 were not covered by tests


[warning] 87-88: x/fungible/keeper/zrc20_methods.go#L87-L88
Added lines #L87 - L88 were not covered by tests


[warning] 90-91: x/fungible/keeper/zrc20_methods.go#L90-L91
Added lines #L90 - L91 were not covered by tests


[warning] 103-104: x/fungible/keeper/zrc20_methods.go#L103-L104
Added lines #L103 - L104 were not covered by tests


[warning] 119-120: x/fungible/keeper/zrc20_methods.go#L119-L120
Added lines #L119 - L120 were not covered by tests


[warning] 123-124: x/fungible/keeper/zrc20_methods.go#L123-L124
Added lines #L123 - L124 were not covered by tests


[warning] 128-129: x/fungible/keeper/zrc20_methods.go#L128-L129
Added lines #L128 - L129 were not covered by tests


[warning] 132-133: x/fungible/keeper/zrc20_methods.go#L132-L133
Added lines #L132 - L133 were not covered by tests


[warning] 137-138: x/fungible/keeper/zrc20_methods.go#L137-L138
Added lines #L137 - L138 were not covered by tests


[warning] 150-151: x/fungible/keeper/zrc20_methods.go#L150-L151
Added lines #L150 - L151 were not covered by tests


[warning] 166-167: x/fungible/keeper/zrc20_methods.go#L166-L167
Added lines #L166 - L167 were not covered by tests


[warning] 170-171: x/fungible/keeper/zrc20_methods.go#L170-L171
Added lines #L170 - L171 were not covered by tests


[warning] 175-176: x/fungible/keeper/zrc20_methods.go#L175-L176
Added lines #L175 - L176 were not covered by tests


[warning] 179-180: x/fungible/keeper/zrc20_methods.go#L179-L180
Added lines #L179 - L180 were not covered by tests


[warning] 184-185: x/fungible/keeper/zrc20_methods.go#L184-L185
Added lines #L184 - L185 were not covered by tests

🔇 Additional comments (12)
x/authority/migrations/v3/migrate.go (1)

21-25: LGTM! Authorization setup is correct and secure.

The authorization for MsgUpdateZRC20Name is properly configured with the appropriate admin policy group, maintaining security controls for token updates.

x/fungible/types/message_update_zrc20_name.go (1)

44-58: LGTM! Validation is thorough and complete.

The ValidateBasic implementation correctly checks:

  • Creator address validity
  • ZRC20 address format
  • Presence of at least one update field
x/fungible/types/codec.go (1)

21-21: LGTM! Codec registration is complete and consistent.

The message type is properly registered in both the Amino codec and interface registry, following the established pattern.

Also applies to: 36-36

x/authority/migrations/v3/migrate_test.go (1)

19-19: LGTM!

The test correctly removes the authorization for MsgUpdateZRC20Name before migration, ensuring proper testing of the migration process.

x/fungible/keeper/msg_server_update_zrc20_name.go (1)

15-62: LGTM with suggestions for test coverage.

The implementation is well-structured with proper authorization checks, input validation, and error handling.

The error paths in contract method calls lack test coverage. Consider adding test cases for:

  • Line 51: Failure in ZRC20SetName
  • Line 57: Failure in ZRC20SetSymbol
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 51-52: x/fungible/keeper/msg_server_update_zrc20_name.go#L51-L52
Added lines #L51 - L52 were not covered by tests


[warning] 57-58: x/fungible/keeper/msg_server_update_zrc20_name.go#L57-L58
Added lines #L57 - L58 were not covered by tests

x/authority/types/authorization_list.go (1)

37-37: LGTM!

The message is correctly added to AdminPolicyMessages, ensuring that only admin policy addresses can update ZRC20 names and symbols.

x/fungible/keeper/msg_server_update_zrc20_name_test.go (1)

16-195: LGTM! Comprehensive test coverage for the ZRC20 name/symbol update functionality.

The test suite thoroughly covers essential scenarios including authorization, validation, error cases, and successful updates. The test structure follows best practices with clear arrange-act-assert patterns.

cmd/zetae2e/local/local.go (1)

333-333: LGTM! Added ZRC20 name update test to admin test suite.

The test case is appropriately placed in the admin test routine since it involves admin-only functionality.

e2e/e2etests/e2etests.go (2)

149-149: LGTM!

The constant follows the established naming convention for test names.


975-981: LGTM!

The test registration follows the established pattern for admin tests, including:

  • Appropriate placement in the admin tests section
  • Consistent use of WithMinimumVersion
  • Clear and concise test description
proto/zetachain/zetacore/fungible/tx.proto (1)

31-31: RPC Method Addition Verification
The addition of the RPC method
  rpc UpdateZRC20Name(MsgUpdateZRC20Name) returns (MsgUpdateZRC20NameResponse);
is consistent with the other service definitions. Please verify that the backend implementation properly enforces the necessary authorization checks and integrates with the existing codec registrations.

changelog.md (1)

14-15: Changelog Entry Clarity
The changelog entry clearly documents the implementation of MsgUpdateZRC20Name along with the PR reference. This meets the documentation standards for change logs. Ensure that any related follow‐up changes (such as updates in tests or additional documentation) are consistently mentioned in future entries.

@lumtis lumtis added this pull request to the merge queue Feb 18, 2025
@lumtis lumtis added the CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change label Feb 18, 2025
Merged via the queue into develop with commit 9092054 Feb 18, 2025
53 checks passed
@lumtis lumtis deleted the feat/msg-update-zrc20-name branch February 18, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADMIN_TESTS Run make start-admin-tests breaking:cli breaking:proto CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a message to rename ZRC20s
3 participants