You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The command export --for-zero-height is used to export the genesis file, but it fails due to an invalid validator address retrieval. The root cause lies in the incorrect validator address fetch via the addr := sdk.ValAddress(iter.Key()[1:]), which will lead to a panic error when this command is executed.
Note that the validator address is fetched via iter.Key()[1:], which excludes the ValidatorKey, but it still includes the prefix, the length of the address. This can be demonstrated in the function GetValidatorKey():
cosmos-sdk/x/staking/types/keys.go
// GetValidatorKey creates the key for the validator with the address
// VALUE: staking/Validator
func GetValidatorKey(operatorAddr sdk.ValAddress) []byte {
return append(ValidatorsKey, address.MustLengthPrefix(operatorAddr)...)
}
Therefore, the iter.Key()[1:] returns the length of the address + address, and it cannot be correctly converted to the validator address via the function sdk.ValAddress().
Steps to Reproduce
Steps to reproduce the behavior:
Start the shentu chain
Stop the shentu chain
Executes the command shentud export --for-zero-height > test_genesis.json
See the screenshot of the error
Expected behavior
The genesis file test_genesis.json should be created.
Screenshots
Environment (please complete the following information)
Summary of the Bug
The command
export --for-zero-height
is used to export the genesis file, but it fails due to an invalid validator address retrieval. The root cause lies in the incorrect validator address fetch via theaddr := sdk.ValAddress(iter.Key()[1:])
, which will lead to a panic error when this command is executed.Note that the validator address is fetched via
iter.Key()[1:]
, which excludes theValidatorKey
, but it still includes the prefix, the length of the address. This can be demonstrated in the functionGetValidatorKey()
:cosmos-sdk/x/staking/types/keys.go
Therefore, the
iter.Key()[1:]
returns the length of the address + address, and it cannot be correctly converted to the validator address via the functionsdk.ValAddress()
.Steps to Reproduce
Steps to reproduce the behavior:
shentud export --for-zero-height > test_genesis.json
Expected behavior
The genesis file
test_genesis.json
should be created.Screenshots
Environment (please complete the following information)
Additional Context
Add any other context about the problem here.
For Admin Use
The text was updated successfully, but these errors were encountered: