-
Notifications
You must be signed in to change notification settings - Fork 6
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
refactor: captains genesis and key naming. #39
Conversation
WalkthroughThe recent updates introduce significant restructuring and renaming across various components of the Changes
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 Configration File (
|
@coderabbitai review |
Actions PerformedReview triggered.
|
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: 8
Out of diff range and nitpick comments (2)
x/captains/keeper/computing_power.go (1)
96-100
: Consider using atomic operations for thread safety.The function
CommitComputingPower
modifies the claimable computing power in a non-atomic way, which could lead to race conditions in a concurrent environment. Consider using atomic operations or transactional mechanisms provided by the datastore if applicable.x/captains/types/genesis.go (1)
Line range hint
70-122
: Validate theDefaultDivision
function and ensure it meets future requirements.The TODO comment suggests that the default computing power bounds need to be updated. It would be beneficial to address this to ensure the defaults remain relevant.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
x/captains/types/captains.pb.go
is excluded by!**/*.pb.go
x/captains/types/genesis.pb.go
is excluded by!**/*.pb.go
x/captains/types/report.pb.go
is excluded by!**/*.pb.go
Files selected for processing (24)
- proto/tabi/captains/v1/captains.proto (1 hunks)
- proto/tabi/captains/v1/genesis.proto (1 hunks)
- proto/tabi/captains/v1/report.proto (1 hunks)
- x/captains/exported/exported.go (1 hunks)
- x/captains/keeper/abci.go (1 hunks)
- x/captains/keeper/computing_power.go (2 hunks)
- x/captains/keeper/emission.go (3 hunks)
- x/captains/keeper/epoch.go (2 hunks)
- x/captains/keeper/genesis.go (1 hunks)
- x/captains/keeper/genesis_test.go (1 hunks)
- x/captains/keeper/grpc_query.go (1 hunks)
- x/captains/keeper/integration_test.go (16 hunks)
- x/captains/keeper/msg_server.go (1 hunks)
- x/captains/keeper/nodes.go (3 hunks)
- x/captains/keeper/pledge_ratio.go (4 hunks)
- x/captains/keeper/pledge_ratio_test.go (2 hunks)
- x/captains/keeper/report.go (8 hunks)
- x/captains/types/genesis.go (3 hunks)
- x/captains/types/genesis_test.go (2 hunks)
- x/captains/types/keys.go (7 hunks)
- x/captains/types/params.go (2 hunks)
- x/claims/keeper/claims.go (2 hunks)
- x/claims/keeper/mock_captains_test.go (3 hunks)
- x/claims/types/expected_keepers.go (1 hunks)
Files skipped from review due to trivial changes (2)
- x/captains/keeper/genesis_test.go
- x/claims/keeper/mock_captains_test.go
Additional comments not posted (68)
x/captains/keeper/abci.go (2)
11-11
: Ensure that the deletion of global computing power for the previous epoch is correctly handled in all relevant parts of the application.Verification successful
The function
delGlobalComputingPowerOnEpoch
is correctly implemented to delete the global computing power for a given epoch from the key-value store. It is invoked inx/captains/keeper/abci.go
to handle the deletion of computing power for the previous epoch.
x/captains/keeper/computing_power.go:37-41
: Implementation ofdelGlobalComputingPowerOnEpoch
.x/captains/keeper/abci.go:11
: Invocation ofdelGlobalComputingPowerOnEpoch
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the deletion of global computing power is correctly handled. # Test: Search for the function usage. Expect: Proper handling in all relevant parts. rg --type python $'delGlobalComputingPowerOnEpoch'Length of output: 80
Script:
#!/bin/bash # Description: Verify that the deletion of global computing power is correctly handled. # Test: Search for the function usage. Expect: Proper handling in all relevant parts. rg --type go 'delGlobalComputingPowerOnEpoch'Length of output: 359
Script:
#!/bin/bash # Description: Extract the implementation of delGlobalComputingPowerOnEpoch. # Test: Ensure the function correctly handles the deletion of global computing power. rg --type go --context 10 'func (k Keeper) delGlobalComputingPowerOnEpoch' x/captains/keeper/computing_power.goLength of output: 113
Script:
#!/bin/bash # Description: Extract the implementation of delGlobalComputingPowerOnEpoch using ast-grep. # Test: Ensure the function correctly handles the deletion of global computing power. ast-grep --lang go --pattern $'func (k Keeper) delGlobalComputingPowerOnEpoch($_, $_) { $$$ }' x/captains/keeper/computing_power.goLength of output: 530
14-14
: Ensure that the deletion of report digest is correctly handled in all relevant parts of the application.x/captains/exported/exported.go (3)
17-18
: Ensure that the new methodCalcAndGetNodeCumulativeEmissionByEpoch
is implemented correctly and used consistently across the application.Verification successful
The method
CalcAndGetNodeCumulativeEmissionByEpoch
is implemented and used consistently across the codebase. Here are the relevant locations:
- Declaration:
x/captains/exported/exported.go
- Implementation:
x/captains/keeper/emission.go
- Usage:
x/claims/keeper/claims.go
- Mock for testing:
x/claims/keeper/mock_captains_test.go
This confirms that the method is correctly integrated into the application.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type python $'CalcAndGetNodeCumulativeEmissionByEpoch'Length of output: 89
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type go 'CalcAndGetNodeCumulativeEmissionByEpoch'Length of output: 1179
20-21
: Ensure that the new methodGetNodeClaimedEmission
is implemented correctly and used consistently across the application.Verification successful
The method
GetNodeClaimedEmission
is implemented and used consistently across the codebaseThe method
GetNodeClaimedEmission
is implemented inx/captains/keeper/emission.go
and is used in multiple files, includingx/captains/keeper/emission.go
,x/claims/types/expected_keepers.go
, andx/claims/keeper/claims.go
. This confirms that the method is implemented and used consistently across the application.
Implementation:
x/captains/keeper/emission.go
:func (k Keeper) GetNodeClaimedEmission(ctx sdk.Context, nodeID string) sdk.Dec
Usage:
x/captains/keeper/emission.go
x/claims/types/expected_keepers.go
x/claims/keeper/claims.go
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type python $'GetNodeClaimedEmission'Length of output: 72
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. # Search for the implementation of GetNodeClaimedEmission in Go files ast-grep --lang go --pattern 'func ($_ GetNodeClaimedEmission) $_' # Search for the usage of GetNodeClaimedEmission in Go files rg 'GetNodeClaimedEmission' --type goLength of output: 1391
23-24
: Ensure that the new methodUpdateGlobalAndNodeClaimedEmission
is implemented correctly and used consistently across the application.Verification successful
The method
UpdateGlobalAndNodeClaimedEmission
is implemented and used consistently across the codebase. Here are the relevant locations:
Implementation:
x/captains/keeper/emission.go: func (k Keeper) UpdateGlobalAndNodeClaimedEmission(ctx sdk.Context, nodeID string) error
References:
x/captains/exported/exported.go
x/claims/types/expected_keepers.go
x/claims/keeper/mock_captains_test.go
x/claims/keeper/claims.go
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type python $'UpdateGlobalAndNodeClaimedEmission'Length of output: 84
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. # Search for the implementation of the method in Go files rg --type go 'func UpdateGlobalAndNodeClaimedEmission' # Search for the usage of the method in Go files rg --type go 'UpdateGlobalAndNodeClaimedEmission'Length of output: 1183
x/captains/types/genesis_test.go (1)
20-52
: Ensure that the new test cases for the genesis state validation are comprehensive and cover all new fields and scenarios introduced in the genesis state.Verification successful
The test cases in
x/captains/types/genesis_test.go
appear to cover various scenarios for the genesis state validation, including both successful and failure cases. The test cases include:
- Default genesis state validation.
- Base state validation with specific parameters.
These test cases seem to address different aspects of the genesis state, ensuring that both valid and invalid states are tested.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the test cases are comprehensive. # Test: Review the test cases and ensure they cover all scenarios. rg --type python $'TestValidateGenesis'Length of output: 69
Script:
#!/bin/bash # Description: Verify that the test cases are comprehensive. # Test: Review the test cases and ensure they cover all scenarios. rg --type go 'func Test' --context 10Length of output: 94900
x/captains/keeper/epoch.go (1)
32-33
: Ensure that the new methodsetEndOnEpoch
is implemented correctly and used consistently across the application.Verification successful
The function
setEndOnEpoch
is implemented inepoch.go
and used in bothreport.go
andgenesis.go
. The context around its usage in these files indicates that it is being used consistently to mark the end of an epoch.
- In
genesis.go
, it is called within theSetBaseState
method whenbs.IsEpochEnd
is true.- In
report.go
, it is called to mark readiness for the next epoch after checking if the report is completed.These usages align with the intended purpose of setting the end epoch.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type python $'setEndOnEpoch'Length of output: 63
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type go 'setEndOnEpoch'Length of output: 307
Script:
#!/bin/bash # Extract lines around the usage of setEndOnEpoch in report.go and genesis.go for context. rg --type go --context 5 'setEndOnEpoch' x/captains/keeper/report.go x/captains/keeper/genesis.goLength of output: 1340
proto/tabi/captains/v1/genesis.proto (1)
5-39
: Ensure that the new protobuf definitions for the genesis state are correctly implemented and used consistently across the application.proto/tabi/captains/v1/report.proto (1)
62-67
: Ensure that the new protobuf definitionBatchBase
is correctly implemented and used consistently across the application.Verification successful
BatchBase
is implemented and used consistently across the codebaseThe
BatchBase
protobuf definition is correctly implemented and used in various parts of the codebase, including:
x/captains/types/report.pb.go
x/captains/types/genesis.pb.go
x/captains/types/genesis.go
x/captains/keeper/report.go
proto/tabi/captains/v1/genesis.proto
proto/tabi/captains/v1/report.proto
These references indicate that the
BatchBase
message is integrated and utilized as expected.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new protobuf definition is implemented and used consistently. # Test: Search for the protobuf usage. Expect: Consistent implementation and usage. rg --type python $'BatchBase'Length of output: 59
Script:
#!/bin/bash # Description: Verify that the new protobuf definition is implemented and used consistently. # Test: Search for the protobuf usage. Expect: Consistent implementation and usage. rg --type py 'BatchBase'Length of output: 173
Script:
#!/bin/bash # Description: Verify that the new protobuf definition is implemented and used consistently. # Test: Search for the protobuf usage. Expect: Consistent implementation and usage. rg 'BatchBase'Length of output: 2758
x/claims/keeper/claims.go (2)
38-38
: Ensure that the new methodUpdateGlobalAndNodeClaimedEmission
is implemented correctly and used consistently across the application.Verification successful
Implementation and Usage of
UpdateGlobalAndNodeClaimedEmission
VerifiedThe method
UpdateGlobalAndNodeClaimedEmission
is implemented and used consistently across the codebase. Here are the relevant locations:
Implementation:
x/captains/keeper/emission.go
: The method is implemented in theKeeper
struct.x/claims/keeper/mock_captains_test.go
: A mock implementation for testing purposes.Usage:
x/claims/keeper/claims.go
: The method is called within the claims processing logic.x/captains/exported/exported.go
: The method is declared in an interface.x/claims/types/expected_keepers.go
: The method is declared in an interface.The method is correctly implemented and used in the appropriate contexts, ensuring that node emissions are updated as expected.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type python $'UpdateGlobalAndNodeClaimedEmission'Length of output: 84
Script:
#!/bin/bash # Description: Verify that the new method is implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type go 'UpdateGlobalAndNodeClaimedEmission'Length of output: 1126
Script:
#!/bin/bash # Extract the implementation and usage of the method for detailed review. rg --type go --context 5 'UpdateGlobalAndNodeClaimedEmission' x/captains/keeper/emission.go x/claims/keeper/mock_captains_test.go x/claims/keeper/claims.go x/captains/exported/exported.go x/claims/types/expected_keepers.goLength of output: 4315
75-77
: Ensure that the new methodsCalcAndGetNodeCumulativeEmissionByEpoch
andGetNodeClaimedEmission
are implemented correctly and used consistently across the application.Verification successful
The methods
CalcAndGetNodeCumulativeEmissionByEpoch
andGetNodeClaimedEmission
are implemented and used consistently across the codebase. Here are the relevant locations:
Implementation:
x/captains/exported/exported.go
x/captains/keeper/emission.go
Usage:
x/claims/keeper/claims.go
x/claims/keeper/mock_captains_test.go
x/claims/types/expected_keepers.go
These methods are correctly implemented and used consistently across the application.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new methods are implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type python $'CalcAndGetNodeCumulativeEmissionByEpoch|GetNodeClaimedEmission'Length of output: 114
Script:
#!/bin/bash # Description: Verify that the new methods are implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type go 'CalcAndGetNodeCumulativeEmissionByEpoch|GetNodeClaimedEmission'Length of output: 2489
x/claims/types/expected_keepers.go (1)
62-69
: Ensure that the new methodsCalcAndGetNodeCumulativeEmissionByEpoch
,GetNodeClaimedEmission
, andUpdateGlobalAndNodeClaimedEmission
are implemented correctly and used consistently across the application.Verification successful
The new methods
CalcAndGetNodeCumulativeEmissionByEpoch
,GetNodeClaimedEmission
, andUpdateGlobalAndNodeClaimedEmission
are implemented and used consistently across the codebase. The implementations are found inx/captains/keeper/emission.go
, and they are used inx/claims/keeper/claims.go
. Additionally, they are defined inx/captains/exported/exported.go
and mocked inx/claims/keeper/mock_captains_test.go
.
CalcAndGetNodeCumulativeEmissionByEpoch
: Implemented inx/captains/keeper/emission.go
and used inx/claims/keeper/claims.go
.GetNodeClaimedEmission
: Implemented inx/captains/keeper/emission.go
and used inx/claims/keeper/claims.go
.UpdateGlobalAndNodeClaimedEmission
: Implemented inx/captains/keeper/emission.go
and used inx/claims/keeper/claims.go
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the new methods are implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type python $'CalcAndGetNodeCumulativeEmissionByEpoch|GetNodeClaimedEmission|UpdateGlobalAndNodeClaimedEmission'Length of output: 149
Script:
#!/bin/bash # Description: Verify that the new methods are implemented and used consistently. # Test: Search for the function implementation and usage. Expect: Consistent implementation and usage. rg --type go 'CalcAndGetNodeCumulativeEmissionByEpoch|GetNodeClaimedEmission|UpdateGlobalAndNodeClaimedEmission'Length of output: 3601
x/captains/types/params.go (1)
43-55
: The updated default parameters inDefaultParams
are clear and well-defined.x/captains/keeper/pledge_ratio_test.go (1)
39-39
: The test cases have been correctly updated to reflect the new function names and logic for global and node-specific pledge calculations.Also applies to: 46-47, 54-55, 62-63, 96-96, 104-104, 112-112, 120-120
proto/tabi/captains/v1/captains.proto (1)
67-83
: The new protobuf messages and fields are clearly defined and enhance the data structure's clarity and consistency.Also applies to: 85-93, 95-97, 104-106, 109-112, 119-121, 128-131, 138-140, 147-155
x/captains/keeper/grpc_query.go (1)
117-117
: The update in theNodeLastEpochInfo
function to useCalcNodeCumulativeEmissionByEpoch
is appropriate and aligns with the renaming objective of the PR.x/captains/keeper/pledge_ratio.go (1)
16-16
: The updates in the pledge ratio calculation functions are consistent with the new function names and logic introduced in the PR.Also applies to: 21-21, 38-38, 106-106, 117-117, 124-124, 131-131
x/captains/keeper/nodes.go (1)
71-71
: The update in theUpdateNode
function to useGetClaimableComputingPower
and the logic for decrementing claimable computing power are appropriate and align with the renaming and logic restructuring objectives of the PR.Also applies to: 93-93
x/captains/keeper/computing_power.go (5)
11-19
: Ensure proper handling of potential errors fromMustNewDecFromStr
.While the function
MustNewDecFromStr
is used to convert a string to aDec
type, it panics if the conversion fails. Consider adding error handling to prevent potential runtime panics.- return sdk.MustNewDecFromStr(string(bz)) + dec, err := sdk.NewDecFromStr(string(bz)) + if err != nil { + return sdk.ZeroDec() // or handle the error appropriately + } + return dec
29-33
: LGTM! Good use of existing functions to maintain DRY principles.The function
incrGlobalComputingPowerOnEpoch
correctly reusesGetGlobalComputingPowerOnEpoch
andsetGlobalComputingPowerOnEpoch
to increment the global computing power, adhering to the DRY principle.
36-39
: LGTM! Simple and effective function for clearing data.The function
delGlobalComputingPowerOnEpoch
effectively uses the store'sDelete
method to remove the computing power record, ensuring clean state management.
144-157
: Consider adding error handling for data retrieval operations.The function
GetGlobalsComputingPower
retrieves global computing power without handling potential errors fromGetGlobalComputingPowerOnEpoch
. Adding error handling would improve robustness.+ power.Amount, err = k.GetGlobalComputingPowerOnEpoch(ctx, power.EpochId) + if err != nil { + continue // or handle the error appropriately + } powers = append(powers, power)
159-173
: Review data consistency and error handling.The function
GetNodesComputingPower
retrieves computing power for all nodes but lacks error handling for theGetNodeComputingPowerOnEpoch
call. Consider adding error checks to ensure data consistency.+ power.Amount, err = k.GetNodeComputingPowerOnEpoch(ctx, power.EpochId, nodeId) + if err != nil { + continue // or handle the error appropriately + } powers = append(powers, power)x/captains/keeper/msg_server.go (1)
266-266
: Ensure proper error handling after removing the error return type.Verification successful
The removal of the error return type from
CommitComputingPower
inmsg_server.go
does not seem to affect the overall error handling in the codebase. The functionCommitComputingPower
inmsg_server.go
handles errors before callingm.k.CommitComputingPower
, and the rest of the code appears to be adjusted accordingly.Key Points:
- The function
CommitComputingPower
inmsg_server.go
handles errors before callingm.k.CommitComputingPower
.- The rest of the code appears to be adjusted accordingly to handle the absence of an error return type.
Conclusion:
The removal of the error return type from
CommitComputingPower
does not introduce any issues in the codebase.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all calls to `CommitComputingPower` handle the absence of an error return. # Test: Search for the function usage and check for error handling. Expect: Proper handling or adjustments in the calling code. rg --type go $'CommitComputingPower'Length of output: 8998
Script:
#!/bin/bash # Description: Verify that the removal of the error return type from `CommitComputingPower` does not affect error handling. # Test: Search for error handling in `msg_server.go` and related files. rg --type go 'CommitComputingPower' -A 5 -B 5Length of output: 32797
x/captains/keeper/report.go (2)
32-34
: Verify data consistency after significant changes in handling report digests.
47-52
: Check the impact of incrementing global computing power on epoch.x/captains/types/keys.go (10)
26-37
: Ensure consistency in naming and usage of new key prefixes.The addition of new key prefixes such as
prefixEpochEmission
,prefixGlobalClaimedEmission
, etc., aligns with the PR's objectives to enhance clarity and consistency in the codebase.
123-132
: Validate the correctness of theEpochEmissionStoreKey
function.The function correctly constructs a key for storing epoch emission data, using the
EpochEmissionKey
prefix and the epoch ID. This is consistent with the intended usage described in the PR summary.
134-143
: Check the implementation ofNodeCumulativeEmissionByEpochStoreKey
.This function correctly constructs a key for storing cumulative emission data by node on a specific epoch, which is crucial for the new data structure introduced in the PR.
159-165
: Confirm the implementation ofNodeClaimedEmissionStoreKey
.The function implementation is correct and aligns with the changes in the PR, ensuring that node claimed emission data is stored with the appropriate key.
169-176
: Check theClaimableComputingPowerStoreKey
function for correctness.This function correctly handles the generation of keys for claimable computing power, which is a new feature introduced in the PR.
180-187
: Validate theGlobalComputingPowerOnEpochStoreKey
function.The function is implemented correctly to handle the storage of global computing power data on a specific epoch, which is part of the new data structure changes.
215-222
: Ensure correctness ofGlobalPledgeOnEpochStoreKey
.The function correctly generates a key for storing global pledge data on a specific epoch, aligning with the new data structures.
Line range hint
227-247
: Check the implementation ofOwnerPledgeOnEpochStoreKey
andParseOwnerPledgeOnEpochPrefixStoreKey
.Both functions are implemented correctly to handle owner-specific pledge data on epochs, which is crucial for the new data structures introduced.
250-256
: Validate theReportDigestOnEpochStoreKey
function.This function is correctly implemented to handle the storage of report digest data on a specific epoch, aligning with the changes in the PR.
Line range hint
273-289
: Review theReportBatchOnEpochPrefixStoreKey
andEndOnEpochStoreKey
functions.Both functions are implemented correctly to handle their respective data types on epochs, which is part of the enhancements made in the PR.
x/captains/types/genesis.go (4)
22-48
: Ensure theNewGenesisState
function correctly initializes all new fields.The function has been updated to include all the new fields such as
BaseState
,EpochesEmission
, etc., which are essential for the new genesis structure as described in the PR.
54-58
: Check theDefaultGenesisState
function for correct default initialization.The function correctly initializes the
GenesisState
with default values for the new fields, ensuring that the system can start with a valid state.
61-66
: Review theDefaultBaseState
function for correct default values.This function provides sensible default values for the
BaseState
, which is crucial for ensuring the system's initial configuration is valid.
123-191
: Ensure comprehensive validation in theValidate
method ofGenesisState
.The method thoroughly validates all the new and existing fields of
GenesisState
, ensuring that the genesis state is consistent and valid before the system starts.x/captains/keeper/integration_test.go (28)
106-106
: Ensure the new method nameGetReportDigest
is consistently used across all test cases.
138-138
: Verify that the new methodGetGlobalComputingPowerOnEpoch
correctly aggregates computing power across nodes.
183-183
: Confirm thatGetReportDigest
correctly retrieves the report digest for the specified epoch.
190-190
: Ensure that the methodGetGlobalComputingPowerOnEpoch
is used correctly to fetch the global computing power for the specified epoch.
218-218
: Check thatGetGlobalComputingPowerOnEpoch
returns the expected computing power sum after all batches are processed.
237-237
: Validate that the computing power sum is correctly maintained across epochs.
242-242
: Confirm thatGetGlobalComputingPowerOnEpoch
correctly returns zero after the epoch ends, indicating reset of values.
270-270
: Ensure thatGetReportDigest
is consistently retrieving the correct report digest for the given epoch.
277-277
: Check that the global computing power is correctly calculated and retrieved for the specified epoch.
283-283
: Verify thatGetNodeCumulativeEmissionByEpoch
andGetNodeComputingPowerOnEpoch
are correctly retrieving node-specific data.
310-310
: Confirm that node-specific cumulative emissions and computing power are reset to zero at the start of a new epoch.
314-314
: Ensure that the global computing power sum is correctly calculated and matches the expected value after all batches are processed.
333-333
: Validate that the computing power sum is correctly maintained across epochs.
338-338
: Confirm thatGetGlobalComputingPowerOnEpoch
correctly returns zero after the epoch ends, indicating reset of values.
378-378
: Ensure thatGetReportDigest
is consistently retrieving the correct report digest for the given epoch.
411-411
: Check that the global computing power is correctly calculated and retrieved for the specified epoch.
466-466
: Confirm thatGetReportDigest
correctly retrieves the report digest for the specified epoch.
474-474
: Ensure that the methodGetGlobalComputingPowerOnEpoch
is used correctly to fetch the global computing power for the specified epoch.
502-502
: Check thatGetGlobalComputingPowerOnEpoch
returns the expected computing power sum after all batches are processed.
521-521
: Validate that the computing power sum is correctly maintained across epochs.
526-526
: Confirm thatGetGlobalComputingPowerOnEpoch
correctly returns zero after the epoch ends, indicating reset of values.
554-554
: Ensure thatGetReportDigest
is consistently retrieving the correct report digest for the given epoch.
562-562
: Check that the global computing power is correctly calculated and retrieved for the specified epoch.
568-568
: Verify thatGetNodeCumulativeEmissionByEpoch
andGetNodeComputingPowerOnEpoch
are correctly retrieving node-specific data.
595-595
: Confirm that node-specific cumulative emissions and computing power are reset to zero at the start of a new epoch.
599-599
: Ensure that the global computing power sum is correctly calculated and matches the expected value after all batches are processed.
618-618
: Validate that the computing power sum is correctly maintained across epochs.
623-623
: Confirm thatGetGlobalComputingPowerOnEpoch
correctly returns zero after the epoch ends, indicating reset of values.
* chore: remove vesting * chore: remove revenue * chore: remove other modules * feature: add testnet cmd * chore: fmt code * add mint proto file * add module file * Complete mint module * fix: testnet cmd * proto-gen: add proto & proto-gen * init claims module * add claims module to app * chore: reorganize tabichain project struct * add claims write interface * add caption-node proto * feat: init caption-node struct * update captain node proto * fix: fix testutils * feat: init token-convert * modify caption-node proto * Complete node creation logic * add query && tx cmd * add test case * chore: fix bug * feat: Add auxiliary interface * Add module cache * feat: add claims module (#15) * refactor: Removed logic for assigning rewards to captain-node in claims (#16) * refactor: Redefine interfaces and Change processing logic (#17) * feat: token-convert module (#18) * proto: define and generate token-convert module * init: token-convert module structure * feat: get token-convert key * feat: token-convert msg sever proto: definiton modification * fix: type err * feat: token-convert app module * feat: msg validation * fix: delete voucher * feat: token-convert query server * feat: token-convert genesis * feat: token-convert tx cli cmd * feat: token-convert query cli cmd * refactor: captains proto (#19) * refactor: captains proto * fix: rename callers to members & add update_params service * feat: refactor claims proto (#21) * feat: refactor claims proto * fix: fix review comment * refactor: captains module interfaces (#20) * fix: compiling error due to proto redefinition. * fix: module name error in token-convert * fix: interface name typo * fix: query authorized members * chore: rename captains event type * refactor: captains keys * refactor: captains interfaces * fix: division proto * feat: captains exported interfaces (#22) * feat: exported interfaces * fix: exported keeper * feat: implement claims module (#23) * add calculate rewards * add query cmd * implement claims * chore: modify CalculateRewards return value * chore: modify CalculateRewards return value * fix bug * chore: add error and add event to claims * fix: fix claims bug (#24) * feat: captains rewards calculation logic (#25) * feat: msg server * feat: impl calculation func for emssion reward * fix: module pkg name * feat: improve calculation algo * abci: incr epoch * fix: commit report * feat: captains optimization (#26) * impr: align report epoch with current epoch * fix: msg validation * feat: captains tx&query cmd * fix: get all powers * fix: init geneis * fix: new genesis * fix: register claim amino error * chore: Remove useless operations (#27) * feat: Restrict sending EVM transactions to allow list only (#28) * refactor: emission formula revised (#29) * refactor emssion formula * revise exported interface in captains * fix: Fixed the MsgUpdateParams non-registration issue of captains module (#30) * refactor: mint output is only given to Validators and delegators (#31) * test: part of captains unit tests (#32) * captains unit test part 1 * captains unit test part 2 * test: token-convert msg server unit test (#33) * add token-convert server unit test * format code * revise formula (#34) * feat: query node emission on last epoch (#35) * fix: add node power on ratio and remove limit on nodes holding * revise proto and fix captains logic * proto: add query for captains * feat: add additional query * refactor: seperate state prune or set from calc func (#36) * fix: seperate set/prune logic from calc func * complete full epoch test * revise proto and func name * test[claims]: implement claims module test (#37) * feat: implement claims module test * fix: set mock keeper * feat: implement claims module claims test * implement claims module query test --------- Co-authored-by: oris <[email protected]> * test: captains integration test (#38) * fix: seperate set/prune logic from calc func * complete full epoch test * revise proto and func name * add grpc test * add captains unit test * fix captains suite * fix test * refactor: captains genesis and key naming. (#39) * rename key * mv report func to report.go * refactor genesis import/export * rename captains expected keeper interface * feat: restrict captains tx as per epoch phase (#40) * feat: restriction on captains txs as per epoch phase * fix func name * add stand-by flag to genesis * rm typo in ante * fix: captains test (#41) * chore: update division default value * fix: restrict claim on rewards and powers * fix tx cli * fix coefficient * fix msg validation * add commit report msg test * fix grpc query * fix: key store error test: captains import and export * chore: Optimize code (#42) * feat: epoches testing framework (#43) * add full epoch testing framework * fix testing error * fix epoch phase * add state transition table and fix tests * chore: rm cpr * rm gitpod * retract do not edit * test&cli: add ante test and draft report cmd (#44) * rename captains exported interface * add ante testing * cli: add draft report * typo * chore: add changelog (#45) --------- Co-authored-by: chivalrouslee <[email protected]> Co-authored-by: richardleeft <[email protected]> Co-authored-by: ppyang <[email protected]>
This PR refactors genesis export/import logic of cpatains module. It also renames key and related functions for better readability.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests
Chores