Skip to content

Commit

Permalink
fix priv key not converted to pub key (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 authored Mar 31, 2023
1 parent f6e81b3 commit ef87b45
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion assembler/bsc_assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewBSCAssembler(cfg *config.Config, executor *executor.BSCExecutor, dao *da
bscExecutor: executor,
daoManager: dao,
greenfieldExecutor: greenfieldExecutor,
blsPubKey: greenfieldExecutor.BlsPrivateKey,
blsPubKey: greenfieldExecutor.BlsPubKey,
metricService: ms,
}
}
Expand Down
2 changes: 1 addition & 1 deletion assembler/greenfield_assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewGreenfieldAssembler(cfg *config.Config, executor *executor.GreenfieldExe
greenfieldExecutor: executor,
daoManager: dao,
bscExecutor: bscExecutor,
blsPubKey: executor.BlsPrivateKey,
blsPubKey: executor.BlsPubKey,
hasRetrievedSequenceByChannelMap: retrievedSequenceByChannelMap,
metricService: ms,
}
Expand Down
16 changes: 12 additions & 4 deletions executor/greenfield_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
_ "encoding/json"
"fmt"
"github.com/prysmaticlabs/prysm/crypto/bls/blst"
"time"

"github.com/avast/retry-go/v4"
Expand Down Expand Up @@ -39,6 +40,7 @@ type GreenfieldExecutor struct {
validators []*tmtypes.Validator // used to cache validators
cdc *codec.ProtoCodec
BlsPrivateKey []byte
BlsPubKey []byte
}

func NewGreenfieldExecutor(cfg *config.Config) *GreenfieldExecutor {
Expand All @@ -51,11 +53,16 @@ func NewGreenfieldExecutor(cfg *config.Config) *GreenfieldExecutor {
panic(err)
}

blsPrivKey := viper.GetString(config.FlagConfigBlsPrivateKey)
if blsPrivKey == "" {
blsPrivKey = getGreenfieldBlsPrivateKey(&cfg.GreenfieldConfig)
blsPrivKeyStr := viper.GetString(config.FlagConfigBlsPrivateKey)
if blsPrivKeyStr == "" {
blsPrivKeyStr = getGreenfieldBlsPrivateKey(&cfg.GreenfieldConfig)
}
blsPrivKeyBts := ethcommon.Hex2Bytes(blsPrivKeyStr)

blsPrivKey, err := blst.SecretKeyFromBytes(blsPrivKeyBts)
if err != nil {
panic(err)
}
clients := sdkclient.NewGnfdCompositClients(
cfg.GreenfieldConfig.GRPCAddrs,
cfg.GreenfieldConfig.RPCAddrs,
Expand All @@ -68,7 +75,8 @@ func NewGreenfieldExecutor(cfg *config.Config) *GreenfieldExecutor {
address: km.GetAddr().String(),
config: cfg,
cdc: Cdc(),
BlsPrivateKey: ethcommon.Hex2Bytes(blsPrivKey),
BlsPrivateKey: blsPrivKeyBts,
BlsPubKey: blsPrivKey.PublicKey().Marshal(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion vote/bsc_vote_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewBSCVoteProcessor(cfg *config.Config, dao *dao.DaoManager, signer *VoteSi
daoManager: dao,
signer: signer,
bscExecutor: bscExecutor,
blsPublicKey: bscExecutor.GreenfieldExecutor.BlsPrivateKey,
blsPublicKey: bscExecutor.GreenfieldExecutor.BlsPubKey,
}
}

Expand Down
3 changes: 2 additions & 1 deletion vote/greenfield_vote_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ type GreenfieldVoteProcessor struct {

func NewGreenfieldVoteProcessor(cfg *config.Config, dao *dao.DaoManager, signer *VoteSigner,
greenfieldExecutor *executor.GreenfieldExecutor) *GreenfieldVoteProcessor {

return &GreenfieldVoteProcessor{
config: cfg,
daoManager: dao,
signer: signer,
greenfieldExecutor: greenfieldExecutor,
blsPublicKey: greenfieldExecutor.BlsPrivateKey,
blsPublicKey: greenfieldExecutor.BlsPubKey,
}
}

Expand Down

0 comments on commit ef87b45

Please sign in to comment.