diff --git a/chainclient/broadcast_tx.go b/chainclient/broadcast_tx.go index 8d7d77f..38e5c64 100644 --- a/chainclient/broadcast_tx.go +++ b/chainclient/broadcast_tx.go @@ -15,32 +15,25 @@ import ( "github.com/vitwit/avail-da-module/types" ) -func GetBinPath() string { +func GetBinPath(daemon string) string { homeDir, err := os.UserHomeDir() if err != nil { log.Fatal(err) } - availdHomePath := filepath.Join(homeDir, ".availsdk") + availdHomePath := filepath.Join(homeDir, daemon) return availdHomePath } -func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec.BinaryCodec) error { +func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec.BinaryCodec, config types.AvailConfiguration, nodeDir string) error { // Define keyring and RPC client configuration - - // homePath := "/home/vitwit/.availsdk" - homePath := GetBinPath() - key := os.Getenv("KEY") - keyName := key - - if keyName == "" { - keyName = "alice" - } - - rpcAddress := "http://localhost:26657" + // homePath := "/home/vitwit/.simapp" + homePath := GetBinPath(nodeDir) + keyName := config.ValidatorKey + rpcAddress := config.CosmosNodeRPC // Create a keyring - kr, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, homePath, os.Stdin, cdc.(codec.Codec)) + kr, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, homePath, os.Stdin, cdc.(codec.Codec)) // TODO : update keyring backend type if err != nil { return fmt.Errorf("error creating keyring: %w", err) } @@ -74,8 +67,6 @@ func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec. return fmt.Errorf("error retrieving account: %w", err) } - fmt.Println("account details......", account.GetAccountNumber(), account.GetSequence()) - // Set the correct account number and sequence factory := NewFactory(clientCtx). WithAccountNumber(account.GetAccountNumber()). diff --git a/keeper/abci.go b/keeper/abci.go index 4609866..d7ba9e2 100644 --- a/keeper/abci.go +++ b/keeper/abci.go @@ -106,10 +106,10 @@ func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) err return nil } + // Calculate pending range of blocks to post data provenHeight := k.GetProvenHeightFromStore(ctx) fromHeight := provenHeight + 1 - endHeight := min(fromHeight+uint64(k.MaxBlocksForBlob), uint64(ctx.BlockHeight())) // exclusive i.e [fromHeight, endHeight) - // Calculate pending range of blocks to post data + endHeight := min(fromHeight+k.relayer.AvailConfig.MaxBlobBlocks, uint64(ctx.BlockHeight())) // exclusive i.e [fromHeight, endHeight) sdkCtx := sdk.UnwrapSDKContext(ctx) ok := k.SetBlobStatusPending(sdkCtx, fromHeight, endHeight-1) @@ -136,7 +136,7 @@ func (k *Keeper) IsValidBlockToPostTODA(height uint64) bool { return false } - if (height-1)%k.PublishToAvailBlockInterval != 0 { + if (height-1)%k.relayer.AvailConfig.PublishBlobInterval != 0 { return false } diff --git a/keeper/keeper.go b/keeper/keeper.go index bd5d509..02f948d 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -3,9 +3,11 @@ package keeper import ( "cosmossdk.io/collections" storetypes "cosmossdk.io/core/store" + "cosmossdk.io/log" storetypes2 "cosmossdk.io/store/types" upgradekeeper "cosmossdk.io/x/upgrade/keeper" "github.com/cosmos/cosmos-sdk/codec" + servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" availblob1 "github.com/vitwit/avail-da-module" @@ -29,11 +31,6 @@ type Keeper struct { cdc codec.BinaryCodec - PublishToAvailBlockInterval uint64 - MaxBlocksForBlob uint - VotingInterval uint64 - appID int - unprovenBlocks map[int64][]byte proposerAddress []byte @@ -45,7 +42,9 @@ func NewKeeper( storeService storetypes.KVStoreService, uk *upgradekeeper.Keeper, key storetypes2.StoreKey, - appID int, + _ servertypes.AppOptions, + _ log.Logger, + relayer *relayer.Relayer, ) *Keeper { sb := collections.NewSchemaBuilder(storeService) @@ -60,14 +59,9 @@ func NewKeeper( storeKey: key, - cdc: cdc, - - appID: appID, - - unprovenBlocks: make(map[int64][]byte), - MaxBlocksForBlob: 20, // Todo: call this from app.go, later change to params - PublishToAvailBlockInterval: 5, // Todo: call this from app.go, later change to params - VotingInterval: 5, + cdc: cdc, + unprovenBlocks: make(map[int64][]byte), + relayer: relayer, } } diff --git a/keeper/msg_server.go b/keeper/msg_server.go index 81671f8..c82e227 100644 --- a/keeper/msg_server.go +++ b/keeper/msg_server.go @@ -45,7 +45,7 @@ func (s msgServer) UpdateBlobStatus(ctx context.Context, req *types.MsgUpdateBlo currentHeight := sdkCtx.BlockHeight() UpdateAvailHeight(sdkCtx, store, req.AvailHeight) // updates avail height at which the blocks got submitted to DA lastVotingEndHeight := s.k.GetVotingEndHeightFromStore(sdkCtx, false) - UpdateVotingEndHeight(sdkCtx, store, uint64(currentHeight)+s.k.VotingInterval, false) + UpdateVotingEndHeight(sdkCtx, store, uint64(currentHeight)+s.k.relayer.AvailConfig.VoteInterval, false) UpdateVotingEndHeight(sdkCtx, store, lastVotingEndHeight, true) } diff --git a/keeper/vote_extension.go b/keeper/vote_extension.go index 199fcb2..8a6ff14 100644 --- a/keeper/vote_extension.go +++ b/keeper/vote_extension.go @@ -64,7 +64,7 @@ func (h *VoteExtHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { return abciResponseVoteExt, nil } - ok, err := h.Keeper.relayer.IsDataAvailable(ctx, from, end, availHeight, "http://localhost:8000") // TODO: read light client url from config + ok, err := h.Keeper.relayer.IsDataAvailable(ctx, from, end, availHeight, h.Keeper.relayer.AvailConfig.LightClientURL) // TODO: read light client url from config if ok { h.logger.Info("submitted data to Avail verified successfully at", "block_height", availHeight, diff --git a/relayer/avail/codec.go b/relayer/avail/codec.go deleted file mode 100644 index 6f092e5..0000000 --- a/relayer/avail/codec.go +++ /dev/null @@ -1,47 +0,0 @@ -package avail - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/auth" - authz "github.com/cosmos/cosmos-sdk/x/authz/module" - "github.com/cosmos/cosmos-sdk/x/distribution" -) - -var ModuleBasics = []module.AppModuleBasic{ - auth.AppModuleBasic{}, - authz.AppModuleBasic{}, - - distribution.AppModuleBasic{}, -} - -type Codec struct { - InterfaceRegistry types.InterfaceRegistry - Marshaler codec.Codec - TxConfig client.TxConfig - Amino *codec.LegacyAmino -} - -// func makeCodec(moduleBasics []module.AppModuleBasic) Codec { -// modBasic := module.NewBasicManager(moduleBasics...) -// encodingConfig := makeCodecConfig() -// std.RegisterLegacyAminoCodec(encodingConfig.Amino) -// std.RegisterInterfaces(encodingConfig.InterfaceRegistry) -// modBasic.RegisterLegacyAminoCodec(encodingConfig.Amino) -// modBasic.RegisterInterfaces(encodingConfig.InterfaceRegistry) - -// return encodingConfig -// } - -// func makeCodecConfig() Codec { -// interfaceRegistry := types.NewInterfaceRegistry() -// marshaler := codec.NewProtoCodec(interfaceRegistry) -// return Codec{ -// InterfaceRegistry: interfaceRegistry, -// Marshaler: marshaler, -// TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes), -// Amino: codec.NewLegacyAmino(), -// } -// } diff --git a/relayer/availclient.go b/relayer/availclient.go index 30e893b..d4695d0 100644 --- a/relayer/availclient.go +++ b/relayer/availclient.go @@ -1,12 +1,14 @@ package relayer +import "github.com/vitwit/avail-da-module/types" + // AvailClient is the client that handles data submission type AvailClient struct { - config AvailConfig + config types.AvailConfiguration } // NewAvailClient initializes a new AvailClient -func NewAvailClient(config AvailConfig) (*AvailClient, error) { +func NewAvailClient(config types.AvailConfiguration) (*AvailClient, error) { // api, err := gsrpc.NewSubstrateAPI(config.AppRpcURL) // if err != nil { // return nil, fmt.Errorf("cannot create api:%w", err) diff --git a/relayer/config.go b/relayer/config.go deleted file mode 100644 index d937770..0000000 --- a/relayer/config.go +++ /dev/null @@ -1,85 +0,0 @@ -package relayer - -import ( - "time" - - servertypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/spf13/cast" -) - -const ( - FlagChainID = "avail.chain-id" - FlagOverrideAppID = "avail.override-app-id" - FlagOverridePubInterval = "avail.override-pub-interval" - FlagQueryInterval = "avail.proof-query-interval" - FlagSeed = "avail-seed" - FlagLightClientURL = "avail.light-client-url" - FlagCosmosNodeRPC = "avail.cosmos-node-rpc" - - DefaultConfigTemplate = ` - - [avail] - - # Avail light client node url for posting data - light-client-url = "http://127.0.0.1:8000" - - # Avail chain id - chain-id = "avail-1" - - # Overrides the expected avail app-id, test-only - override-app-id = "1" - - # Overrides the expected chain's publish-to-avail block interval, test-only - override-pub-interval = 5 - - # Seed for avail - seed = "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice" - - # RPC of cosmos node to get the block data - cosmos-node-rpc = "http://127.0.0.1:26657" - ` -) - -var DefaultAvailConfig = AvailConfig{ - ChainID: "avail-1", - ProofQueryInterval: 12 * time.Second, - Seed: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice", - AppID: 0, - CosmosNodeRPC: "http://127.0.0.1:26657", -} - -// AvailConfig defines the configuration for the in-process Avail relayer. -type AvailConfig struct { - // avail light node url - LightClientURL string `mapstructure:"light-client-url"` - - // avail chain ID - ChainID string `mapstructure:"chain-id"` - - // Overrides built-in app-id used - AppID int `mapstructure:"app-id"` - - // Overrides built-in publish-to-avail block interval - OverridePubInterval int `mapstructure:"override-pub-interval"` - - // Query avail for new block proofs this often - ProofQueryInterval time.Duration `mapstructure:"proof-query-interval"` - - // avail config - Seed string `json:"seed"` - - // RPC of the cosmos node to fetch the block data - CosmosNodeRPC string `json:"cosmos-node-rpc"` -} - -func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfig { - return AvailConfig{ - ChainID: cast.ToString(appOpts.Get(FlagChainID)), - AppID: cast.ToInt(appOpts.Get(FlagOverrideAppID)), - OverridePubInterval: cast.ToInt(appOpts.Get(FlagOverridePubInterval)), - ProofQueryInterval: cast.ToDuration(appOpts.Get(FlagQueryInterval)), - Seed: cast.ToString(appOpts.Get(FlagSeed)), - LightClientURL: cast.ToString(appOpts.Get(FlagLightClientURL)), - CosmosNodeRPC: cast.ToString(appOpts.Get(FlagCosmosNodeRPC)), - } -} diff --git a/relayer/publish.go b/relayer/publish.go index 1d16548..41e6515 100644 --- a/relayer/publish.go +++ b/relayer/publish.go @@ -18,12 +18,12 @@ func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []i } // only publish new blocks on interval - if (height-1)%int64(r.availPublishBlockInterval) != 0 { + if (height-1)%int64(r.AvailConfig.PublishBlobInterval) != 0 { return nil } var blocks []int64 - for block := height - int64(r.availPublishBlockInterval); block < height; block++ { + for block := height - int64(r.AvailConfig.PublishBlobInterval); block < height; block++ { // this could be false after a genesis restart if block > provenHeight { blocks = append(blocks, block) @@ -80,12 +80,12 @@ func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCo bb := r.GetBlocksDataFromLocal(ctx, blocks) - blockInfo, err := r.SubmitDataToAvailClient(r.rpcClient.config.Seed, r.rpcClient.config.AppID, bb, blocks, r.rpcClient.config.LightClientURL) + blockInfo, err := r.SubmitDataToAvailClient(r.AvailConfig.Seed, r.AvailConfig.AppID, bb, blocks, r.AvailConfig.LightClientURL) if err != nil { r.logger.Error("Error while submitting block(s) to Avail DA", "height_start", blocks[0], "height_end", blocks[len(blocks)-1], - "appID", strconv.Itoa(r.rpcClient.config.AppID), + "appID", strconv.Itoa(r.AvailConfig.AppID), ) // execute tx about failure submission @@ -97,7 +97,7 @@ func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCo }, // AvailHeight: uint64(blockInfo.BlockNumber), IsSuccess: false, - }, cdc) + }, cdc, r.AvailConfig, r.NodeDir) if err != nil { fmt.Println("error while submitting tx...", err) } @@ -116,8 +116,8 @@ func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCo IsSuccess: true, } - // TODO : execute tx about successful submission - err = dacli.ExecuteTX(ctx, msg, cdc) + // execute tx about successful submission + err = dacli.ExecuteTX(ctx, msg, cdc, r.AvailConfig, r.NodeDir) if err != nil { fmt.Println("error while submitting tx...", err) } diff --git a/relayer/relayer.go b/relayer/relayer.go index 30b8b8f..c4e99d9 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/vitwit/avail-da-module/relayer/local" + "github.com/vitwit/avail-da-module/types" ) const ( @@ -29,15 +30,12 @@ type Relayer struct { submittedBlocksCache map[int64]bool - rpcClient *AvailClient localProvider *local.CosmosProvider clientCtx client.Context availChainID string - - availPublishBlockInterval int - availLastQueriedHeight int64 - availAppID int + AvailConfig types.AvailConfiguration + NodeDir string } // NewRelayer creates a new Relayer instance @@ -45,12 +43,9 @@ func NewRelayer( logger log.Logger, cdc codec.BinaryCodec, appOpts servertypes.AppOptions, + nodeDir string, ) (*Relayer, error) { - cfg := AvailConfigFromAppOpts(appOpts) - client, err := NewAvailClient(cfg) - if err != nil { - return nil, err - } + cfg := types.AvailConfigFromAppOpts(appOpts) // local sdk-based chain provider localProvider, err := local.NewProvider(cdc, cfg.CosmosNodeRPC) @@ -61,18 +56,14 @@ func NewRelayer( return &Relayer{ logger: logger, - pollInterval: cfg.ProofQueryInterval, - provenHeights: make(chan int64, 10000), commitHeights: make(chan int64, 10000), - rpcClient: client, - localProvider: localProvider, - availChainID: cfg.ChainID, - availLastQueriedHeight: 1, // Defaults to 1, but init genesis can set this based on client state's latest height - submittedBlocksCache: make(map[int64]bool), - availAppID: cfg.AppID, - availPublishBlockInterval: 5, + localProvider: localProvider, + availChainID: cfg.ChainID, + submittedBlocksCache: make(map[int64]bool), + NodeDir: nodeDir, + AvailConfig: cfg, }, nil } diff --git a/relayer/submit_data.go b/relayer/submit_data.go index 730b4ad..313e90e 100644 --- a/relayer/submit_data.go +++ b/relayer/submit_data.go @@ -39,7 +39,7 @@ func (r *Relayer) SubmitDataToAvailClient(_ string, _ int, data []byte, blocks [ r.logger.Error("Error while posting block(s) to Avail DA", "height_start", blocks[0], "height_end", blocks[len(blocks)-1], - "appID", strconv.Itoa(r.rpcClient.config.AppID), + "appID", strconv.Itoa(r.AvailConfig.AppID), ) } @@ -47,7 +47,7 @@ func (r *Relayer) SubmitDataToAvailClient(_ string, _ int, data []byte, blocks [ r.logger.Info("Successfully posted block(s) to Avail DA", "height_start", blocks[0], "height_end", blocks[len(blocks)-1], - "appID", strconv.Itoa(r.rpcClient.config.AppID), + "appID", strconv.Itoa(r.AvailConfig.AppID), "block_hash", blockInfo.BlockHash, "block_number", blockInfo.BlockNumber, "hash", blockInfo.Hash, @@ -214,7 +214,7 @@ func (r *Relayer) SubmitDataToAvailDA(apiURL, seed string, availAppID int, data r.logger.Info("Posted block(s) to Avail DA", "height_start", blocks[0], "height_end", blocks[len(blocks)-1], - "appID", strconv.Itoa(r.rpcClient.config.AppID), + "appID", strconv.Itoa(r.AvailConfig.AppID), ) } diff --git a/simapp/app/app.go b/simapp/app/app.go index 5c11f7f..d161e4b 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -147,11 +147,6 @@ const ( appName = "avail-sdk" NodeDir = ".availsdk" Bech32Prefix = "cosmos" - // TODO: Change me - AvailAppID = 1 - - // publish blocks to avail every n rollchain blocks. - publishToAvailBlockInterval = 5 // smaller size == faster testing ) // These constants are derived from the above variables. @@ -686,23 +681,26 @@ func NewChainApp( AddRoute(icahosttypes.SubModuleName, icaHostStack) app.IBCKeeper.SetRouter(ibcRouter) - app.AvailBlobKeeper = availblobkeeper.NewKeeper( - appCodec, - runtime.NewKVStoreService(keys[availblob1.StoreKey]), - app.UpgradeKeeper, - keys[availblob1.StoreKey], - AvailAppID, - ) - app.Availblobrelayer, err = availblobrelayer.NewRelayer( logger, appCodec, appOpts, + NodeDir, ) if err != nil { panic(err) } + app.AvailBlobKeeper = availblobkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[availblob1.StoreKey]), + app.UpgradeKeeper, + keys[availblob1.StoreKey], + appOpts, + logger, + app.Availblobrelayer, + ) + // must be done after relayer is created app.AvailBlobKeeper.SetRelayer(app.Availblobrelayer) diff --git a/simapp/cmd/availd/commads.go b/simapp/cmd/availd/commads.go index c6f9538..89f639c 100644 --- a/simapp/cmd/availd/commads.go +++ b/simapp/cmd/availd/commads.go @@ -40,7 +40,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" availblobcli "github.com/vitwit/avail-da-module/client/cli" - "github.com/vitwit/avail-da-module/relayer" + availtypes "github.com/vitwit/avail-da-module/types" ) // initCometBFTConfig helps to override default CometBFT Config values. @@ -63,7 +63,7 @@ func initAppConfig() (string, interface{}) { type CustomAppConfig struct { serverconfig.Config - Avail *relayer.AvailConfig `mapstructure:"avail"` + Avail *availtypes.AvailConfiguration `mapstructure:"avail"` } // Optionally allow the chain developer to overwrite the SDK's default @@ -81,15 +81,15 @@ func initAppConfig() (string, interface{}) { // own app.toml to override, or use this default value. // // In simapp, we set the min gas prices to 0. - srvCfg.MinGasPrices = "0avail" + srvCfg.MinGasPrices = "0stake" // srvCfg.BaseConfig.IAVLDisableFastNode = true // disable fastnode by default customAppConfig := CustomAppConfig{ Config: *srvCfg, - Avail: &relayer.DefaultAvailConfig, + Avail: &availtypes.DefaultAvailConfig, } - customAppTemplate := serverconfig.DefaultConfigTemplate + relayer.DefaultConfigTemplate + customAppTemplate := serverconfig.DefaultConfigTemplate + availtypes.DefaultConfigTemplate return customAppTemplate, customAppConfig } diff --git a/types/avail_config.go b/types/avail_config.go new file mode 100644 index 0000000..897af29 --- /dev/null +++ b/types/avail_config.go @@ -0,0 +1,108 @@ +package types + +import ( + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/spf13/cast" +) + +// AvailConfig defines the configuration for the in-process Avail relayer. +type AvailConfiguration struct { + // avail light node url + LightClientURL string `mapstructure:"light-client-url"` + + // avail chain ID + ChainID string `mapstructure:"chain-id"` + + // Overrides built-in app-id used + AppID int `mapstructure:"app-id"` + + // avail config + Seed string `json:"seed"` + + // RPC of the cosmos node to fetch the block data + CosmosNodeRPC string `json:"cosmos-node-rpc"` + + MaxBlobBlocks uint64 `json:"max-blob-blocks"` + + PublishBlobInterval uint64 `json:"publish-blob-interval"` + + VoteInterval uint64 `json:"vote-interval"` + ValidatorKey string `json:"validator-key"` + // CosmosNodeDir string `json:"cosmos-node-dir"` +} + +const ( + FlagChainID = "avail.chain-id" + FlagOverrideAppID = "avail.override-app-id" + FlagOverridePubInterval = "avail.override-pub-interval" + FlagQueryInterval = "avail.proof-query-interval" + FlagSeed = "avail-seed" + FlagLightClientURL = "avail.light-client-url" + FlagCosmosNodeRPC = "avail.cosmos-node-rpc" + FlagMaxBlobBlocks = "avail.max-blob-blocks" + FlagPublishBlobInterval = "avail.publish-blob-interval" + FlagVoteInterval = "avail.vote-interval" + FlagValidatorKey = "avail.validator-key" + FlagCosmosNodeDir = "avail.cosmos-node-dir" + + DefaultConfigTemplate = ` + + [avail] + + # Avail light client node url for posting data + light-client-url = "http://127.0.0.1:8000" + + # Avail chain id + chain-id = "avail-1" + + # Overrides the expected avail app-id, test-only + override-app-id = "1" + + # Seed for avail + seed = "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice" + + # RPC of cosmos node to get the block data + cosmos-node-rpc = "http://127.0.0.1:26657" + + # Maximum number of blocks over which blobs can be processed + max-blob-blocks = 10 + + # The frequency at which block data is posted to the Avail Network + publish-blob-interval = 5 + + # It is the period before validators verify whether data is truly included in + # Avail and confirm it with the network using vote extension + vote-interval = 5 + + # It is the keyname of the cosmos validator account to sign the transactions + validator-key = "alice" + ` +) + +var DefaultAvailConfig = AvailConfiguration{ + ChainID: "avail-1", + Seed: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice", + AppID: 1, + CosmosNodeRPC: "http://127.0.0.1:26657", + MaxBlobBlocks: 20, + PublishBlobInterval: 10, + VoteInterval: 5, + LightClientURL: "http://127.0.0.1:8000", + ValidatorKey: "alice", + // CosmosNodeDir: ".availsdk", +} + +func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfiguration { + return AvailConfiguration{ + ChainID: cast.ToString(appOpts.Get(FlagChainID)), + AppID: cast.ToInt(appOpts.Get(FlagOverrideAppID)), + Seed: cast.ToString(appOpts.Get(FlagSeed)), + LightClientURL: cast.ToString(appOpts.Get(FlagLightClientURL)), + CosmosNodeRPC: cast.ToString(appOpts.Get(FlagCosmosNodeRPC)), + MaxBlobBlocks: cast.ToUint64(appOpts.Get(FlagMaxBlobBlocks)), + PublishBlobInterval: cast.ToUint64(appOpts.Get(FlagPublishBlobInterval)), + VoteInterval: cast.ToUint64(appOpts.Get(FlagVoteInterval)), + ValidatorKey: cast.ToString(appOpts.Get(FlagValidatorKey)), + // CosmosNodeDir: cast.ToString(appOpts.Get(FlagCosmosNodeDir)), + } +}