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: enforce usdc blacklist checks #5

Merged
merged 7 commits into from
Aug 15, 2024
Merged

feat: enforce usdc blacklist checks #5

merged 7 commits into from
Aug 15, 2024

Conversation

johnletey
Copy link
Member

@johnletey johnletey commented Aug 7, 2024

Summary by CodeRabbit

  • New Features

    • Integrated a new Fiat Token Factory for enhanced fiat token management.
    • Improved genesis configuration by adding metadata for "Circle USD Coin" and updating staking parameters.
  • Bug Fixes

    • Enhanced functionality of the Keeper to handle fiat token transfer restrictions effectively.
  • Tests

    • Updated test cases to incorporate the Fiat Token Factory Keeper, allowing for more comprehensive testing scenarios.

@johnletey johnletey added this to the v1.0.0 milestone Aug 7, 2024
@johnletey johnletey requested a review from g-luca August 7, 2024 15:31
@johnletey johnletey self-assigned this Aug 7, 2024
Copy link

coderabbitai bot commented Aug 7, 2024

Walkthrough

This update integrates the FiatTokenFactory into the Go project, significantly enhancing the blockchain's token management capabilities. Key changes include new dependencies, updates to the genesis configuration, and adjustments to the keeper and application logic. These enhancements improve metadata handling, state management, and the robustness of testing, marking a substantial evolution in the project's architecture and functionality.

Changes

File(s) Change Summary
go.mod, simapp/go.mod Added new dependencies for FiatTokenFactory and related functionalities; removed several indirect dependencies.
local.sh Updated genesis configuration for "Circle USD Coin," including new metadata attributes and minting denom.
simapp/app.go Integrated FiatTokenFactory module, added FTFKeeper to SimApp, and adjusted initialization order.
utils/mocks/fiattokenfactory.go, utils/mocks/halo.go Created mock implementations for FiatTokenFactoryKeeper and enhanced HaloKeeper to utilize the new keeper.
x/halo/keeper/keeper.go Updated Keeper struct to include ftfKeeper and modified methods to integrate fiat token management logic.
x/halo/keeper/msg_server_test.go Adjusted test cases to incorporate FTFKeeper, enhancing the testing framework for fiat token operations.
x/halo/types/expected_keepers.go Introduced FiatTokenFactoryKeeper interface for improved management of fiat token states and interactions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SimApp
    participant FTFKeeper
    participant HaloKeeper

    User->>SimApp: Create Transaction
    SimApp->>FTFKeeper: Check Minting Denom
    FTFKeeper-->>SimApp: Return "uusdc"
    SimApp->>HaloKeeper: Process Transaction
    HaloKeeper-->>User: Transaction Result
Loading

🐇 In fields of green, where tokens play,
New fiat friends join in the fray.
With keepers and mocks, we leap and bound,
In this code garden, joy is found!
Hops of change, so bright and new,
A lively dance, for me and you! ✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@johnletey johnletey marked this pull request as ready for review August 13, 2024 19:08
@johnletey johnletey requested a review from g-luca August 13, 2024 19:09
Copy link

codecov bot commented Aug 13, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f65893b and bb65ee8.

Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • go.work.sum is excluded by !**/*.sum
  • simapp/go.sum is excluded by !**/*.sum
Files selected for processing (9)
  • go.mod (5 hunks)
  • local.sh (1 hunks)
  • simapp/app.go (8 hunks)
  • simapp/go.mod (8 hunks)
  • utils/mocks/fiattokenfactory.go (1 hunks)
  • utils/mocks/halo.go (2 hunks)
  • x/halo/keeper/keeper.go (4 hunks)
  • x/halo/keeper/msg_server_test.go (11 hunks)
  • x/halo/types/expected_keepers.go (2 hunks)
Additional context used
GitHub Check: codecov/patch
x/halo/keeper/keeper.go

[warning] 58-59: x/halo/keeper/keeper.go#L58-L59
Added lines #L58 - L59 were not covered by tests


[warning] 67-67: x/halo/keeper/keeper.go#L67
Added line #L67 was not covered by tests


[warning] 71-71: x/halo/keeper/keeper.go#L71
Added line #L71 was not covered by tests


[warning] 75-75: x/halo/keeper/keeper.go#L75
Added line #L75 was not covered by tests

Additional comments not posted (33)
utils/mocks/fiattokenfactory.go (2)

19-21: LGTM! The GetPaused method is correctly implemented.

The method accurately returns the paused status of the FTFKeeper.


23-25: LGTM! The GetMintingDenom method is correctly implemented.

The method returns the correct minting denomination as "uusdc".

x/halo/types/expected_keepers.go (1)

20-24: LGTM! The FiatTokenFactoryKeeper interface is well-defined.

The interface provides necessary methods for interacting with fiat token-related data, enhancing modularity and functionality.

utils/mocks/halo.go (2)

23-25: Initialize FTFKeeper correctly in HaloKeeper.

The FTFKeeper is initialized with Paused: false, which is appropriate for testing scenarios. Ensure this aligns with the intended test conditions.


Line range hint 29-48:
Verify the integration of FTFKeeper in HaloKeeperWithKeepers.

The function signature now includes ftf FTFKeeper, and it is integrated into the keeper initialization. Ensure that all necessary interactions with FTFKeeper are correctly handled.

Verification successful

FTFKeeper Integration Verified

The FTFKeeper is correctly integrated into the HaloKeeperWithKeepers function and is actively used in the SendRestrictionFn method within keeper.go. This confirms its role in handling transfer restrictions, utilizing its methods effectively. No issues were found with its integration.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `FTFKeeper` in the codebase.

# Test: Search for usage of `FTFKeeper` to ensure it's correctly integrated.
rg --type go 'FTFKeeper'

Length of output: 1942


Script:

#!/bin/bash
# Description: Check the usage of `FTFKeeper` within the keeper logic to verify its integration.

# Test: Search for usage of `FTFKeeper` within `keeper.go` to ensure it's correctly integrated.
rg --type go 'FTFKeeper' -A 5 x/halo/keeper/keeper.go

Length of output: 444


Script:

#!/bin/bash
# Description: Search for any references to `ftfKeeper` within `keeper.go` to confirm its usage.

# Test: Search for `ftfKeeper` to find any interactions or method calls involving it.
rg --type go 'ftfKeeper' -A 5 x/halo/keeper/keeper.go

Length of output: 1402

local.sh (2)

30-30: Metadata addition for "Circle USD Coin" is correct.

The JSON object for the "Circle USD Coin" metadata is correctly structured and uses jq appropriately.


32-32: Minting denom configuration for fiat-tokenfactory is correct.

The jq command correctly sets the minting denom to "uusdc" in the genesis JSON file.

x/halo/keeper/keeper.go (4)

24-24: Addition of ftfKeeper to Keeper struct is correct.

The ftfKeeper field is correctly added to the Keeper struct, facilitating integration with the FiatTokenFactoryKeeper.


Line range hint 35-47: Constructor modification to include ftfKeeper is correct.

The NewKeeper constructor correctly initializes the ftfKeeper field, maintaining consistency with other parameters.


57-60: SetFTFKeeper method implementation is correct.

The SetFTFKeeper method is correctly implemented, allowing dynamic assignment of the ftfKeeper.

Tools
GitHub Check: codecov/patch

[warning] 58-59: x/halo/keeper/keeper.go#L58-L59
Added lines #L58 - L59 were not covered by tests


64-77: SendRestrictionFn logic enhancement is correct but requires tests.

The integration of minting denom checks and blacklist status is correctly implemented. However, ensure these lines are covered by tests.

Do you want me to generate unit tests for this method or open a GitHub issue to track this task?

Verification successful

SendRestrictionFn is adequately tested.

The SendRestrictionFn method is covered by tests in x/halo/keeper/keeper_test.go, which include assertions for conditions related to the paused state and blacklist checks. No further action is needed regarding test coverage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the test coverage for SendRestrictionFn method.

# Test: Check for test coverage. Expect: Lines related to blacklist checks and paused state are covered.
rg --type go -A 5 'SendRestrictionFn'

Length of output: 8276

Tools
GitHub Check: codecov/patch

[warning] 67-67: x/halo/keeper/keeper.go#L67
Added line #L67 was not covered by tests


[warning] 71-71: x/halo/keeper/keeper.go#L71
Added line #L71 was not covered by tests


[warning] 75-75: x/halo/keeper/keeper.go#L75
Added line #L75 was not covered by tests

simapp/go.mod (3)

Line range hint 6-87: Dependency additions are appropriate.

The added dependencies align with the project's objectives, enhancing functionality and integration capabilities.


Line range hint 6-87: Dependency removals are appropriate.

The removal of gomega and copy suggests a strategic decision to streamline the codebase without affecting functionality.


155-155: Replace directive modification is appropriate.

The update to the cosmos-sdk replace directive aligns with the project's goals, ensuring compatibility with send restrictions.

simapp/app.go (7)

48-50: Ensure imports are necessary and used.

The new imports for fiattokenfactory and its components (ftf, ftfkeeper, ftftypes) are necessary for integrating the FiatTokenFactory module.


104-104: Addition of FTFKeeper to SimApp struct.

The FTFKeeper field has been added to the SimApp struct to manage the FiatTokenFactory's state. This integration seems correct and consistent with the module's requirements.


138-138: Add FTF StoreKey to keys.

The addition of ftftypes.StoreKey to the keys variable ensures that the application has access to the necessary storage for the FiatTokenFactory. This is a crucial step for state management.


175-178: Initialize FTFKeeper in NewSimApp.

The FTFKeeper is correctly instantiated using ftfkeeper.NewKeeper, integrating it into the app's management system. This setup is necessary for the FiatTokenFactory module's functionality.


189-189: Register FTF module in module manager.

The ftf.NewAppModule registration within the module manager ensures that the FiatTokenFactory module is part of the application's lifecycle. This is essential for module initialization and execution.


195-205: Set module initialization order.

The order of module initialization and execution is adjusted to prioritize ftftypes.ModuleName. This ensures the FiatTokenFactory is initialized before x/genutils, maintaining the integrity of the Halo send restrictions during the genesis transaction process.


313-313: Add FTF module to params keeper.

The addition of paramsKeeper.Subspace(ftftypes.ModuleName) ensures that the FiatTokenFactory module has its own parameter subspace for configuration. This is necessary for managing module-specific parameters.

go.mod (1)

7-7: Addition of noble-fiattokenfactory dependency.

The addition of github.com/circlefin/noble-fiattokenfactory at a specific version indicates the integration of new functionality related to fiat token management. Ensure that this dependency is necessary and correctly used in the project.

Verification successful

Dependency Usage Confirmed

The noble-fiattokenfactory dependency is actively used in the codebase, as evidenced by its imports in several files. This suggests its integration is necessary for the project's functionality. No issues found regarding its usage.

  • x/halo/types/expected_keepers.go
  • utils/mocks/fiattokenfactory.go
  • simapp/app.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify usage of the new `noble-fiattokenfactory` dependency.

# Test: Search for usage of `noble-fiattokenfactory` in the codebase. Expect: Occurrences of its usage.
rg --type go 'noble-fiattokenfactory'

Length of output: 540

x/halo/keeper/msg_server_test.go (11)

30-33: Integrate FTFKeeper in TestDeposit.

The ftf variable, an instance of mocks.FTFKeeper, is added to the TestDeposit function setup. This enhances the test by accounting for scenarios involving the FTFKeeper.


106-109: Integrate FTFKeeper in TestDepositFor.

The ftf variable is added to the TestDepositFor function setup, ensuring that the test environment considers the functionality of the FTFKeeper.


213-216: Integrate FTFKeeper in TestDepositForWithRestrictions.

The ftf variable is integrated into the TestDepositForWithRestrictions function, allowing the test to simulate conditions where FTFKeeper functionality is relevant.


265-268: Integrate FTFKeeper in TestWithdraw.

The ftf variable is added to the TestWithdraw function setup. This integration ensures that the test setup reflects scenarios involving the FTFKeeper.


408-411: Integrate FTFKeeper in TestWithdrawTo.

The ftf variable is included in the TestWithdrawTo function, enhancing the test setup by incorporating the FTFKeeper.


588-591: Integrate FTFKeeper in TestWithdrawToAdmin.

The ftf variable is added to the TestWithdrawToAdmin function setup, ensuring comprehensive testing of scenarios involving the FTFKeeper.


690-690: Integrate FTFKeeper in TestBurn.

The ftf variable is added to the TestBurn function setup, allowing the test to account for the presence of the FTFKeeper.


749-749: Integrate FTFKeeper in TestBurnFor.

The ftf variable is included in the TestBurnFor function setup, enhancing the test by considering the FTFKeeper.


818-818: Integrate FTFKeeper in TestMint.

The ftf variable is added to the TestMint function setup, ensuring that the test environment considers the FTFKeeper.


883-886: Integrate FTFKeeper in TestMintWithRestrictions.

The ftf variable is integrated into the TestMintWithRestrictions function, allowing the test to simulate conditions where FTFKeeper functionality is relevant.


909-912: Integrate FTFKeeper in TestTradeToFiat.

The ftf variable is added to the TestTradeToFiat function setup, ensuring comprehensive testing of scenarios involving the FTFKeeper.

Comment on lines 15 to 16
func (k FTFKeeper) GetBlacklisted(_ sdk.Context, bz []byte) (ftftypes.Blacklisted, bool) {
return ftftypes.Blacklisted{AddressBz: bz}, false // TODO
Copy link

Choose a reason for hiding this comment

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

Implement the TODO in GetBlacklisted.

The GetBlacklisted method currently returns a placeholder value. Ensure that the actual logic for retrieving blacklisted addresses is implemented.

Would you like me to help implement the logic for this method or open a GitHub issue to track this task?

Copy link

@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: 0

Outside diff range, codebase verification and nitpick comments (1)
x/halo/keeper/keeper_test.go (1)

134-135: Add comments to explain new test case fields.

The fields ftfPaused and ftfBlacklist have been added to the test case struct. Consider adding comments to explain their purpose for future maintainability.

ftfPaused        bool   // Indicates if the FiatTokenFactory is paused
ftfBlacklist     [][]byte // List of addresses blacklisted by the FiatTokenFactory
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bb65ee8 and 9e32436.

Files selected for processing (2)
  • utils/mocks/fiattokenfactory.go (1 hunks)
  • x/halo/keeper/keeper_test.go (3 hunks)
Files skipped from review due to trivial changes (1)
  • utils/mocks/fiattokenfactory.go
Additional comments not posted (2)
x/halo/keeper/keeper_test.go (2)

213-242: Ensure new test cases cover all edge scenarios.

The new test cases for ftfPaused and ftfBlacklist enhance the coverage. Ensure that all possible scenarios, such as different combinations of paused states and blacklisted addresses, are tested.

Verification successful

Edge Cases for ftfPaused and ftfBlacklist are Adequately Covered

The test cases in keeper_test.go cover various combinations of paused states and blacklisted addresses, ensuring comprehensive coverage of edge scenarios for ftfPaused and ftfBlacklist.

  • Test cases include situations where transfers are paused, not paused, and where specific addresses are blacklisted for sending or receiving.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all edge cases related to `ftfPaused` and `ftfBlacklist` are covered.

# Test: Search for test cases using `ftfPaused` and `ftfBlacklist`.
rg --type go -A 5 'ftfPaused|ftfBlacklist'

Length of output: 2043


Script:

#!/bin/bash
# Description: List all test cases in the keeper_test.go file to verify coverage of edge cases.
rg --type go 'name:' -A 5 x/halo/keeper/keeper_test.go

Length of output: 3535


253-254: Consider verifying the mock setup for FTFKeeper.

The SetFTFKeeper mock setup is crucial for these tests. Ensure that the mock accurately simulates real-world conditions.

Verification successful

Mock Setup for FTFKeeper Verified

The mock setup for FTFKeeper in the test file accurately simulates real-world conditions by allowing different states to be tested through the Paused and Blacklist fields. The setup in keeper_test.go correctly uses the SetFTFKeeper function to inject the mock. No issues found.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the mock setup for `FTFKeeper`.

# Test: Check the implementation of `SetFTFKeeper` in the mocks.
ast-grep --lang go --pattern $'func SetFTFKeeper($_) { $$$ }'

Length of output: 62


Script:

#!/bin/bash
# Search for the definition of the FTFKeeper mock and its usage in the test files.
ast-grep --lang go --pattern $'type FTFKeeper struct { $$$ }'

# Search for the usage of SetFTFKeeper in the test files to understand how it's being used.
rg 'SetFTFKeeper' -A 5

Length of output: 1632

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9e32436 and 3c9b4cc.

Files selected for processing (1)
  • x/halo/keeper/keeper_test.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • x/halo/keeper/keeper_test.go

Copy link

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3c9b4cc and af66b12.

Files selected for processing (1)
  • utils/mocks/fiattokenfactory.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • utils/mocks/fiattokenfactory.go

@johnletey johnletey merged commit 865b1ce into main Aug 15, 2024
3 checks passed
@johnletey johnletey deleted the usdc-blacklist branch August 16, 2024 08:27
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.

2 participants