From 860581028f33f314c9467bc82737800138cfc88f Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Wed, 18 Sep 2024 15:15:38 +0530 Subject: [PATCH 1/6] add config params --- keeper/abci.go | 7 +++-- keeper/keeper.go | 35 ++++++++++++++++++------ keeper/msg_server.go | 2 +- keeper/vote_extension.go | 2 +- relayer/config.go | 58 ++++++++++++++++++++++++---------------- relayer/publish.go | 4 +-- relayer/relayer.go | 28 +++++++++++-------- simapp/app/app.go | 2 ++ 8 files changed, 90 insertions(+), 48 deletions(-) diff --git a/keeper/abci.go b/keeper/abci.go index b9e84b5..02fb8f4 100644 --- a/keeper/abci.go +++ b/keeper/abci.go @@ -106,7 +106,7 @@ func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) err provenHeight := k.GetProvenHeightFromStore(ctx) fromHeight := provenHeight + 1 - endHeight := min(fromHeight+uint64(k.MaxBlocksForBlob), uint64(ctx.BlockHeight())) // exclusive i.e [fromHeight, endHeight) + endHeight := min(fromHeight+uint64(k.relayer.MaxBlobBlocks), uint64(ctx.BlockHeight())) // exclusive i.e [fromHeight, endHeight) // Calculate pending range of blocks to post data sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -134,7 +134,10 @@ func (k *Keeper) IsValidBlockToPostTODA(height uint64) bool { return false } - if (height-1)%k.PublishToAvailBlockInterval != 0 { + fmt.Println("******* intervallllll.......", k.relayer.PublishBlockInterval, (height-1)%k.relayer.PublishBlockInterval) + + if (height-1)%k.relayer.PublishBlockInterval != 0 { // TODO : check this condition, if the node height is 40 and start cada + fmt.Println("insideeeee........") return false } diff --git a/keeper/keeper.go b/keeper/keeper.go index bd5d509..8210832 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -1,11 +1,15 @@ package keeper import ( + "fmt" + "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,10 +33,12 @@ type Keeper struct { cdc codec.BinaryCodec - PublishToAvailBlockInterval uint64 - MaxBlocksForBlob uint - VotingInterval uint64 - appID int + // PublishToAvailBlockInterval uint64 + // MaxBlocksForBlob uint + // VotingInterval uint64 + appID int + // CosmosNodeRPC string + // AvailLightClientURL string unprovenBlocks map[int64][]byte @@ -46,8 +52,18 @@ func NewKeeper( uk *upgradekeeper.Keeper, key storetypes2.StoreKey, appID int, + appOpts servertypes.AppOptions, + logger log.Logger, ) *Keeper { sb := collections.NewSchemaBuilder(storeService) + // cfg := relayer.AvailConfigFromAppOpts(appOpts) + + relayer, err := relayer.NewRelayer(logger, cdc, appOpts) + if err != nil { + fmt.Println("error while getting relayer config") + return nil + } + fmt.Println("relayer config.........", relayer) return &Keeper{ upgradeKeeper: uk, @@ -64,10 +80,13 @@ func NewKeeper( 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, + unprovenBlocks: make(map[int64][]byte), + // MaxBlocksForBlob: uint(cfg.MaxBlobBlocks), + // PublishToAvailBlockInterval: cfg.BlobInterval, + // VotingInterval: cfg.VoteInterval, + // CosmosNodeRPC: cfg.CosmosNodeRPC, + // AvailLightClientURL: cfg.LightClientURL, + relayer: relayer, } } diff --git a/keeper/msg_server.go b/keeper/msg_server.go index 0e79f33..b3ac62f 100644 --- a/keeper/msg_server.go +++ b/keeper/msg_server.go @@ -44,7 +44,7 @@ func (s msgServer) UpdateBlobStatus(ctx context.Context, req *types.MsgUpdateBlo } else { currentHeight := sdkCtx.BlockHeight() UpdateAvailHeight(sdkCtx, store, req.AvailHeight) // updates avail height at which the blocks got submitted to DA - UpdateVotingEndHeight(sdkCtx, store, uint64(currentHeight)+s.k.VotingInterval) + UpdateVotingEndHeight(sdkCtx, store, uint64(currentHeight)+s.k.relayer.VoteInterval) } UpdateBlobStatus(sdkCtx, store, newStatus) diff --git a/keeper/vote_extension.go b/keeper/vote_extension.go index 10c6ea7..7f10522 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.AvailLightClientURL) // 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/config.go b/relayer/config.go index d937770..0e6c364 100644 --- a/relayer/config.go +++ b/relayer/config.go @@ -1,8 +1,6 @@ package relayer import ( - "time" - servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/spf13/cast" ) @@ -15,6 +13,9 @@ const ( FlagSeed = "avail-seed" FlagLightClientURL = "avail.light-client-url" FlagCosmosNodeRPC = "avail.cosmos-node-rpc" + FlagMaxBlobBlocks = "avail.max-blob-blocks" + FlagBlobInterval = "avail.blob-interval" + FlagVoteInterval = "avail.vote-interval" DefaultConfigTemplate = ` @@ -29,23 +30,33 @@ const ( # 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" + + # 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 + 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 ` ) 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", + ChainID: "avail-1", + Seed: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice", + AppID: 0, + CosmosNodeRPC: "http://127.0.0.1:26657", + MaxBlobBlocks: 20, + BlobInterval: 10, + VoteInterval: 5, + LightClientURL: "http://127.0.0.1:8000", } // AvailConfig defines the configuration for the in-process Avail relayer. @@ -59,27 +70,28 @@ type AvailConfig struct { // 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"` + + MaxBlobBlocks uint64 `json:"max-blob-blocks"` + + BlobInterval uint64 `json:"blob-interval"` + + VoteInterval uint64 `json:"vote-interval"` } 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)), + 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)), + BlobInterval: cast.ToUint64(appOpts.Get(FlagBlobInterval)), + VoteInterval: cast.ToUint64(appOpts.Get(FlagVoteInterval)), } } diff --git a/relayer/publish.go b/relayer/publish.go index 1d16548..d678eff 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.PublishBlockInterval) != 0 { return nil } var blocks []int64 - for block := height - int64(r.availPublishBlockInterval); block < height; block++ { + for block := height - int64(r.PublishBlockInterval); block < height; block++ { // this could be false after a genesis restart if block > provenHeight { blocks = append(blocks, block) diff --git a/relayer/relayer.go b/relayer/relayer.go index 30b8b8f..d32c78f 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -35,9 +35,12 @@ type Relayer struct { availChainID string - availPublishBlockInterval int - availLastQueriedHeight int64 - availAppID int + PublishBlockInterval uint64 + AvailLastQueriedHeight int64 + availAppID int + MaxBlobBlocks uint64 + VoteInterval uint64 + AvailLightClientURL string } // NewRelayer creates a new Relayer instance @@ -61,18 +64,21 @@ func NewRelayer( return &Relayer{ logger: logger, - pollInterval: cfg.ProofQueryInterval, + // 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, + 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, + PublishBlockInterval: cfg.BlobInterval, + MaxBlobBlocks: cfg.MaxBlobBlocks, + VoteInterval: cfg.VoteInterval, + AvailLightClientURL: cfg.LightClientURL, }, nil } diff --git a/simapp/app/app.go b/simapp/app/app.go index 5c11f7f..125d0d8 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -692,6 +692,8 @@ func NewChainApp( app.UpgradeKeeper, keys[availblob1.StoreKey], AvailAppID, + appOpts, + logger, ) app.Availblobrelayer, err = availblobrelayer.NewRelayer( From ba493cf873da83c672759c0a5c38252ac0d0f124 Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Wed, 18 Sep 2024 16:02:03 +0530 Subject: [PATCH 2/6] fix --- keeper/abci.go | 5 +---- keeper/keeper.go | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/keeper/abci.go b/keeper/abci.go index 02fb8f4..858bfa2 100644 --- a/keeper/abci.go +++ b/keeper/abci.go @@ -106,7 +106,7 @@ func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) err provenHeight := k.GetProvenHeightFromStore(ctx) fromHeight := provenHeight + 1 - endHeight := min(fromHeight+uint64(k.relayer.MaxBlobBlocks), uint64(ctx.BlockHeight())) // exclusive i.e [fromHeight, endHeight) + endHeight := min(fromHeight+k.relayer.MaxBlobBlocks, uint64(ctx.BlockHeight())) // exclusive i.e [fromHeight, endHeight) // Calculate pending range of blocks to post data sdkCtx := sdk.UnwrapSDKContext(ctx) @@ -134,10 +134,7 @@ func (k *Keeper) IsValidBlockToPostTODA(height uint64) bool { return false } - fmt.Println("******* intervallllll.......", k.relayer.PublishBlockInterval, (height-1)%k.relayer.PublishBlockInterval) - if (height-1)%k.relayer.PublishBlockInterval != 0 { // TODO : check this condition, if the node height is 40 and start cada - fmt.Println("insideeeee........") return false } diff --git a/keeper/keeper.go b/keeper/keeper.go index 8210832..f45e891 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -63,7 +63,6 @@ func NewKeeper( fmt.Println("error while getting relayer config") return nil } - fmt.Println("relayer config.........", relayer) return &Keeper{ upgradeKeeper: uk, From 8a804ee4fd73defa61ee6c8a4651a116d065736a Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 19 Sep 2024 11:43:06 +0530 Subject: [PATCH 3/6] update config params --- keeper/abci.go | 6 ++--- keeper/keeper.go | 29 +++-------------------- keeper/msg_server.go | 2 +- keeper/vote_extension.go | 2 +- relayer/availclient.go | 4 ++-- relayer/config.go | 46 ++++++++++++++++++------------------ relayer/publish.go | 8 +++---- relayer/relayer.go | 29 ++++------------------- relayer/submit_data.go | 6 ++--- simapp/app/app.go | 19 ++++++++------- simapp/cmd/availd/commads.go | 2 +- 11 files changed, 56 insertions(+), 97 deletions(-) diff --git a/keeper/abci.go b/keeper/abci.go index 858bfa2..1435485 100644 --- a/keeper/abci.go +++ b/keeper/abci.go @@ -104,10 +104,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+k.relayer.MaxBlobBlocks, 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) @@ -134,7 +134,7 @@ func (k *Keeper) IsValidBlockToPostTODA(height uint64) bool { return false } - if (height-1)%k.relayer.PublishBlockInterval != 0 { // TODO : check this condition, if the node height is 40 and start cada + if (height-1)%k.relayer.AvailConfig.PublishBlobInterval != 0 { return false } diff --git a/keeper/keeper.go b/keeper/keeper.go index f45e891..7bd0b8a 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - "cosmossdk.io/collections" storetypes "cosmossdk.io/core/store" "cosmossdk.io/log" @@ -33,13 +31,6 @@ type Keeper struct { cdc codec.BinaryCodec - // PublishToAvailBlockInterval uint64 - // MaxBlocksForBlob uint - // VotingInterval uint64 - appID int - // CosmosNodeRPC string - // AvailLightClientURL string - unprovenBlocks map[int64][]byte proposerAddress []byte @@ -54,15 +45,9 @@ func NewKeeper( appID int, appOpts servertypes.AppOptions, logger log.Logger, + relayer *relayer.Relayer, ) *Keeper { sb := collections.NewSchemaBuilder(storeService) - // cfg := relayer.AvailConfigFromAppOpts(appOpts) - - relayer, err := relayer.NewRelayer(logger, cdc, appOpts) - if err != nil { - fmt.Println("error while getting relayer config") - return nil - } return &Keeper{ upgradeKeeper: uk, @@ -75,17 +60,9 @@ func NewKeeper( storeKey: key, - cdc: cdc, - - appID: appID, - + cdc: cdc, unprovenBlocks: make(map[int64][]byte), - // MaxBlocksForBlob: uint(cfg.MaxBlobBlocks), - // PublishToAvailBlockInterval: cfg.BlobInterval, - // VotingInterval: cfg.VoteInterval, - // CosmosNodeRPC: cfg.CosmosNodeRPC, - // AvailLightClientURL: cfg.LightClientURL, - relayer: relayer, + relayer: relayer, } } diff --git a/keeper/msg_server.go b/keeper/msg_server.go index b3ac62f..8de286e 100644 --- a/keeper/msg_server.go +++ b/keeper/msg_server.go @@ -44,7 +44,7 @@ func (s msgServer) UpdateBlobStatus(ctx context.Context, req *types.MsgUpdateBlo } else { currentHeight := sdkCtx.BlockHeight() UpdateAvailHeight(sdkCtx, store, req.AvailHeight) // updates avail height at which the blocks got submitted to DA - UpdateVotingEndHeight(sdkCtx, store, uint64(currentHeight)+s.k.relayer.VoteInterval) + UpdateVotingEndHeight(sdkCtx, store, uint64(currentHeight)+s.k.relayer.AvailConfig.VoteInterval) } UpdateBlobStatus(sdkCtx, store, newStatus) diff --git a/keeper/vote_extension.go b/keeper/vote_extension.go index 7f10522..8734ad5 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, h.Keeper.relayer.AvailLightClientURL) // 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/availclient.go b/relayer/availclient.go index 30e893b..b0be51a 100644 --- a/relayer/availclient.go +++ b/relayer/availclient.go @@ -2,11 +2,11 @@ package relayer // AvailClient is the client that handles data submission type AvailClient struct { - config AvailConfig + config AvailConfiguration } // NewAvailClient initializes a new AvailClient -func NewAvailClient(config AvailConfig) (*AvailClient, error) { +func NewAvailClient(config 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 index 0e6c364..6fbd472 100644 --- a/relayer/config.go +++ b/relayer/config.go @@ -14,7 +14,7 @@ const ( FlagLightClientURL = "avail.light-client-url" FlagCosmosNodeRPC = "avail.cosmos-node-rpc" FlagMaxBlobBlocks = "avail.max-blob-blocks" - FlagBlobInterval = "avail.blob-interval" + FlagPublishBlobInterval = "avail.publish-blob-interval" FlagVoteInterval = "avail.vote-interval" DefaultConfigTemplate = ` @@ -40,7 +40,7 @@ const ( max-blob-blocks = 10 # The frequency at which block data is posted to the Avail Network - blob-interval = 5 + 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 @@ -48,19 +48,19 @@ const ( ` ) -var DefaultAvailConfig = AvailConfig{ - ChainID: "avail-1", - Seed: "bottom drive obey lake curtain smoke basket hold race lonely fit walk//Alice", - AppID: 0, - CosmosNodeRPC: "http://127.0.0.1:26657", - MaxBlobBlocks: 20, - BlobInterval: 10, - VoteInterval: 5, - LightClientURL: "http://127.0.0.1:8000", +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", } // AvailConfig defines the configuration for the in-process Avail relayer. -type AvailConfig struct { +type AvailConfiguration struct { // avail light node url LightClientURL string `mapstructure:"light-client-url"` @@ -78,20 +78,20 @@ type AvailConfig struct { MaxBlobBlocks uint64 `json:"max-blob-blocks"` - BlobInterval uint64 `json:"blob-interval"` + PublishBlobInterval uint64 `json:"publish-blob-interval"` VoteInterval uint64 `json:"vote-interval"` } -func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfig { - return AvailConfig{ - 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)), - BlobInterval: cast.ToUint64(appOpts.Get(FlagBlobInterval)), - VoteInterval: cast.ToUint64(appOpts.Get(FlagVoteInterval)), +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)), } } diff --git a/relayer/publish.go b/relayer/publish.go index d678eff..42de8a1 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.PublishBlockInterval) != 0 { + if (height-1)%int64(r.AvailConfig.PublishBlobInterval) != 0 { return nil } var blocks []int64 - for block := height - int64(r.PublishBlockInterval); 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 diff --git a/relayer/relayer.go b/relayer/relayer.go index d32c78f..fae8262 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -29,18 +29,11 @@ type Relayer struct { submittedBlocksCache map[int64]bool - rpcClient *AvailClient localProvider *local.CosmosProvider clientCtx client.Context availChainID string - - PublishBlockInterval uint64 - AvailLastQueriedHeight int64 - availAppID int - MaxBlobBlocks uint64 - VoteInterval uint64 - AvailLightClientURL string + AvailConfig AvailConfiguration } // NewRelayer creates a new Relayer instance @@ -50,10 +43,6 @@ func NewRelayer( appOpts servertypes.AppOptions, ) (*Relayer, error) { cfg := AvailConfigFromAppOpts(appOpts) - client, err := NewAvailClient(cfg) - if err != nil { - return nil, err - } // local sdk-based chain provider localProvider, err := local.NewProvider(cdc, cfg.CosmosNodeRPC) @@ -64,21 +53,13 @@ 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, - PublishBlockInterval: cfg.BlobInterval, - MaxBlobBlocks: cfg.MaxBlobBlocks, - VoteInterval: cfg.VoteInterval, - AvailLightClientURL: cfg.LightClientURL, + localProvider: localProvider, + availChainID: cfg.ChainID, + submittedBlocksCache: make(map[int64]bool), + 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 125d0d8..39dc3e8 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -686,6 +686,15 @@ func NewChainApp( AddRoute(icahosttypes.SubModuleName, icaHostStack) app.IBCKeeper.SetRouter(ibcRouter) + app.Availblobrelayer, err = availblobrelayer.NewRelayer( + logger, + appCodec, + appOpts, + ) + if err != nil { + panic(err) + } + app.AvailBlobKeeper = availblobkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[availblob1.StoreKey]), @@ -694,17 +703,9 @@ func NewChainApp( AvailAppID, appOpts, logger, + app.Availblobrelayer, ) - app.Availblobrelayer, err = availblobrelayer.NewRelayer( - logger, - appCodec, - appOpts, - ) - if err != nil { - panic(err) - } - // 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..6af7a54 100644 --- a/simapp/cmd/availd/commads.go +++ b/simapp/cmd/availd/commads.go @@ -63,7 +63,7 @@ func initAppConfig() (string, interface{}) { type CustomAppConfig struct { serverconfig.Config - Avail *relayer.AvailConfig `mapstructure:"avail"` + Avail *relayer.AvailConfiguration `mapstructure:"avail"` } // Optionally allow the chain developer to overwrite the SDK's default From 2b9a01babfff071ac9f2a5242bcaaaebd56edd4e Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 19 Sep 2024 12:33:49 +0530 Subject: [PATCH 4/6] fix avail config --- chainclient/broadcast_tx.go | 26 +++------ relayer/avail/codec.go | 47 ---------------- relayer/availclient.go | 6 +- relayer/publish.go | 6 +- relayer/relayer.go | 5 +- simapp/cmd/availd/commads.go | 10 ++-- relayer/config.go => types/avail_config.go | 64 +++++++++++++--------- 7 files changed, 63 insertions(+), 101 deletions(-) delete mode 100644 relayer/avail/codec.go rename relayer/config.go => types/avail_config.go (84%) diff --git a/chainclient/broadcast_tx.go b/chainclient/broadcast_tx.go index 8d7d77f..44ab486 100644 --- a/chainclient/broadcast_tx.go +++ b/chainclient/broadcast_tx.go @@ -12,35 +12,29 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "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) 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(config.DaemonHome) + 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 +68,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/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 b0be51a..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 AvailConfiguration + config types.AvailConfiguration } // NewAvailClient initializes a new AvailClient -func NewAvailClient(config AvailConfiguration) (*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/publish.go b/relayer/publish.go index 42de8a1..75412da 100644 --- a/relayer/publish.go +++ b/relayer/publish.go @@ -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) 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) if err != nil { fmt.Println("error while submitting tx...", err) } diff --git a/relayer/relayer.go b/relayer/relayer.go index fae8262..a1114f6 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 ( @@ -33,7 +34,7 @@ type Relayer struct { clientCtx client.Context availChainID string - AvailConfig AvailConfiguration + AvailConfig types.AvailConfiguration } // NewRelayer creates a new Relayer instance @@ -42,7 +43,7 @@ func NewRelayer( cdc codec.BinaryCodec, appOpts servertypes.AppOptions, ) (*Relayer, error) { - cfg := AvailConfigFromAppOpts(appOpts) + cfg := types.AvailConfigFromAppOpts(appOpts) // local sdk-based chain provider localProvider, err := local.NewProvider(cdc, cfg.CosmosNodeRPC) diff --git a/simapp/cmd/availd/commads.go b/simapp/cmd/availd/commads.go index 6af7a54..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.AvailConfiguration `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/relayer/config.go b/types/avail_config.go similarity index 84% rename from relayer/config.go rename to types/avail_config.go index 6fbd472..f084ea3 100644 --- a/relayer/config.go +++ b/types/avail_config.go @@ -1,10 +1,36 @@ -package relayer +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"` + DaemonHome string `json:"daemon-home"` +} + const ( FlagChainID = "avail.chain-id" FlagOverrideAppID = "avail.override-app-id" @@ -16,6 +42,8 @@ const ( FlagMaxBlobBlocks = "avail.max-blob-blocks" FlagPublishBlobInterval = "avail.publish-blob-interval" FlagVoteInterval = "avail.vote-interval" + FlagValidatorKey = "avail.validator-key" + FlagDaemonHome = "avail.daemon-home" DefaultConfigTemplate = ` @@ -45,6 +73,12 @@ const ( # 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" + + # It is the name of the daemon home (ex: .simapp) + daemon-home = ".availsdk" ` ) @@ -57,30 +91,8 @@ var DefaultAvailConfig = AvailConfiguration{ PublishBlobInterval: 10, VoteInterval: 5, LightClientURL: "http://127.0.0.1:8000", -} - -// 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: "alice", + DaemonHome: ".availsdk", } func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfiguration { @@ -93,5 +105,7 @@ func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfiguration { MaxBlobBlocks: cast.ToUint64(appOpts.Get(FlagMaxBlobBlocks)), PublishBlobInterval: cast.ToUint64(appOpts.Get(FlagPublishBlobInterval)), VoteInterval: cast.ToUint64(appOpts.Get(FlagVoteInterval)), + ValidatorKey: cast.ToString(appOpts.Get(FlagValidatorKey)), + DaemonHome: cast.ToString(appOpts.Get(FlagDaemonHome)), } } From 7bc42e22016acd688f5a6dae4fdfa06b7dc3c95d Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 19 Sep 2024 12:59:48 +0530 Subject: [PATCH 5/6] fix and refactor relayer --- chainclient/broadcast_tx.go | 5 ++--- keeper/keeper.go | 1 - relayer/publish.go | 4 ++-- relayer/relayer.go | 3 +++ simapp/app/app.go | 7 +------ types/avail_config.go | 11 ++++------- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/chainclient/broadcast_tx.go b/chainclient/broadcast_tx.go index 44ab486..0860b70 100644 --- a/chainclient/broadcast_tx.go +++ b/chainclient/broadcast_tx.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/vitwit/avail-da-module/types" ) @@ -26,10 +25,10 @@ func GetBinPath(daemon string) string { return availdHomePath } -func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec.BinaryCodec, config types.AvailConfiguration) 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/.simapp" - homePath := GetBinPath(config.DaemonHome) + homePath := GetBinPath(NodeDir) keyName := config.ValidatorKey rpcAddress := config.CosmosNodeRPC diff --git a/keeper/keeper.go b/keeper/keeper.go index 7bd0b8a..cde3aa1 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -42,7 +42,6 @@ func NewKeeper( storeService storetypes.KVStoreService, uk *upgradekeeper.Keeper, key storetypes2.StoreKey, - appID int, appOpts servertypes.AppOptions, logger log.Logger, relayer *relayer.Relayer, diff --git a/relayer/publish.go b/relayer/publish.go index 75412da..41e6515 100644 --- a/relayer/publish.go +++ b/relayer/publish.go @@ -97,7 +97,7 @@ func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCo }, // AvailHeight: uint64(blockInfo.BlockNumber), IsSuccess: false, - }, cdc, r.AvailConfig) + }, cdc, r.AvailConfig, r.NodeDir) if err != nil { fmt.Println("error while submitting tx...", err) } @@ -117,7 +117,7 @@ func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCo } // execute tx about successful submission - err = dacli.ExecuteTX(ctx, msg, cdc, r.AvailConfig) + 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 a1114f6..c4e99d9 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -35,6 +35,7 @@ type Relayer struct { availChainID string AvailConfig types.AvailConfiguration + NodeDir string } // NewRelayer creates a new Relayer instance @@ -42,6 +43,7 @@ func NewRelayer( logger log.Logger, cdc codec.BinaryCodec, appOpts servertypes.AppOptions, + nodeDir string, ) (*Relayer, error) { cfg := types.AvailConfigFromAppOpts(appOpts) @@ -60,6 +62,7 @@ func NewRelayer( localProvider: localProvider, availChainID: cfg.ChainID, submittedBlocksCache: make(map[int64]bool), + NodeDir: nodeDir, AvailConfig: cfg, }, nil } diff --git a/simapp/app/app.go b/simapp/app/app.go index 39dc3e8..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. @@ -690,6 +685,7 @@ func NewChainApp( logger, appCodec, appOpts, + NodeDir, ) if err != nil { panic(err) @@ -700,7 +696,6 @@ func NewChainApp( runtime.NewKVStoreService(keys[availblob1.StoreKey]), app.UpgradeKeeper, keys[availblob1.StoreKey], - AvailAppID, appOpts, logger, app.Availblobrelayer, diff --git a/types/avail_config.go b/types/avail_config.go index f084ea3..897af29 100644 --- a/types/avail_config.go +++ b/types/avail_config.go @@ -28,7 +28,7 @@ type AvailConfiguration struct { VoteInterval uint64 `json:"vote-interval"` ValidatorKey string `json:"validator-key"` - DaemonHome string `json:"daemon-home"` + // CosmosNodeDir string `json:"cosmos-node-dir"` } const ( @@ -43,7 +43,7 @@ const ( FlagPublishBlobInterval = "avail.publish-blob-interval" FlagVoteInterval = "avail.vote-interval" FlagValidatorKey = "avail.validator-key" - FlagDaemonHome = "avail.daemon-home" + FlagCosmosNodeDir = "avail.cosmos-node-dir" DefaultConfigTemplate = ` @@ -76,9 +76,6 @@ const ( # It is the keyname of the cosmos validator account to sign the transactions validator-key = "alice" - - # It is the name of the daemon home (ex: .simapp) - daemon-home = ".availsdk" ` ) @@ -92,7 +89,7 @@ var DefaultAvailConfig = AvailConfiguration{ VoteInterval: 5, LightClientURL: "http://127.0.0.1:8000", ValidatorKey: "alice", - DaemonHome: ".availsdk", + // CosmosNodeDir: ".availsdk", } func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfiguration { @@ -106,6 +103,6 @@ func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfiguration { PublishBlobInterval: cast.ToUint64(appOpts.Get(FlagPublishBlobInterval)), VoteInterval: cast.ToUint64(appOpts.Get(FlagVoteInterval)), ValidatorKey: cast.ToString(appOpts.Get(FlagValidatorKey)), - DaemonHome: cast.ToString(appOpts.Get(FlagDaemonHome)), + // CosmosNodeDir: cast.ToString(appOpts.Get(FlagCosmosNodeDir)), } } From 2f9e5b9d586d260e00a752d545f1eec4e723da33 Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 19 Sep 2024 13:04:04 +0530 Subject: [PATCH 6/6] fix lint --- chainclient/broadcast_tx.go | 4 ++-- keeper/keeper.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chainclient/broadcast_tx.go b/chainclient/broadcast_tx.go index 0860b70..38e5c64 100644 --- a/chainclient/broadcast_tx.go +++ b/chainclient/broadcast_tx.go @@ -25,10 +25,10 @@ func GetBinPath(daemon string) string { return availdHomePath } -func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec.BinaryCodec, config types.AvailConfiguration, NodeDir string) 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/.simapp" - homePath := GetBinPath(NodeDir) + homePath := GetBinPath(nodeDir) keyName := config.ValidatorKey rpcAddress := config.CosmosNodeRPC diff --git a/keeper/keeper.go b/keeper/keeper.go index cde3aa1..02f948d 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -42,8 +42,8 @@ func NewKeeper( storeService storetypes.KVStoreService, uk *upgradekeeper.Keeper, key storetypes2.StoreKey, - appOpts servertypes.AppOptions, - logger log.Logger, + _ servertypes.AppOptions, + _ log.Logger, relayer *relayer.Relayer, ) *Keeper { sb := collections.NewSchemaBuilder(storeService)