Failure to export genesis file
SphereDonout opened this issue · 1 comments
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 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)
- Chain Version: 7ef6233
- Golang Version: go1.19.4 darwin/amd64
- OS: macOS
Additional Context
Add any other context about the problem here.
For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate contributors tagged