From 79f503a724991d63528e0339254d4ff7d78f2657 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Mon, 29 Apr 2019 16:40:26 -0700 Subject: [PATCH] Initialize shard keys in txgen --- cmd/client/txgen/main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/client/txgen/main.go b/cmd/client/txgen/main.go index c59b9ebb6..055e204d8 100644 --- a/cmd/client/txgen/main.go +++ b/cmd/client/txgen/main.go @@ -9,7 +9,10 @@ import ( "sync" "time" + bls2 "github.com/harmony-one/bls/ffi/go/bls" + "github.com/harmony-one/harmony/core" + "github.com/harmony-one/harmony/internal/utils/contract" "github.com/harmony-one/harmony/crypto/bls" @@ -128,6 +131,19 @@ func main() { node := node.New(host, c, nil, false) c.SetStakeInfoFinder(gsif) c.ChainReader = node.Blockchain() + // Replace public keys with genesis accounts for the shard + c.PublicKeys = nil + startIdx := core.GenesisShardSize * shardID + endIdx := startIdx + core.GenesisShardSize + for _, acct := range contract.GenesisBLSAccounts[startIdx:endIdx] { + secretKey := bls2.SecretKey{} + if err := secretKey.SetHexString(acct.Private); err != nil { + _, _ = fmt.Fprintf(os.Stderr, "cannot parse secret key: %v\n", + err) + os.Exit(1) + } + c.PublicKeys = append(c.PublicKeys, secretKey.GetPublicKey()) + } // Assign many fake addresses so we have enough address to play with at first nodes = append(nodes, node) }