Skip to content

Commit

Permalink
fix: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Jan 4, 2024
1 parent 0b7e3ef commit 9a97704
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ func NewApp(
pvKeyFile := filepath.Join(homePath, cast.ToString(appOpts.Get("priv_validator_key_file")))
vrfKeyFile := utils.PrivValidatorKeyFileToVRFKeyFile(pvKeyFile)
vrfKey, err := utils.LoadVRFKey(vrfKeyFile)
if vrfKey == nil || err != nil {
if err != nil {
// TO-DO if validator, panic
app.Logger().Info("failed to load vrf key")
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions app/utils/vrf_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"bytes"
"context"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -146,7 +145,7 @@ func (v *VRFKey) SignTransaction(
}

bytesToSign, err := authsigning.GetSignBytesAdapter(
context.Background(),
ctx,
txConfig.SignModeHandler(),
signMode,
signerData,
Expand Down Expand Up @@ -239,7 +238,7 @@ func LoadVRFKey(keyFilePath string) (*VRFKey, error) {

func InitializeVRFKey(config *cfg.Config) (vrfPubKey sdkcrypto.PubKey, err error) {
pvKeyFile := config.PrivValidatorKeyFile()
if err := os.MkdirAll(filepath.Dir(pvKeyFile), 0o777); err != nil {
if err := os.MkdirAll(filepath.Dir(pvKeyFile), 0o755); err != nil {
return nil, fmt.Errorf("could not create directory %q: %w", filepath.Dir(pvKeyFile), err)
}

Expand Down
10 changes: 7 additions & 3 deletions x/randomness/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func (h *ProposalHandler) PrepareProposalHandler(

stop := h.txSelector.SelectTxForProposal(ctx, uint64(req.MaxTxBytes), maxBlockGas, newSeedTx, newSeedTxBz)
if stop {
return nil, fmt.Errorf("max block gas exceeded by just new seed tx")
return nil, fmt.Errorf("max block gas or tx bytes exceeded by just new seed tx")
}

// perform mandatory checks on the other txs
// include txs in the proposal until max tx bytes or block gas limits are reached
for _, txBz := range req.Txs {
tx, err := h.txVerifier.TxDecode(txBz)
if err != nil {
Expand Down Expand Up @@ -235,7 +235,11 @@ func generateAndSignNewSeedTx(ctx sdk.Context, txConfig client.TxConfig, vrfSign
txsigning.SignMode_SIGN_MODE_DIRECT,
account,
)
if err := txBuilder.SetSignatures(sig); err != nil {
if err != nil {
return nil, nil, err
}
err = txBuilder.SetSignatures(sig)
if err != nil {
return nil, nil, err
}

Expand Down
3 changes: 1 addition & 2 deletions x/staking/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ type TxCreateValidatorConfig struct {
}

func BuildCreateValidatorWithVRFMsg(clientCtx client.Context, config TxCreateValidatorConfig, txBldr tx.Factory, generateOnly bool, valCodec address.Codec) (tx.Factory, sdk.Msg, error) {
amounstStr := config.Amount
amount, err := sdk.ParseCoinNormalized(amounstStr)
amount, err := sdk.ParseCoinNormalized(config.Amount)
if err != nil {
return txBldr, nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions x/staking/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ var (
_ codectypes.UnpackInterfacesMessage = (*MsgCreateValidatorWithVRF)(nil)
)

// NewMsgCreateValidator creates a new MsgCreateValidator instance.
// Delegator address and validator address are the same.
// NewMsgCreateValidatorWithVRF creates a MsgCreateValidatorWithVRF instance.
func NewMsgCreateValidatorWithVRF(
valAddr string, pubKey cryptotypes.PubKey, vrfPubKey cryptotypes.PubKey,
selfDelegation sdk.Coin, description types.Description, commission types.CommissionRates, minSelfDelegation math.Int,
Expand Down

0 comments on commit 9a97704

Please sign in to comment.