-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat(genesis_bridge): revised genesis bridge impl #565
Conversation
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.
nice job!
few small suggestions/comments.
x/hub-genesis/keeper/genesis_info.go
Outdated
|
||
// Create the genesis info | ||
genesisInfo := types.GenesisInfo{ | ||
GenesisChecksum: "", // TODO: populate checksum value |
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.
possibly a quick win to validate using json checksum.
golang:
package main
import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"sort"
)
func getJSONChecksum(filePath string) (string, error) {
fileContent, err := ioutil.ReadFile(filePath)
if err != nil {
return "", err
}
var jsonObject map[string]interface{}
err = json.Unmarshal(fileContent, &jsonObject)
if err != nil {
return "", err
}
keys := make([]string, 0, len(jsonObject))
for k := range jsonObject {
keys = append(keys, k)
}
sort.Strings(keys)
sortedJSON, err := json.Marshal(jsonObject)
if err != nil {
return "", err
}
hash := sha256.Sum256(sortedJSON)
return hex.EncodeToString(hash[:]), nil
}
func main() {
checksum, err := getJSONChecksum("path/to/your/file.json")
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("Checksum:", checksum)
}
and roller can use same method for vadlidate it or through cli:
jq -cS . file.json | sha256sum
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.
added separate issue #569
} | ||
|
||
// validate the funds in the module account are equal to the sum of the funds in the genesis accounts | ||
expectedTotal := math.ZeroInt() |
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.
do we check somewhere the maximun number of genesis accounts allowed?
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.
on the hub side
Description
Closes #XXX
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.
PR review checkboxes:
I have...
Unreleased
section inCHANGELOG.md
godoc
commentsSDK Checklist
map
time.Now()
sendCoin
and notSendCoins
Full security checklist here
For Reviewer:
After reviewer approval: