-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
WalkthroughThis 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
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
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
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 ☂️ |
There was a problem hiding this 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
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! TheGetPaused
method is correctly implemented.The method accurately returns the paused status of the
FTFKeeper
.
23-25
: LGTM! TheGetMintingDenom
method is correctly implemented.The method returns the correct minting denomination as
"uusdc"
.x/halo/types/expected_keepers.go (1)
20-24
: LGTM! TheFiatTokenFactoryKeeper
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
: InitializeFTFKeeper
correctly inHaloKeeper
.The
FTFKeeper
is initialized withPaused: false
, which is appropriate for testing scenarios. Ensure this aligns with the intended test conditions.
Line range hint
29-48
:
Verify the integration ofFTFKeeper
inHaloKeeperWithKeepers
.The function signature now includes
ftf FTFKeeper
, and it is integrated into the keeper initialization. Ensure that all necessary interactions withFTFKeeper
are correctly handled.Verification successful
FTFKeeper Integration Verified
The
FTFKeeper
is correctly integrated into theHaloKeeperWithKeepers
function and is actively used in theSendRestrictionFn
method withinkeeper.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.goLength 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.goLength 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 offtfKeeper
to Keeper struct is correct.The
ftfKeeper
field is correctly added to theKeeper
struct, facilitating integration with the FiatTokenFactoryKeeper.
Line range hint
35-47
: Constructor modification to includeftfKeeper
is correct.The
NewKeeper
constructor correctly initializes theftfKeeper
field, maintaining consistency with other parameters.
57-60
: SetFTFKeeper method implementation is correct.The
SetFTFKeeper
method is correctly implemented, allowing dynamic assignment of theftfKeeper
.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 inx/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 testssimapp/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
andcopy
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 theSimApp
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 thekeys
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 usingftfkeeper.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 beforex/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 ofmocks.FTFKeeper
, is added to theTestDeposit
function setup. This enhances the test by accounting for scenarios involving theFTFKeeper
.
106-109
: Integrate FTFKeeper in TestDepositFor.The
ftf
variable is added to theTestDepositFor
function setup, ensuring that the test environment considers the functionality of theFTFKeeper
.
213-216
: Integrate FTFKeeper in TestDepositForWithRestrictions.The
ftf
variable is integrated into theTestDepositForWithRestrictions
function, allowing the test to simulate conditions whereFTFKeeper
functionality is relevant.
265-268
: Integrate FTFKeeper in TestWithdraw.The
ftf
variable is added to theTestWithdraw
function setup. This integration ensures that the test setup reflects scenarios involving theFTFKeeper
.
408-411
: Integrate FTFKeeper in TestWithdrawTo.The
ftf
variable is included in theTestWithdrawTo
function, enhancing the test setup by incorporating theFTFKeeper
.
588-591
: Integrate FTFKeeper in TestWithdrawToAdmin.The
ftf
variable is added to theTestWithdrawToAdmin
function setup, ensuring comprehensive testing of scenarios involving theFTFKeeper
.
690-690
: Integrate FTFKeeper in TestBurn.The
ftf
variable is added to theTestBurn
function setup, allowing the test to account for the presence of theFTFKeeper
.
749-749
: Integrate FTFKeeper in TestBurnFor.The
ftf
variable is included in theTestBurnFor
function setup, enhancing the test by considering theFTFKeeper
.
818-818
: Integrate FTFKeeper in TestMint.The
ftf
variable is added to theTestMint
function setup, ensuring that the test environment considers theFTFKeeper
.
883-886
: Integrate FTFKeeper in TestMintWithRestrictions.The
ftf
variable is integrated into theTestMintWithRestrictions
function, allowing the test to simulate conditions whereFTFKeeper
functionality is relevant.
909-912
: Integrate FTFKeeper in TestTradeToFiat.The
ftf
variable is added to theTestTradeToFiat
function setup, ensuring comprehensive testing of scenarios involving theFTFKeeper
.
utils/mocks/fiattokenfactory.go
Outdated
func (k FTFKeeper) GetBlacklisted(_ sdk.Context, bz []byte) (ftftypes.Blacklisted, bool) { | ||
return ftftypes.Blacklisted{AddressBz: bz}, false // TODO |
There was a problem hiding this comment.
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?
There was a problem hiding this 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
andftfBlacklist
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
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
andftfBlacklist
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
andftfBlacklist
are Adequately CoveredThe test cases in
keeper_test.go
cover various combinations of paused states and blacklisted addresses, ensuring comprehensive coverage of edge scenarios forftfPaused
andftfBlacklist
.
- 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.goLength of output: 3535
253-254
: Consider verifying the mock setup forFTFKeeper
.The
SetFTFKeeper
mock setup is crucial for these tests. Ensure that the mock accurately simulates real-world conditions.Verification successful
Mock Setup for
FTFKeeper
VerifiedThe mock setup for
FTFKeeper
in the test file accurately simulates real-world conditions by allowing different states to be tested through thePaused
andBlacklist
fields. The setup inkeeper_test.go
correctly uses theSetFTFKeeper
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 5Length of output: 1632
There was a problem hiding this 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
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
There was a problem hiding this 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
Files selected for processing (1)
- utils/mocks/fiattokenfactory.go (1 hunks)
Files skipped from review due to trivial changes (1)
- utils/mocks/fiattokenfactory.go
Summary by CodeRabbit
New Features
Bug Fixes
Tests