-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(staking): move delegation and validator interfaces to ./types #18198
Conversation
WalkthroughWalkthroughThe changes across various files indicate a significant refactoring effort to decouple certain modules from Changes
Assessment against linked issues
TipsChat with CodeRabbit Bot (
|
fire |
a829a61
to
28cca68
Compare
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.
Review Status
Actionable comments generated: 6
Configuration used: CodeRabbit UI
Files selected for processing (34)
- math/int.go (1 hunks)
- simapp/export.go (2 hunks)
- tests/integration/slashing/keeper/keeper_test.go (2 hunks)
- tests/integration/staking/keeper/slash_test.go (3 hunks)
- tests/integration/staking/keeper/validator_test.go (2 hunks)
- types/staking.go (2 hunks)
- x/distribution/keeper/allocation.go (2 hunks)
- x/distribution/keeper/delegation.go (4 hunks)
- x/distribution/keeper/grpc_query.go (3 hunks)
- x/distribution/keeper/invariants.go (3 hunks)
- x/distribution/keeper/validator.go (2 hunks)
- x/distribution/testutil/expected_keepers_mocks.go (5 hunks)
- x/distribution/types/expected_keepers.go (1 hunks)
- x/evidence/testutil/expected_keepers_mocks.go (14 hunks)
- x/evidence/types/expected_keepers.go (2 hunks)
- x/gov/keeper/tally.go (3 hunks)
- x/gov/keeper/tally_test.go (2 hunks)
- x/gov/testutil/expected_keepers_mocks.go (33 hunks)
- x/gov/types/expected_keepers.go (2 hunks)
- x/slashing/abci_test.go (2 hunks)
- x/slashing/keeper/genesis.go (2 hunks)
- x/slashing/testutil/expected_keepers_mocks.go (4 hunks)
- x/slashing/types/expected_keepers.go (2 hunks)
- x/staking/keeper/alias_functions.go (4 hunks)
- x/staking/keeper/delegation.go (1 hunks)
- x/staking/keeper/genesis.go (1 hunks)
- x/staking/keeper/grpc_query.go (1 hunks)
- x/staking/keeper/invariants.go (1 hunks)
- x/staking/keeper/msg_server.go (1 hunks)
- x/staking/keeper/slash.go (1 hunks)
- x/staking/testutil/expected_keepers_mocks.go (6 hunks)
- x/staking/types/delegation.go (1 hunks)
- x/staking/types/expected_keepers.go (3 hunks)
- x/staking/types/validator.go (4 hunks)
Files skipped from review due to trivial changes (3)
- math/int.go
- x/staking/types/delegation.go
- x/staking/types/expected_keepers.go
Additional comments: 105
simapp/export.go (2)
78-81: The change from
stakingtypes.ValidatorI
tosdk.ValidatorI
is consistent with the summary and the rest of the code in the hunk appears to be compatible with this change. The use ofpanic
for error handling is appropriate in this context.124-127: The use of
sdk.ValidatorI
in theIterateValidators
function is consistent with the changes described in the summary. The error handling and logic within the hunk are appropriate and follow the Cosmos SDK's conventions.tests/integration/slashing/keeper/keeper_test.go (2)
279-283: The changes in
TestHandleNewValidator
correctly reflect the use ofsdk.Bonded
instead ofstakingtypes.Bonded
. This aligns with the refactor to use constants from thesdk
package.337-341: The changes in
TestHandleAlreadyJailed
correctly reflect the use ofsdk.Unbonding
instead ofstakingtypes.Unbonding
. This aligns with the refactor to use constants from thesdk
package.tests/integration/staking/keeper/slash_test.go (4)
384-387: The code correctly reflects the changes mentioned in the summary, where
validator.GetStatus()
now returnssdk.Unbonding
instead oftypes.Unbonding
.384-387: The use of
sdk.Unbonding
in the assertions is consistent with the refactor mentioned in the summary, indicating that the validator status is now being accessed through thesdk
package.384-387: The logic for checking the validator's status after a slash operation appears to be unchanged and consistent with the expected behavior of the staking module.
384-387: The test logic in
slash_test.go
correctly uses the updatedsdk.Unbonding
status, reflecting the changes made in the refactor.tests/integration/staking/keeper/validator_test.go (3)
110-112: The change from
types.BondStatus
tosdk.BondStatus
inexpectedValStatus
is correctly reflected in the code.124-124: The update of the format specifier from
%s
to%x
in thefmt.Sprintf
call for thestatus
variable is correctly reflected in the code.107-115: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [107-126]
No additional issues found in the provided hunks. The changes made are consistent and do not introduce any new logic, security, or performance concerns.
types/staking.go (4)
3-9: The import changes are consistent with the summary provided.
34-42: The changes to
TokensToConsensusPower
andTokensFromConsensusPower
functions to usemath.Int
are consistent with the summary.61-91: The addition of
DelegationI
andValidatorI
interfaces is consistent with the summary and the pull request description.61-91: Verify that the new interfaces are properly integrated and do not break existing functionality throughout the codebase.
x/distribution/keeper/allocation.go (2)
86-86: The change in the parameter type of
AllocateTokensToValidator
fromstakingtypes.ValidatorI
tosdk.ValidatorI
is consistent with the refactor and should not cause issues as long as all calls to this function are updated accordingly.8-13: The removal of the import "cosmossdk.io/x/staking/types" is consistent with the refactor and is not present in the provided file, which aligns with the summary.
x/distribution/keeper/delegation.go (11)
8-13: The removal of
stakingtypes
and the update to usesdk
package types in the function signatures are correctly reflected in the code.49-52: The logic and control flow within
calculateDelegationRewardsBetween
function appear to be correctly adjusted to accommodate the newsdk.ValidatorI
type.88-91: The logic and control flow within
CalculateDelegationRewards
function appear to be correctly adjusted to accommodate the newsdk.ValidatorI
andsdk.DelegationI
types.198-201: The logic and control flow within
withdrawDelegationRewards
function appear to be correctly adjusted to accommodate the newsdk.ValidatorI
andsdk.DelegationI
types.198-201: The error handling within
withdrawDelegationRewards
function is consistent with the previous implementation and correctly useserrors.Is
for checking specific error types.49-52: No performance issues are evident in the
calculateDelegationRewardsBetween
function due to the type changes.88-91: No performance issues are evident in the
CalculateDelegationRewards
function due to the type changes.198-201: No performance issues are evident in the
withdrawDelegationRewards
function due to the type changes.49-52: No new potential data races are introduced in the
calculateDelegationRewardsBetween
function due to the type changes.88-91: No new potential data races are introduced in the
CalculateDelegationRewards
function due to the type changes.198-201: No new potential data races are introduced in the
withdrawDelegationRewards
function due to the type changes.x/distribution/keeper/grpc_query.go (1)
- 267-272: The change from
stakingtypes.DelegationI
tosdk.DelegationI
in theIterateDelegations
function call is consistent with the summary. Ensure that all implementations ofDelegationI
are compatible with the newsdk.DelegationI
interface.x/distribution/keeper/invariants.go (3)
5-10: The removal of the
stakingtypes
import is consistent with the summary and the changes made in the codebase.92-95: The change from
stakingtypes.ValidatorI
tosdk.ValidatorI
in theIterateValidators
function call aligns with the summary and the refactor's goal of decoupling modules.134-136: The change from
stakingtypes.ValidatorI
tosdk.ValidatorI
in theIterateValidators
function call within theReferenceCountInvariant
function is consistent with the refactor's objectives.x/distribution/keeper/validator.go (2)
17-20: The change from
stakingtypes.ValidatorI
tosdk.ValidatorI
in theinitializeValidator
function signature is consistent with the summary.46-49: The change from
stakingtypes.ValidatorI
tosdk.ValidatorI
in theIncrementValidatorPeriod
function signature is consistent with the summary.x/distribution/testutil/expected_keepers_mocks.go (5)
347-354: The changes to the
Delegation
method correctly reflect the updates mentioned in the summary, wheretypes.DelegationI
has been replaced withtypes0.DelegationI
.407-411: The changes to the
IterateDelegations
method correctly reflect the updates mentioned in the summary, wheretypes.DelegationI
has been replaced withtypes0.DelegationI
.421-425: The changes to the
IterateValidators
method correctly reflect the updates mentioned in the summary, wheretypes.ValidatorI
has been replaced withtypes0.ValidatorI
.435-442: The changes to the
Validator
method correctly reflect the updates mentioned in the summary, wheretypes.ValidatorI
has been replaced withtypes0.ValidatorI
.464-471: The changes to the
ValidatorByConsAddr
method correctly reflect the updates mentioned in the summary, wheretypes.ConsAddress
has been replaced withtypes0.ConsAddress
.x/distribution/types/expected_keepers.go (3)
63-63: The summary states that the return type of
GetAllSDKDelegations
has been changed to return an array ofstakingtypes.Delegation
instead ofsdk.Delegation
, but the hunk shows that the function still returnsstakingtypes.Delegation
. Please verify if the summary or the code needs to be updated.64-64: The summary states that the return type of
GetAllValidators
has been changed to return an array ofstakingtypes.Validator
instead ofsdk.Validator
, but the hunk shows that the function still returnsstakingtypes.Validator
. Please verify if the summary or the code needs to be updated.53-58: The changes to the
StakingKeeper
interface to usesdk
types instead ofstakingtypes
for theValidator
,ValidatorByConsAddr
, andDelegation
functions are consistent with the summary and reflect the intended refactor.x/evidence/testutil/expected_keepers_mocks.go (14)
12-18: The import paths have been correctly updated to reflect the changes in the Cosmos SDK structure.
57-63: The function signature of
ValidatorByConsAddr
has been correctly updated to use the new types.95-101: The function signature of
GetPubkey
has been correctly updated to use the new types.110-114: The function signature of
HasValidatorSigningInfo
has been correctly updated to use the new types.124-128: The function signature of
IsTombstoned
has been correctly updated to use the new types.138-142: The function signature of
Jail
has been correctly updated to use the new types.152-156: The function signature of
JailUntil
has been correctly updated to use the new types.166-170: The function signature of
Slash
has been correctly updated to use the new types.195-199: The function signature of
SlashWithInfractionReason
has been correctly updated to use the new types.209-213: The function signature of
Tombstone
has been correctly updated to use the new types.246-249: The function signature of
SetAccount
inMockAccountKeeper
has been correctly updated to use the new types.281-286: The function signature of
GetAllBalances
inMockBankKeeper
has been correctly updated to use the new types.295-299: The function signature of
MintCoins
inMockBankKeeper
has been correctly updated to use the new types.309-313: The function signature of
SendCoinsFromModuleToAccount
inMockBankKeeper
has been correctly updated to use the new types.x/evidence/types/expected_keepers.go (2)
7-12: The removal of the import "cosmossdk.io/x/staking/types" aligns with the summary and the refactor's goal to decouple modules.
20-20: The change in the return type of
ValidatorByConsAddr()
fromstakingtypes.ValidatorI
tosdk.ValidatorI
is consistent with the summary and the refactor's objectives.x/gov/keeper/tally.go (3)
6-11: The removal of the import "cosmossdk.io/x/staking/types" is consistent with the summary.
28-28: The function signature for
IterateBondedValidatorsByPower
correctly usessdk.ValidatorI
as per the summary.65-65: The function signature for
IterateDelegations
correctly usessdk.DelegationI
as per the summary.x/gov/keeper/tally_test.go (2)
43-49: The change in the type of the second parameter in the function passed to
IterateDelegations
fromstakingtypes.DelegationI
tosdk.DelegationI
is correctly reflected in the code.382-388: The change in the type of the second parameter in the function passed to
IterateBondedValidatorsByPower
fromstakingtypes.ValidatorI
tosdk.ValidatorI
is correctly reflected in the code.x/gov/testutil/expected_keepers_mocks.go (3)
12-18: The import paths have been correctly updated to reflect the new location of the types in the
github.com/cosmos/cosmos-sdk/types
package.69-78: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [58-1041]
The function signatures in the mocks have been correctly updated to use types from the
types0
package, ensuring consistency with the new import paths.
- 55-64: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [12-1041]
The summary mentions the replacement of
types1
withtypes0
, but the hunks do not show any previous usage oftypes1
. Please verify iftypes1
was indeed used before and whether all necessary replacements have been made.x/gov/types/expected_keepers.go (3)
5-10: The removal of the
stakingtypes
import aligns with the summary and the changes in the function signatures.14-18: The change in the
validator
parameter type fromstakingtypes.ValidatorI
tosdk.ValidatorI
in theIterateBondedValidatorsByPower
function is consistent with the summary.20-24: The change in the
delegation
parameter type fromstakingtypes.DelegationI
tosdk.DelegationI
in theIterateDelegations
function is consistent with the summary.x/slashing/abci_test.go (1)
- 119-122: The change from
stakingtypes.Unbonding
tosdk.Unbonding
is consistent with the summary and reflects the refactor within the Cosmos SDK to improve modularity. Ensure that all references to theUnbonding
status in the codebase are updated to usesdk.Unbonding
.x/slashing/keeper/genesis.go (3)
4-9: The import statement for
stakingtypes "cosmossdk.io/x/staking/types"
has been correctly removed as it is no longer needed.14-18: The
IterateValidators
function signature has been updated to usesdk.ValidatorI
instead ofstakingtypes.ValidatorI
, which aligns with the refactor to move interfaces to thetypes
package.12-18: Verify that all references to the old
stakingtypes.ValidatorI
andstakingtypes.DelegationI
interfaces have been updated throughout the entire codebase to use the newsdk.ValidatorI
andsdk.DelegationI
interfaces.x/slashing/testutil/expected_keepers_mocks.go (4)
198-204: The change in the return type of the
Delegation
function totypes0.DelegationI
is consistent with the summary.244-247: The change in the parameter type of the callback function in
IterateValidators
totypes0.ValidatorI
is consistent with the summary.331-336: The change in the return type of the
Validator
function totypes0.ValidatorI
is consistent with the summary.360-365: The summary states that the parameter type of the
ValidatorByConsAddr
function has been changed, but the hunk shows a change in the return type totypes0.ValidatorI
. Please verify this discrepancy.- func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 context.Context, arg1 types0.ConsAddress) (types0.ValidatorI, error) { + func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 context.Context, arg1 types0.ValidatorI) (types0.ValidatorI, error) {x/slashing/types/expected_keepers.go (2)
34-41: The changes to the
StakingKeeper
interface to usesdk
types instead ofstakingtypes
types are consistent with the summary and the broader refactor goals.49-49: The return type of
GetAllValidators
should be[]sdk.ValidatorI
to align with the refactor's goal of usingsdk
types instead ofstakingtypes
types. The current return type[]stakingtypes.Validator
is inconsistent with the summary and the refactor's objectives.- GetAllValidators(ctx context.Context) ([]stakingtypes.Validator, error) + GetAllValidators(ctx context.Context) ([]sdk.ValidatorI, error)x/staking/keeper/alias_functions.go (4)
16-19: The changes to the function signature of
IterateValidators
match the summary and the refactor's intent.43-46: The changes to the function signature of
IterateBondedValidatorsByPower
match the summary and the refactor's intent.74-80: The changes to the return type of
Validator
andValidatorByConsAddr
match the summary and the refactor's intent.96-100: The changes to the function signature of
IterateDelegations
match the summary and the refactor's intent.x/staking/keeper/delegation.go (1)
- 1080-1080: The summary states that
BeginRedelegation
has been modified to usetypes.BondStatus
to convert the status obtained fromsrcValidator.GetStatus()
before passing it to theDelegate
function. However, the code does not show any conversion usingtypes.BondStatus
. Please verify if the code reflects the intended changes or if the summary needs to be updated.x/staking/keeper/genesis.go (1)
- 74-81: The update in the switch statement to use
sdk.Bonded
,sdk.Unbonding
, andsdk.Unbonded
is consistent with the summary and the broader refactor to use thesdk
package for statuses. This change should be verified across the entire codebase to ensure that all references to these constants are updated accordingly.x/staking/keeper/grpc_query.go (1)
- 46-49: The change from
val.GetStatus().String()
tostring(val.GetStatus())
in the comparison logic should be verified to ensure that theStatus
field of theValidator
type is correctly compared as a string. This is a critical change as it affects how validators are filtered based on their status.x/staking/keeper/invariants.go (5)
61-68: The changes to the
IterateValidators
function and the use ofsdk
package statuses (sdk.Bonded
,sdk.Unbonding
,sdk.Unbonded
) are consistent with the summary and the pull request description. This should ensure that theModuleAccountInvariants
function works with the updated interfaces and types.58-58: The use of
panic
for error handling when the bond denomination cannot be fetched is appropriate here, as it indicates a critical failure that should halt the program execution.68-68: The use of
panic
in case of an invalid validator status is also appropriate, as it indicates a critical and unexpected state that should not occur under normal operation.62-67: The update of the validator status checks to use the
sdk
package statuses (sdk.Bonded
,sdk.Unbonding
,sdk.Unbonded
) aligns with the refactor described in the summary and pull request.63-66: The logic for updating the
bonded
andnotBonded
variables based on the validator's status and tokens appears to be correct and unchanged, which is expected as the summary does not mention any logic changes in this area.x/staking/keeper/msg_server.go (1)
- 645-650: The changes to the
RotateConsPubKey
function are consistent with the summary and the pull request description. The use ofsdk.Bonded
aligns with the refactor to access constants through thesdk
package, and the error message now includes the status value using%x
format specifier, which is suitable for logging purposes.x/staking/keeper/slash.go (3)
184-192: The code correctly uses
sdk.Bonded
,sdk.Unbonding
, andsdk.Unbonded
statuses from thesdk
package as per the summary. This change aligns with the refactor to use thesdk
package for status constants.189-189: The summary does not mention the use of
sdk.Unbonded
, but the code has been updated to include this status as well. This might be an oversight in the summary.182-192: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1-191]
The rest of the file is not annotated with changes, so it is assumed to be consistent with the refactor to use the
sdk
package for status constants and other related changes.x/staking/testutil/expected_keepers_mocks.go (6)
310-315: The change in the return type of the
Delegation
method fromtypes.DelegationI
totypes0.DelegationI
is consistent with the summary.340-343: The change in the parameter type of the callback function in
IterateBondedValidatorsByPower
fromtypes.ValidatorI
totypes0.ValidatorI
aligns with the summary.354-357: The change in the parameter type of the callback function in
IterateValidators
fromtypes.ValidatorI
totypes0.ValidatorI
is in accordance with the summary.471-476: The change in the return type of the
Validator
method fromtypes.ValidatorI
totypes0.ValidatorI
matches the summary.486-491: The change in the return type of the
ValidatorByConsAddr
method fromtypes.ValidatorI
totypes0.ValidatorI
is consistent with the summary.538-541: The change in the parameter type of the callback function in
IterateDelegations
fromtypes.DelegationI
totypes0.DelegationI
aligns with the summary.x/staking/types/validator.go (4)
41-41: The implementation of the
sdk.ValidatorI
interface byValidator
is correctly updated to reflect the new interface location.80-84: The
ToSDKValidators
method correctly converts a slice ofValidator
to a slice ofsdk.ValidatorI
, aligning with the new interface location.174-187: The methods
IsBonded
,IsUnbonded
, andIsUnbonding
are correctly using thesdk
package constants for status comparison.461-461: The
GetStatus
method's return type is correctly updated tosdk.BondStatus
, reflecting the new type location.
// Validator Set | ||
|
||
// IterateValidators iterates through the validator set and perform the provided function | ||
func (k Keeper) IterateValidators(ctx context.Context, fn func(index int64, validator types.ValidatorI) (stop bool)) error { | ||
func (k Keeper) IterateValidators(ctx context.Context, fn func(index int64, validator sdk.ValidatorI) (stop bool)) error { | ||
store := k.storeService.OpenKVStore(ctx) | ||
iterator, err := store.Iterator(types.ValidatorsKey, storetypes.PrefixEndBytes(types.ValidatorsKey)) | ||
if err != nil { |
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.
Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [26-26]
The comment "XXX is this safe will the validator unexposed fields be able to get written to?" should be addressed or removed if it's no longer relevant. It's important to ensure that the code is clean and free of outdated or unnecessary comments.
Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [53-53]
Similarly, the comment "XXX is this safe will the validator unexposed fields be able to get written to?" in IterateBondedValidatorsByPower
should be addressed or removed if it's no longer relevant.
currValidators := make(map[string]v1.ValidatorGovInfo) | ||
|
||
// fetch all the bonded validators, insert them into currValidators | ||
err = keeper.sk.IterateBondedValidatorsByPower(ctx, func(index int64, validator stakingtypes.ValidatorI) (stop bool) { | ||
err = keeper.sk.IterateBondedValidatorsByPower(ctx, func(index int64, validator sdk.ValidatorI) (stop bool) { | ||
valBz, err := keeper.sk.ValidatorAddressCodec().StringToBytes(validator.GetOperator()) | ||
if err != nil { | ||
return false |
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.
Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [6-31]
Consider refactoring the Tally
function to improve maintainability and reduce complexity as indicated by the existing TODO comment.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
x/staking/keeper/genesis.go
Outdated
panic(fmt.Sprintf("invalid validator status: %v", validator.GetStatus())) | ||
panic("invalid validator status") |
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.
There is a duplicate panic call in the default case of the switch statement. The second panic call should be removed as it is redundant and the first panic call already includes the invalid status value.
82 panic(fmt.Sprintf("invalid validator status: %v", validator.GetStatus()))
- panic("invalid validator status")
Committable suggestion
❗ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
panic(fmt.Sprintf("invalid validator status: %v", validator.GetStatus())) | |
panic("invalid validator status") | |
panic(fmt.Sprintf("invalid validator status: %v", validator.GetStatus())) |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- types/staking.go (2 hunks)
Additional comments: 5
types/staking.go (5)
3-9: The import changes are consistent with the summary provided. The
sdkmath
package has been replaced withcosmossdk.io/math
, and new packagescmtprotocrypto
andcryptotypes
have been added.34-42: The function signatures for
TokensToConsensusPower
andTokensFromConsensusPower
have been correctly updated to usemath.Int
as per the summary.47-91: The new constants and interfaces
BondStatus
,DelegationI
, andValidatorI
have been added as described in the summary.47-91: The new interfaces and constants are well-defined and follow the Cosmos SDK design patterns.
61-91: The methods within the new interfaces
DelegationI
andValidatorI
are correctly typed and align with the expected functionality within the Cosmos SDK.
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.
lgtm! Can we get a changelog (./ or ./x/staking 🤷🏾♂️) given that there is an import change ?
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- x/staking/keeper/genesis.go (1 hunks)
Additional comments: 1
x/staking/keeper/genesis.go (1)
- 74-83: The changes to the
InitGenesis
function correctly reflect the updates mentioned in the summary, including the use ofsdk
statuses and the improved panic message in the default case of the switch statement.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- types/staking.go (2 hunks)
Additional comments: 4
types/staking.go (4)
3-9: The import changes are consistent with the summary provided.
35-42: The function signatures for
TokensToConsensusPower
andTokensFromConsensusPower
have been correctly updated to usemath.Int
.47-91: The addition of the
BondStatus
constant type and theDelegationI
andValidatorI
interfaces align with the summary and the pull request's goal of decoupling modules.47-91: The newly added interfaces and constants are well-defined and follow Go conventions.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- tests/integration/staking/keeper/validator_test.go (3 hunks)
- types/staking.go (2 hunks)
Additional comments: 8
tests/integration/staking/keeper/validator_test.go (3)
107-108: The summary states that
types.BondStatus
has been replaced withsdk.BondStatus
, but the code still usestypes.Validator
. Please verify iftypes.Validator
should also be replaced withsdk.Validator
to maintain consistency with the changes described.124-124: The change from
%s
to%x
infmt.Sprintf
for thestatus
variable is consistent with the summary and is a valid change if the intention is to print the status as a hexadecimal number.158-158: The expected status of the validator has been changed from
types.Unbonded
tosdk.Unbonding
. This change is not mentioned in the summary but seems to be in line with the other changes wheretypes.BondStatus
is replaced withsdk.BondStatus
. Please ensure that this change is intentional and correctly reflects the desired test behavior.types/staking.go (5)
3-9: The import changes are consistent with the summary provided.
35-36: The update to the
TokensToConsensusPower
function signature is consistent with the summary.40-41: The update to the
TokensFromConsensusPower
function signature is consistent with the summary.47-103: The addition of new constants and interfaces aligns with the summary.
47-103: Please verify that the new constants and interfaces do not conflict with any existing ones in the codebase.
Description
Closes: #17331
Closes: #17330
This pr proposes moving the staking interfaces to the cosmos-sdk as a short term solution to decouple staking from evidence, distribution and others, this allows teams like berachain and cosmos hub to import these types without needing to fork the cosmos sdk
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
New Features
Style Updates
Documentation