From 9140ef225edbe40fd7699b3d290aa02de1c90664 Mon Sep 17 00:00:00 2001 From: Fangyu Gai Date: Fri, 17 Feb 2023 17:21:32 +0800 Subject: [PATCH 1/4] keep single encoding config in the application --- app/test_helpers.go | 11 +++++++---- app/utils.go | 4 ++-- cmd/babylond/cmd/root.go | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/test_helpers.go b/app/test_helpers.go index 170e95d19..7d4442650 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -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" @@ -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 @@ -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 } diff --git a/app/utils.go b/app/utils.go index 9705ebe72..28ba53ddf 100644 --- a/app/utils.go +++ b/app/utils.go @@ -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" ) @@ -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()) @@ -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). diff --git a/cmd/babylond/cmd/root.go b/cmd/babylond/cmd/root.go index c04b2dac8..24f758502 100644 --- a/cmd/babylond/cmd/root.go +++ b/cmd/babylond/cmd/root.go @@ -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) } @@ -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) } From 9aadd538c61b9c2f35430c2ab5bc9df83718adf4 Mon Sep 17 00:00:00 2001 From: Fangyu Gai Date: Mon, 20 Feb 2023 22:05:57 +0800 Subject: [PATCH 2/4] remove test encoding config --- app/app_test.go | 4 ++-- app/encoding.go | 18 ++++++++------ app/modules.go | 2 +- app/params/proto.go | 14 +++++------ app/test_helpers.go | 7 +++--- app/utils.go | 2 -- cmd/babylond/cmd/add_gen_bls_test.go | 5 ++-- cmd/babylond/cmd/genaccounts_test.go | 7 +++--- cmd/babylond/cmd/genbls_test.go | 2 +- cmd/babylond/cmd/root.go | 2 +- cmd/babylond/cmd/testnet_test.go | 5 ++-- cmd/babylond/cmd/validate_genesis_test.go | 4 ++-- simapp/sim_bench_test.go | 4 ++-- simapp/sim_test.go | 24 ++++++++++--------- test/e2e/util/codec.go | 2 +- test/utils.go | 15 ++++++------ x/checkpointing/client/cli/tx_test.go | 13 +++++----- x/checkpointing/keeper/bls_signer_test.go | 13 +++++----- x/epoching/simulation/decoder_test.go | 12 ++++++---- x/zoneconcierge/keeper/keeper_test.go | 9 +++---- .../keeper/proof_tx_in_block_test.go | 7 +++--- x/zoneconcierge/module_ibc_packet_test.go | 7 +++--- x/zoneconcierge/module_test.go | 7 +++--- 23 files changed, 100 insertions(+), 85 deletions(-) diff --git a/app/app_test.go b/app/app_test.go index 429796666..6c8cad27e 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -11,7 +11,7 @@ import ( ) func TestBabylonBlockedAddrs(t *testing.T) { - encCfg := MakeTestEncodingConfig() + encCfg := MakeEncodingConfig() db := dbm.NewMemDB() signer, _ := SetupPrivSigner() logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) @@ -48,7 +48,7 @@ func TestGetMaccPerms(t *testing.T) { } func TestUpgradeStateOnGenesis(t *testing.T) { - encCfg := MakeTestEncodingConfig() + encCfg := MakeEncodingConfig() db := dbm.NewMemDB() privSigner, err := SetupPrivSigner() require.NoError(t, err) diff --git a/app/encoding.go b/app/encoding.go index c414f23f0..f18c66c04 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -1,16 +1,20 @@ package app import ( - appparams "github.com/babylonchain/babylon/app/params" "github.com/cosmos/cosmos-sdk/std" + + appparams "github.com/babylonchain/babylon/app/params" ) -// MakeTestEncodingConfig creates an EncodingConfig for testing. This function -// should be used only in tests or when creating a new app instance (NewApp*()). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -func MakeTestEncodingConfig() appparams.EncodingConfig { - encodingConfig := appparams.MakeTestEncodingConfig() +var encodingConfig appparams.EncodingConfig = MakeEncodingConfig() + +func GetEncodingConfig() appparams.EncodingConfig { + return encodingConfig +} + +// MakeEncodingConfig creates an EncodingConfig. +func MakeEncodingConfig() appparams.EncodingConfig { + encodingConfig := appparams.MakeEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) diff --git a/app/modules.go b/app/modules.go index d3fafbc66..8a9252c50 100644 --- a/app/modules.go +++ b/app/modules.go @@ -23,5 +23,5 @@ func (app *BabylonApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper { } func (app *BabylonApp) GetTxConfig() client.TxConfig { - return MakeTestEncodingConfig().TxConfig + return GetEncodingConfig().TxConfig } diff --git a/app/params/proto.go b/app/params/proto.go index a752d1079..7effc3297 100644 --- a/app/params/proto.go +++ b/app/params/proto.go @@ -9,19 +9,17 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/tx" ) -// MakeTestEncodingConfig creates an EncodingConfig for a non-amino based test configuration. -// This function should be used only internally (in the SDK). -// App user should'nt create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -func MakeTestEncodingConfig() EncodingConfig { - cdc := codec.NewLegacyAmino() +// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. +func MakeEncodingConfig() EncodingConfig { + amino := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewProtoCodec(interfaceRegistry) + txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes) return EncodingConfig{ InterfaceRegistry: interfaceRegistry, Marshaler: marshaler, - TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes), - Amino: cdc, + TxConfig: txCfg, + Amino: amino, } } diff --git a/app/test_helpers.go b/app/test_helpers.go index 7d4442650..e59ba90c0 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -15,9 +15,10 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" + "github.com/babylonchain/babylon/testutil/datagen" + "github.com/babylonchain/babylon/app/params" appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/testutil/datagen" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -79,7 +80,7 @@ type SetupOptions struct { func setup(withGenesis bool, invCheckPeriod uint) (*BabylonApp, GenesisState) { db := dbm.NewMemDB() - encCdc := MakeTestEncodingConfig() + encCdc := MakeEncodingConfig() privSigner, err := SetupPrivSigner() if err != nil { panic(err) @@ -244,7 +245,7 @@ func SetupPrivSigner() (*PrivSigner, error) { if err != nil { return nil, err } - encodingCfg := appparams.MakeTestEncodingConfig() + encodingCfg := appparams.MakeEncodingConfig() privSigner, _ := InitPrivSigner(client.Context{}, ".", kr, encodingCfg) privSigner.WrappedPV.Clean(nodeCfg.PrivValidatorKeyFile(), nodeCfg.PrivValidatorStateFile()) return privSigner, nil diff --git a/app/utils.go b/app/utils.go index 28ba53ddf..d6a3126e7 100644 --- a/app/utils.go +++ b/app/utils.go @@ -59,8 +59,6 @@ func InitPrivSigner(clientCtx client.Context, nodeDir string, kr keyring.Keyring } wrappedPV := privval.LoadOrGenWrappedFilePV(pvKeyFile, pvStateFile) - // TODO this should probably not create separate config, but rahter accept it - // as argument clientCtx = clientCtx. WithInterfaceRegistry(encodingCfg.InterfaceRegistry). WithCodec(encodingCfg.Marshaler). diff --git a/cmd/babylond/cmd/add_gen_bls_test.go b/cmd/babylond/cmd/add_gen_bls_test.go index f1e631ba3..afdbdcfb0 100644 --- a/cmd/babylond/cmd/add_gen_bls_test.go +++ b/cmd/babylond/cmd/add_gen_bls_test.go @@ -3,10 +3,11 @@ package cmd_test import ( "context" "fmt" - "github.com/cosmos/cosmos-sdk/server/config" "path/filepath" "testing" + "github.com/cosmos/cosmos-sdk/server/config" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -36,7 +37,7 @@ func Test_AddGenBlsCmdWithoutGentx(t *testing.T) { tmcfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := app.MakeTestEncodingConfig().Marshaler + appCodec := app.MakeEncodingConfig().Marshaler err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/cmd/babylond/cmd/genaccounts_test.go b/cmd/babylond/cmd/genaccounts_test.go index ef8a2101a..148ce8166 100644 --- a/cmd/babylond/cmd/genaccounts_test.go +++ b/cmd/babylond/cmd/genaccounts_test.go @@ -13,8 +13,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" - "github.com/babylonchain/babylon/app" - bbncmd "github.com/babylonchain/babylon/cmd/babylond/cmd" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -22,6 +20,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" + + "github.com/babylonchain/babylon/app" + bbncmd "github.com/babylonchain/babylon/cmd/babylond/cmd" ) var testMbm = module.NewBasicManager(genutil.AppModuleBasic{}) @@ -73,7 +74,7 @@ func TestAddGenesisAccountCmd(t *testing.T) { cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := app.MakeTestEncodingConfig().Marshaler + appCodec := app.MakeEncodingConfig().Marshaler err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/cmd/babylond/cmd/genbls_test.go b/cmd/babylond/cmd/genbls_test.go index 46904a3c6..d2e0a52a2 100644 --- a/cmd/babylond/cmd/genbls_test.go +++ b/cmd/babylond/cmd/genbls_test.go @@ -28,7 +28,7 @@ import ( func Test_GenBlsCmd(t *testing.T) { home := t.TempDir() - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.MakeEncodingConfig() logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) diff --git a/cmd/babylond/cmd/root.go b/cmd/babylond/cmd/root.go index 24f758502..bca56a194 100644 --- a/cmd/babylond/cmd/root.go +++ b/cmd/babylond/cmd/root.go @@ -40,7 +40,7 @@ import ( // NewRootCmd creates a new root command for babylond. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.MakeEncodingConfig() initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). diff --git a/cmd/babylond/cmd/testnet_test.go b/cmd/babylond/cmd/testnet_test.go index a8660c821..3c235cf1a 100644 --- a/cmd/babylond/cmd/testnet_test.go +++ b/cmd/babylond/cmd/testnet_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - "github.com/babylonchain/babylon/app" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -15,11 +14,13 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" + + "github.com/babylonchain/babylon/app" ) func Test_TestnetCmd(t *testing.T) { home := t.TempDir() - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.MakeEncodingConfig() logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) diff --git a/cmd/babylond/cmd/validate_genesis_test.go b/cmd/babylond/cmd/validate_genesis_test.go index 070ce5037..e61fc93d2 100644 --- a/cmd/babylond/cmd/validate_genesis_test.go +++ b/cmd/babylond/cmd/validate_genesis_test.go @@ -26,7 +26,7 @@ import ( func TestCheckCorrespondence(t *testing.T) { homePath := t.TempDir() - encodingCft := app.MakeTestEncodingConfig() + encodingCft := app.MakeEncodingConfig() clientCtx := client.Context{}.WithCodec(encodingCft.Marshaler).WithTxConfig(encodingCft.TxConfig) // generate valid genesis doc @@ -85,7 +85,7 @@ func TestCheckCorrespondence(t *testing.T) { } func generateTestGenesisState(home string, n int) (map[string]json.RawMessage, *tmtypes.GenesisDoc) { - encodingConfig := app.MakeTestEncodingConfig() + encodingConfig := app.MakeEncodingConfig() logger := log.NewNopLogger() cfg, _ := genutiltest.CreateDefaultTendermintConfig(home) diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 7eb28b0d3..af355bdd7 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -39,7 +39,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { if err != nil { b.Fatal(err) } - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -93,7 +93,7 @@ func BenchmarkInvariants(b *testing.B) { if err != nil { b.Fatal(err) } - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( diff --git a/simapp/sim_test.go b/simapp/sim_test.go index e18fd3c35..beaeeae3a 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -12,13 +12,10 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/babylonchain/babylon/app" storetypes "github.com/cosmos/cosmos-sdk/store/types" - btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" - btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" - checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" + "github.com/babylonchain/babylon/app" + "github.com/cosmos/cosmos-sdk/baseapp" sdksimapp "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/simapp/helpers" @@ -38,6 +35,11 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/tendermint/tendermint/abci/types" + + btccheckpointtypes "github.com/babylonchain/babylon/x/btccheckpoint/types" + btclightclienttypes "github.com/babylonchain/babylon/x/btclightclient/types" + checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" + epochingtypes "github.com/babylonchain/babylon/x/epoching/types" ) // Get flags every time the simulator is run @@ -77,7 +79,7 @@ func TestFullAppSimulation(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // run randomized simulation @@ -117,7 +119,7 @@ func TestAppImportExport(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // Run randomized simulation @@ -157,7 +159,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", newBabylon.Name()) var genesisState app.GenesisState @@ -221,7 +223,7 @@ func TestAppSimulationAfterImport(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // Run randomized simulation @@ -266,7 +268,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", newBabylon.Name()) newBabylon.InitChain(abci.RequestInitChain{ @@ -319,7 +321,7 @@ func TestAppStateDeterminism(t *testing.T) { db := dbm.NewMemDB() privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeTestEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/test/e2e/util/codec.go b/test/e2e/util/codec.go index 7fb561788..f0a0abc46 100644 --- a/test/e2e/util/codec.go +++ b/test/e2e/util/codec.go @@ -22,7 +22,7 @@ func init() { } func initEncodingConfigAndCdc() (params.EncodingConfig, codec.Codec) { - encodingConfig := babylonApp.MakeTestEncodingConfig() + encodingConfig := babylonApp.MakeEncodingConfig() encodingConfig.InterfaceRegistry.RegisterImplementations( (*sdk.Msg)(nil), diff --git a/test/utils.go b/test/utils.go index 532a78527..c20b077c7 100644 --- a/test/utils.go +++ b/test/utils.go @@ -8,12 +8,6 @@ import ( tm "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - "github.com/babylonchain/babylon/app" - appparams "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/testutil/datagen" - bbn "github.com/babylonchain/babylon/types" - btccheckpoint "github.com/babylonchain/babylon/x/btccheckpoint/types" - lightclient "github.com/babylonchain/babylon/x/btclightclient/types" "github.com/btcsuite/btcd/wire" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -22,6 +16,13 @@ import ( acctypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/tendermint/tendermint/types" "google.golang.org/grpc" + + "github.com/babylonchain/babylon/app" + appparams "github.com/babylonchain/babylon/app/params" + "github.com/babylonchain/babylon/testutil/datagen" + bbn "github.com/babylonchain/babylon/types" + btccheckpoint "github.com/babylonchain/babylon/x/btccheckpoint/types" + lightclient "github.com/babylonchain/babylon/x/btclightclient/types" ) type TestTxSender struct { @@ -37,7 +38,7 @@ func NewTestTxSender( genesisPath string, conn *grpc.ClientConn, ) (*TestTxSender, error) { - cfg := app.MakeTestEncodingConfig() + cfg := app.MakeEncodingConfig() kb, err := keyring.New("babylond", "test", keyringPath, nil, cfg.Marshaler) diff --git a/x/checkpointing/client/cli/tx_test.go b/x/checkpointing/client/cli/tx_test.go index c7150d3cc..e4ed90073 100644 --- a/x/checkpointing/client/cli/tx_test.go +++ b/x/checkpointing/client/cli/tx_test.go @@ -22,11 +22,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/client/cli" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/app/params" - "github.com/babylonchain/babylon/privval" - testutilcli "github.com/babylonchain/babylon/testutil/cli" - checkpointcli "github.com/babylonchain/babylon/x/checkpointing/client/cli" abci "github.com/tendermint/tendermint/abci/types" tmconfig "github.com/tendermint/tendermint/config" tmbytes "github.com/tendermint/tendermint/libs/bytes" @@ -35,6 +30,12 @@ import ( rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock" coretypes "github.com/tendermint/tendermint/rpc/core/types" tmtypes "github.com/tendermint/tendermint/types" + + "github.com/babylonchain/babylon/app" + "github.com/babylonchain/babylon/app/params" + "github.com/babylonchain/babylon/privval" + testutilcli "github.com/babylonchain/babylon/testutil/cli" + checkpointcli "github.com/babylonchain/babylon/x/checkpointing/client/cli" ) type mockTendermintRPC struct { @@ -70,7 +71,7 @@ type CLITestSuite struct { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = app.MakeTestEncodingConfig() + s.encCfg = app.MakeEncodingConfig() s.kr = keyring.NewInMemory(s.encCfg.Marshaler) ctrl := gomock.NewController(s.T()) mockAccountRetriever := mocks.NewMockAccountRetriever(ctrl) diff --git a/x/checkpointing/keeper/bls_signer_test.go b/x/checkpointing/keeper/bls_signer_test.go index b204c667a..b12254b9e 100644 --- a/x/checkpointing/keeper/bls_signer_test.go +++ b/x/checkpointing/keeper/bls_signer_test.go @@ -4,11 +4,6 @@ import ( "fmt" "testing" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/crypto/bls12381" - testkeeper "github.com/babylonchain/babylon/testutil/keeper" - "github.com/babylonchain/babylon/testutil/mocks" - epochingtypes "github.com/babylonchain/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -16,6 +11,12 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/tmhash" + + "github.com/babylonchain/babylon/app" + "github.com/babylonchain/babylon/crypto/bls12381" + testkeeper "github.com/babylonchain/babylon/testutil/keeper" + "github.com/babylonchain/babylon/testutil/mocks" + epochingtypes "github.com/babylonchain/babylon/x/epoching/types" ) var ( @@ -41,7 +42,7 @@ var ( func TestKeeper_SendBlsSig(t *testing.T) { cfg := network.DefaultConfig() - encodingCfg := app.MakeTestEncodingConfig() + encodingCfg := app.MakeEncodingConfig() cfg.InterfaceRegistry = encodingCfg.InterfaceRegistry cfg.TxConfig = encodingCfg.TxConfig cfg.NumValidators = 1 diff --git a/x/epoching/simulation/decoder_test.go b/x/epoching/simulation/decoder_test.go index f8fc723d6..831886e52 100644 --- a/x/epoching/simulation/decoder_test.go +++ b/x/epoching/simulation/decoder_test.go @@ -2,17 +2,19 @@ package simulation_test import ( "fmt" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "testing" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/x/epoching/simulation" - "github.com/babylonchain/babylon/x/epoching/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" + + "github.com/babylonchain/babylon/app" + "github.com/babylonchain/babylon/x/epoching/simulation" + "github.com/babylonchain/babylon/x/epoching/types" ) // nolint:deadcode,unused,varcheck @@ -25,7 +27,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := app.MakeTestEncodingConfig().Marshaler + cdc := app.MakeEncodingConfig().Marshaler dec := simulation.NewDecodeStore(cdc) epochNumber := uint64(123) diff --git a/x/zoneconcierge/keeper/keeper_test.go b/x/zoneconcierge/keeper/keeper_test.go index 12069d90f..830206240 100644 --- a/x/zoneconcierge/keeper/keeper_test.go +++ b/x/zoneconcierge/keeper/keeper_test.go @@ -4,12 +4,13 @@ import ( "encoding/json" "testing" - "github.com/babylonchain/babylon/app" - "github.com/babylonchain/babylon/testutil/datagen" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" sdk "github.com/cosmos/cosmos-sdk/types" ibctmtypes "github.com/cosmos/ibc-go/v5/modules/light-clients/07-tendermint/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" + + "github.com/babylonchain/babylon/app" + "github.com/babylonchain/babylon/testutil/datagen" + zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" ) // SetupTest creates a coordinator with 2 test chains, and a ZoneConcierge keeper. @@ -20,7 +21,7 @@ func SetupTest(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *i ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(t, false) bbnApp = babylonApp - encCdc := app.MakeTestEncodingConfig() + encCdc := app.MakeEncodingConfig() genesis := app.NewDefaultGenesisState(encCdc.Marshaler) return babylonApp, genesis } diff --git a/x/zoneconcierge/keeper/proof_tx_in_block_test.go b/x/zoneconcierge/keeper/proof_tx_in_block_test.go index 11944081a..1042ac9f6 100644 --- a/x/zoneconcierge/keeper/proof_tx_in_block_test.go +++ b/x/zoneconcierge/keeper/proof_tx_in_block_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/babylonchain/babylon/app" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -13,12 +11,15 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/spf13/pflag" "github.com/stretchr/testify/require" + + "github.com/babylonchain/babylon/app" + zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" ) func TestProveTxInBlock(t *testing.T) { // setup virtual network cfg := network.DefaultConfig() - encodingCfg := app.MakeTestEncodingConfig() + encodingCfg := app.MakeEncodingConfig() cfg.InterfaceRegistry = encodingCfg.InterfaceRegistry cfg.TxConfig = encodingCfg.TxConfig cfg.NumValidators = 2 diff --git a/x/zoneconcierge/module_ibc_packet_test.go b/x/zoneconcierge/module_ibc_packet_test.go index 468e766e3..e431b6d1a 100644 --- a/x/zoneconcierge/module_ibc_packet_test.go +++ b/x/zoneconcierge/module_ibc_packet_test.go @@ -4,10 +4,11 @@ import ( "encoding/json" "math/rand" - "github.com/babylonchain/babylon/app" - zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v5/testing" + + "github.com/babylonchain/babylon/app" + zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" ) // SetupTest creates a coordinator with 2 test chains. @@ -17,7 +18,7 @@ func (suite *ZoneConciergeTestSuite) SetupTestForIBCPackets() { ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(suite.T(), false) suite.zcKeeper = babylonApp.ZoneConciergeKeeper - encCdc := app.MakeTestEncodingConfig() + encCdc := app.MakeEncodingConfig() genesis := app.NewDefaultGenesisState(encCdc.Marshaler) return babylonApp, genesis } diff --git a/x/zoneconcierge/module_test.go b/x/zoneconcierge/module_test.go index 8289001a0..4d9cf9a13 100644 --- a/x/zoneconcierge/module_test.go +++ b/x/zoneconcierge/module_test.go @@ -7,8 +7,6 @@ import ( "testing" "time" - "github.com/babylonchain/babylon/app" - zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,6 +24,9 @@ import ( tmbytes "github.com/tendermint/tendermint/libs/bytes" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + + "github.com/babylonchain/babylon/app" + zckeeper "github.com/babylonchain/babylon/x/zoneconcierge/keeper" ) // ZoneConciergeTestSuite provides a test suite for IBC functionalities in ZoneConcierge @@ -65,7 +66,7 @@ func (suite *ZoneConciergeTestSuite) SetupTest() { ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(suite.T(), false) suite.zcKeeper = babylonApp.ZoneConciergeKeeper - encCdc := app.MakeTestEncodingConfig() + encCdc := app.MakeEncodingConfig() return babylonApp, app.NewDefaultGenesisState(encCdc.Marshaler) } babylonChainID := ibctesting.GetChainID(1) From 733f11375a0c8d8d69f25678838cf3d3c08e688a Mon Sep 17 00:00:00 2001 From: Fangyu Gai Date: Tue, 21 Feb 2023 12:05:35 +0800 Subject: [PATCH 3/4] address comment --- app/app_test.go | 4 +- app/encoding.go | 8 +- app/params/proto.go | 4 +- app/test_helpers.go | 4 +- babylon/config/app.toml | 262 ++++++++++ babylon/config/client.toml | 17 + babylon/config/config.toml | 466 ++++++++++++++++++ cmd/babylond/cmd/add_gen_bls_test.go | 2 +- cmd/babylond/cmd/genaccounts_test.go | 2 +- cmd/babylond/cmd/genbls_test.go | 2 +- cmd/babylond/cmd/root.go | 2 +- cmd/babylond/cmd/testnet_test.go | 2 +- cmd/babylond/cmd/validate_genesis_test.go | 4 +- simapp/sim_bench_test.go | 4 +- simapp/sim_test.go | 12 +- test/e2e/util/codec.go | 2 +- test/utils.go | 2 +- x/checkpointing/client/cli/tx_test.go | 2 +- x/epoching/simulation/decoder_test.go | 2 +- x/zoneconcierge/keeper/keeper_test.go | 2 +- .../keeper/proof_tx_in_block_test.go | 2 +- x/zoneconcierge/module_ibc_packet_test.go | 2 +- x/zoneconcierge/module_test.go | 2 +- 23 files changed, 778 insertions(+), 33 deletions(-) create mode 100644 babylon/config/app.toml create mode 100644 babylon/config/client.toml create mode 100644 babylon/config/config.toml diff --git a/app/app_test.go b/app/app_test.go index 6c8cad27e..df3f279e6 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -11,7 +11,7 @@ import ( ) func TestBabylonBlockedAddrs(t *testing.T) { - encCfg := MakeEncodingConfig() + encCfg := GetEncodingConfig() db := dbm.NewMemDB() signer, _ := SetupPrivSigner() logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) @@ -48,7 +48,7 @@ func TestGetMaccPerms(t *testing.T) { } func TestUpgradeStateOnGenesis(t *testing.T) { - encCfg := MakeEncodingConfig() + encCfg := GetEncodingConfig() db := dbm.NewMemDB() privSigner, err := SetupPrivSigner() require.NoError(t, err) diff --git a/app/encoding.go b/app/encoding.go index f18c66c04..800f0e302 100644 --- a/app/encoding.go +++ b/app/encoding.go @@ -6,15 +6,15 @@ import ( appparams "github.com/babylonchain/babylon/app/params" ) -var encodingConfig appparams.EncodingConfig = MakeEncodingConfig() +var encodingConfig = makeEncodingConfig() func GetEncodingConfig() appparams.EncodingConfig { return encodingConfig } -// MakeEncodingConfig creates an EncodingConfig. -func MakeEncodingConfig() appparams.EncodingConfig { - encodingConfig := appparams.MakeEncodingConfig() +// makeEncodingConfig creates an EncodingConfig. +func makeEncodingConfig() appparams.EncodingConfig { + encodingConfig := appparams.GetEncodingConfig() std.RegisterLegacyAminoCodec(encodingConfig.Amino) std.RegisterInterfaces(encodingConfig.InterfaceRegistry) ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) diff --git a/app/params/proto.go b/app/params/proto.go index 7effc3297..f2f36aae3 100644 --- a/app/params/proto.go +++ b/app/params/proto.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/tx" ) -// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. -func MakeEncodingConfig() EncodingConfig { +// GetEncodingConfig creates an EncodingConfig for an amino based test configuration. +func GetEncodingConfig() EncodingConfig { amino := codec.NewLegacyAmino() interfaceRegistry := types.NewInterfaceRegistry() marshaler := codec.NewProtoCodec(interfaceRegistry) diff --git a/app/test_helpers.go b/app/test_helpers.go index e59ba90c0..e02cf9fde 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -80,7 +80,7 @@ type SetupOptions struct { func setup(withGenesis bool, invCheckPeriod uint) (*BabylonApp, GenesisState) { db := dbm.NewMemDB() - encCdc := MakeEncodingConfig() + encCdc := GetEncodingConfig() privSigner, err := SetupPrivSigner() if err != nil { panic(err) @@ -245,7 +245,7 @@ func SetupPrivSigner() (*PrivSigner, error) { if err != nil { return nil, err } - encodingCfg := appparams.MakeEncodingConfig() + encodingCfg := appparams.GetEncodingConfig() privSigner, _ := InitPrivSigner(client.Context{}, ".", kr, encodingCfg) privSigner.WrappedPV.Clean(nodeCfg.PrivValidatorKeyFile(), nodeCfg.PrivValidatorStateFile()) return privSigner, nil diff --git a/babylon/config/app.toml b/babylon/config/app.toml new file mode 100644 index 000000000..d56079b31 --- /dev/null +++ b/babylon/config/app.toml @@ -0,0 +1,262 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Base Configuration ### +############################################################################### + +# The minimum gas prices a validator is willing to accept for processing a +# transaction. A transaction's fees must meet the minimum of any denomination +# specified in this config (e.g. 0.25token1;0.0001token2). +minimum-gas-prices = "0bbn" + +# default: the last 362880 states are kept, pruning at 10 block intervals +# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +# everything: 2 latest states will be kept; pruning at 10 block intervals. +# custom: allow pruning options to be manually specified through 'pruning-keep-recent', and 'pruning-interval' +pruning = "default" + +# These are applied if and only if the pruning strategy is custom. +pruning-keep-recent = "0" +pruning-interval = "0" + +# HaltHeight contains a non-zero block height at which a node will gracefully +# halt and shutdown that can be used to assist upgrades and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-height = 0 + +# HaltTime contains a non-zero minimum block time (in Unix seconds) at which +# a node will gracefully halt and shutdown that can be used to assist upgrades +# and testing. +# +# Note: Commitment of state will be attempted on the corresponding block. +halt-time = 0 + +# MinRetainBlocks defines the minimum block height offset from the current +# block being committed, such that all blocks past this offset are pruned +# from Tendermint. It is used as part of the process of determining the +# ResponseCommit.RetainHeight value during ABCI Commit. A value of 0 indicates +# that no blocks should be pruned. +# +# This configuration value is only responsible for pruning Tendermint blocks. +# It has no bearing on application state pruning which is determined by the +# "pruning-*" configurations. +# +# Note: Tendermint block pruning is dependant on this parameter in conunction +# with the unbonding (safety threshold) period, state pruning and state sync +# snapshot parameters to determine the correct minimum value of +# ResponseCommit.RetainHeight. +min-retain-blocks = 0 + +# InterBlockCache enables inter-block caching. +inter-block-cache = true + +# IndexEvents defines the set of events in the form {eventType}.{attributeKey}, +# which informs Tendermint what to index. If empty, all events will be indexed. +# +# Example: +# ["message.sender", "message.recipient"] +index-events = [] + +# IavlCacheSize set the size of the iavl tree cache. +# Default cache size is 50mb. +iavl-cache-size = 781250 + +# IavlDisableFastNode enables or disables the fast node feature of IAVL. +# Default is false. +iavl-disable-fastnode = false + +# AppDBBackend defines the database backend type to use for the application and snapshots DBs. +# An empty string indicates that a fallback will be used. +# First fallback is the deprecated compile-time types.DBBackend value. +# Second fallback (if the types.DBBackend also isn't set), is the db-backend value set in Tendermint's config.toml. +app-db-backend = "" + +############################################################################### +### Telemetry Configuration ### +############################################################################### + +[telemetry] + +# Prefixed with keys to separate services. +service-name = "" + +# Enabled enables the application telemetry functionality. When enabled, +# an in-memory sink is also enabled by default. Operators may also enabled +# other sinks such as Prometheus. +enabled = false + +# Enable prefixing gauge values with hostname. +enable-hostname = false + +# Enable adding hostname to labels. +enable-hostname-label = false + +# Enable adding service to labels. +enable-service-label = false + +# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink. +prometheus-retention-time = 0 + +# GlobalLabels defines a global set of name/value label tuples applied to all +# metrics emitted using the wrapper functions defined in telemetry package. +# +# Example: +# [["chain_id", "cosmoshub-1"]] +global-labels = [ +] + +############################################################################### +### API Configuration ### +############################################################################### + +[api] + +# Enable defines if the API server should be enabled. +enable = false + +# Swagger defines if swagger documentation should automatically be registered. +swagger = false + +# Address defines the API server to listen on. +address = "tcp://0.0.0.0:1317" + +# MaxOpenConnections defines the number of maximum open connections. +max-open-connections = 1000 + +# RPCReadTimeout defines the Tendermint RPC read timeout (in seconds). +rpc-read-timeout = 10 + +# RPCWriteTimeout defines the Tendermint RPC write timeout (in seconds). +rpc-write-timeout = 0 + +# RPCMaxBodyBytes defines the Tendermint maximum response body (in bytes). +rpc-max-body-bytes = 1000000 + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enabled-unsafe-cors = false + +############################################################################### +### Rosetta Configuration ### +############################################################################### + +[rosetta] + +# Enable defines if the Rosetta API server should be enabled. +enable = false + +# Address defines the Rosetta API server to listen on. +address = ":8080" + +# Network defines the name of the blockchain that will be returned by Rosetta. +blockchain = "app" + +# Network defines the name of the network that will be returned by Rosetta. +network = "network" + +# Retries defines the number of retries when connecting to the node before failing. +retries = 3 + +# Offline defines if Rosetta server should run in offline mode. +offline = false + +# EnableDefaultSuggestedFee defines if the server should suggest fee by default. +# If 'construction/medata' is called without gas limit and gas price, +# suggested fee based on gas-to-suggest and denom-to-suggest will be given. +enable-fee-suggestion = false + +# GasToSuggest defines gas limit when calculating the fee +gas-to-suggest = 200000 + +# DenomToSuggest defines the defult denom for fee suggestion. +# Price must be in minimum-gas-prices. +denom-to-suggest = "uatom" + +############################################################################### +### gRPC Configuration ### +############################################################################### + +[grpc] + +# Enable defines if the gRPC server should be enabled. +enable = true + +# Address defines the gRPC server address to bind to. +address = "0.0.0.0:9090" + +# MaxRecvMsgSize defines the max message size in bytes the server can receive. +# The default value is 10MB. +max-recv-msg-size = "10485760" + +# MaxSendMsgSize defines the max message size in bytes the server can send. +# The default value is math.MaxInt32. +max-send-msg-size = "2147483647" + +############################################################################### +### gRPC Web Configuration ### +############################################################################### + +[grpc-web] + +# GRPCWebEnable defines if the gRPC-web should be enabled. +# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op. +enable = true + +# Address defines the gRPC-web server address to bind to. +address = "0.0.0.0:9091" + +# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). +enable-unsafe-cors = false + +############################################################################### +### State Sync Configuration ### +############################################################################### + +# State sync snapshots allow other nodes to rapidly join the network without replaying historical +# blocks, instead downloading and applying a snapshot of the application state at a given height. +[state-sync] + +# snapshot-interval specifies the block interval at which local state sync snapshots are +# taken (0 to disable). +snapshot-interval = 0 + +# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). +snapshot-keep-recent = 2 + +############################################################################### +### Store / State Streaming ### +############################################################################### + +[store] +streamers = [] + +[streamers] +[streamers.file] +keys = ["*", ] +write_dir = "" +prefix = "" + +############################################################################### +### Babylon Bitcoin configuration ### +############################################################################### + +[btc-config] + +# Configures which bitcoin network should be used for checkpointing +# valid values are: [mainnet, testnet, simnet, regtest] +network = "mainnet" + + +# Configures what tag should be prepended to op_return data in btc transaction +# for it to be considered as valid babylon checkpoint. Must have exactly 4 bytes. +checkpoint-tag = "bbtm" + +[signer-config] + +# Configures which key that the BLS signer uses to sign BLS-sig transactions +key-name = "default" +# Configures the gas-price that the signer would like to pay +gas-price = "0.01ubbn" +# Configures the adjustment of the gas cost of estimation +gas-adjustment = "1.5" diff --git a/babylon/config/client.toml b/babylon/config/client.toml new file mode 100644 index 000000000..3eb226310 --- /dev/null +++ b/babylon/config/client.toml @@ -0,0 +1,17 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +############################################################################### +### Client Configuration ### +############################################################################### + +# The network chain ID +chain-id = "bbn-test1" +# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) +keyring-backend = "os" +# CLI output format (text|json) +output = "text" +# : to Tendermint RPC interface for this chain +node = "tcp://localhost:26657" +# Transaction broadcasting mode (sync|async|block) +broadcast-mode = "sync" diff --git a/babylon/config/config.toml b/babylon/config/config.toml new file mode 100644 index 000000000..0ca5d9683 --- /dev/null +++ b/babylon/config/config.toml @@ -0,0 +1,466 @@ +# This is a TOML config file. +# For more information, see https://github.com/toml-lang/toml + +# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or +# relative to the home directory (e.g. "data"). The home directory is +# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable +# or --home cmd flag. + +####################################################################### +### Main Base Config Options ### +####################################################################### + +# TCP or UNIX socket address of the ABCI application, +# or the name of an ABCI application compiled in with the Tendermint binary +proxy_app = "tcp://127.0.0.1:26658" + +# A custom human readable name for this node +moniker = "lanpos-MacBook-Pro.local" + +# If this node is many blocks behind the tip of the chain, FastSync +# allows them to catchup quickly by downloading blocks in parallel +# and verifying their commits +fast_sync = true + +# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb +# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) +# - pure go +# - stable +# * cleveldb (uses levigo wrapper) +# - fast +# - requires gcc +# - use cleveldb build tag (go build -tags cleveldb) +# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) +# - EXPERIMENTAL +# - may be faster is some use-cases (random reads - indexer) +# - use boltdb build tag (go build -tags boltdb) +# * rocksdb (uses github.com/tecbot/gorocksdb) +# - EXPERIMENTAL +# - requires gcc +# - use rocksdb build tag (go build -tags rocksdb) +# * badgerdb (uses github.com/dgraph-io/badger) +# - EXPERIMENTAL +# - use badgerdb build tag (go build -tags badgerdb) +db_backend = "goleveldb" + +# Database directory +db_dir = "data" + +# Output level for logging, including package level options +log_level = "info" + +# Output format: 'plain' (colored text) or 'json' +log_format = "plain" + +##### additional base config options ##### + +# Path to the JSON file containing the initial validator set and other meta data +genesis_file = "config/genesis.json" + +# Path to the JSON file containing the private key to use as a validator in the consensus protocol +priv_validator_key_file = "config/priv_validator_key.json" + +# Path to the JSON file containing the last sign state of a validator +priv_validator_state_file = "data/priv_validator_state.json" + +# TCP or UNIX socket address for Tendermint to listen on for +# connections from an external PrivValidator process +priv_validator_laddr = "" + +# Path to the JSON file containing the private key to use for node authentication in the p2p protocol +node_key_file = "config/node_key.json" + +# Mechanism to connect to the ABCI application: socket | grpc +abci = "socket" + +# If true, query the ABCI app on connecting to a new peer +# so the app can decide if we should keep the connection or not +filter_peers = false + + +####################################################################### +### Advanced Configuration Options ### +####################################################################### + +####################################################### +### RPC Server Configuration Options ### +####################################################### +[rpc] + +# TCP or UNIX socket address for the RPC server to listen on +laddr = "tcp://127.0.0.1:26657" + +# A list of origins a cross-domain request can be executed from +# Default value '[]' disables cors support +# Use '["*"]' to allow any origin +cors_allowed_origins = [] + +# A list of methods the client is allowed to use with cross-domain requests +cors_allowed_methods = ["HEAD", "GET", "POST", ] + +# A list of non simple headers the client is allowed to use with cross-domain requests +cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] + +# TCP or UNIX socket address for the gRPC server to listen on +# NOTE: This server only supports /broadcast_tx_commit +grpc_laddr = "" + +# Maximum number of simultaneous connections. +# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +grpc_max_open_connections = 900 + +# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool +unsafe = false + +# Maximum number of simultaneous connections (including WebSocket). +# Does not include gRPC connections. See grpc_max_open_connections +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} +# 1024 - 40 - 10 - 50 = 924 = ~900 +max_open_connections = 900 + +# Maximum number of unique clientIDs that can /subscribe +# If you're using /broadcast_tx_commit, set to the estimated maximum number +# of broadcast_tx_commit calls per block. +max_subscription_clients = 100 + +# Maximum number of unique queries a given client can /subscribe to +# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to +# the estimated # maximum number of broadcast_tx_commit calls per block. +max_subscriptions_per_client = 5 + +# Experimental parameter to specify the maximum number of events a node will +# buffer, per subscription, before returning an error and closing the +# subscription. Must be set to at least 100, but higher values will accommodate +# higher event throughput rates (and will use more memory). +experimental_subscription_buffer_size = 200 + +# Experimental parameter to specify the maximum number of RPC responses that +# can be buffered per WebSocket client. If clients cannot read from the +# WebSocket endpoint fast enough, they will be disconnected, so increasing this +# parameter may reduce the chances of them being disconnected (but will cause +# the node to use more memory). +# +# Must be at least the same as "experimental_subscription_buffer_size", +# otherwise connections could be dropped unnecessarily. This value should +# ideally be somewhat higher than "experimental_subscription_buffer_size" to +# accommodate non-subscription-related RPC responses. +experimental_websocket_write_buffer_size = 200 + +# If a WebSocket client cannot read fast enough, at present we may +# silently drop events instead of generating an error or disconnecting the +# client. +# +# Enabling this experimental parameter will cause the WebSocket connection to +# be closed instead if it cannot read fast enough, allowing for greater +# predictability in subscription behaviour. +experimental_close_on_slow_client = false + +# How long to wait for a tx to be committed during /broadcast_tx_commit. +# WARNING: Using a value larger than 10s will result in increasing the +# global HTTP write timeout, which applies to all connections and endpoints. +# See https://github.com/tendermint/tendermint/issues/3435 +timeout_broadcast_tx_commit = "10s" + +# Maximum size of request body, in bytes +max_body_bytes = 1000000 + +# Maximum size of request header, in bytes +max_header_bytes = 1048576 + +# The path to a file containing certificate that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# If the certificate is signed by a certificate authority, +# the certFile should be the concatenation of the server's certificate, any intermediates, +# and the CA's certificate. +# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_cert_file = "" + +# The path to a file containing matching private key that is used to create the HTTPS server. +# Might be either absolute path or path related to Tendermint's config directory. +# NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server. +# Otherwise, HTTP server is run. +tls_key_file = "" + +# pprof listen address (https://golang.org/pkg/net/http/pprof) +pprof_laddr = "localhost:6060" + +####################################################### +### P2P Configuration Options ### +####################################################### +[p2p] + +# Address to listen for incoming connections +laddr = "tcp://0.0.0.0:26656" + +# Address to advertise to peers for them to dial +# If empty, will use the same port as the laddr, +# and will introspect on the listener or use UPnP +# to figure out the address. ip and port are required +# example: 159.89.10.97:26656 +external_address = "" + +# Comma separated list of seed nodes to connect to +seeds = "" + +# Comma separated list of nodes to keep persistent connections to +persistent_peers = "" + +# UPNP port forwarding +upnp = false + +# Path to address book +addr_book_file = "config/addrbook.json" + +# Set true for strict address routability rules +# Set false for private or local networks +addr_book_strict = true + +# Maximum number of inbound peers +max_num_inbound_peers = 40 + +# Maximum number of outbound peers to connect to, excluding persistent peers +max_num_outbound_peers = 10 + +# List of node IDs, to which a connection will be (re)established ignoring any existing limits +unconditional_peer_ids = "" + +# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) +persistent_peers_max_dial_period = "0s" + +# Time to wait before flushing messages out on the connection +flush_throttle_timeout = "100ms" + +# Maximum size of a message packet payload, in bytes +max_packet_msg_payload_size = 1024 + +# Rate at which packets can be sent, in bytes/second +send_rate = 5120000 + +# Rate at which packets can be received, in bytes/second +recv_rate = 5120000 + +# Set true to enable the peer-exchange reactor +pex = true + +# Seed mode, in which node constantly crawls the network and looks for +# peers. If another node asks it for addresses, it responds and disconnects. +# +# Does not work if the peer-exchange reactor is disabled. +seed_mode = false + +# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) +private_peer_ids = "" + +# Toggle to disable guard against peers connecting from the same ip. +allow_duplicate_ip = false + +# Peer connection configuration. +handshake_timeout = "20s" +dial_timeout = "3s" + +####################################################### +### Mempool Configuration Option ### +####################################################### +[mempool] + +# Mempool version to use: +# 1) "v0" - (default) FIFO mempool. +# 2) "v1" - prioritized mempool. +version = "v0" + +recheck = true +broadcast = true +wal_dir = "" + +# Maximum number of transactions in the mempool +size = 5000 + +# Limit the total size of all txs in the mempool. +# This only accounts for raw transactions (e.g. given 1MB transactions and +# max_txs_bytes=5MB, mempool will only accept 5 transactions). +max_txs_bytes = 1073741824 + +# Size of the cache (used to filter transactions we saw earlier) in transactions +cache_size = 10000 + +# Do not remove invalid transactions from the cache (default: false) +# Set to true if it's not possible for any invalid transaction to become valid +# again in the future. +keep-invalid-txs-in-cache = false + +# Maximum size of a single transaction. +# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. +max_tx_bytes = 1048576 + +# Maximum size of a batch of transactions to send to a peer +# Including space needed by encoding (one varint per transaction). +# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 +max_batch_bytes = 0 + +# ttl-duration, if non-zero, defines the maximum amount of time a transaction +# can exist for in the mempool. +# +# Note, if ttl-num-blocks is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if it's +# insertion time into the mempool is beyond ttl-duration. +ttl-duration = "0s" + +# ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction +# can exist for in the mempool. +# +# Note, if ttl-duration is also defined, a transaction will be removed if it +# has existed in the mempool at least ttl-num-blocks number of blocks or if +# it's insertion time into the mempool is beyond ttl-duration. +ttl-num-blocks = 0 + +####################################################### +### State Sync Configuration Options ### +####################################################### +[statesync] +# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine +# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in +# the network to take and serve state machine snapshots. State sync is not attempted if the node +# has any local state (LastBlockHeight > 0). The node will have a truncated block history, +# starting from the height of the snapshot. +enable = false + +# RPC servers (comma-separated) for light client verification of the synced state machine and +# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding +# header hash obtained from a trusted source, and a period during which validators can be trusted. +# +# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 +# weeks) during which they can be financially punished (slashed) for misbehavior. +rpc_servers = "" +trust_height = 0 +trust_hash = "" +trust_period = "168h0m0s" + +# Time to spend discovering snapshots before initiating a restore. +discovery_time = "15s" + +# Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). +# Will create a new, randomly named directory within, and remove it when done. +temp_dir = "" + +# The timeout duration before re-requesting a chunk, possibly from a different +# peer (default: 1 minute). +chunk_request_timeout = "10s" + +# The number of concurrent chunk fetchers to run (default: 1). +chunk_fetchers = "4" + +####################################################### +### Fast Sync Configuration Connections ### +####################################################### +[fastsync] + +# Fast Sync version to use: +# 1) "v0" (default) - the legacy fast sync implementation +# 2) "v1" - refactor of v0 version for better testability +# 2) "v2" - complete redesign of v0, optimized for testability & readability +version = "v0" + +####################################################### +### Consensus Configuration Options ### +####################################################### +[consensus] + +wal_file = "data/cs.wal/wal" + +# How long we wait for a proposal block before prevoting nil +timeout_propose = "3s" +# How much timeout_propose increases with each round +timeout_propose_delta = "500ms" +# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) +timeout_prevote = "1s" +# How much the timeout_prevote increases with each round +timeout_prevote_delta = "500ms" +# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) +timeout_precommit = "1s" +# How much the timeout_precommit increases with each round +timeout_precommit_delta = "500ms" +# How long we wait after committing a block, before starting on the new +# height (this gives us a chance to receive some more precommits, even +# though we already have +2/3). +timeout_commit = "5s" + +# How many blocks to look back to check existence of the node's consensus votes before joining consensus +# When non-zero, the node will panic upon restart +# if the same consensus key was used to sign {double_sign_check_height} last blocks. +# So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. +double_sign_check_height = 0 + +# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) +skip_timeout_commit = false + +# EmptyBlocks mode and possible interval between empty blocks +create_empty_blocks = true +create_empty_blocks_interval = "0s" + +# Reactor sleep duration parameters +peer_gossip_sleep_duration = "100ms" +peer_query_maj23_sleep_duration = "2s" + +####################################################### +### Storage Configuration Options ### +####################################################### +[storage] + +# Set to true to discard ABCI responses from the state store, which can save a +# considerable amount of disk space. Set to false to ensure ABCI responses are +# persisted. ABCI responses are required for /block_results RPC queries, and to +# reindex events in the command-line tool. +discard_abci_responses = false + +####################################################### +### Transaction Indexer Configuration Options ### +####################################################### +[tx_index] + +# What indexer to use for transactions +# +# The application will set which txs to index. In some cases a node operator will be able +# to decide which txs to index based on configuration set in the application. +# +# Options: +# 1) "null" +# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). +# - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. +# 3) "psql" - the indexer services backed by PostgreSQL. +# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. +indexer = "kv" + +# The PostgreSQL connection configuration, the connection format: +# postgresql://:@:/? +psql-conn = "" + +####################################################### +### Instrumentation Configuration Options ### +####################################################### +[instrumentation] + +# When true, Prometheus metrics are served under /metrics on +# PrometheusListenAddr. +# Check out the documentation for the list of available metrics. +prometheus = false + +# Address to listen for Prometheus collector(s) connections +prometheus_listen_addr = ":26660" + +# Maximum number of simultaneous connections. +# If you want to accept a larger number than the default, make sure +# you increase your OS limits. +# 0 - unlimited. +max_open_connections = 3 + +# Instrumentation namespace +namespace = "tendermint" diff --git a/cmd/babylond/cmd/add_gen_bls_test.go b/cmd/babylond/cmd/add_gen_bls_test.go index afdbdcfb0..ac6c34b2a 100644 --- a/cmd/babylond/cmd/add_gen_bls_test.go +++ b/cmd/babylond/cmd/add_gen_bls_test.go @@ -37,7 +37,7 @@ func Test_AddGenBlsCmdWithoutGentx(t *testing.T) { tmcfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := app.MakeEncodingConfig().Marshaler + appCodec := app.GetEncodingConfig().Marshaler err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/cmd/babylond/cmd/genaccounts_test.go b/cmd/babylond/cmd/genaccounts_test.go index 148ce8166..803df1f55 100644 --- a/cmd/babylond/cmd/genaccounts_test.go +++ b/cmd/babylond/cmd/genaccounts_test.go @@ -74,7 +74,7 @@ func TestAddGenesisAccountCmd(t *testing.T) { cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := app.MakeEncodingConfig().Marshaler + appCodec := app.GetEncodingConfig().Marshaler err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/cmd/babylond/cmd/genbls_test.go b/cmd/babylond/cmd/genbls_test.go index d2e0a52a2..5f7379a55 100644 --- a/cmd/babylond/cmd/genbls_test.go +++ b/cmd/babylond/cmd/genbls_test.go @@ -28,7 +28,7 @@ import ( func Test_GenBlsCmd(t *testing.T) { home := t.TempDir() - encodingConfig := app.MakeEncodingConfig() + encodingConfig := app.GetEncodingConfig() logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) diff --git a/cmd/babylond/cmd/root.go b/cmd/babylond/cmd/root.go index bca56a194..43429f7f3 100644 --- a/cmd/babylond/cmd/root.go +++ b/cmd/babylond/cmd/root.go @@ -40,7 +40,7 @@ import ( // NewRootCmd creates a new root command for babylond. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - encodingConfig := app.MakeEncodingConfig() + encodingConfig := app.GetEncodingConfig() initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). diff --git a/cmd/babylond/cmd/testnet_test.go b/cmd/babylond/cmd/testnet_test.go index 3c235cf1a..1fc62f834 100644 --- a/cmd/babylond/cmd/testnet_test.go +++ b/cmd/babylond/cmd/testnet_test.go @@ -20,7 +20,7 @@ import ( func Test_TestnetCmd(t *testing.T) { home := t.TempDir() - encodingConfig := app.MakeEncodingConfig() + encodingConfig := app.GetEncodingConfig() logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) diff --git a/cmd/babylond/cmd/validate_genesis_test.go b/cmd/babylond/cmd/validate_genesis_test.go index e61fc93d2..aae452917 100644 --- a/cmd/babylond/cmd/validate_genesis_test.go +++ b/cmd/babylond/cmd/validate_genesis_test.go @@ -26,7 +26,7 @@ import ( func TestCheckCorrespondence(t *testing.T) { homePath := t.TempDir() - encodingCft := app.MakeEncodingConfig() + encodingCft := app.GetEncodingConfig() clientCtx := client.Context{}.WithCodec(encodingCft.Marshaler).WithTxConfig(encodingCft.TxConfig) // generate valid genesis doc @@ -85,7 +85,7 @@ func TestCheckCorrespondence(t *testing.T) { } func generateTestGenesisState(home string, n int) (map[string]json.RawMessage, *tmtypes.GenesisDoc) { - encodingConfig := app.MakeEncodingConfig() + encodingConfig := app.GetEncodingConfig() logger := log.NewNopLogger() cfg, _ := genutiltest.CreateDefaultTendermintConfig(home) diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index af355bdd7..797931399 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -39,7 +39,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { if err != nil { b.Fatal(err) } - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -93,7 +93,7 @@ func BenchmarkInvariants(b *testing.B) { if err != nil { b.Fatal(err) } - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( diff --git a/simapp/sim_test.go b/simapp/sim_test.go index beaeeae3a..4bab4fd39 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -79,7 +79,7 @@ func TestFullAppSimulation(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // run randomized simulation @@ -119,7 +119,7 @@ func TestAppImportExport(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // Run randomized simulation @@ -159,7 +159,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", newBabylon.Name()) var genesisState app.GenesisState @@ -223,7 +223,7 @@ func TestAppSimulationAfterImport(t *testing.T) { privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", babylon.Name()) // Run randomized simulation @@ -268,7 +268,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) + newBabylon := app.NewBabylonApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "BabylonApp", newBabylon.Name()) newBabylon.InitChain(abci.RequestInitChain{ @@ -321,7 +321,7 @@ func TestAppStateDeterminism(t *testing.T) { db := dbm.NewMemDB() privSigner, err := app.SetupPrivSigner() require.NoError(t, err) - babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.MakeEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) + babylon := app.NewBabylonApp(logger, db, nil, true, map[int64]bool{}, app.DefaultNodeHome, FlagPeriodValue, app.GetEncodingConfig(), privSigner, sdksimapp.EmptyAppOptions{}, interBlockCacheOpt()) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/test/e2e/util/codec.go b/test/e2e/util/codec.go index f0a0abc46..73e4bb911 100644 --- a/test/e2e/util/codec.go +++ b/test/e2e/util/codec.go @@ -22,7 +22,7 @@ func init() { } func initEncodingConfigAndCdc() (params.EncodingConfig, codec.Codec) { - encodingConfig := babylonApp.MakeEncodingConfig() + encodingConfig := babylonApp.GetEncodingConfig() encodingConfig.InterfaceRegistry.RegisterImplementations( (*sdk.Msg)(nil), diff --git a/test/utils.go b/test/utils.go index c20b077c7..12bfec43b 100644 --- a/test/utils.go +++ b/test/utils.go @@ -38,7 +38,7 @@ func NewTestTxSender( genesisPath string, conn *grpc.ClientConn, ) (*TestTxSender, error) { - cfg := app.MakeEncodingConfig() + cfg := app.GetEncodingConfig() kb, err := keyring.New("babylond", "test", keyringPath, nil, cfg.Marshaler) diff --git a/x/checkpointing/client/cli/tx_test.go b/x/checkpointing/client/cli/tx_test.go index e4ed90073..155627884 100644 --- a/x/checkpointing/client/cli/tx_test.go +++ b/x/checkpointing/client/cli/tx_test.go @@ -71,7 +71,7 @@ type CLITestSuite struct { } func (s *CLITestSuite) SetupSuite() { - s.encCfg = app.MakeEncodingConfig() + s.encCfg = app.GetEncodingConfig() s.kr = keyring.NewInMemory(s.encCfg.Marshaler) ctrl := gomock.NewController(s.T()) mockAccountRetriever := mocks.NewMockAccountRetriever(ctrl) diff --git a/x/epoching/simulation/decoder_test.go b/x/epoching/simulation/decoder_test.go index 831886e52..79f173215 100644 --- a/x/epoching/simulation/decoder_test.go +++ b/x/epoching/simulation/decoder_test.go @@ -27,7 +27,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := app.MakeEncodingConfig().Marshaler + cdc := app.GetEncodingConfig().Marshaler dec := simulation.NewDecodeStore(cdc) epochNumber := uint64(123) diff --git a/x/zoneconcierge/keeper/keeper_test.go b/x/zoneconcierge/keeper/keeper_test.go index 830206240..eb69f4f86 100644 --- a/x/zoneconcierge/keeper/keeper_test.go +++ b/x/zoneconcierge/keeper/keeper_test.go @@ -21,7 +21,7 @@ func SetupTest(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *i ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(t, false) bbnApp = babylonApp - encCdc := app.MakeEncodingConfig() + encCdc := app.GetEncodingConfig() genesis := app.NewDefaultGenesisState(encCdc.Marshaler) return babylonApp, genesis } diff --git a/x/zoneconcierge/keeper/proof_tx_in_block_test.go b/x/zoneconcierge/keeper/proof_tx_in_block_test.go index 1042ac9f6..889121542 100644 --- a/x/zoneconcierge/keeper/proof_tx_in_block_test.go +++ b/x/zoneconcierge/keeper/proof_tx_in_block_test.go @@ -19,7 +19,7 @@ import ( func TestProveTxInBlock(t *testing.T) { // setup virtual network cfg := network.DefaultConfig() - encodingCfg := app.MakeEncodingConfig() + encodingCfg := app.GetEncodingConfig() cfg.InterfaceRegistry = encodingCfg.InterfaceRegistry cfg.TxConfig = encodingCfg.TxConfig cfg.NumValidators = 2 diff --git a/x/zoneconcierge/module_ibc_packet_test.go b/x/zoneconcierge/module_ibc_packet_test.go index e431b6d1a..01f56aacb 100644 --- a/x/zoneconcierge/module_ibc_packet_test.go +++ b/x/zoneconcierge/module_ibc_packet_test.go @@ -18,7 +18,7 @@ func (suite *ZoneConciergeTestSuite) SetupTestForIBCPackets() { ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(suite.T(), false) suite.zcKeeper = babylonApp.ZoneConciergeKeeper - encCdc := app.MakeEncodingConfig() + encCdc := app.GetEncodingConfig() genesis := app.NewDefaultGenesisState(encCdc.Marshaler) return babylonApp, genesis } diff --git a/x/zoneconcierge/module_test.go b/x/zoneconcierge/module_test.go index 4d9cf9a13..b15dc3320 100644 --- a/x/zoneconcierge/module_test.go +++ b/x/zoneconcierge/module_test.go @@ -66,7 +66,7 @@ func (suite *ZoneConciergeTestSuite) SetupTest() { ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(suite.T(), false) suite.zcKeeper = babylonApp.ZoneConciergeKeeper - encCdc := app.MakeEncodingConfig() + encCdc := app.GetEncodingConfig() return babylonApp, app.NewDefaultGenesisState(encCdc.Marshaler) } babylonChainID := ibctesting.GetChainID(1) From 3827a9660ef01426c68ddb8d2c0fda7f549d9a20 Mon Sep 17 00:00:00 2001 From: Fangyu Gai Date: Tue, 21 Feb 2023 12:18:59 +0800 Subject: [PATCH 4/4] remove config files --- babylon/config/app.toml | 262 --------------------- babylon/config/client.toml | 17 -- babylon/config/config.toml | 466 ------------------------------------- 3 files changed, 745 deletions(-) delete mode 100644 babylon/config/app.toml delete mode 100644 babylon/config/client.toml delete mode 100644 babylon/config/config.toml diff --git a/babylon/config/app.toml b/babylon/config/app.toml deleted file mode 100644 index d56079b31..000000000 --- a/babylon/config/app.toml +++ /dev/null @@ -1,262 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -############################################################################### -### Base Configuration ### -############################################################################### - -# The minimum gas prices a validator is willing to accept for processing a -# transaction. A transaction's fees must meet the minimum of any denomination -# specified in this config (e.g. 0.25token1;0.0001token2). -minimum-gas-prices = "0bbn" - -# default: the last 362880 states are kept, pruning at 10 block intervals -# nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) -# everything: 2 latest states will be kept; pruning at 10 block intervals. -# custom: allow pruning options to be manually specified through 'pruning-keep-recent', and 'pruning-interval' -pruning = "default" - -# These are applied if and only if the pruning strategy is custom. -pruning-keep-recent = "0" -pruning-interval = "0" - -# HaltHeight contains a non-zero block height at which a node will gracefully -# halt and shutdown that can be used to assist upgrades and testing. -# -# Note: Commitment of state will be attempted on the corresponding block. -halt-height = 0 - -# HaltTime contains a non-zero minimum block time (in Unix seconds) at which -# a node will gracefully halt and shutdown that can be used to assist upgrades -# and testing. -# -# Note: Commitment of state will be attempted on the corresponding block. -halt-time = 0 - -# MinRetainBlocks defines the minimum block height offset from the current -# block being committed, such that all blocks past this offset are pruned -# from Tendermint. It is used as part of the process of determining the -# ResponseCommit.RetainHeight value during ABCI Commit. A value of 0 indicates -# that no blocks should be pruned. -# -# This configuration value is only responsible for pruning Tendermint blocks. -# It has no bearing on application state pruning which is determined by the -# "pruning-*" configurations. -# -# Note: Tendermint block pruning is dependant on this parameter in conunction -# with the unbonding (safety threshold) period, state pruning and state sync -# snapshot parameters to determine the correct minimum value of -# ResponseCommit.RetainHeight. -min-retain-blocks = 0 - -# InterBlockCache enables inter-block caching. -inter-block-cache = true - -# IndexEvents defines the set of events in the form {eventType}.{attributeKey}, -# which informs Tendermint what to index. If empty, all events will be indexed. -# -# Example: -# ["message.sender", "message.recipient"] -index-events = [] - -# IavlCacheSize set the size of the iavl tree cache. -# Default cache size is 50mb. -iavl-cache-size = 781250 - -# IavlDisableFastNode enables or disables the fast node feature of IAVL. -# Default is false. -iavl-disable-fastnode = false - -# AppDBBackend defines the database backend type to use for the application and snapshots DBs. -# An empty string indicates that a fallback will be used. -# First fallback is the deprecated compile-time types.DBBackend value. -# Second fallback (if the types.DBBackend also isn't set), is the db-backend value set in Tendermint's config.toml. -app-db-backend = "" - -############################################################################### -### Telemetry Configuration ### -############################################################################### - -[telemetry] - -# Prefixed with keys to separate services. -service-name = "" - -# Enabled enables the application telemetry functionality. When enabled, -# an in-memory sink is also enabled by default. Operators may also enabled -# other sinks such as Prometheus. -enabled = false - -# Enable prefixing gauge values with hostname. -enable-hostname = false - -# Enable adding hostname to labels. -enable-hostname-label = false - -# Enable adding service to labels. -enable-service-label = false - -# PrometheusRetentionTime, when positive, enables a Prometheus metrics sink. -prometheus-retention-time = 0 - -# GlobalLabels defines a global set of name/value label tuples applied to all -# metrics emitted using the wrapper functions defined in telemetry package. -# -# Example: -# [["chain_id", "cosmoshub-1"]] -global-labels = [ -] - -############################################################################### -### API Configuration ### -############################################################################### - -[api] - -# Enable defines if the API server should be enabled. -enable = false - -# Swagger defines if swagger documentation should automatically be registered. -swagger = false - -# Address defines the API server to listen on. -address = "tcp://0.0.0.0:1317" - -# MaxOpenConnections defines the number of maximum open connections. -max-open-connections = 1000 - -# RPCReadTimeout defines the Tendermint RPC read timeout (in seconds). -rpc-read-timeout = 10 - -# RPCWriteTimeout defines the Tendermint RPC write timeout (in seconds). -rpc-write-timeout = 0 - -# RPCMaxBodyBytes defines the Tendermint maximum response body (in bytes). -rpc-max-body-bytes = 1000000 - -# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). -enabled-unsafe-cors = false - -############################################################################### -### Rosetta Configuration ### -############################################################################### - -[rosetta] - -# Enable defines if the Rosetta API server should be enabled. -enable = false - -# Address defines the Rosetta API server to listen on. -address = ":8080" - -# Network defines the name of the blockchain that will be returned by Rosetta. -blockchain = "app" - -# Network defines the name of the network that will be returned by Rosetta. -network = "network" - -# Retries defines the number of retries when connecting to the node before failing. -retries = 3 - -# Offline defines if Rosetta server should run in offline mode. -offline = false - -# EnableDefaultSuggestedFee defines if the server should suggest fee by default. -# If 'construction/medata' is called without gas limit and gas price, -# suggested fee based on gas-to-suggest and denom-to-suggest will be given. -enable-fee-suggestion = false - -# GasToSuggest defines gas limit when calculating the fee -gas-to-suggest = 200000 - -# DenomToSuggest defines the defult denom for fee suggestion. -# Price must be in minimum-gas-prices. -denom-to-suggest = "uatom" - -############################################################################### -### gRPC Configuration ### -############################################################################### - -[grpc] - -# Enable defines if the gRPC server should be enabled. -enable = true - -# Address defines the gRPC server address to bind to. -address = "0.0.0.0:9090" - -# MaxRecvMsgSize defines the max message size in bytes the server can receive. -# The default value is 10MB. -max-recv-msg-size = "10485760" - -# MaxSendMsgSize defines the max message size in bytes the server can send. -# The default value is math.MaxInt32. -max-send-msg-size = "2147483647" - -############################################################################### -### gRPC Web Configuration ### -############################################################################### - -[grpc-web] - -# GRPCWebEnable defines if the gRPC-web should be enabled. -# NOTE: gRPC must also be enabled, otherwise, this configuration is a no-op. -enable = true - -# Address defines the gRPC-web server address to bind to. -address = "0.0.0.0:9091" - -# EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk). -enable-unsafe-cors = false - -############################################################################### -### State Sync Configuration ### -############################################################################### - -# State sync snapshots allow other nodes to rapidly join the network without replaying historical -# blocks, instead downloading and applying a snapshot of the application state at a given height. -[state-sync] - -# snapshot-interval specifies the block interval at which local state sync snapshots are -# taken (0 to disable). -snapshot-interval = 0 - -# snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). -snapshot-keep-recent = 2 - -############################################################################### -### Store / State Streaming ### -############################################################################### - -[store] -streamers = [] - -[streamers] -[streamers.file] -keys = ["*", ] -write_dir = "" -prefix = "" - -############################################################################### -### Babylon Bitcoin configuration ### -############################################################################### - -[btc-config] - -# Configures which bitcoin network should be used for checkpointing -# valid values are: [mainnet, testnet, simnet, regtest] -network = "mainnet" - - -# Configures what tag should be prepended to op_return data in btc transaction -# for it to be considered as valid babylon checkpoint. Must have exactly 4 bytes. -checkpoint-tag = "bbtm" - -[signer-config] - -# Configures which key that the BLS signer uses to sign BLS-sig transactions -key-name = "default" -# Configures the gas-price that the signer would like to pay -gas-price = "0.01ubbn" -# Configures the adjustment of the gas cost of estimation -gas-adjustment = "1.5" diff --git a/babylon/config/client.toml b/babylon/config/client.toml deleted file mode 100644 index 3eb226310..000000000 --- a/babylon/config/client.toml +++ /dev/null @@ -1,17 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -############################################################################### -### Client Configuration ### -############################################################################### - -# The network chain ID -chain-id = "bbn-test1" -# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) -keyring-backend = "os" -# CLI output format (text|json) -output = "text" -# : to Tendermint RPC interface for this chain -node = "tcp://localhost:26657" -# Transaction broadcasting mode (sync|async|block) -broadcast-mode = "sync" diff --git a/babylon/config/config.toml b/babylon/config/config.toml deleted file mode 100644 index 0ca5d9683..000000000 --- a/babylon/config/config.toml +++ /dev/null @@ -1,466 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -# NOTE: Any path below can be absolute (e.g. "/var/myawesomeapp/data") or -# relative to the home directory (e.g. "data"). The home directory is -# "$HOME/.tendermint" by default, but could be changed via $TMHOME env variable -# or --home cmd flag. - -####################################################################### -### Main Base Config Options ### -####################################################################### - -# TCP or UNIX socket address of the ABCI application, -# or the name of an ABCI application compiled in with the Tendermint binary -proxy_app = "tcp://127.0.0.1:26658" - -# A custom human readable name for this node -moniker = "lanpos-MacBook-Pro.local" - -# If this node is many blocks behind the tip of the chain, FastSync -# allows them to catchup quickly by downloading blocks in parallel -# and verifying their commits -fast_sync = true - -# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb -# * goleveldb (github.com/syndtr/goleveldb - most popular implementation) -# - pure go -# - stable -# * cleveldb (uses levigo wrapper) -# - fast -# - requires gcc -# - use cleveldb build tag (go build -tags cleveldb) -# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt) -# - EXPERIMENTAL -# - may be faster is some use-cases (random reads - indexer) -# - use boltdb build tag (go build -tags boltdb) -# * rocksdb (uses github.com/tecbot/gorocksdb) -# - EXPERIMENTAL -# - requires gcc -# - use rocksdb build tag (go build -tags rocksdb) -# * badgerdb (uses github.com/dgraph-io/badger) -# - EXPERIMENTAL -# - use badgerdb build tag (go build -tags badgerdb) -db_backend = "goleveldb" - -# Database directory -db_dir = "data" - -# Output level for logging, including package level options -log_level = "info" - -# Output format: 'plain' (colored text) or 'json' -log_format = "plain" - -##### additional base config options ##### - -# Path to the JSON file containing the initial validator set and other meta data -genesis_file = "config/genesis.json" - -# Path to the JSON file containing the private key to use as a validator in the consensus protocol -priv_validator_key_file = "config/priv_validator_key.json" - -# Path to the JSON file containing the last sign state of a validator -priv_validator_state_file = "data/priv_validator_state.json" - -# TCP or UNIX socket address for Tendermint to listen on for -# connections from an external PrivValidator process -priv_validator_laddr = "" - -# Path to the JSON file containing the private key to use for node authentication in the p2p protocol -node_key_file = "config/node_key.json" - -# Mechanism to connect to the ABCI application: socket | grpc -abci = "socket" - -# If true, query the ABCI app on connecting to a new peer -# so the app can decide if we should keep the connection or not -filter_peers = false - - -####################################################################### -### Advanced Configuration Options ### -####################################################################### - -####################################################### -### RPC Server Configuration Options ### -####################################################### -[rpc] - -# TCP or UNIX socket address for the RPC server to listen on -laddr = "tcp://127.0.0.1:26657" - -# A list of origins a cross-domain request can be executed from -# Default value '[]' disables cors support -# Use '["*"]' to allow any origin -cors_allowed_origins = [] - -# A list of methods the client is allowed to use with cross-domain requests -cors_allowed_methods = ["HEAD", "GET", "POST", ] - -# A list of non simple headers the client is allowed to use with cross-domain requests -cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time", ] - -# TCP or UNIX socket address for the gRPC server to listen on -# NOTE: This server only supports /broadcast_tx_commit -grpc_laddr = "" - -# Maximum number of simultaneous connections. -# Does not include RPC (HTTP&WebSocket) connections. See max_open_connections -# If you want to accept a larger number than the default, make sure -# you increase your OS limits. -# 0 - unlimited. -# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} -# 1024 - 40 - 10 - 50 = 924 = ~900 -grpc_max_open_connections = 900 - -# Activate unsafe RPC commands like /dial_seeds and /unsafe_flush_mempool -unsafe = false - -# Maximum number of simultaneous connections (including WebSocket). -# Does not include gRPC connections. See grpc_max_open_connections -# If you want to accept a larger number than the default, make sure -# you increase your OS limits. -# 0 - unlimited. -# Should be < {ulimit -Sn} - {MaxNumInboundPeers} - {MaxNumOutboundPeers} - {N of wal, db and other open files} -# 1024 - 40 - 10 - 50 = 924 = ~900 -max_open_connections = 900 - -# Maximum number of unique clientIDs that can /subscribe -# If you're using /broadcast_tx_commit, set to the estimated maximum number -# of broadcast_tx_commit calls per block. -max_subscription_clients = 100 - -# Maximum number of unique queries a given client can /subscribe to -# If you're using GRPC (or Local RPC client) and /broadcast_tx_commit, set to -# the estimated # maximum number of broadcast_tx_commit calls per block. -max_subscriptions_per_client = 5 - -# Experimental parameter to specify the maximum number of events a node will -# buffer, per subscription, before returning an error and closing the -# subscription. Must be set to at least 100, but higher values will accommodate -# higher event throughput rates (and will use more memory). -experimental_subscription_buffer_size = 200 - -# Experimental parameter to specify the maximum number of RPC responses that -# can be buffered per WebSocket client. If clients cannot read from the -# WebSocket endpoint fast enough, they will be disconnected, so increasing this -# parameter may reduce the chances of them being disconnected (but will cause -# the node to use more memory). -# -# Must be at least the same as "experimental_subscription_buffer_size", -# otherwise connections could be dropped unnecessarily. This value should -# ideally be somewhat higher than "experimental_subscription_buffer_size" to -# accommodate non-subscription-related RPC responses. -experimental_websocket_write_buffer_size = 200 - -# If a WebSocket client cannot read fast enough, at present we may -# silently drop events instead of generating an error or disconnecting the -# client. -# -# Enabling this experimental parameter will cause the WebSocket connection to -# be closed instead if it cannot read fast enough, allowing for greater -# predictability in subscription behaviour. -experimental_close_on_slow_client = false - -# How long to wait for a tx to be committed during /broadcast_tx_commit. -# WARNING: Using a value larger than 10s will result in increasing the -# global HTTP write timeout, which applies to all connections and endpoints. -# See https://github.com/tendermint/tendermint/issues/3435 -timeout_broadcast_tx_commit = "10s" - -# Maximum size of request body, in bytes -max_body_bytes = 1000000 - -# Maximum size of request header, in bytes -max_header_bytes = 1048576 - -# The path to a file containing certificate that is used to create the HTTPS server. -# Might be either absolute path or path related to Tendermint's config directory. -# If the certificate is signed by a certificate authority, -# the certFile should be the concatenation of the server's certificate, any intermediates, -# and the CA's certificate. -# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. -# Otherwise, HTTP server is run. -tls_cert_file = "" - -# The path to a file containing matching private key that is used to create the HTTPS server. -# Might be either absolute path or path related to Tendermint's config directory. -# NOTE: both tls-cert-file and tls-key-file must be present for Tendermint to create HTTPS server. -# Otherwise, HTTP server is run. -tls_key_file = "" - -# pprof listen address (https://golang.org/pkg/net/http/pprof) -pprof_laddr = "localhost:6060" - -####################################################### -### P2P Configuration Options ### -####################################################### -[p2p] - -# Address to listen for incoming connections -laddr = "tcp://0.0.0.0:26656" - -# Address to advertise to peers for them to dial -# If empty, will use the same port as the laddr, -# and will introspect on the listener or use UPnP -# to figure out the address. ip and port are required -# example: 159.89.10.97:26656 -external_address = "" - -# Comma separated list of seed nodes to connect to -seeds = "" - -# Comma separated list of nodes to keep persistent connections to -persistent_peers = "" - -# UPNP port forwarding -upnp = false - -# Path to address book -addr_book_file = "config/addrbook.json" - -# Set true for strict address routability rules -# Set false for private or local networks -addr_book_strict = true - -# Maximum number of inbound peers -max_num_inbound_peers = 40 - -# Maximum number of outbound peers to connect to, excluding persistent peers -max_num_outbound_peers = 10 - -# List of node IDs, to which a connection will be (re)established ignoring any existing limits -unconditional_peer_ids = "" - -# Maximum pause when redialing a persistent peer (if zero, exponential backoff is used) -persistent_peers_max_dial_period = "0s" - -# Time to wait before flushing messages out on the connection -flush_throttle_timeout = "100ms" - -# Maximum size of a message packet payload, in bytes -max_packet_msg_payload_size = 1024 - -# Rate at which packets can be sent, in bytes/second -send_rate = 5120000 - -# Rate at which packets can be received, in bytes/second -recv_rate = 5120000 - -# Set true to enable the peer-exchange reactor -pex = true - -# Seed mode, in which node constantly crawls the network and looks for -# peers. If another node asks it for addresses, it responds and disconnects. -# -# Does not work if the peer-exchange reactor is disabled. -seed_mode = false - -# Comma separated list of peer IDs to keep private (will not be gossiped to other peers) -private_peer_ids = "" - -# Toggle to disable guard against peers connecting from the same ip. -allow_duplicate_ip = false - -# Peer connection configuration. -handshake_timeout = "20s" -dial_timeout = "3s" - -####################################################### -### Mempool Configuration Option ### -####################################################### -[mempool] - -# Mempool version to use: -# 1) "v0" - (default) FIFO mempool. -# 2) "v1" - prioritized mempool. -version = "v0" - -recheck = true -broadcast = true -wal_dir = "" - -# Maximum number of transactions in the mempool -size = 5000 - -# Limit the total size of all txs in the mempool. -# This only accounts for raw transactions (e.g. given 1MB transactions and -# max_txs_bytes=5MB, mempool will only accept 5 transactions). -max_txs_bytes = 1073741824 - -# Size of the cache (used to filter transactions we saw earlier) in transactions -cache_size = 10000 - -# Do not remove invalid transactions from the cache (default: false) -# Set to true if it's not possible for any invalid transaction to become valid -# again in the future. -keep-invalid-txs-in-cache = false - -# Maximum size of a single transaction. -# NOTE: the max size of a tx transmitted over the network is {max_tx_bytes}. -max_tx_bytes = 1048576 - -# Maximum size of a batch of transactions to send to a peer -# Including space needed by encoding (one varint per transaction). -# XXX: Unused due to https://github.com/tendermint/tendermint/issues/5796 -max_batch_bytes = 0 - -# ttl-duration, if non-zero, defines the maximum amount of time a transaction -# can exist for in the mempool. -# -# Note, if ttl-num-blocks is also defined, a transaction will be removed if it -# has existed in the mempool at least ttl-num-blocks number of blocks or if it's -# insertion time into the mempool is beyond ttl-duration. -ttl-duration = "0s" - -# ttl-num-blocks, if non-zero, defines the maximum number of blocks a transaction -# can exist for in the mempool. -# -# Note, if ttl-duration is also defined, a transaction will be removed if it -# has existed in the mempool at least ttl-num-blocks number of blocks or if -# it's insertion time into the mempool is beyond ttl-duration. -ttl-num-blocks = 0 - -####################################################### -### State Sync Configuration Options ### -####################################################### -[statesync] -# State sync rapidly bootstraps a new node by discovering, fetching, and restoring a state machine -# snapshot from peers instead of fetching and replaying historical blocks. Requires some peers in -# the network to take and serve state machine snapshots. State sync is not attempted if the node -# has any local state (LastBlockHeight > 0). The node will have a truncated block history, -# starting from the height of the snapshot. -enable = false - -# RPC servers (comma-separated) for light client verification of the synced state machine and -# retrieval of state data for node bootstrapping. Also needs a trusted height and corresponding -# header hash obtained from a trusted source, and a period during which validators can be trusted. -# -# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2 -# weeks) during which they can be financially punished (slashed) for misbehavior. -rpc_servers = "" -trust_height = 0 -trust_hash = "" -trust_period = "168h0m0s" - -# Time to spend discovering snapshots before initiating a restore. -discovery_time = "15s" - -# Temporary directory for state sync snapshot chunks, defaults to the OS tempdir (typically /tmp). -# Will create a new, randomly named directory within, and remove it when done. -temp_dir = "" - -# The timeout duration before re-requesting a chunk, possibly from a different -# peer (default: 1 minute). -chunk_request_timeout = "10s" - -# The number of concurrent chunk fetchers to run (default: 1). -chunk_fetchers = "4" - -####################################################### -### Fast Sync Configuration Connections ### -####################################################### -[fastsync] - -# Fast Sync version to use: -# 1) "v0" (default) - the legacy fast sync implementation -# 2) "v1" - refactor of v0 version for better testability -# 2) "v2" - complete redesign of v0, optimized for testability & readability -version = "v0" - -####################################################### -### Consensus Configuration Options ### -####################################################### -[consensus] - -wal_file = "data/cs.wal/wal" - -# How long we wait for a proposal block before prevoting nil -timeout_propose = "3s" -# How much timeout_propose increases with each round -timeout_propose_delta = "500ms" -# How long we wait after receiving +2/3 prevotes for “anything” (ie. not a single block or nil) -timeout_prevote = "1s" -# How much the timeout_prevote increases with each round -timeout_prevote_delta = "500ms" -# How long we wait after receiving +2/3 precommits for “anything” (ie. not a single block or nil) -timeout_precommit = "1s" -# How much the timeout_precommit increases with each round -timeout_precommit_delta = "500ms" -# How long we wait after committing a block, before starting on the new -# height (this gives us a chance to receive some more precommits, even -# though we already have +2/3). -timeout_commit = "5s" - -# How many blocks to look back to check existence of the node's consensus votes before joining consensus -# When non-zero, the node will panic upon restart -# if the same consensus key was used to sign {double_sign_check_height} last blocks. -# So, validators should stop the state machine, wait for some blocks, and then restart the state machine to avoid panic. -double_sign_check_height = 0 - -# Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) -skip_timeout_commit = false - -# EmptyBlocks mode and possible interval between empty blocks -create_empty_blocks = true -create_empty_blocks_interval = "0s" - -# Reactor sleep duration parameters -peer_gossip_sleep_duration = "100ms" -peer_query_maj23_sleep_duration = "2s" - -####################################################### -### Storage Configuration Options ### -####################################################### -[storage] - -# Set to true to discard ABCI responses from the state store, which can save a -# considerable amount of disk space. Set to false to ensure ABCI responses are -# persisted. ABCI responses are required for /block_results RPC queries, and to -# reindex events in the command-line tool. -discard_abci_responses = false - -####################################################### -### Transaction Indexer Configuration Options ### -####################################################### -[tx_index] - -# What indexer to use for transactions -# -# The application will set which txs to index. In some cases a node operator will be able -# to decide which txs to index based on configuration set in the application. -# -# Options: -# 1) "null" -# 2) "kv" (default) - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend). -# - When "kv" is chosen "tx.height" and "tx.hash" will always be indexed. -# 3) "psql" - the indexer services backed by PostgreSQL. -# When "kv" or "psql" is chosen "tx.height" and "tx.hash" will always be indexed. -indexer = "kv" - -# The PostgreSQL connection configuration, the connection format: -# postgresql://:@:/? -psql-conn = "" - -####################################################### -### Instrumentation Configuration Options ### -####################################################### -[instrumentation] - -# When true, Prometheus metrics are served under /metrics on -# PrometheusListenAddr. -# Check out the documentation for the list of available metrics. -prometheus = false - -# Address to listen for Prometheus collector(s) connections -prometheus_listen_addr = ":26660" - -# Maximum number of simultaneous connections. -# If you want to accept a larger number than the default, make sure -# you increase your OS limits. -# 0 - unlimited. -max_open_connections = 3 - -# Instrumentation namespace -namespace = "tendermint"