mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Add tool and script for interop testing (#3417)
* add tool and script for interop testing * identity * lint * merge upstream, fix conflict, update script, add comment * add comma separated support for --peer= * remove NUM_VALIDATORS, comma fix * WIP docker image * use CI builder * pr feedback * whatever antoine says * ignore git in docker * jobs=auto * disable remote cache * try to cache the golang part * try to cache the golang part * nvm * From Antoine with love * fix
This commit is contained in:
committed by
Raul Jordan
parent
af07c13730
commit
3708a8f476
65
tools/interop/convert-keys/main.go
Normal file
65
tools/interop/convert-keys/main.go
Normal file
@@ -0,0 +1,65 @@
|
||||
// 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"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
keygen "github.com/prysmaticlabs/prysm/tools/unencrypted-keys-gen"
|
||||
)
|
||||
|
||||
// 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 outFile.Close()
|
||||
if err := keygen.SaveUnencryptedKeysToFile(outFile, out); err != nil {
|
||||
log.Fatalf("Failed to save %v", err)
|
||||
}
|
||||
log.Printf("Wrote %s\n", os.Args[2])
|
||||
}
|
||||
Reference in New Issue
Block a user