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

Gov module should use byte prefixes instead of strings for keys #4437

Closed
4 tasks
fedekunze opened this issue May 29, 2019 · 0 comments · Fixed by #4460
Closed
4 tasks

Gov module should use byte prefixes instead of strings for keys #4437

fedekunze opened this issue May 29, 2019 · 0 comments · Fixed by #4460
Assignees
Labels

Comments

@fedekunze
Copy link
Collaborator

Summary of Bug

Currently x/gov uses strings instead of bytes for storing the keys on the store. This makes it harder to parse/split and adds extra bytes to the keys:

func KeyProposal(proposalID uint64) []byte {
	return []byte(fmt.Sprintf("proposals:%d", proposalID))
}

func KeyDeposit(proposalID uint64, depositorAddr sdk.AccAddress) []byte {
	return []byte(fmt.Sprintf("deposits:%d:%d", proposalID, depositorAddr))
}

func KeyVote(proposalID uint64, voterAddr sdk.AccAddress) []byte {
	return []byte(fmt.Sprintf("votes:%d:%d", proposalID, voterAddr))
}

Suggested changes:

var (
    ProposalKeyPrefix        = []byte{0x0}
    DepositsKeyPrefix        = []byte{0x1}
    VotesKeyPrefix             = []byte{0x2}
)

keyProposal: 0x0<proposalID_bytes>
keyDeposit:0x1<proposalID_bytes><depositorAddress_Bytes>
keyVotes: 0x2<proposalID_bytes><voterAddress_Bytes>


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant