Skip to content

Commit

Permalink
keep single encoding config in the application
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Feb 17, 2023
1 parent c92e948 commit 9140ef2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import (
"cosmossdk.io/math"
tmconfig "github.com/tendermint/tendermint/config"

tmjson "github.com/tendermint/tendermint/libs/json"

"github.com/babylonchain/babylon/app/params"
appparams "github.com/babylonchain/babylon/app/params"
"github.com/babylonchain/babylon/testutil/datagen"
tmjson "github.com/tendermint/tendermint/libs/json"

txformat "github.com/babylonchain/babylon/btctxformatter"
bbn "github.com/babylonchain/babylon/types"
bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -43,6 +42,9 @@ import (
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

txformat "github.com/babylonchain/babylon/btctxformatter"
bbn "github.com/babylonchain/babylon/types"
)

// DefaultConsensusParams defines the default Tendermint consensus params used in
Expand Down Expand Up @@ -242,7 +244,8 @@ func SetupPrivSigner() (*PrivSigner, error) {
if err != nil {
return nil, err
}
privSigner, _ := InitPrivSigner(client.Context{}, ".", kr)
encodingCfg := appparams.MakeTestEncodingConfig()
privSigner, _ := InitPrivSigner(client.Context{}, ".", kr, encodingCfg)
privSigner.WrappedPV.Clean(nodeCfg.PrivValidatorKeyFile(), nodeCfg.PrivValidatorStateFile())
return privSigner, nil
}
Expand Down
4 changes: 2 additions & 2 deletions app/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
tmconfig "github.com/tendermint/tendermint/config"
tmos "github.com/tendermint/tendermint/libs/os"

appparams "github.com/babylonchain/babylon/app/params"
"github.com/babylonchain/babylon/privval"
)

Expand Down Expand Up @@ -43,7 +44,7 @@ type PrivSigner struct {
ClientCtx client.Context
}

func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring) (*PrivSigner, error) {
func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring, encodingCfg appparams.EncodingConfig) (*PrivSigner, error) {
// setup private validator
nodeCfg := tmconfig.DefaultConfig()
pvKeyFile := filepath.Join(nodeDir, nodeCfg.PrivValidatorKeyFile())
Expand All @@ -60,7 +61,6 @@ func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring

// TODO this should probably not create separate config, but rahter accept it
// as argument
encodingCfg := MakeTestEncodingConfig()
clientCtx = clientCtx.
WithInterfaceRegistry(encodingCfg.InterfaceRegistry).
WithCodec(encodingCfg.Marshaler).
Expand Down
4 changes: 2 additions & 2 deletions cmd/babylond/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a
if err != nil {
panic(err)
}
privSigner, err := app.InitPrivSigner(clientCtx, homeDir, clientCtx.Keyring)
privSigner, err := app.InitPrivSigner(clientCtx, homeDir, clientCtx.Keyring, a.encCfg)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -337,7 +337,7 @@ func (a appCreator) appExport(
panic(err)
}

privSigner, err := app.InitPrivSigner(clientCtx, homePath, kr)
privSigner, err := app.InitPrivSigner(clientCtx, homePath, kr, a.encCfg)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 9140ef2

Please sign in to comment.