Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change relayer call args to use secp256k1 private keys #2729

Merged
merged 1 commit into from
Aug 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions ignite/pkg/relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package relayer

import (
"context"
"encoding/hex"
"fmt"
"strings"
"sync"
"time"

"github.com/cosmos/cosmos-sdk/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

Expand All @@ -19,6 +21,7 @@ import (
)

const (
algoSecp256k1 = "secp256k1"
ibcSetupGas int64 = 2256000
relayDuration = time.Second * 5
)
Expand Down Expand Up @@ -200,12 +203,25 @@ func (r Relayer) prepare(ctx context.Context, conf relayerconf.Config, chainID s
}
}

key, err := r.ca.ExportHex(chain.Account, "")
// Get the key in ASCII armored format
passphrase := ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeronimoalbi So the passphrase is not required ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbruyelle good question. To be honest I am not sure about the reason why we were using an empty passphrase.

These changes just make it explicit that we are using an empty passphrase which should be the same for the Export and UnarmorDecryptPrivKey calls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes I didn't notice it was already the case before! OK for me.

key, err := r.ca.Export(chain.Account, passphrase)
if err != nil {
return relayerconf.Chain{}, "", err
}

return chain, key, nil
// Unarmor the key to be able to read it as bytes
priv, algo, err := crypto.UnarmorDecryptPrivKey(key, passphrase)
if err != nil {
return relayerconf.Chain{}, "", err
}

// Check the algorithm because the TS relayer expects a secp256k1 private key
if algo != algoSecp256k1 {
return relayerconf.Chain{}, "", fmt.Errorf("private key algorithm must be secp256k1 instead of %s", algo)
}

return chain, hex.EncodeToString(priv.Bytes()), nil
}

func (r Relayer) balance(ctx context.Context, rpcAddress, account, addressPrefix string) (sdk.Coins, error) {
Expand Down