Skip to content
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

Failure to export genesis file #748

Open
3 tasks
SphereDonout opened this issue Aug 7, 2023 · 0 comments
Open
3 tasks

Failure to export genesis file #748

SphereDonout opened this issue Aug 7, 2023 · 0 comments

Comments

@SphereDonout
Copy link

SphereDonout commented Aug 7, 2023

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:

  1. Start the shentu chain
  2. Stop the shentu chain
  3. Executes the command shentud export --for-zero-height > test_genesis.json
  4. See the screenshot of the error

Expected behavior

The genesis file test_genesis.json should be created.

Screenshots

Screenshot 2023-08-06 at 9 26 09 PM

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant