From fc380f2cfec4c01083a7ee99dbe99749cd5fa3e1 Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Fri, 2 Aug 2024 11:24:38 -0400 Subject: [PATCH 1/2] init --- clientcontroller/factory.go | 14 +++++++------- finality-provider/config/config.go | 6 +++--- finality-provider/service/app.go | 2 +- itest/cosmwasm/bcd/bcd_test_manager.go | 2 +- itest/cosmwasm/wasmd/wasmd_test_manager.go | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/clientcontroller/factory.go b/clientcontroller/factory.go index 1c962c9e..d2265fab 100644 --- a/clientcontroller/factory.go +++ b/clientcontroller/factory.go @@ -13,9 +13,9 @@ import ( ) const ( - BabylonConsumerChainName = "babylon" - OPStackL2ConsumerChainName = "OPStackL2" - WasmConsumerChainName = "wasm" + BabylonConsumerChainType = "babylon" + OPStackL2ConsumerChainType = "OPStackL2" + WasmConsumerChainType = "wasm" ) // NewClientController TODO: this is always going to be babylon so rename accordingly @@ -34,18 +34,18 @@ func NewConsumerController(config *fpcfg.Config, logger *zap.Logger) (api.Consum err error ) - switch config.ChainName { - case BabylonConsumerChainName: + switch config.ChainType { + case BabylonConsumerChainType: ccc, err = babylon.NewBabylonConsumerController(config.BabylonConfig, &config.BTCNetParams, logger) if err != nil { return nil, fmt.Errorf("failed to create Babylon rpc client: %w", err) } - case OPStackL2ConsumerChainName: + case OPStackL2ConsumerChainType: ccc, err = opstackl2.NewOPStackL2ConsumerController(config.OPStackL2Config, logger) if err != nil { return nil, fmt.Errorf("failed to create OPStack L2 consumer client: %w", err) } - case WasmConsumerChainName: + case WasmConsumerChainType: wasmEncodingCfg := cosmwasmcfg.GetWasmdEncodingConfig() ccc, err = cosmwasm.NewCosmwasmConsumerController(config.CosmwasmConfig, wasmEncodingCfg, logger) if err != nil { diff --git a/finality-provider/config/config.go b/finality-provider/config/config.go index 2afe7b53..bdc9c2ca 100644 --- a/finality-provider/config/config.go +++ b/finality-provider/config/config.go @@ -18,7 +18,7 @@ import ( ) const ( - defaultChainName = "babylon" + defaultChainType = "babylon" defaultLogLevel = zapcore.InfoLevel defaultLogDirname = "logs" defaultLogFilename = "fpd.log" @@ -55,7 +55,7 @@ var ( // Config is the main config for the fpd cli command type Config struct { LogLevel string `long:"loglevel" description:"Logging level for all subsystems" choice:"trace" choice:"debug" choice:"info" choice:"warn" choice:"error" choice:"fatal"` - ChainName string `long:"chainname" description:"the name of the consumer chain"` + ChainType string `long:"chaintype" description:"the type of the consumer chain"` NumPubRand uint64 `long:"numPubRand" description:"The number of Schnorr public randomness for each commitment"` NumPubRandMax uint64 `long:"numpubrandmax" description:"The upper bound of the number of Schnorr public randomness for each commitment"` MinRandHeightGap uint64 `long:"minrandheightgap" description:"The minimum gap between the last committed rand height and the current Babylon block height"` @@ -94,7 +94,7 @@ func DefaultConfigWithHome(homePath string) Config { bbnCfg.KeyDirectory = homePath pollerCfg := DefaultChainPollerConfig() cfg := Config{ - ChainName: defaultChainName, + ChainType: defaultChainType, LogLevel: defaultLogLevel.String(), DatabaseConfig: DefaultDBConfigWithHomePath(homePath), BabylonConfig: &bbnCfg, diff --git a/finality-provider/service/app.go b/finality-provider/service/app.go index e0bcf68f..73f56d8b 100644 --- a/finality-provider/service/app.go +++ b/finality-provider/service/app.go @@ -66,7 +66,7 @@ func NewFinalityProviderAppFromConfig( } consumerCon, err := fpcc.NewConsumerController(cfg, logger) if err != nil { - return nil, fmt.Errorf("failed to create rpc client for the consumer chain %s: %v", cfg.ChainName, err) + return nil, fmt.Errorf("failed to create rpc client for the consumer chain %s: %v", cfg.ChainType, err) } // if the EOTSManagerAddress is empty, run a local EOTS manager; // otherwise connect a remote one with a gRPC client diff --git a/itest/cosmwasm/bcd/bcd_test_manager.go b/itest/cosmwasm/bcd/bcd_test_manager.go index e1437eb5..d14f6a0a 100644 --- a/itest/cosmwasm/bcd/bcd_test_manager.go +++ b/itest/cosmwasm/bcd/bcd_test_manager.go @@ -91,7 +91,7 @@ func StartBcdTestManager(t *testing.T) *BcdTestManager { cfg.CosmwasmConfig.KeyDirectory = wh.dataDir // make random contract address for now to avoid validation errors, later we will update it with the correct address in the test cfg.CosmwasmConfig.BtcStakingContractAddress = datagen.GenRandomAccount().GetAddress().String() - cfg.ChainName = fpcc.WasmConsumerChainName + cfg.ChainType = fpcc.WasmConsumerChainType cfg.CosmwasmConfig.AccountPrefix = "bbnc" cfg.CosmwasmConfig.ChainID = bcdChainID cfg.CosmwasmConfig.RPCAddr = fmt.Sprintf("http://localhost:%d", bcdRpcPort) diff --git a/itest/cosmwasm/wasmd/wasmd_test_manager.go b/itest/cosmwasm/wasmd/wasmd_test_manager.go index c8c8d180..ebaeca40 100644 --- a/itest/cosmwasm/wasmd/wasmd_test_manager.go +++ b/itest/cosmwasm/wasmd/wasmd_test_manager.go @@ -78,7 +78,7 @@ func StartWasmdTestManager(t *testing.T) *WasmdTestManager { // later in the e2e tests we would upload the contract and update the addresses // investigate if there is a better way to handle this cfg.CosmwasmConfig.BtcStakingContractAddress = datagen.GenRandomAccount().GetAddress().String() - cfg.ChainName = fpcc.WasmConsumerChainName + cfg.ChainType = fpcc.WasmConsumerChainType cfg.CosmwasmConfig.AccountPrefix = "wasm" cfg.CosmwasmConfig.ChainID = wasmdChainID tempApp := wasmapp.NewWasmApp(sdklogs.NewNopLogger(), dbm.NewMemDB(), nil, false, simtestutil.NewAppOptionsWithFlagHome(t.TempDir()), []wasmkeeper.Option{}) From 4b115dce47b8d4abb42edc451552d7439fb2ad1e Mon Sep 17 00:00:00 2001 From: bap2pecs Date: Mon, 12 Aug 2024 22:39:46 -0400 Subject: [PATCH 2/2] comments --- finality-provider/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finality-provider/config/config.go b/finality-provider/config/config.go index bdc9c2ca..5e8856cd 100644 --- a/finality-provider/config/config.go +++ b/finality-provider/config/config.go @@ -55,7 +55,7 @@ var ( // Config is the main config for the fpd cli command type Config struct { LogLevel string `long:"loglevel" description:"Logging level for all subsystems" choice:"trace" choice:"debug" choice:"info" choice:"warn" choice:"error" choice:"fatal"` - ChainType string `long:"chaintype" description:"the type of the consumer chain"` + ChainType string `long:"chaintype" description:"the type of the consumer chain (babylon/OPStackL2/wasm)"` NumPubRand uint64 `long:"numPubRand" description:"The number of Schnorr public randomness for each commitment"` NumPubRandMax uint64 `long:"numpubrandmax" description:"The upper bound of the number of Schnorr public randomness for each commitment"` MinRandHeightGap uint64 `long:"minrandheightgap" description:"The minimum gap between the last committed rand height and the current Babylon block height"`