-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Supplier] Deny supplier staking with unknown services #693
Conversation
WalkthroughThis update introduces an extensive set of changes focused on enhancing the service provisioning and staking mechanisms within the system. Key highlights include the addition of a Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SupplierModule
participant ServiceModule
participant BankKeeper
User->>SupplierModule: StakeSupplier
SupplierModule->>ServiceModule: Check if Service Exists
ServiceModule-->>SupplierModule: Service Exists / Not Found
alt Service Exists
SupplierModule->>BankKeeper: Send Coins for Staking
BankKeeper-->>SupplierModule: Confirm Transaction
SupplierModule-->>User: Staking Successful
else Service Not Found
SupplierModule-->>User: Error: Service Not Found
end
Poem
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 (
|
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 (16)
- config.yml (1 hunks)
- localnet/poktrolld/config/supplier1_stake_config.yaml (1 hunks)
- testutil/integration/app.go (1 hunks)
- testutil/keeper/proof.go (4 hunks)
- testutil/keeper/supplier.go (2 hunks)
- testutil/keeper/tokenomics.go (2 hunks)
- x/service/keeper/service.go (1 hunks)
- x/service/keeper/service_test.go (1 hunks)
- x/service/module/genesis.go (1 hunks)
- x/service/types/expected_keepers.go (1 hunks)
- x/supplier/keeper/keeper.go (3 hunks)
- x/supplier/keeper/msg_server_stake_supplier.go (1 hunks)
- x/supplier/keeper/msg_server_stake_supplier_test.go (1 hunks)
- x/supplier/module/module.go (3 hunks)
- x/supplier/types/errors.go (1 hunks)
- x/supplier/types/expected_keepers.go (2 hunks)
Files skipped from review due to trivial changes (4)
- config.yml
- localnet/poktrolld/config/supplier1_stake_config.yaml
- x/service/keeper/service.go
- x/supplier/types/errors.go
Additional comments not posted (27)
x/service/module/genesis.go (1)
27-27
: LGTM! The function name is now more grammatically correct.The change from
GetAllService
toGetAllServices
is appropriate and aligns with best practices.x/service/types/expected_keepers.go (2)
Line range hint
9-9
:
Addition ofSpendableCoins
method approved.The
SpendableCoins
method enhances the functionality of theBankKeeper
interface.
Line range hint
25-29
:
NewServiceKeeper
interface approved.The addition of the
ServiceKeeper
interface with theGetService
method is appropriate and aligns with the new feature introduced in the PR.x/supplier/types/expected_keepers.go (2)
21-21
: Addition ofSpendableCoins
method approved.The
SpendableCoins
method enhances the functionality of theBankKeeper
interface.
26-29
: NewServiceKeeper
interface approved.The addition of the
ServiceKeeper
interface with theGetService
method is appropriate and aligns with the new feature introduced in the PR.x/supplier/keeper/keeper.go (3)
24-25
: Addition ofserviceKeeper
field approved.The
serviceKeeper
field enhances the functionality of theKeeper
struct.
36-36
: Update toNewKeeper
function approved.The
NewKeeper
function now correctly accepts and initializes theserviceKeeper
field.
48-49
: Initialization ofserviceKeeper
field approved.The
serviceKeeper
field is correctly initialized in theNewKeeper
function.x/service/keeper/service_test.go (1)
72-72
: LGTM! Verify the function usage in the codebase.The code change is approved.
However, ensure that all function calls to
GetAllServices
match the new signature.Verification successful
All instances of the
GetAllServices
function call match the new signature.
x/service/keeper/service_test.go
: Verifiedx/service/module/genesis.go
: VerifiedScripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `GetAllServices` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type go -A 5 $'GetAllServices'Length of output: 1026
Script:
#!/bin/bash # Description: Verify the context of GetAllServices call in x/service/module/genesis.go # Fetching the context around the GetAllServices call in genesis.go to verify it matches the new signature rg --type go -A 5 -B 5 $'GetAllServices' x/service/module/genesis.goLength of output: 407
testutil/keeper/supplier.go (5)
23-24
: LGTM!The imports for
servicekeeper
andsharedtypes
are correctly added.
47-48
: LGTM!The mock expectation for
SpendableCoins
is correctly added.
49-55
: LGTM!The
serviceKeeper
initialization is correctly added.
63-63
: LGTM!The
serviceKeeper
instance is correctly passed to theKeeper
.
71-74
: LGTM! Verify the function usage in the codebase.The services are correctly added for testing.
However, ensure that all function calls to
SetService
match the new signature.Verification successful
Verified: All instances of
SetService
in the codebase match the new signature.
testutil/keeper/supplier.go
testutil/integration/app.go
x/service/module/genesis.go
x/service/keeper/msg_server_add_service.go
x/service/keeper/service_test.go
x/service/keeper/service.go
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `SetService` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type go -A 5 $'SetService'Length of output: 2544
x/supplier/keeper/msg_server_stake_supplier.go (1)
30-36
: LGTM! Verify the function usage in the codebase.The new checks for verifying the existence of services before staking are correctly added.
However, ensure that all function calls to
GetService
match the new signature.Verification successful
Ensure all function calls to
GetService
match the new signature.From the provided output, we can see multiple occurrences of
GetService
. Here are the critical points to check:
- Function Definition:
x/supplier/types/expected_keepers.go
: GetService(ctx context.Context, serviceId string) (sharedtypes.Service, bool)- Function Calls:
x/supplier/keeper/msg_server_stake_supplier.go
: if _, serviceFound := k.serviceKeeper.GetService(ctx, serviceConfig.Service.Id); !serviceFound { ... }x/service/keeper/msg_server_add_service.go
: if _, found := k.GetService(ctx, msg.Service.Id); found { ... }x/service/keeper/query_service.go
: service, found := k.GetService(ctx, req.Id)x/service/keeper/service_test.go
: foundService, found := keeper.GetService(ctx, service.Id)x/service/keeper/service_test.go
: _, found := keeper.GetService(ctx, service.Id)x/service/keeper/msg_server_add_service_test.go
: serviceFound, found := k.GetService(ctx, preExistingService.Id)x/service/keeper/msg_server_add_service_test.go
: serviceFound, found := k.GetService(ctx, test.service.Id)All the function calls listed above correctly match the new signature
GetService(ctx, serviceId string) (sharedtypes.Service, bool)
.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `GetService` match the new signature. # Test: Search for the function usage. Expect: Only occurances of the new signature. rg --type go -A 5 $'GetService'Length of output: 77998
x/supplier/module/module.go (6)
101-101
: LGTM!The
serviceKeeper
field is correctly added to theAppModule
struct.
109-109
: LGTM!The
serviceKeeper
parameter is correctly added to theNewAppModule
function.
116-116
: LGTM!The
serviceKeeper
field is correctly initialized in theAppModule
struct.
185-185
: LGTM!The
serviceKeeper
field is correctly added to theModuleInputs
struct.
207-207
: LGTM!The
serviceKeeper
parameter is correctly passed to theNewKeeper
function.
214-214
: LGTM! Verify the function usage in the codebase.The
serviceKeeper
parameter is correctly passed to theNewAppModule
function.However, ensure that all function calls to
NewAppModule
match the new signature.x/supplier/keeper/msg_server_stake_supplier_test.go (1)
238-266
: LGTM!The test function
TestMsgServer_StakeSupplier_FailWithNonExistingService
correctly tests the scenario of staking a supplier with a non-existing service and ensures that the appropriate error is returned.testutil/keeper/proof.go (2)
31-31
: LGTM!The added imports for
servicekeeper
andservicetypes
are necessary for the newserviceKeeper
functionality.Also applies to: 41-42
186-194
: LGTM!The creation and integration of the
serviceKeeper
instance is correctly implemented.Also applies to: 202-202
testutil/keeper/tokenomics.go (2)
39-40
: LGTM!The added imports for
servicekeeper
andservicetypes
are necessary for the newserviceKeeper
functionality.
288-296
: LGTM!The creation and integration of the
serviceKeeper
instance is correctly implemented.Also applies to: 304-304
testutil/integration/app.go (1)
341-341
: LGTM!The creation and integration of the
serviceKeeper
instance inNewCompleteIntegrationApp
is correctly implemented.Also applies to: 348-348
testutil/keeper/tokenomics.go
Outdated
@@ -283,13 +285,23 @@ func NewTokenomicsModuleKeepers( | |||
) | |||
require.NoError(t, appKeeper.SetParams(ctx, apptypes.DefaultParams())) | |||
|
|||
// Construct a service keeper need by the supplier keeper. |
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.
// Construct a service keeper need by the supplier keeper. | |
// Construct a service keeper needed by the supplier keeper. |
The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks. You may need to run GCP workloads (requires changing the namespace to 693) |
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)
- testutil/keeper/tokenomics.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- testutil/keeper/tokenomics.go
Summary
Prevent
Supplier
s from staking with non-existing services.This PR does not enforce/restrict the
Service
creation.Issue
Type of change
Select one or more:
Testing
Documentation changes (only if making doc changes)
make docusaurus_start
; only needed if you make doc changesLocal Testing (only if making code changes)
make go_develop_and_test
make test_e2e
PR Testing (only if making code changes)
devnet-test-e2e
label to the PR.make trigger_ci
if you want to re-trigger tests without any code changesSanity Checklist
Summary by CodeRabbit
Bug Fixes
New Features
serviceKeeper
andsupplierKeeper
functionality.BankKeeper
.Improvements
GetAllService
toGetAllServices
for clarity.ErrSupplierServiceNotFound
error code.Tests