prysm-pulse/tools/interop/convert-keys/main.go
Preston Van Loon 49a0d3caf0
Refactor dependencies, make Prysm "go gettable" (#6053)
* Fix a few deps to work with go.mod, check in generated files

* Update Gossipsub to 1.1 (#5998)

* update libs

* add new validators

* add new deps

* new set of deps

* tls

* further fix gossip update

* get everything to build

* clean up

* gaz

* fix build

* fix all tests

* add deps to images

* imports

Co-authored-by: rauljordan <raul@prysmaticlabs.com>

* Beacon chain builds with go build

* fix bazel

* fix dep

* lint

* Add github action for testing go

* on PR for any branch

* fix libp2p test failure

* Fix TestProcessBlock_PassesProcessingConditions by updating the proposer index in test

* Revert "Fix TestProcessBlock_PassesProcessingConditions by updating the proposer index in test"

This reverts commit 43676894ab01f03fe90a9b8ee3ecfbc2ec1ec4e4.

* Compute and set proposer index instead of hard code

* Add back go mod/sum, fix deps

* go build ./...

* Temporarily skip two tests

* Fix kafka confluent patch

* Fix kafka confluent patch

* fix kafka build

* fix kafka

* Add info in DEPENDENCIES. Added a stub link for Why Bazel? until https://github.com/prysmaticlabs/documentation/issues/138

* Update fuzz ssz files as well

* Update fuzz ssz files as well

* getting closer

* rollback rules_go and gazelle

* fix gogo protobuf

* install librdkafka-dev as part of github actions

* Update kafka to a recent version where librkafkfa is not required for go modules

* clarify comment

* fix kafka build

* disable go tests

* comment

* Fix geth dependencies for end to end

* rename word

* lint

* fix docker

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: rauljordan <raul@prysmaticlabs.com>
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
2020-05-31 14:44:34 +08:00

70 lines
1.6 KiB
Go

// Used for converting keys.yaml files from eth2.0-pm for interop testing.
// See: https://github.com/ethereum/eth2.0-pm/tree/master/interop/mocked_start
//
// This code can be discarded after interop testing.
package main
import (
"encoding/hex"
"fmt"
"io/ioutil"
"log"
"os"
keygen "github.com/prysmaticlabs/prysm/tools/unencrypted-keys-gen/keygen"
"gopkg.in/yaml.v2"
)
// KeyPair with hex encoded data.
type KeyPair struct {
Priv string `yaml:"privkey"`
Pub string `yaml:"pubkey"`
}
// KeyPairs represent the data format in the upstream yaml.
type KeyPairs []KeyPair
func main() {
if len(os.Args) < 3 {
fmt.Println("Usage: convert-keys path/to/keys.yaml path/to/output.json")
return
}
inFile := os.Args[1]
in, err := ioutil.ReadFile(inFile)
if err != nil {
log.Fatalf("Failed to read file %s: %v", inFile, err)
}
data := make(KeyPairs, 0)
if err := yaml.Unmarshal(in, &data); err != nil {
log.Fatalf("Failed to unmarshal yaml: %v", err)
}
out := &keygen.UnencryptedKeysContainer{}
for _, key := range data {
pk, err := hex.DecodeString(key.Priv[2:])
if err != nil {
log.Fatalf("Failed to decode hex string %s: %v", key.Priv, err)
}
out.Keys = append(out.Keys, &keygen.UnencryptedKeys{
ValidatorKey: pk,
WithdrawalKey: pk,
})
}
outFile, err := os.Create(os.Args[2])
if err != nil {
log.Fatalf("Failed to create file at %s: %v", os.Args[2], err)
}
defer func() {
if err := outFile.Close(); err != nil {
panic(err)
}
}()
if err := keygen.SaveUnencryptedKeysToFile(outFile, out); err != nil {
log.Fatalf("Failed to save %v", err)
}
log.Printf("Wrote %s\n", os.Args[2])
}