From 60329da483e161f57e0a503829649fab6f067b82 Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Fri, 20 Sep 2024 14:28:38 +0530 Subject: [PATCH 01/14] refactor code --- client/cli/keys.go | 29 --------------------------- client/cli/query.go | 4 ++-- client/client.go | 19 ------------------ keeper/abci.go | 39 +++++++++++++++++++++++------------- keeper/abciTypes.go | 15 -------------- simapp/cmd/availd/commads.go | 8 +------- 6 files changed, 28 insertions(+), 86 deletions(-) delete mode 100644 client/cli/keys.go delete mode 100644 client/client.go delete mode 100644 keeper/abciTypes.go diff --git a/client/cli/keys.go b/client/cli/keys.go deleted file mode 100644 index e777e62..0000000 --- a/client/cli/keys.go +++ /dev/null @@ -1,29 +0,0 @@ -package cli - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/spf13/cobra" - availblob "github.com/vitwit/avail-da-module" -) - -const ( - FlagPubKey = "pubkey" - FlagAddress = "address" - FlagLedger = "ledger" - FlagCoinType = "coin-type" -) - -// NewKeysCmd returns a root CLI command handler for all x/availblob keys commands. -func NewKeysCmd() *cobra.Command { - keysCmd := &cobra.Command{ - Use: availblob.ModuleName, - Short: availblob.ModuleName + " keys subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - } - - keysCmd.AddCommand() - - return keysCmd -} diff --git a/client/cli/query.go b/client/cli/query.go index d7ed55a..4037c0d 100644 --- a/client/cli/query.go +++ b/client/cli/query.go @@ -27,8 +27,8 @@ func GetQueryCmd() *cobra.Command { func GetLatestBlobStatusInfo() *cobra.Command { cmd := &cobra.Command{ Use: "get-da-status", - Short: "Show what range of blocks are being submitted and their status", - Long: `Show what range of blocks are being submitted and their status, + Short: "Shows what range of blocks are being submitted and their status", + Long: `Shows what range of blocks are being submitted and their status, `, Example: "simd query cada get-da-status", Args: cobra.ExactArgs(0), diff --git a/client/client.go b/client/client.go deleted file mode 100644 index 2dd67e8..0000000 --- a/client/client.go +++ /dev/null @@ -1,19 +0,0 @@ -package client - -const ( - KeyringBackendTest = "test" -) - -// ChainClient is client to interact with SPN. -type ChainClient struct { - Address string `json:"address"` - AddressPrefix string `json:"account_address_prefix"` - RPC string `json:"rpc"` - Key string `json:"key"` - Mnemonic string `json:"mnemonic"` - KeyringServiceName string `json:"keyring_service_name"` - HDPath string `json:"hd_path"` - Enabled bool `json:"enabled"` - ChainName string `json:"chain_name"` - Denom string `json:"denom"` -} diff --git a/keeper/abci.go b/keeper/abci.go index 466f973..656d467 100644 --- a/keeper/abci.go +++ b/keeper/abci.go @@ -10,6 +10,18 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// StakeWeightedVotes represents the aggregated stake-weighted votes from validators, +// along with the associated commit information for a specific consensus round. +type StakeWeightedVotes struct { + // A map where the key is the range of pending blocks(e.g. "1 10"), and the value is the + // validator's voting power. + Votes map[string]int64 + + // ExtendedCommitInfo Contains additional information about the commit phase, including + // vote extensions and details about the current consensus round. + ExtendedCommitInfo abci.ExtendedCommitInfo +} + // ProofOfBlobProposalHandler manages the proposal and vote extension logic related to // blob transactions in the consensus process. type ProofOfBlobProposalHandler struct { @@ -60,12 +72,13 @@ func (h *ProofOfBlobProposalHandler) PrepareProposal(ctx sdk.Context, req *abci. Votes: votes, ExtendedCommitInfo: req.LocalLastCommit, } - bz, err := json.Marshal(injectedVoteExtTx) - if err != nil { - fmt.Println("failed to encode injected vote extension tx", "err", err) - } - proposalTxs = append(proposalTxs, bz) + // if there is any another tx, it might give any marshelling error, so ignoring this err + bz, _ := json.Marshal(injectedVoteExtTx) + + // proposalTxs = append(proposalTxs, bz) + + proposalTxs = append([][]byte{bz}, proposalTxs...) return &abci.ResponsePrepareProposal{ Txs: proposalTxs, }, nil @@ -81,11 +94,12 @@ func (h *ProofOfBlobProposalHandler) ProcessProposal(_ sdk.Context, req *abci.Re var injectedVoteExtTx StakeWeightedVotes if err := json.Unmarshal(req.Txs[0], &injectedVoteExtTx); err != nil { - fmt.Println("failed to decode injected vote extension tx", "err", err) - // return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}, nil + // if there is any another tx, it might give any unmarshelling error, so ignoring this err + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil } // TODO: write some validations + // if injectedVoteExtTx.ExtendedCommitInfo != nil {// } return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil } @@ -99,9 +113,7 @@ func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) err if len(req.Txs) > 0 && currentHeight == int64(votingEndHeight) && blobStatus == InVotingState { var injectedVoteExtTx StakeWeightedVotes - if err := json.Unmarshal(req.Txs[0], &injectedVoteExtTx); err != nil { - fmt.Println("preblocker failed to decode injected vote extension tx", "err", err) - } else { + if err := json.Unmarshal(req.Txs[0], &injectedVoteExtTx); err == nil { from := k.GetStartHeightFromStore(ctx) to := k.GetEndHeightFromStore(ctx) @@ -121,7 +133,7 @@ func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) err } currentBlockHeight := ctx.BlockHeight() - if !k.IsValidBlockToPostTODA(uint64(currentBlockHeight)) { + if !k.IsValidBlockToPostToDA(uint64(currentBlockHeight)) { return nil } @@ -137,7 +149,6 @@ func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) err } var blocksToSumit []int64 - for i := fromHeight; i < endHeight; i++ { blocksToSumit = append(blocksToSumit, int64(i)) } @@ -150,9 +161,9 @@ func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) err return nil } -// IsValidBlockToPostTODA checks if the given block height is valid for posting data. +// IsValidBlockToPostToDA checks if the given block height is valid for posting data. // The block is considered valid if it meets the defined interval for posting. -func (k *Keeper) IsValidBlockToPostTODA(height uint64) bool { +func (k *Keeper) IsValidBlockToPostToDA(height uint64) bool { if height <= uint64(1) { return false } diff --git a/keeper/abciTypes.go b/keeper/abciTypes.go deleted file mode 100644 index 6369e5f..0000000 --- a/keeper/abciTypes.go +++ /dev/null @@ -1,15 +0,0 @@ -package keeper - -import abci "github.com/cometbft/cometbft/abci/types" - -// StakeWeightedVotes represents the aggregated stake-weighted votes from validators, -// along with the associated commit information for a specific consensus round. -type StakeWeightedVotes struct { - // A map where the key is the range of pending blocks(e.g. "1 10"), and the value is the - // validator's voting power. - Votes map[string]int64 - - // ExtendedCommitInfo Contains additional information about the commit phase, including - // vote extensions and details about the current consensus round. - ExtendedCommitInfo abci.ExtendedCommitInfo -} diff --git a/simapp/cmd/availd/commads.go b/simapp/cmd/availd/commads.go index 7aacef9..c10d56d 100644 --- a/simapp/cmd/availd/commads.go +++ b/simapp/cmd/availd/commads.go @@ -24,7 +24,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/snapshot" @@ -41,7 +40,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "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" availtypes "github.com/vitwit/avail-da-module/types" ) @@ -117,16 +115,12 @@ func initRootCmd( AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) - keysCmd := keys.Commands() - keysCmd.AddCommand(availblobcli.NewKeysCmd()) - - // add keybase, auxiliary RPC, query, genesis, and tx child commands + // add keybase, RPC, query, genesis, and tx child commands rootCmd.AddCommand( server.StatusCommand(), genesisCommand(txConfig, basicManager), queryCommand(), txCommand(), - keysCmd, resetCommand(), ) } From bbb9818b9ebb4acc3a39fda328007de73f48b6ac Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Fri, 20 Sep 2024 15:00:57 +0530 Subject: [PATCH 02/14] refactor --- keeper/{status.go => blob_status.go} | 2 +- keeper/collections.go | 183 ++++++--------------------- keeper/genesis.go | 24 +--- keeper/keeper.go | 21 ++- keeper/msg_server.go | 1 + keeper/msg_server_test.go | 6 +- keeper/snapshotter.go | 139 -------------------- keeper/vote_extension.go | 5 +- keys.go | 20 +-- module/depinject.go | 11 -- module/module.go | 2 +- 11 files changed, 69 insertions(+), 345 deletions(-) rename keeper/{status.go => blob_status.go} (88%) delete mode 100644 keeper/snapshotter.go diff --git a/keeper/status.go b/keeper/blob_status.go similarity index 88% rename from keeper/status.go rename to keeper/blob_status.go index 4fe257d..8ac2e33 100644 --- a/keeper/status.go +++ b/keeper/blob_status.go @@ -10,7 +10,7 @@ import ( func (k *Keeper) SetBlobStatusPending(ctx sdk.Context, startHeight, endHeight uint64) bool { store := ctx.KVStore(k.storeKey) - if !CanUpdateStatusToPending(store) { // TOodo: we should check for expiration too + if !CanUpdateStatusToPending(store) { // Todo: we should check for expiration too (what if the status was pending for too long) return false } diff --git a/keeper/collections.go b/keeper/collections.go index 4c6af52..6b3b4c8 100644 --- a/keeper/collections.go +++ b/keeper/collections.go @@ -2,21 +2,10 @@ package keeper import ( "context" - "fmt" - "time" - "cosmossdk.io/collections" "github.com/vitwit/avail-da-module/types" ) -const ( - // Window for a transaction to be committed - ResubmissionTime = 75 * time.Second - - // Buffer for relayer polling logic to retrieve a proof - RelayerPollingBuffer = 15 * time.Second -) - func (k *Keeper) SetValidatorAvailAddress(ctx context.Context, validator types.Validator) error { return k.Validators.Set(ctx, validator.ValidatorAddress, validator.AvailAddress) } @@ -50,146 +39,46 @@ func (k *Keeper) GetAllValidators(ctx context.Context) (types.Validators, error) return validators, nil } -func (k *Keeper) SetProvenHeight(ctx context.Context, height uint64) error { - return k.ProvenHeight.Set(ctx, height) -} +// func (k *Keeper) SetProvenHeight(ctx context.Context, height uint64) error { +// return k.ProvenHeight.Set(ctx, height) +// } -func (k *Keeper) GetProvenHeight(ctx context.Context) (uint64, error) { - return k.ProvenHeight.Get(ctx) -} +// func (k *Keeper) GetProvenHeight(ctx context.Context) (uint64, error) { +// return k.ProvenHeight.Get(ctx) +// } -func (k *Keeper) SetClientID(ctx context.Context, clientID string) error { - return k.ClientID.Set(ctx, clientID) -} +// func (k *Keeper) SetClientID(ctx context.Context, clientID string) error { +// return k.ClientID.Set(ctx, clientID) +// } -func (k *Keeper) GetClientID(ctx context.Context) (string, error) { - return k.ClientID.Get(ctx) -} +// func (k *Keeper) GetClientID(ctx context.Context) (string, error) { +// return k.ClientID.Get(ctx) +// } // IsBlockPending return true if a block height is already pending -func (k Keeper) IsBlockPending(ctx context.Context, blockHeight int64) bool { - found, err := k.PendingBlocksToTimeouts.Has(ctx, blockHeight) - if err != nil { - return false - } - return found -} +// func (k Keeper) IsBlockPending(ctx context.Context, blockHeight int64) bool { +// found, err := k.PendingBlocksToTimeouts.Has(ctx, blockHeight) +// if err != nil { +// return false +// } +// return found +// } // IsBlockExpired will return true if a block is pending and expired, otherwise it returns false -func (k *Keeper) IsBlockExpired(ctx context.Context, currentBlockTime time.Time, blockHeight int64) bool { - currentBlockTimeNs := currentBlockTime.UnixNano() - found, err := k.PendingBlocksToTimeouts.Has(ctx, blockHeight) - if err != nil { - return false - } - if found { - expiration, err := k.PendingBlocksToTimeouts.Get(ctx, blockHeight) - if err != nil { - return false - } - if currentBlockTimeNs >= expiration { - return true - } - } - return false -} - -// AddUpdatePendingBlock will add a new pending block or update an existing pending block -func (k *Keeper) AddUpdatePendingBlock(ctx context.Context, pendingBlock int64, currentBlockTime time.Time) error { - found, err := k.PendingBlocksToTimeouts.Has(ctx, pendingBlock) - if err != nil { - return fmt.Errorf("remove pending blocks, block %d error", pendingBlock) - } - if found { - if err = k.RemovePendingBlock(ctx, pendingBlock); err != nil { - return err - } - } - expiration := currentBlockTime.Add(ResubmissionTime + RelayerPollingBuffer).UnixNano() - if err = k.PendingBlocksToTimeouts.Set(ctx, pendingBlock, expiration); err != nil { - return fmt.Errorf("add/update pending block, set pending block (%d) to timeout (%d)", pendingBlock, expiration) - } - if err = k.AddPendingBlockToTimeoutsMap(ctx, pendingBlock, expiration); err != nil { - return fmt.Errorf("add/update pending block, add pending block to timeouts map, %v", err) - } - return nil -} - -func (k *Keeper) AddPendingBlockToTimeoutsMap(ctx context.Context, height, expiration int64) error { - found, err := k.TimeoutsToPendingBlocks.Has(ctx, expiration) - if err != nil { - return err - } - var pendingBlocks types.PendingBlocks - if found { - pendingBlocks, err = k.TimeoutsToPendingBlocks.Get(ctx, expiration) - if err != nil { - return err - } - } - pendingBlocks.BlockHeights = append(pendingBlocks.BlockHeights, height) - if err = k.TimeoutsToPendingBlocks.Set(ctx, expiration, pendingBlocks); err != nil { - return err - } - return nil -} - -// // RemovePendingBlock removes proven block from pending state -// This function will remove the proven block from the PendingBlocksToTimeouts map and TimeoutsToPendingBlocks map -func (k *Keeper) RemovePendingBlock(ctx context.Context, provenBlock int64) error { - found, err := k.PendingBlocksToTimeouts.Has(ctx, provenBlock) - if err != nil { - return fmt.Errorf("remove pending blocks, block %d error", provenBlock) - } - if found { - expiration, err := k.PendingBlocksToTimeouts.Get(ctx, provenBlock) - if err != nil { - return fmt.Errorf("remove pending blocks, getting pending block %d", provenBlock) - } - if err = k.PendingBlocksToTimeouts.Remove(ctx, provenBlock); err != nil { - return fmt.Errorf("remove pending blocks, removing block %d", provenBlock) - } - pendingBlocks, err := k.TimeoutsToPendingBlocks.Get(ctx, expiration) - if err != nil { - return fmt.Errorf("remove pending blocks, getting expiration %d", expiration) - } - var newPendingBlocks []int64 - for _, blockHeight := range pendingBlocks.BlockHeights { - if blockHeight != provenBlock { - newPendingBlocks = append(newPendingBlocks, blockHeight) - } - } - if len(newPendingBlocks) > 0 { - pendingBlocks.BlockHeights = newPendingBlocks - if err = k.TimeoutsToPendingBlocks.Set(ctx, expiration, pendingBlocks); err != nil { - return fmt.Errorf("remove pending block, set new pending blocks") - } - } else { - if err = k.TimeoutsToPendingBlocks.Remove(ctx, expiration); err != nil { - return fmt.Errorf("remove pending blocks, removing timeout set %d", expiration) - } - } - } - return nil -} - -// GetExpiredBlocks returns all expired blocks, proposer will propose publishing based on this set -func (k Keeper) GetExpiredBlocks(ctx context.Context, currentBlockTime time.Time) []int64 { - currentBlockTimeNs := currentBlockTime.UnixNano() - iterator, err := k.TimeoutsToPendingBlocks. - Iterate(ctx, (&collections.Range[int64]{}).StartInclusive(0).EndInclusive(currentBlockTimeNs)) - if err != nil { - return nil - } - defer iterator.Close() - - var expiredBlocks []int64 - for ; iterator.Valid(); iterator.Next() { - pendingBlocks, err := iterator.Value() - if err != nil { - return nil - } - expiredBlocks = append(expiredBlocks, pendingBlocks.BlockHeights...) - } - return expiredBlocks -} +// func (k *Keeper) IsBlockExpired(ctx context.Context, currentBlockTime time.Time, blockHeight int64) bool { +// currentBlockTimeNs := currentBlockTime.UnixNano() +// found, err := k.PendingBlocksToTimeouts.Has(ctx, blockHeight) +// if err != nil { +// return false +// } +// if found { +// expiration, err := k.PendingBlocksToTimeouts.Get(ctx, blockHeight) +// if err != nil { +// return false +// } +// if currentBlockTimeNs >= expiration { +// return true +// } +// } +// return false +// } diff --git a/keeper/genesis.go b/keeper/genesis.go index e0050dd..a756217 100644 --- a/keeper/genesis.go +++ b/keeper/genesis.go @@ -13,14 +13,6 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) error { } } - // Set proven height to genesis height, we do not init any pending block on a genesis init/restart - // if err := k.SetProvenHeight(ctx, ctx.HeaderInfo().Height); err != nil { - // return err - // } - - k.relayer.NotifyProvenHeight(ctx.HeaderInfo().Height) - - // TODO: client state k.SetAvailGenesisState(ctx, data) return nil @@ -33,18 +25,14 @@ func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { panic(err) } - provenHeight, err := k.GetProvenHeight(ctx) - if err != nil { - panic(err) - } - - if err != nil { - panic(err) - } + // provenHeight, err := k.GetProvenHeight(ctx) + // if err != nil { + // panic(err) + // } return &types.GenesisState{ - Validators: vals.Validators, - ProvenHeight: provenHeight, + Validators: vals.Validators, + // ProvenHeight: provenHeight, } } diff --git a/keeper/keeper.go b/keeper/keeper.go index 64d1879..f8a86cc 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -12,7 +12,6 @@ import ( "github.com/spf13/cobra" availblob1 "github.com/vitwit/avail-da-module" "github.com/vitwit/avail-da-module/relayer" - "github.com/vitwit/avail-da-module/types" ) type Keeper struct { @@ -20,11 +19,11 @@ type Keeper struct { upgradeKeeper *upgradekeeper.Keeper relayer *relayer.Relayer - Validators collections.Map[string, string] - ClientID collections.Item[string] - ProvenHeight collections.Item[uint64] - PendingBlocksToTimeouts collections.Map[int64, int64] - TimeoutsToPendingBlocks collections.Map[int64, types.PendingBlocks] + Validators collections.Map[string, string] + // ClientID collections.Item[string] + // ProvenHeight collections.Item[uint64] + // PendingBlocksToTimeouts collections.Map[int64, int64] + // TimeoutsToPendingBlocks collections.Map[int64, types.PendingBlocks] // keyring keyring.Keyring storeKey storetypes2.StoreKey @@ -51,11 +50,11 @@ func NewKeeper( return &Keeper{ upgradeKeeper: uk, - Validators: collections.NewMap(sb, availblob1.ValidatorsKey, "validators", collections.StringKey, collections.StringValue), - ClientID: collections.NewItem(sb, availblob1.ClientIDKey, "client_id", collections.StringValue), - ProvenHeight: collections.NewItem(sb, availblob1.ProvenHeightKey, "proven_height", collections.Uint64Value), - PendingBlocksToTimeouts: collections.NewMap(sb, availblob1.PendingBlocksToTimeouts, "pending_blocks_to_timeouts", collections.Int64Key, collections.Int64Value), - TimeoutsToPendingBlocks: collections.NewMap(sb, availblob1.TimeoutsToPendingBlocks, "timeouts_to_pending_blocks", collections.Int64Key, codec.CollValue[types.PendingBlocks](cdc)), + Validators: collections.NewMap(sb, availblob1.ValidatorsKey, "validators", collections.StringKey, collections.StringValue), + // ClientID: collections.NewItem(sb, availblob1.ClientIDKey, "client_id", collections.StringValue), + // ProvenHeight: collections.NewItem(sb, availblob1.ProvenHeightKey, "proven_height", collections.Uint64Value), + // PendingBlocksToTimeouts: collections.NewMap(sb, availblob1.PendingBlocksToTimeouts, "pending_blocks_to_timeouts", collections.Int64Key, collections.Int64Value), + // TimeoutsToPendingBlocks: collections.NewMap(sb, availblob1.TimeoutsToPendingBlocks, "timeouts_to_pending_blocks", collections.Int64Key, codec.CollValue[types.PendingBlocks](cdc)), storeKey: key, diff --git a/keeper/msg_server.go b/keeper/msg_server.go index 2304ea1..415b1d4 100644 --- a/keeper/msg_server.go +++ b/keeper/msg_server.go @@ -52,6 +52,7 @@ func (s msgServer) UpdateBlobStatus(ctx context.Context, req *types.MsgUpdateBlo UpdateVotingEndHeight(sdkCtx, store, lastVotingEndHeight, true) } + // update status of the blob range UpdateBlobStatus(sdkCtx, store, newStatus) return &types.MsgUpdateBlobStatusResponse{}, nil diff --git a/keeper/msg_server_test.go b/keeper/msg_server_test.go index aa40e54..1fa8773 100644 --- a/keeper/msg_server_test.go +++ b/keeper/msg_server_test.go @@ -6,10 +6,10 @@ import ( ) func (s *TestSuite) TestMsgServer_UpdateBlobStatus() { - err := s.keeper.SetProvenHeight(s.ctx, 10) - s.Require().NoError(err) + // err := s.keeper.SetProvenHeight(s.ctx, 10) + // s.Require().NoError(err) - err = availkeeper.UpdateEndHeight(s.ctx, s.store, uint64(20)) + err := availkeeper.UpdateEndHeight(s.ctx, s.store, uint64(20)) s.Require().NoError(err) testCases := []struct { diff --git a/keeper/snapshotter.go b/keeper/snapshotter.go deleted file mode 100644 index 7bcbe46..0000000 --- a/keeper/snapshotter.go +++ /dev/null @@ -1,139 +0,0 @@ -package keeper - -import ( - "io" - - errorsmod "cosmossdk.io/errors" - snapshot "cosmossdk.io/store/snapshots/types" - storetypes "cosmossdk.io/store/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - availblob1 "github.com/vitwit/avail-da-module" -) - -var _ snapshot.ExtensionSnapshotter = &AvailBlobSnapshotter{} - -// SnapshotFormat defines the default snapshot extension encoding format. -// SnapshotFormat 1 is a proto marshaled UnprovenBlock type. -const SnapshotFormat = 1 - -// AvailBlobSnapshotter implements the snapshot.ExtensionSnapshotter interface and is used to -// import and export unproven blocks so they can be proven when needed. -// State sync would otherwise missed these blocks and the node would panic. -type AvailBlobSnapshotter struct { - cms storetypes.MultiStore - keeper *Keeper -} - -// NewAvailblobSnapshotter creates and returns a new snapshot.ExtensionSnapshotter implementation for availblob. -func NewAvailblobSnapshotter(cms storetypes.MultiStore, keeper *Keeper) snapshot.ExtensionSnapshotter { - return &AvailBlobSnapshotter{ - cms: cms, - keeper: keeper, - } -} - -// SnapshotName implements the snapshot.ExtensionSnapshotter interface. -// A unique name should be provided such that the implementation can be identified by the manager. -func (*AvailBlobSnapshotter) SnapshotName() string { - return availblob1.ModuleName -} - -// SnapshotFormat implements the snapshot.ExtensionSnapshotter interface. -// This is the default format used for encoding payloads when taking a snapshot. -func (*AvailBlobSnapshotter) SnapshotFormat() uint32 { - return SnapshotFormat -} - -// SupportedFormats implements the snapshot.ExtensionSnapshotter interface. -// This defines a list of supported formats the snapshotter extension can restore from. -func (*AvailBlobSnapshotter) SupportedFormats() []uint32 { - return []uint32{SnapshotFormat} -} - -// SnapshotExtension implements the snapshot.ExntensionSnapshotter interface. -// SnapshotExtension is used to write data payloads into the underlying protobuf stream from the local client. -func (s *AvailBlobSnapshotter) SnapshotExtension(height uint64, _ snapshot.ExtensionPayloadWriter) error { - cacheMS, err := s.cms.CacheMultiStoreWithVersion(int64(height)) - if err != nil { - return err - } - - sdkCtx := sdk.NewContext(cacheMS, tmproto.Header{}, false, nil) - - provenHeight, err := s.keeper.GetProvenHeight(sdkCtx) - if err != nil { - return err - } - _ = provenHeight - - // for unprovenHeight := provenHeight + 1; unprovenHeight <= int64(height); unprovenHeight++ { - // blockProtoBz, err := s.keeper.relayer.GetLocalBlockAtHeight(unprovenHeight) - // if err != nil { - // return err - // } - - // unprovenBlock := availblob1.UnprovenBlock{ - // Height: unprovenHeight, - // Block: blockProtoBz, - // } - - // unprovenBlockBz, err := unprovenBlock.Marshal() - // if err != nil { - // return err - // } - - // if err = payloadWriter(unprovenBlockBz); err != nil { - // return err - // } - // } - - return nil -} - -// RestoreExtension implements the snapshot.ExtensionSnapshotter interface. -// RestoreExtension is used to read data from an existing extension state snapshot into the availblob keeper. -// The payload reader returns io.EOF when it has reached the end of the extension state snapshot. -func (s *AvailBlobSnapshotter) RestoreExtension(height uint64, format uint32, payloadReader snapshot.ExtensionPayloadReader) error { - if format == s.SnapshotFormat() { - return s.processAllItems(int64(height), payloadReader, restoreV1) - } - - return errorsmod.Wrapf(snapshot.ErrUnknownFormat, "expected %d, got %d", s.SnapshotFormat(), format) -} - -func (s *AvailBlobSnapshotter) processAllItems( - height int64, - payloadReader snapshot.ExtensionPayloadReader, - cb func(*Keeper, int64, []byte) error, -) error { - for { - payload, err := payloadReader() - if err == io.EOF { - break - } else if err != nil { - return err - } - - if err := cb(s.keeper, height, payload); err != nil { - return errorsmod.Wrap(err, "failure processing snapshot item") - } - } - - return nil -} - -func restoreV1(_ *Keeper, _ int64, _ []byte) error { - // var unprovenBlock availblob1.UnprovenBlock - // if err := k.cdc.Unmarshal(unprovenBlockBz, &unprovenBlock); err != nil { - // return errorsmod.Wrap(err, "failed to unmarshal unproven block") - // } - - // if unprovenBlock.Height > height { - // return fmt.Errorf("unproven block height is greater than current height") - // } - - // k.relayer.PushSnapshotBlocks(unprovenBlock.Height, unprovenBlock.Block) - - return nil -} diff --git a/keeper/vote_extension.go b/keeper/vote_extension.go index a435d99..8428a11 100644 --- a/keeper/vote_extension.go +++ b/keeper/vote_extension.go @@ -15,7 +15,6 @@ type VoteExtHandler struct { Keeper *Keeper } -// TODO: add required parameters like avail light client url, etc.. func NewVoteExtHandler( logger log.Logger, keeper *Keeper, @@ -57,7 +56,6 @@ func (h *VoteExtHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { Votes: Votes, } - // TODO: use better marshaling instead of json (eg: proto marshaling) votesBytes, err := json.Marshal(voteExt) if err != nil { return nil, fmt.Errorf("failed to marshal vote extension: %w", err) @@ -83,7 +81,6 @@ func (h *VoteExtHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { Votes: Votes, } - // TODO: use proto marshaling instead votesBytes, err := json.Marshal(voteExt) if err != nil { return nil, fmt.Errorf("failed to marshal vote extension: %w", err) @@ -99,7 +96,7 @@ func (h *VoteExtHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { // This function is used to verify the correctness and validity of the vote extensions submitted during the voting process. func (h *VoteExtHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteExtensionHandler { return func(_ sdk.Context, _ *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { - // TODO: write proper validation for the votes + // TODO: add proper validation for the votes if any return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil } } diff --git a/keys.go b/keys.go index 7209acf..f90c0a0 100644 --- a/keys.go +++ b/keys.go @@ -19,27 +19,27 @@ var ( ProvenHeightKey = collections.NewPrefix(2) // PendingBlocksToTimeouts maps pending blocks to their timeout - PendingBlocksToTimeouts = collections.NewPrefix(3) + // PendingBlocksToTimeouts = collections.NewPrefix(3) // TimeoutsToPendingBlocks maps timeouts to a set of pending blocks - TimeoutsToPendingBlocks = collections.NewPrefix(4) + // TimeoutsToPendingBlocks = collections.NewPrefix(4) // light client store key - ClientStoreKey = []byte("client_store/") + // ClientStoreKey = []byte("client_store/") - PendingBlobsKey = collections.NewPrefix(5) + PendingBlobsKey = collections.NewPrefix(3) - BlobStatusKey = collections.NewPrefix(6) + BlobStatusKey = collections.NewPrefix(4) - PrevHeightKey = collections.NewPrefix(7) + PrevHeightKey = collections.NewPrefix(5) - NextHeightKey = collections.NewPrefix(8) + NextHeightKey = collections.NewPrefix(6) - VotingEndHeightKey = collections.NewPrefix(9) + VotingEndHeightKey = collections.NewPrefix(7) - LastVotingEndHeightKey = collections.NewPrefix(10) + LastVotingEndHeightKey = collections.NewPrefix(8) - AvailHeightKey = collections.NewPrefix(11) + AvailHeightKey = collections.NewPrefix(9) ) const ( diff --git a/module/depinject.go b/module/depinject.go index 4f21cb1..9e0f58e 100644 --- a/module/depinject.go +++ b/module/depinject.go @@ -8,22 +8,12 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// var _ appmodule.AppModule = AppModule{} - -func init() { - // appmodule.Register( - // // new(modulev1.Module), - // // appmodule.Provide(ProvideModule), - // ) -} - type Inputs struct { depinject.In Cdc codec.Codec StoreService store.KVStoreService - // StakingKeeper stakingkeeper.Keeper UpgradeKeeper upgradekeeper.Keeper } @@ -31,5 +21,4 @@ type Outputs struct { depinject.Out Module appmodule.AppModule - // Keeper *keeper.Keeper } diff --git a/module/module.go b/module/module.go index 4e58549..3eb4d1f 100644 --- a/module/module.go +++ b/module/module.go @@ -154,7 +154,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. return nil } -// ExportGenesis returns the exported genesis state as raw bytes for the rollchain +// ExportGenesis returns the exported genesis state as raw bytes for the cada // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { gs := am.keeper.ExportGenesis(ctx) From f9ad6fee4b49f769f24f36a9d012a9f4c13e447e Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Fri, 20 Sep 2024 15:24:30 +0530 Subject: [PATCH 03/14] remove unused code --- relayer/availclient.go | 26 +- relayer/client.go | 298 +++++++++--------- .../{cosmosprovider.go => cosmos_provider.go} | 0 relayer/process.go | 13 +- relayer/publish.go | 44 +-- relayer/relayer.go | 8 +- simapp/app/app.go | 6 +- types/avail_config.go | 2 +- types/codec.go | 2 +- types/validation.go | 1 - 10 files changed, 199 insertions(+), 201 deletions(-) rename relayer/local/{cosmosprovider.go => cosmos_provider.go} (100%) delete mode 100644 types/validation.go diff --git a/relayer/availclient.go b/relayer/availclient.go index d4695d0..8ad7e81 100644 --- a/relayer/availclient.go +++ b/relayer/availclient.go @@ -1,18 +1,18 @@ package relayer -import "github.com/vitwit/avail-da-module/types" +// import "github.com/vitwit/avail-da-module/types" -// AvailClient is the client that handles data submission -type AvailClient struct { - config types.AvailConfiguration -} +// // AvailClient is the client that handles data submission +// type AvailClient struct { +// config types.AvailConfiguration +// } -// NewAvailClient initializes a new AvailClient -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) - // } +// // NewAvailClient initializes a new AvailClient +// 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) +// // } - return &AvailClient{config: config}, nil -} +// return &AvailClient{config: config}, nil +// } diff --git a/relayer/client.go b/relayer/client.go index 95fa9ab..af26f6b 100644 --- a/relayer/client.go +++ b/relayer/client.go @@ -1,151 +1,151 @@ package relayer -import ( - "fmt" - - cometrpc "github.com/cometbft/cometbft/rpc/client/http" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/std" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/go-bip39" -) - -const ( - defaultGasAdjustment = 1.0 - defaultGasLimit = 300000 -) - -// var availdHomePath = xfilepath.JoinFromHome(xfilepath.Path("availsdk")) - -func NewClientCtx(kr keyring.Keyring, c *cometrpc.HTTP, chainID string, - cdc codec.BinaryCodec, homepath string, fromAddress sdk.AccAddress, -) client.Context { - encodingConfig := MakeEncodingConfig() - - broadcastMode := flags.BroadcastSync - - return client.Context{}. - WithCodec(cdc.(codec.Codec)). - WithChainID(chainID). - WithFromAddress(fromAddress). - WithFromName("testkey"). - WithKeyringDir(homepath). - WithBroadcastMode(broadcastMode). - WithTxConfig(authTx.NewTxConfig(cdc.(codec.Codec), authTx.DefaultSignModes)). - WithKeyring(kr). - WithAccountRetriever(authtypes.AccountRetriever{}). - WithClient(c).WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithSkipConfirmation(true) -} - -// NewFactory creates a new Factory. -func NewFactory(clientCtx client.Context) tx.Factory { - return tx.Factory{}. - WithChainID(clientCtx.ChainID). - WithKeybase(clientCtx.Keyring). - WithGas(defaultGasLimit). - WithGasAdjustment(defaultGasAdjustment). - WithSignMode(signing.SignMode_SIGN_MODE_DIRECT). - WithAccountRetriever(clientCtx.AccountRetriever). - WithTxConfig(clientCtx.TxConfig) -} - -// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. -func MakeEncodingConfig(modules ...module.AppModuleBasic) EncodingConfig { - aminoCodec := codec.NewLegacyAmino() - interfaceRegistry := codectypes.NewInterfaceRegistry() - codec := codec.NewProtoCodec(interfaceRegistry) - txCfg := authTx.NewTxConfig(codec, authTx.DefaultSignModes) - - encCfg := EncodingConfig{ - InterfaceRegistry: interfaceRegistry, - Codec: codec, - TxConfig: txCfg, - Amino: aminoCodec, - } - - mb := module.NewBasicManager(modules...) - - std.RegisterLegacyAminoCodec(encCfg.Amino) - std.RegisterInterfaces(encCfg.InterfaceRegistry) - mb.RegisterLegacyAminoCodec(encCfg.Amino) - mb.RegisterInterfaces(encCfg.InterfaceRegistry) - - return encCfg -} - -// EncodingConfig specifies the concrete encoding types to use for a given app. -// This is provided for compatibility between protobuf and amino implementations. -type EncodingConfig struct { - InterfaceRegistry codectypes.InterfaceRegistry - Codec codec.Codec - TxConfig client.TxConfig - Amino *codec.LegacyAmino -} - -// ImportMnemonic is to import existing account mnemonic in keyring -func ImportMnemonic(keyName, mnemonic, hdPath string, c client.Context) (*keyring.Record, error) { - info, err := AccountCreate(keyName, mnemonic, hdPath, c) // return account also - if err != nil { - return nil, err - } - - return info, nil -} - -// AccountCreate creates an account by name and mnemonic (optional) in the keyring. -func AccountCreate(accountName, mnemonic, _ string, c client.Context) (*keyring.Record, error) { - if mnemonic == "" { - entropySeed, err := bip39.NewEntropy(256) - if err != nil { - return nil, err - } - mnemonic, err = bip39.NewMnemonic(entropySeed) - if err != nil { - return nil, err - } - } - - algos, _ := c.Keyring.SupportedAlgorithms() - algo, err := keyring.NewSigningAlgoFromString(string(hd.Secp256k1Type), algos) - if err != nil { - return nil, err - } - - path := hd.CreateHDPath(118, 0, 0).String() - // fmt.Println("pathhh......", path) - - // record, str, err := c.Keyring.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - // fmt.Println("recorddddd.......", err, str, record) - - // k, _, err = kb.NewMnemonic("test", English, types.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) - info, err := c.Keyring.NewAccount(accountName, mnemonic, keyring.DefaultBIP39Passphrase, path, algo) - fmt.Println("after creationnnn.........", info, err) - if err != nil { - return nil, err - } - // pk, err := info.GetPubKey() - // if err != nil { - // return nil, err - // } - - // addr := sdk.AccAddress(pk.Address()) - // fmt.Println("address hereee...", addr) - - // aa, err := info.GetAddress() - // fmt.Println("here aa and err.......", aa, err) - - // account := c.ToAccount(info) - // account.Mnemonic = mnemonic - return info, nil -} +// import ( +// "fmt" + +// cometrpc "github.com/cometbft/cometbft/rpc/client/http" +// "github.com/cosmos/cosmos-sdk/client" +// "github.com/cosmos/cosmos-sdk/client/flags" +// "github.com/cosmos/cosmos-sdk/client/tx" +// "github.com/cosmos/cosmos-sdk/codec" +// codectypes "github.com/cosmos/cosmos-sdk/codec/types" +// "github.com/cosmos/cosmos-sdk/crypto/hd" +// "github.com/cosmos/cosmos-sdk/crypto/keyring" +// "github.com/cosmos/cosmos-sdk/std" +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/cosmos/cosmos-sdk/types/module" +// "github.com/cosmos/cosmos-sdk/types/tx/signing" +// authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" +// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +// "github.com/cosmos/go-bip39" +// ) + +// const ( +// defaultGasAdjustment = 1.0 +// defaultGasLimit = 300000 +// ) + +// // var availdHomePath = xfilepath.JoinFromHome(xfilepath.Path("availsdk")) + +// func NewClientCtx(kr keyring.Keyring, c *cometrpc.HTTP, chainID string, +// cdc codec.BinaryCodec, homepath string, fromAddress sdk.AccAddress, +// ) client.Context { +// encodingConfig := MakeEncodingConfig() + +// broadcastMode := flags.BroadcastSync + +// return client.Context{}. +// WithCodec(cdc.(codec.Codec)). +// WithChainID(chainID). +// WithFromAddress(fromAddress). +// WithFromName("testkey"). +// WithKeyringDir(homepath). +// WithBroadcastMode(broadcastMode). +// WithTxConfig(authTx.NewTxConfig(cdc.(codec.Codec), authTx.DefaultSignModes)). +// WithKeyring(kr). +// WithAccountRetriever(authtypes.AccountRetriever{}). +// WithClient(c).WithInterfaceRegistry(encodingConfig.InterfaceRegistry). +// WithSkipConfirmation(true) +// } + +// // NewFactory creates a new Factory. +// func NewFactory(clientCtx client.Context) tx.Factory { +// return tx.Factory{}. +// WithChainID(clientCtx.ChainID). +// WithKeybase(clientCtx.Keyring). +// WithGas(defaultGasLimit). +// WithGasAdjustment(defaultGasAdjustment). +// WithSignMode(signing.SignMode_SIGN_MODE_DIRECT). +// WithAccountRetriever(clientCtx.AccountRetriever). +// WithTxConfig(clientCtx.TxConfig) +// } + +// // MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. +// func MakeEncodingConfig(modules ...module.AppModuleBasic) EncodingConfig { +// aminoCodec := codec.NewLegacyAmino() +// interfaceRegistry := codectypes.NewInterfaceRegistry() +// codec := codec.NewProtoCodec(interfaceRegistry) +// txCfg := authTx.NewTxConfig(codec, authTx.DefaultSignModes) + +// encCfg := EncodingConfig{ +// InterfaceRegistry: interfaceRegistry, +// Codec: codec, +// TxConfig: txCfg, +// Amino: aminoCodec, +// } + +// mb := module.NewBasicManager(modules...) + +// std.RegisterLegacyAminoCodec(encCfg.Amino) +// std.RegisterInterfaces(encCfg.InterfaceRegistry) +// mb.RegisterLegacyAminoCodec(encCfg.Amino) +// mb.RegisterInterfaces(encCfg.InterfaceRegistry) + +// return encCfg +// } + +// // EncodingConfig specifies the concrete encoding types to use for a given app. +// // This is provided for compatibility between protobuf and amino implementations. +// type EncodingConfig struct { +// InterfaceRegistry codectypes.InterfaceRegistry +// Codec codec.Codec +// TxConfig client.TxConfig +// Amino *codec.LegacyAmino +// } + +// // ImportMnemonic is to import existing account mnemonic in keyring +// func ImportMnemonic(keyName, mnemonic, hdPath string, c client.Context) (*keyring.Record, error) { +// info, err := AccountCreate(keyName, mnemonic, hdPath, c) // return account also +// if err != nil { +// return nil, err +// } + +// return info, nil +// } + +// // AccountCreate creates an account by name and mnemonic (optional) in the keyring. +// func AccountCreate(accountName, mnemonic, _ string, c client.Context) (*keyring.Record, error) { +// if mnemonic == "" { +// entropySeed, err := bip39.NewEntropy(256) +// if err != nil { +// return nil, err +// } +// mnemonic, err = bip39.NewMnemonic(entropySeed) +// if err != nil { +// return nil, err +// } +// } + +// algos, _ := c.Keyring.SupportedAlgorithms() +// algo, err := keyring.NewSigningAlgoFromString(string(hd.Secp256k1Type), algos) +// if err != nil { +// return nil, err +// } + +// path := hd.CreateHDPath(118, 0, 0).String() +// // fmt.Println("pathhh......", path) + +// // record, str, err := c.Keyring.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) +// // fmt.Println("recorddddd.......", err, str, record) + +// // k, _, err = kb.NewMnemonic("test", English, types.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) +// info, err := c.Keyring.NewAccount(accountName, mnemonic, keyring.DefaultBIP39Passphrase, path, algo) +// fmt.Println("after creationnnn.........", info, err) +// if err != nil { +// return nil, err +// } +// // pk, err := info.GetPubKey() +// // if err != nil { +// // return nil, err +// // } + +// // addr := sdk.AccAddress(pk.Address()) +// // fmt.Println("address hereee...", addr) + +// // aa, err := info.GetAddress() +// // fmt.Println("here aa and err.......", aa, err) + +// // account := c.ToAccount(info) +// // account.Mnemonic = mnemonic +// return info, nil +// } diff --git a/relayer/local/cosmosprovider.go b/relayer/local/cosmos_provider.go similarity index 100% rename from relayer/local/cosmosprovider.go rename to relayer/local/cosmos_provider.go diff --git a/relayer/process.go b/relayer/process.go index 914d8ae..ec8381d 100644 --- a/relayer/process.go +++ b/relayer/process.go @@ -20,21 +20,20 @@ func (r *Relayer) Start() error { case height := <-r.provenHeights: r.updateHeight(height) case <-timer.C: - // TODO: client update } } } // NotifyCommitHeight is called by the app to notify the relayer of the latest commit height -func (r *Relayer) NotifyCommitHeight(height int64) { - r.commitHeights <- height -} +// func (r *Relayer) NotifyCommitHeight(height int64) { +// r.commitHeights <- height +// } // NotifyProvenHeight is called by the app to notify the relayer of the latest proven height // i.e. the height of the highest incremental block that was proven to be posted to Avail. -func (r *Relayer) NotifyProvenHeight(height int64) { - r.provenHeights <- height -} +// func (r *Relayer) NotifyProvenHeight(height int64) { +// r.provenHeights <- height +// } // updateHeight is called when the provenHeight has changed func (r *Relayer) updateHeight(height int64) { diff --git a/relayer/publish.go b/relayer/publish.go index ada0da0..8789355 100644 --- a/relayer/publish.go +++ b/relayer/publish.go @@ -10,28 +10,28 @@ import ( "github.com/vitwit/avail-da-module/types" ) -func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []int64 { - height := ctx.BlockHeight() - - if height <= 1 { - return nil - } - - // only publish new blocks on interval - if (height-1)%int64(r.AvailConfig.PublishBlobInterval) != 0 { - return nil - } - - var blocks []int64 - 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) - } - } - - return blocks -} +// func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []int64 { +// height := ctx.BlockHeight() + +// if height <= 1 { +// return nil +// } + +// // only publish new blocks on interval +// if (height-1)%int64(r.AvailConfig.PublishBlobInterval) != 0 { +// return nil +// } + +// var blocks []int64 +// 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) +// } +// } + +// return blocks +// } // PostBlocks is called in the PreBlocker. The proposer will publish the blocks at this point // once their block has been accepted. The method launches the posting process in a separate diff --git a/relayer/relayer.go b/relayer/relayer.go index a5e7422..9ef7021 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -11,10 +11,10 @@ import ( "github.com/vitwit/avail-da-module/types" ) -const ( - DefaultMaxFlushSize = int(20) - MaxMaxFlushSize = int(100) -) +// const ( +// DefaultMaxFlushSize = int(20) +// MaxMaxFlushSize = int(100) +// ) // Relayer is responsible for posting new blocks to Avail type Relayer struct { diff --git a/simapp/app/app.go b/simapp/app/app.go index f268922..525fc1a 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -1018,7 +1018,7 @@ func (app *ChainApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.Respon } //app.Availblobrelayer.NotifyCommitHeight(req.Height) - app.Availblobrelayer.NotifyCommitHeight(req.Height) + // app.Availblobrelayer.NotifyCommitHeight(req.Height) return res, nil } @@ -1224,9 +1224,9 @@ func (app *ChainApp) RegisterTendermintService(clientCtx client.Context) { func (app *ChainApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) - app.Availblobrelayer.SetClientContext(clientCtx) + // app.Availblobrelayer.SetClientContext(clientCtx) - go app.Availblobrelayer.Start() + // go app.Availblobrelayer.Start() } // GetMaccPerms returns a copy of the module account permissions diff --git a/types/avail_config.go b/types/avail_config.go index 897af29..21b5b72 100644 --- a/types/avail_config.go +++ b/types/avail_config.go @@ -89,7 +89,7 @@ var DefaultAvailConfig = AvailConfiguration{ VoteInterval: 5, LightClientURL: "http://127.0.0.1:8000", ValidatorKey: "alice", - // CosmosNodeDir: ".availsdk", + // CosmosNodeDir: ".simapp", } func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfiguration { diff --git a/types/codec.go b/types/codec.go index 8050079..09b8858 100644 --- a/types/codec.go +++ b/types/codec.go @@ -11,7 +11,7 @@ import ( // RegisterLegacyAminoCodec registers the necessary interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - legacy.RegisterAminoMsg(cdc, &MsgUpdateBlobStatusRequest{}, "availblob/MsgUpdateBlobStatusRequest") + legacy.RegisterAminoMsg(cdc, &MsgUpdateBlobStatusRequest{}, "cada/MsgUpdateBlobStatusRequest") } // RegisterInterfaces registers the interfaces types with the interface registry. diff --git a/types/validation.go b/types/validation.go deleted file mode 100644 index ab1254f..0000000 --- a/types/validation.go +++ /dev/null @@ -1 +0,0 @@ -package types From 501c614a194d79593de1d0bd3a1cf8c184dfa2c2 Mon Sep 17 00:00:00 2001 From: saiteja Date: Fri, 20 Sep 2024 15:25:39 +0530 Subject: [PATCH 04/14] remove integration test --- client/cli/cli_test.go | 252 ++++++++++++++++++++--------------------- 1 file changed, 126 insertions(+), 126 deletions(-) diff --git a/client/cli/cli_test.go b/client/cli/cli_test.go index 5497fd3..7d973d0 100644 --- a/client/cli/cli_test.go +++ b/client/cli/cli_test.go @@ -1,128 +1,128 @@ package cli_test -import ( - "fmt" - "testing" - - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/crypto/hd" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/suite" - "github.com/vitwit/avail-da-module/client/cli" - network "github.com/vitwit/avail-da-module/network" - - app "simapp/app" - - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" -) - -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} - -type IntegrationTestSuite struct { - suite.Suite - - cfg network.Config - network *network.Network - addresses []string -} - -const aliceMnemonic = "all soap kiwi cushion federal skirt tip shock exist tragic verify lunar shine rely torch please view future lizard garbage humble medal leisure mimic" - -func (s *IntegrationTestSuite) SetupSuite() { - s.T().Log("setting up integration test suite") - - var err error - - // Setup network config - cfg := network.DefaultConfig(app.NewTestNetworkFixture) - cfg.NumValidators = 1 - s.cfg = cfg - - // Initialize the network - s.network, err = network.New(s.T(), s.T().TempDir(), cfg) - s.Require().NoError(err) - - kb := s.network.Validators[0].ClientCtx.Keyring - path := sdk.GetConfig().GetFullBIP44Path() - info, err := kb.NewAccount("alice", aliceMnemonic, "", path, hd.Secp256k1) - s.Require().NoError(err) - - add, err := info.GetAddress() - s.Require().NoError(err) - s.addresses = append(s.addresses, add.String()) - - _, err = s.network.WaitForHeight(1) - s.Require().NoError(err) -} - -func (s *IntegrationTestSuite) TearDownSuite() { - s.T().Log("tearing down integration suite") - s.network.Cleanup() -} - -func (s *IntegrationTestSuite) TestNewUpdateBlobStatusCmd() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectErr bool - }{ - { - "update blob status - success", - []string{ - "1", - "10", - "success", - "120", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - }, - false, - }, - { - "update blob status - failure", - []string{ - "1", - "10", - "failure", - "120", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - }, - false, - }, - { - "update blob status - invalid status", - []string{ - "1", - "10", - "invalid", - "120", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]), - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - }, - false, - }, - } - - for _, tc := range testCases { - s.Run(tc.name, func() { - cmd := cli.NewUpdateBlobStatusCmd() - res, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, tc.args) - if tc.expectErr { - if err != nil { - s.Require().Error(err) - } - } - - s.Require().NoError(nil) - s.Require().NotNil(res) - }) - } -} +// import ( +// "fmt" +// "testing" + +// "github.com/cosmos/cosmos-sdk/client/flags" +// "github.com/cosmos/cosmos-sdk/crypto/hd" +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/stretchr/testify/suite" +// "github.com/vitwit/avail-da-module/client/cli" +// network "github.com/vitwit/avail-da-module/network" + +// app "simapp/app" + +// clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" +// ) + +// func TestIntegrationTestSuite(t *testing.T) { +// suite.Run(t, new(IntegrationTestSuite)) +// } + +// type IntegrationTestSuite struct { +// suite.Suite + +// cfg network.Config +// network *network.Network +// addresses []string +// } + +// const aliceMnemonic = "all soap kiwi cushion federal skirt tip shock exist tragic verify lunar shine rely torch please view future lizard garbage humble medal leisure mimic" + +// func (s *IntegrationTestSuite) SetupSuite() { +// s.T().Log("setting up integration test suite") + +// var err error + +// // Setup network config +// cfg := network.DefaultConfig(app.NewTestNetworkFixture) +// cfg.NumValidators = 1 +// s.cfg = cfg + +// // Initialize the network +// s.network, err = network.New(s.T(), s.T().TempDir(), cfg) +// s.Require().NoError(err) + +// kb := s.network.Validators[0].ClientCtx.Keyring +// path := sdk.GetConfig().GetFullBIP44Path() +// info, err := kb.NewAccount("alice", aliceMnemonic, "", path, hd.Secp256k1) +// s.Require().NoError(err) + +// add, err := info.GetAddress() +// s.Require().NoError(err) +// s.addresses = append(s.addresses, add.String()) + +// _, err = s.network.WaitForHeight(1) +// s.Require().NoError(err) +// } + +// func (s *IntegrationTestSuite) TearDownSuite() { +// s.T().Log("tearing down integration suite") +// s.network.Cleanup() +// } + +// func (s *IntegrationTestSuite) TestNewUpdateBlobStatusCmd() { +// val := s.network.Validators[0] + +// testCases := []struct { +// name string +// args []string +// expectErr bool +// }{ +// { +// "update blob status - success", +// []string{ +// "1", +// "10", +// "success", +// "120", +// fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]), +// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), +// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), +// }, +// false, +// }, +// { +// "update blob status - failure", +// []string{ +// "1", +// "10", +// "failure", +// "120", +// fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]), +// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), +// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), +// }, +// false, +// }, +// { +// "update blob status - invalid status", +// []string{ +// "1", +// "10", +// "invalid", +// "120", +// fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]), +// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), +// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), +// }, +// false, +// }, +// } + +// for _, tc := range testCases { +// s.Run(tc.name, func() { +// cmd := cli.NewUpdateBlobStatusCmd() +// res, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, tc.args) +// if tc.expectErr { +// if err != nil { +// s.Require().Error(err) +// } +// } + +// s.Require().NoError(nil) +// s.Require().NotNil(res) +// }) +// } +// } From 2a98c555cf3844ee879bbb0de282778243c4f4f9 Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Fri, 20 Sep 2024 15:47:13 +0530 Subject: [PATCH 05/14] add keys --- client/cli/keys.go | 29 +++++++++++++++++++++++ simapp/cmd/availd/commads.go | 6 +++++ simapp/go.mod | 16 +------------ simapp/go.sum | 45 ++---------------------------------- 4 files changed, 38 insertions(+), 58 deletions(-) create mode 100644 client/cli/keys.go diff --git a/client/cli/keys.go b/client/cli/keys.go new file mode 100644 index 0000000..e777e62 --- /dev/null +++ b/client/cli/keys.go @@ -0,0 +1,29 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + availblob "github.com/vitwit/avail-da-module" +) + +const ( + FlagPubKey = "pubkey" + FlagAddress = "address" + FlagLedger = "ledger" + FlagCoinType = "coin-type" +) + +// NewKeysCmd returns a root CLI command handler for all x/availblob keys commands. +func NewKeysCmd() *cobra.Command { + keysCmd := &cobra.Command{ + Use: availblob.ModuleName, + Short: availblob.ModuleName + " keys subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + keysCmd.AddCommand() + + return keysCmd +} diff --git a/simapp/cmd/availd/commads.go b/simapp/cmd/availd/commads.go index c10d56d..9687111 100644 --- a/simapp/cmd/availd/commads.go +++ b/simapp/cmd/availd/commads.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/snapshot" @@ -40,6 +41,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "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" availtypes "github.com/vitwit/avail-da-module/types" ) @@ -115,12 +117,16 @@ func initRootCmd( AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) + keysCmd := keys.Commands() + keysCmd.AddCommand(availblobcli.NewKeysCmd()) + // add keybase, RPC, query, genesis, and tx child commands rootCmd.AddCommand( server.StatusCommand(), genesisCommand(txConfig, basicManager), queryCommand(), txCommand(), + keysCmd, resetCommand(), ) } diff --git a/simapp/go.mod b/simapp/go.mod index 7b44172..03b8faf 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -49,7 +49,7 @@ require ( github.com/cometbft/cometbft v0.38.10 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-sdk v0.50.8 - github.com/cosmos/gogoproto v1.5.0 + github.com/cosmos/gogoproto v1.7.0 github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 github.com/cosmos/ibc-go/modules/capability v1.0.1 github.com/cosmos/ibc-go/v8 v8.3.2 @@ -77,7 +77,6 @@ require ( filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect - github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/DataDog/datadog-go v3.2.0+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect @@ -87,7 +86,6 @@ require ( github.com/bits-and-blooms/bitset v1.8.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect - github.com/centrifuge/go-substrate-rpc-client/v4 v4.2.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect @@ -109,9 +107,6 @@ require ( github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/deckarep/golang-set v1.8.0 // indirect - github.com/decred/base58 v1.0.4 // indirect - github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect @@ -120,7 +115,6 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/emicklei/dot v1.6.1 // indirect - github.com/ethereum/go-ethereum v1.10.20 // indirect github.com/fatih/color v1.15.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -130,7 +124,6 @@ require ( github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-stack/stack v1.8.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -152,8 +145,6 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.4 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect @@ -183,7 +174,6 @@ require ( github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect @@ -193,7 +183,6 @@ require ( github.com/oklog/run v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect - github.com/pierrec/xxHash v0.1.5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.19.0 // indirect @@ -209,13 +198,11 @@ require ( github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect - github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect github.com/ulikunitz/xz v0.5.11 // indirect - github.com/vedhavyas/go-subkey/v2 v2.0.0 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect go.etcd.io/bbolt v1.3.8 // indirect @@ -242,7 +229,6 @@ require ( google.golang.org/grpc v1.65.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index ab5adf8..41ac6bd 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -805,8 +805,6 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25 github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= -github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= @@ -818,8 +816,6 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEV github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= @@ -841,8 +837,6 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/availproject/go-substrate-rpc-client/v4 v4.1.0-avail-2.1.5-rc1 h1:mIYkc6eyi3iANW/dC+g7P49OfL54xnM61bq9B3a5pGw= -github.com/availproject/go-substrate-rpc-client/v4 v4.1.0-avail-2.1.5-rc1/go.mod h1:MeGquF7RkixfmXKXqwFF0a1iPLQiJGVlHjSLnJD4SD4= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+RQ= github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= @@ -864,8 +858,6 @@ github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdi github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= -github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -939,14 +931,13 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI= github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= -github.com/cosmos/gogoproto v1.5.0 h1:SDVwzEqZDDBoslaeZg+dGE55hdzHfgUA40pEanMh52o= -github.com/cosmos/gogoproto v1.5.0/go.mod h1:iUM31aofn3ymidYG6bUR5ZFrk+Om8p5s754eMUcyp8I= +github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fro= +github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/cosmos/iavl v1.1.4 h1:Z0cVVjeQqOUp78/nWt/uhQy83vYluWlAMGQ4zbH9G34= github.com/cosmos/iavl v1.1.4/go.mod h1:vCYmRQUJU1wwj0oRD3wMEtOM9sJNDP+GFMaXmIxZ/rU= github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 h1:dyLNlDElY6+5zW/BT/dO/3Ad9FpQblfh+9dQpYQodbA= @@ -974,11 +965,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= -github.com/decred/base58 v1.0.4 h1:QJC6B0E0rXOPA8U/kw2rP+qiRJsUaE2Er+pYb3siUeA= -github.com/decred/base58 v1.0.4/go.mod h1:jJswKPEdvpFpvf7dsDvFZyLT22xZ9lWqEByX38oGd9E= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= @@ -1025,8 +1011,6 @@ github.com/envoyproxy/protoc-gen-validate v0.10.0/go.mod h1:DRjgyB0I43LtJapqN6Ni github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= github.com/envoyproxy/protoc-gen-validate v1.0.1/go.mod h1:0vj8bNkYbSTNS2PIyH87KZaeN4x9zpL9Qt8fQC7d+vs= github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= -github.com/ethereum/go-ethereum v1.10.20 h1:75IW830ClSS40yrQC1ZCMZCt5I+zU16oqId2SiQwdQ4= -github.com/ethereum/go-ethereum v1.10.20/go.mod h1:LWUN82TCHGpxB3En5HVmLLzPD7YSrEUFmFfN1nKkVN0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -1080,8 +1064,6 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -1089,8 +1071,6 @@ github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= @@ -1260,11 +1240,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4Zs github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= -github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= -github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/consul/api v1.25.1/go.mod h1:iiLVwR/htV7mas/sy0O+XSuEnrdBUUydemjxcUrAt4g= github.com/hashicorp/consul/sdk v0.14.1/go.mod h1:vFt03juSzocLRFo59NkeQHHmQa6+g7oU0pfzdI1mUhg= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -1418,9 +1393,6 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b h1:QrHweqAtyJ9EwCaGHBu1fghwxIPiopAHV06JlXrMHjk= -github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b/go.mod h1:xxLb2ip6sSUts3g1irPVHyk/DGslwQsNOo9I7smJfNU= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= @@ -1492,8 +1464,6 @@ github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2 github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pierrec/xxHash v0.1.5 h1:n/jBpwTHiER4xYvK3/CdPVnLDPchj8eTJFFLUb4QHBo= -github.com/pierrec/xxHash v0.1.5/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -1550,8 +1520,6 @@ github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWR github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -1609,18 +1577,12 @@ github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2l github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= -github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= -github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= -github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= -github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/vedhavyas/go-subkey/v2 v2.0.0 h1:LemDIsrVtRSOkp0FA8HxP6ynfKjeOj3BY2U9UNfeDMA= -github.com/vedhavyas/go-subkey/v2 v2.0.0/go.mod h1:95aZ+XDCWAUUynjlmi7BtPExjXgXxByE0WfBwbmIRH4= github.com/vitwit/cosmos-sdk v0.50.6-0.20240905105834-9a5babf69986 h1:e38Z5AymIZ3dFCbAStFFo7baNnHYsHi8DTvMZHeoSfY= github.com/vitwit/cosmos-sdk v0.50.6-0.20240905105834-9a5babf69986/go.mod h1:+92hG6i+t1PRQ67ajr6D/Wgcnh/ifvnSte0u2rOszdU= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= @@ -1691,7 +1653,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -2501,8 +2462,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 9e9455d1861f45a0e0d0aa1b2c1c788c422c8951 Mon Sep 17 00:00:00 2001 From: saiteja Date: Fri, 20 Sep 2024 15:53:39 +0530 Subject: [PATCH 06/14] fix: voting end height parse --- keeper/store.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keeper/store.go b/keeper/store.go index 87945b1..215d8ca 100644 --- a/keeper/store.go +++ b/keeper/store.go @@ -2,7 +2,7 @@ package keeper import ( "encoding/binary" - "fmt" + "strconv" "cosmossdk.io/collections" storetypes2 "cosmossdk.io/store/types" @@ -41,7 +41,7 @@ func ParseVotingEndHeight(height uint64) string { if height == 0 { return "" } - return fmt.Sprintln(height) + return strconv.FormatUint(height, 10) } // CanUpdateStatusToPending checks if the blob status can be updated to "pending". From 1bd6795a8de291d945ea26292418246e2eb7f940 Mon Sep 17 00:00:00 2001 From: saiteja Date: Mon, 23 Sep 2024 12:46:31 +0530 Subject: [PATCH 07/14] feat : update genesis state --- go.mod | 42 +------- go.sum | 35 +------ keeper/genesis.go | 21 +--- proto/sdk/avail/v1beta1/genesis.proto | 8 +- proto/sdk/avail/v1beta1/validator.proto | 27 ------ types/genesis.pb.go | 121 ++---------------------- 6 files changed, 12 insertions(+), 242 deletions(-) delete mode 100644 proto/sdk/avail/v1beta1/validator.proto diff --git a/go.mod b/go.mod index 2a34ef8..9caf174 100644 --- a/go.mod +++ b/go.mod @@ -31,47 +31,17 @@ require ( github.com/spf13/cobra v1.8.1 google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 google.golang.org/grpc v1.65.0 - simapp v0.0.0-00010101000000-000000000000 ) require ( cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/compute/metadata v0.3.0 // indirect - cloud.google.com/go/iam v1.1.6 // indirect cloud.google.com/go/storage v1.38.0 // indirect - cosmossdk.io/client/v2 v2.0.0-beta.4 // indirect - cosmossdk.io/x/circuit v0.1.1 // indirect - cosmossdk.io/x/evidence v0.1.1 // indirect - cosmossdk.io/x/feegrant v0.1.1 // indirect - cosmossdk.io/x/nft v0.1.1 // indirect github.com/99designs/keyring v1.2.1 // indirect - github.com/aws/aws-sdk-go v1.44.224 // indirect - github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect - github.com/bits-and-blooms/bitset v1.8.0 // indirect github.com/btcsuite/btcd/btcutil v1.1.5 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect - github.com/chzyer/readline v1.5.1 // indirect - github.com/cockroachdb/apd/v2 v2.0.2 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect - github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 // indirect - github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect - github.com/cosmos/ibc-go/v8 v8.3.2 // indirect - github.com/go-logr/logr v1.4.1 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect - github.com/google/s2a-go v0.1.7 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.3 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-getter v1.7.4 // indirect - github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/iancoleman/orderedmap v0.3.0 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/manifoldco/promptui v0.9.0 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc5 // indirect github.com/opencontainers/runc v1.1.5 // indirect github.com/prometheus/client_golang v1.19.0 // indirect @@ -80,21 +50,11 @@ require ( github.com/prometheus/procfs v0.13.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/ulikunitz/xz v0.5.11 // indirect - go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/oauth2 v0.20.0 // indirect - golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.171.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect ) require ( - cosmossdk.io/errors v1.0.1 + cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/math v1.3.0 cosmossdk.io/x/tx v0.13.3 // indirect filippo.io/edwards25519 v1.0.0 // indirect diff --git a/go.sum b/go.sum index 2321d2f..6fd4479 100644 --- a/go.sum +++ b/go.sum @@ -213,6 +213,7 @@ cloud.google.com/go/compute v1.19.3/go.mod h1:qxvISKp/gYnXkSAD1ppcSOveRAmzxicEv/ cloud.google.com/go/compute v1.20.1/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= +cloud.google.com/go/compute v1.24.0 h1:phWcR2eWzRJaL/kOiJwfFsPs4BaKq1j6vnpZrc1YlVg= cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= @@ -764,8 +765,6 @@ cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcP cloud.google.com/go/workflows v1.11.1/go.mod h1:Z+t10G1wF7h8LgdY/EmRcQY8ptBD/nvofaL6FqlET6g= cosmossdk.io/api v0.7.5 h1:eMPTReoNmGUm8DeiQL9DyM8sYDjEhWzL1+nLbI9DqtQ= cosmossdk.io/api v0.7.5/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= -cosmossdk.io/client/v2 v2.0.0-beta.4 h1:LGIzWbVTOof/IHQZeoWwxPX0fq607ONXhsfA7eUrQIg= -cosmossdk.io/client/v2 v2.0.0-beta.4/go.mod h1:c753d0sBv3AQRx6X+BOKL1aGpKjZMTZAHGiLPbVi5TE= cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s= cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0= cosmossdk.io/core v0.11.0 h1:vtIafqUi+1ZNAE/oxLOQQ7Oek2n4S48SWLG8h/+wdbo= @@ -780,14 +779,6 @@ cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= cosmossdk.io/store v1.1.0 h1:LnKwgYMc9BInn9PhpTFEQVbL9UK475G2H911CGGnWHk= cosmossdk.io/store v1.1.0/go.mod h1:oZfW/4Fc/zYqu3JmQcQdUJ3fqu5vnYTn3LZFFy8P8ng= -cosmossdk.io/x/circuit v0.1.1 h1:KPJCnLChWrxD4jLwUiuQaf5mFD/1m7Omyo7oooefBVQ= -cosmossdk.io/x/circuit v0.1.1/go.mod h1:B6f/urRuQH8gjt4eLIXfZJucrbreuYrKh5CSjaOxr+Q= -cosmossdk.io/x/evidence v0.1.0 h1:J6OEyDl1rbykksdGynzPKG5R/zm6TacwW2fbLTW4nCk= -cosmossdk.io/x/evidence v0.1.0/go.mod h1:hTaiiXsoiJ3InMz1uptgF0BnGqROllAN8mwisOMMsfw= -cosmossdk.io/x/feegrant v0.1.1 h1:EKFWOeo/pup0yF0svDisWWKAA9Zags6Zd0P3nRvVvw8= -cosmossdk.io/x/feegrant v0.1.1/go.mod h1:2GjVVxX6G2fta8LWj7pC/ytHjryA6MHAJroBWHFNiEQ= -cosmossdk.io/x/nft v0.1.1 h1:pslAVS8P5NkW080+LWOamInjDcq+v2GSCo+BjN9sxZ8= -cosmossdk.io/x/nft v0.1.1/go.mod h1:Kac6F6y2gsKvoxU+fy8uvxRTi4BIhLOor2zgCNQwVgY= cosmossdk.io/x/tx v0.13.3 h1:Ha4mNaHmxBc6RMun9aKuqul8yHiL78EKJQ8g23Zf73g= cosmossdk.io/x/tx v0.13.3/go.mod h1:I8xaHv0rhUdIvIdptKIqzYy27+n2+zBVaxO6fscFhys= cosmossdk.io/x/upgrade v0.1.1 h1:aoPe2gNvH+Gwt/Pgq3dOxxQVU3j5P6Xf+DaUJTDZATc= @@ -912,14 +903,10 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= -github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI= github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= -github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= @@ -984,12 +971,6 @@ github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fr github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/cosmos/iavl v1.1.4 h1:Z0cVVjeQqOUp78/nWt/uhQy83vYluWlAMGQ4zbH9G34= github.com/cosmos/iavl v1.1.4/go.mod h1:vCYmRQUJU1wwj0oRD3wMEtOM9sJNDP+GFMaXmIxZ/rU= -github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 h1:dyLNlDElY6+5zW/BT/dO/3Ad9FpQblfh+9dQpYQodbA= -github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2/go.mod h1:82hPO/tRawbuFad2gPwChvpZ0JEIoNi91LwVneAYCeM= -github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= -github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= -github.com/cosmos/ibc-go/v8 v8.2.1 h1:MTsnZZjxvGD4Fv5pYyx5UkELafSX0rlPt6IfsE2BpTQ= -github.com/cosmos/ibc-go/v8 v8.2.1/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= @@ -1118,7 +1099,6 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -1226,12 +1206,10 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= @@ -1385,8 +1363,6 @@ github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0Jr github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= -github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= @@ -1405,7 +1381,6 @@ github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4E github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= @@ -1823,8 +1798,6 @@ go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1838,8 +1811,6 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -2183,7 +2154,6 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2349,8 +2319,6 @@ golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= @@ -2714,7 +2682,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/keeper/genesis.go b/keeper/genesis.go index a756217..ae2509c 100644 --- a/keeper/genesis.go +++ b/keeper/genesis.go @@ -7,33 +7,14 @@ import ( // InitGenesis initializes the module's state from a genesis state. func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) error { - for _, v := range data.Validators { - if err := k.SetValidatorAvailAddress(ctx, v); err != nil { - return err - } - } - - k.SetAvailGenesisState(ctx, data) return nil } // ExportGenesis exports the module's state to a genesis state. func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - vals, err := k.GetAllValidators(ctx) - if err != nil { - panic(err) - } - - // provenHeight, err := k.GetProvenHeight(ctx) - // if err != nil { - // panic(err) - // } - return &types.GenesisState{ - Validators: vals.Validators, - // ProvenHeight: provenHeight, - } + return &types.GenesisState{} } // SetAvailGenesisState imports avail light client's full state diff --git a/proto/sdk/avail/v1beta1/genesis.proto b/proto/sdk/avail/v1beta1/genesis.proto index 8cf6dfb..3d9ca4c 100644 --- a/proto/sdk/avail/v1beta1/genesis.proto +++ b/proto/sdk/avail/v1beta1/genesis.proto @@ -1,15 +1,9 @@ syntax = "proto3"; package sdk.avail.v1beta1; -import "gogoproto/gogo.proto"; -import "sdk/avail/v1beta1/validator.proto"; option go_package = "github.com/vitwit/avail-da-module/types"; // GenesisState defines the avail da module's genesis state. message GenesisState { - repeated Validator validators = 1 [ (gogoproto.nullable) = false ]; - - // the height of the last block that was proven to be posted to Avail. - // increment only, never skipping heights. - uint64 proven_height = 2; + } diff --git a/proto/sdk/avail/v1beta1/validator.proto b/proto/sdk/avail/v1beta1/validator.proto deleted file mode 100644 index 06ba5c6..0000000 --- a/proto/sdk/avail/v1beta1/validator.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; -package sdk.avail.v1beta1; - -import "amino/amino.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/vitwit/avail-da-module/types"; - -// Validator is a mapping of a local validator's address to its Avail transaction posting address -// for the purpose of feegranting blob posting on the DA layer. -message Validator { - option (amino.name) = "availblob/Validator"; - - string validator_address = 1; - // [ (cosmos_proto.scalar) = "cosmos.ValidatorAddressString" ]; - - string avail_address = 2; - // [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; -} - -// Validators is a collection of Validators. -message Validators { - option (amino.name) = "availblob/Validators"; - - // A list of all the validators - repeated Validator validators = 1 [ (gogoproto.nullable) = false ]; - } \ No newline at end of file diff --git a/types/genesis.pb.go b/types/genesis.pb.go index a91d26b..43a5ff8 100644 --- a/types/genesis.pb.go +++ b/types/genesis.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" math "math" @@ -25,10 +24,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the avail da module's genesis state. type GenesisState struct { - Validators []Validator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators"` - // the height of the last block that was proven to be posted to Avail. - // increment only, never skipping heights. - ProvenHeight uint64 `protobuf:"varint,2,opt,name=proven_height,json=provenHeight,proto3" json:"proven_height,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -64,20 +59,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetValidators() []Validator { - if m != nil { - return m.Validators - } - return nil -} - -func (m *GenesisState) GetProvenHeight() uint64 { - if m != nil { - return m.ProvenHeight - } - return 0 -} - func init() { proto.RegisterType((*GenesisState)(nil), "sdk.avail.v1beta1.GenesisState") } @@ -85,22 +66,17 @@ func init() { func init() { proto.RegisterFile("sdk/avail/v1beta1/genesis.proto", fileDescriptor_b83d128538762178) } var fileDescriptor_b83d128538762178 = []byte{ - // 239 bytes of a gzipped FileDescriptorProto + // 150 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2f, 0x4e, 0xc9, 0xd6, 0x4f, 0x2c, 0x4b, 0xcc, 0xcc, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2c, 0x4e, 0xc9, - 0xd6, 0x03, 0x2b, 0xd0, 0x83, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xea, 0x83, - 0x58, 0x10, 0x85, 0x52, 0x8a, 0x98, 0x26, 0x95, 0x25, 0xe6, 0x64, 0xa6, 0x24, 0x96, 0xe4, 0x17, - 0x41, 0x94, 0x28, 0x95, 0x73, 0xf1, 0xb8, 0x43, 0x0c, 0x0f, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x72, - 0xe2, 0xe2, 0x82, 0x2b, 0x29, 0x96, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x92, 0xd1, 0xc3, 0xb0, - 0x50, 0x2f, 0x0c, 0xa6, 0xc8, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0x24, 0x5d, 0x42, 0xca, - 0x5c, 0xbc, 0x05, 0x45, 0xf9, 0x65, 0xa9, 0x79, 0xf1, 0x19, 0xa9, 0x99, 0xe9, 0x19, 0x25, 0x12, - 0x4c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x3c, 0x10, 0x41, 0x0f, 0xb0, 0x98, 0x93, 0xe3, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, - 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xa9, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, - 0x25, 0xe7, 0xe7, 0xea, 0x97, 0x65, 0x96, 0x94, 0x67, 0x96, 0x40, 0xfc, 0xa0, 0x9b, 0x92, 0xa8, - 0x9b, 0x9b, 0x9f, 0x52, 0x9a, 0x93, 0xaa, 0x5f, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xf6, - 0x82, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x46, 0x1e, 0x50, 0xc0, 0x31, 0x01, 0x00, 0x00, + 0xd6, 0x03, 0x2b, 0xd0, 0x83, 0x2a, 0x50, 0xe2, 0xe3, 0xe2, 0x71, 0x87, 0xa8, 0x09, 0x2e, 0x49, + 0x2c, 0x49, 0x75, 0x72, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, + 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xf5, + 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xb2, 0xcc, 0x92, 0xf2, 0xcc, + 0x12, 0x88, 0x5d, 0xba, 0x29, 0x89, 0xba, 0xb9, 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xfa, 0x25, 0x95, + 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0xcb, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x18, 0x5a, + 0x23, 0xdb, 0x8f, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -123,25 +99,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ProvenHeight != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.ProvenHeight)) - i-- - dAtA[i] = 0x10 - } - if len(m.Validators) > 0 { - for iNdEx := len(m.Validators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Validators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } return len(dAtA) - i, nil } @@ -162,15 +119,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if len(m.Validators) > 0 { - for _, e := range m.Validators { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.ProvenHeight != 0 { - n += 1 + sovGenesis(uint64(m.ProvenHeight)) - } return n } @@ -209,59 +157,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validators", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Validators = append(m.Validators, Validator{}) - if err := m.Validators[len(m.Validators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProvenHeight", wireType) - } - m.ProvenHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProvenHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) From 3cca79ae4b2e9653219ea9048385487accc733f1 Mon Sep 17 00:00:00 2001 From: NagaTulasi Date: Mon, 23 Sep 2024 14:22:00 +0530 Subject: [PATCH 08/14] remove commented code --- chainclient/broadcast_tx.go | 5 +- chainclient/create_client.go | 20 ----- client/cli/keys.go | 6 +- client/cli/query.go | 5 +- client/cli/tx.go | 7 +- keeper/abci.go | 2 - keeper/collections.go | 44 ---------- keeper/genesis.go | 16 ---- keeper/keeper.go | 20 ++--- keeper/keeper_test.go | 5 +- keeper/msg_server_test.go | 2 - keeper/process_handle.go | 43 ---------- keeper/store.go | 32 ++++---- keys.go | 74 ----------------- module/module.go | 17 ++-- relayer/client.go | 151 ----------------------------------- relayer/init_test.go | 4 +- relayer/publish.go | 24 ------ relayer/relayer.go | 5 -- types/keys.go | 45 +++++++++++ 20 files changed, 86 insertions(+), 441 deletions(-) delete mode 100644 keeper/process_handle.go delete mode 100644 keys.go delete mode 100644 relayer/client.go create mode 100644 types/keys.go diff --git a/chainclient/broadcast_tx.go b/chainclient/broadcast_tx.go index ace3a0e..511076d 100644 --- a/chainclient/broadcast_tx.go +++ b/chainclient/broadcast_tx.go @@ -30,7 +30,6 @@ func GetBinPath(daemon string) string { // It uses keyring and RPC client configurations to interact with the network. 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) keyName := config.ValidatorKey rpcAddress := config.CosmosNodeRPC @@ -70,13 +69,13 @@ func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec. return fmt.Errorf("error retrieving account: %w", err) } + // Create a transaction factory // Set the correct account number and sequence factory := NewFactory(clientCtx). WithAccountNumber(account.GetAccountNumber()). WithSequence(account.GetSequence()) - // Create a transaction factory and set the validator address in the message - // factory := NewFactory(clientCtx) + // set the validator address in the message msg.ValidatorAddress = valAddr.String() // Generate and broadcast the transaction diff --git a/chainclient/create_client.go b/chainclient/create_client.go index c5a2816..bc511e2 100644 --- a/chainclient/create_client.go +++ b/chainclient/create_client.go @@ -1,8 +1,6 @@ package chainclient import ( - "fmt" - cometrpc "github.com/cometbft/cometbft/rpc/client/http" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -123,29 +121,11 @@ func AccountCreate(accountName, mnemonic, _ string, c client.Context) (*keyring. } path := hd.CreateHDPath(118, 0, 0).String() - // fmt.Println("pathhh......", path) - - // record, str, err := c.Keyring.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - // fmt.Println("recorddddd.......", err, str, record) - // k, _, err = kb.NewMnemonic("test", English, types.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) info, err := c.Keyring.NewAccount(accountName, mnemonic, keyring.DefaultBIP39Passphrase, path, algo) - fmt.Println("after creationnnn.........", info, err) if err != nil { return nil, err } - // pk, err := info.GetPubKey() - // if err != nil { - // return nil, err - // } - - // addr := sdk.AccAddress(pk.Address()) - // fmt.Println("address hereee...", addr) - - // aa, err := info.GetAddress() - // fmt.Println("here aa and err.......", aa, err) - // account := c.ToAccount(info) - // account.Mnemonic = mnemonic return info, nil } diff --git a/client/cli/keys.go b/client/cli/keys.go index e777e62..d47fa14 100644 --- a/client/cli/keys.go +++ b/client/cli/keys.go @@ -3,7 +3,7 @@ package cli import ( "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - availblob "github.com/vitwit/avail-da-module" + types "github.com/vitwit/avail-da-module/types" ) const ( @@ -16,8 +16,8 @@ const ( // NewKeysCmd returns a root CLI command handler for all x/availblob keys commands. func NewKeysCmd() *cobra.Command { keysCmd := &cobra.Command{ - Use: availblob.ModuleName, - Short: availblob.ModuleName + " keys subcommands", + Use: types.ModuleName, + Short: types.ModuleName + " keys subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/client/cli/query.go b/client/cli/query.go index 4037c0d..6f7f646 100644 --- a/client/cli/query.go +++ b/client/cli/query.go @@ -6,14 +6,13 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - availblob "github.com/vitwit/avail-da-module" - "github.com/vitwit/avail-da-module/types" + types "github.com/vitwit/avail-da-module/types" ) // GetQueryCmd returns the root query command for the avail-da module. func GetQueryCmd() *cobra.Command { cmd := &cobra.Command{ - Use: availblob.ModuleName, + Use: types.ModuleName, Short: "Querying commands for the avail-da module", RunE: client.ValidateCmd, } diff --git a/client/cli/tx.go b/client/cli/tx.go index fa8abd7..c154bad 100644 --- a/client/cli/tx.go +++ b/client/cli/tx.go @@ -9,16 +9,15 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" - availblob "github.com/vitwit/avail-da-module" "github.com/vitwit/avail-da-module/keeper" - "github.com/vitwit/avail-da-module/types" + types "github.com/vitwit/avail-da-module/types" ) // NewTxCmd creates and returns a Cobra command for transaction subcommands related to the availblob module. func NewTxCmd(_ *keeper.Keeper) *cobra.Command { txCmd := &cobra.Command{ - Use: availblob.ModuleName, - Short: availblob.ModuleName + " transaction subcommands", + Use: types.ModuleName, + Short: types.ModuleName + " transaction subcommands", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/keeper/abci.go b/keeper/abci.go index 656d467..90b0c87 100644 --- a/keeper/abci.go +++ b/keeper/abci.go @@ -76,8 +76,6 @@ func (h *ProofOfBlobProposalHandler) PrepareProposal(ctx sdk.Context, req *abci. // if there is any another tx, it might give any marshelling error, so ignoring this err bz, _ := json.Marshal(injectedVoteExtTx) - // proposalTxs = append(proposalTxs, bz) - proposalTxs = append([][]byte{bz}, proposalTxs...) return &abci.ResponsePrepareProposal{ Txs: proposalTxs, diff --git a/keeper/collections.go b/keeper/collections.go index 6b3b4c8..8b51247 100644 --- a/keeper/collections.go +++ b/keeper/collections.go @@ -38,47 +38,3 @@ func (k *Keeper) GetAllValidators(ctx context.Context) (types.Validators, error) return validators, nil } - -// func (k *Keeper) SetProvenHeight(ctx context.Context, height uint64) error { -// return k.ProvenHeight.Set(ctx, height) -// } - -// func (k *Keeper) GetProvenHeight(ctx context.Context) (uint64, error) { -// return k.ProvenHeight.Get(ctx) -// } - -// func (k *Keeper) SetClientID(ctx context.Context, clientID string) error { -// return k.ClientID.Set(ctx, clientID) -// } - -// func (k *Keeper) GetClientID(ctx context.Context) (string, error) { -// return k.ClientID.Get(ctx) -// } - -// IsBlockPending return true if a block height is already pending -// func (k Keeper) IsBlockPending(ctx context.Context, blockHeight int64) bool { -// found, err := k.PendingBlocksToTimeouts.Has(ctx, blockHeight) -// if err != nil { -// return false -// } -// return found -// } - -// IsBlockExpired will return true if a block is pending and expired, otherwise it returns false -// func (k *Keeper) IsBlockExpired(ctx context.Context, currentBlockTime time.Time, blockHeight int64) bool { -// currentBlockTimeNs := currentBlockTime.UnixNano() -// found, err := k.PendingBlocksToTimeouts.Has(ctx, blockHeight) -// if err != nil { -// return false -// } -// if found { -// expiration, err := k.PendingBlocksToTimeouts.Get(ctx, blockHeight) -// if err != nil { -// return false -// } -// if currentBlockTimeNs >= expiration { -// return true -// } -// } -// return false -// } diff --git a/keeper/genesis.go b/keeper/genesis.go index ae2509c..97ff7a0 100644 --- a/keeper/genesis.go +++ b/keeper/genesis.go @@ -7,26 +7,10 @@ import ( // InitGenesis initializes the module's state from a genesis state. func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) error { - return nil } // ExportGenesis exports the module's state to a genesis state. func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - return &types.GenesisState{} } - -// SetAvailGenesisState imports avail light client's full state -func (k Keeper) SetAvailGenesisState(_ sdk.Context, _ *types.GenesisState) { - // if gs != nil { - // store := ctx.KVStore(k.storeKey) - // for _, metadata := range gs.Metadata { - // store.Set(metadata.Key, metadata.Value) - // } - // avail.SetClientState(store, k.cdc, &gs.ClientState) - // for _, consensusStateWithHeight := range gs.ConsensusStates { - // avail.SetConsensusState(store, k.cdc, &consensusStateWithHeight.ConsensusState, consensusStateWithHeight.Height) - // } - // } -} diff --git a/keeper/keeper.go b/keeper/keeper.go index f8a86cc..6b1e3fb 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -10,21 +10,16 @@ import ( 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" "github.com/vitwit/avail-da-module/relayer" + types "github.com/vitwit/avail-da-module/types" ) type Keeper struct { - // stakingKeeper *stakingkeeper.Keeper upgradeKeeper *upgradekeeper.Keeper - relayer *relayer.Relayer + + relayer *relayer.Relayer Validators collections.Map[string, string] - // ClientID collections.Item[string] - // ProvenHeight collections.Item[uint64] - // PendingBlocksToTimeouts collections.Map[int64, int64] - // TimeoutsToPendingBlocks collections.Map[int64, types.PendingBlocks] - // keyring keyring.Keyring storeKey storetypes2.StoreKey @@ -33,7 +28,8 @@ type Keeper struct { unprovenBlocks map[int64][]byte ProposerAddress []byte - ClientCmd *cobra.Command + + ClientCmd *cobra.Command } func NewKeeper( @@ -50,11 +46,7 @@ func NewKeeper( return &Keeper{ upgradeKeeper: uk, - Validators: collections.NewMap(sb, availblob1.ValidatorsKey, "validators", collections.StringKey, collections.StringValue), - // ClientID: collections.NewItem(sb, availblob1.ClientIDKey, "client_id", collections.StringValue), - // ProvenHeight: collections.NewItem(sb, availblob1.ProvenHeightKey, "proven_height", collections.Uint64Value), - // PendingBlocksToTimeouts: collections.NewMap(sb, availblob1.PendingBlocksToTimeouts, "pending_blocks_to_timeouts", collections.Int64Key, collections.Int64Value), - // TimeoutsToPendingBlocks: collections.NewMap(sb, availblob1.TimeoutsToPendingBlocks, "timeouts_to_pending_blocks", collections.Int64Key, codec.CollValue[types.PendingBlocks](cdc)), + Validators: collections.NewMap(sb, types.ValidatorsKey, "validators", collections.StringKey, collections.StringValue), storeKey: key, diff --git a/keeper/keeper_test.go b/keeper/keeper_test.go index 6f21bb4..c1d7ebd 100644 --- a/keeper/keeper_test.go +++ b/keeper/keeper_test.go @@ -19,11 +19,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/stretchr/testify/suite" - cada "github.com/vitwit/avail-da-module" "github.com/vitwit/avail-da-module/keeper" module "github.com/vitwit/avail-da-module/module" relayer "github.com/vitwit/avail-da-module/relayer" - "github.com/vitwit/avail-da-module/types" + types "github.com/vitwit/avail-da-module/types" ) type TestSuite struct { @@ -52,7 +51,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (s *TestSuite) SetupTest() { - key := storetypes.NewKVStoreKey(cada.ModuleName) + key := storetypes.NewKVStoreKey(types.ModuleName) storeService := runtime.NewKVStoreService(key) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) diff --git a/keeper/msg_server_test.go b/keeper/msg_server_test.go index 1fa8773..6da59f4 100644 --- a/keeper/msg_server_test.go +++ b/keeper/msg_server_test.go @@ -6,8 +6,6 @@ import ( ) func (s *TestSuite) TestMsgServer_UpdateBlobStatus() { - // err := s.keeper.SetProvenHeight(s.ctx, 10) - // s.Require().NoError(err) err := availkeeper.UpdateEndHeight(s.ctx, s.store, uint64(20)) s.Require().NoError(err) diff --git a/keeper/process_handle.go b/keeper/process_handle.go deleted file mode 100644 index 84821e6..0000000 --- a/keeper/process_handle.go +++ /dev/null @@ -1,43 +0,0 @@ -package keeper - -// import ( -// "time" - -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/vitwit/avail-da-module/types" -// ) - -// func (k Keeper) processPendingBlocks(_ sdk.Context, _ time.Time, _ *types.PendingBlocks) error { -// // if pendingBlocks != nil { -// // height := ctx.BlockHeight() -// // numBlocks := len(pendingBlocks.BlockHeights) -// // if numBlocks > 2 && numBlocks > k.publishToAvailBlockInterval { -// // return fmt.Errorf("process pending blocks, included pending blocks (%d) exceeds limit (%d)", numBlocks, k.publishToAvailBlockInterval) -// // } -// // for _, pendingBlock := range pendingBlocks.BlockHeights { -// // if pendingBlock <= 0 { -// // return fmt.Errorf("process pending blocks, invalid block: %d", pendingBlock) -// // } -// // if pendingBlock >= height { -// // return fmt.Errorf("process pending blocks, start (%d) cannot be >= this block height (%d)", pendingBlock, height) -// // } -// // // Check if already pending, if so, is it expired? -// // if k.IsBlockPending(ctx, pendingBlock) && !k.IsBlockExpired(ctx, currentBlockTime, pendingBlock) { -// // return fmt.Errorf("process pending blocks, block height (%d) is pending, but not expired", pendingBlock) -// // } -// // } -// // // Ensure publish boundries includes new blocks, once they are on-chain, they will be tracked appropriately -// // provenHeight, err := k.GetProvenHeight(ctx) -// // if err != nil { -// // return fmt.Errorf("process pending blocks, getting proven height, %v", err) -// // } -// // newBlocks := k.relayer.ProposePostNextBlocks(ctx, provenHeight) -// // for i, newBlock := range newBlocks { -// // if newBlock != pendingBlocks.BlockHeights[i] { -// // return fmt.Errorf("process pending blocks, block (%d) must be included", newBlock) -// // } -// // } -// // } - -// return nil -// } diff --git a/keeper/store.go b/keeper/store.go index 215d8ca..172a71a 100644 --- a/keeper/store.go +++ b/keeper/store.go @@ -7,7 +7,7 @@ import ( "cosmossdk.io/collections" storetypes2 "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - availblob1 "github.com/vitwit/avail-da-module" + types "github.com/vitwit/avail-da-module/types" ) const ( @@ -47,7 +47,7 @@ func ParseVotingEndHeight(height uint64) string { // CanUpdateStatusToPending checks if the blob status can be updated to "pending". // This function verifies whether the current status allows transitioning to the "pending" state. func CanUpdateStatusToPending(store storetypes2.KVStore) bool { - statusBytes := store.Get(availblob1.BlobStatusKey) + statusBytes := store.Get(types.BlobStatusKey) if len(statusBytes) == 0 { return true } @@ -59,7 +59,7 @@ func CanUpdateStatusToPending(store storetypes2.KVStore) bool { // GetStatusFromStore retrieves the current status of the blob from the store. func GetStatusFromStore(store storetypes2.KVStore) uint32 { - statusBytes := store.Get(availblob1.BlobStatusKey) + statusBytes := store.Get(types.BlobStatusKey) if len(statusBytes) == 0 { return ReadyState @@ -76,35 +76,35 @@ func UpdateBlobStatus(_ sdk.Context, store storetypes2.KVStore, status uint32) e binary.BigEndian.PutUint32(statusBytes, status) - store.Set(availblob1.BlobStatusKey, statusBytes) + store.Set(types.BlobStatusKey, statusBytes) return nil } // UpdateStartHeight updates the start height in the KV store. func UpdateStartHeight(_ sdk.Context, store storetypes2.KVStore, startHeight uint64) error { - return updateHeight(store, availblob1.PrevHeightKey, startHeight) + return updateHeight(store, types.PrevHeightKey, startHeight) } // UpdateEndHeight updates the end height in the KV store. func UpdateEndHeight(_ sdk.Context, store storetypes2.KVStore, endHeight uint64) error { - return updateHeight(store, availblob1.NextHeightKey, endHeight) + return updateHeight(store, types.NextHeightKey, endHeight) } // UpdateProvenHeight updates the proven height in the KV store. func UpdateProvenHeight(_ sdk.Context, store storetypes2.KVStore, provenHeight uint64) error { - return updateHeight(store, availblob1.ProvenHeightKey, provenHeight) + return updateHeight(store, types.ProvenHeightKey, provenHeight) } // UpdateAvailHeight updates the avail height in the store func UpdateAvailHeight(_ sdk.Context, store storetypes2.KVStore, availHeight uint64) error { - return updateHeight(store, availblob1.AvailHeightKey, availHeight) + return updateHeight(store, types.AvailHeightKey, availHeight) } // UpdateVotingEndHeight updates the voting end height in the KV store. func UpdateVotingEndHeight(_ sdk.Context, store storetypes2.KVStore, votingEndHeight uint64, isLastVoting bool) error { - key := availblob1.VotingEndHeightKey + key := types.VotingEndHeightKey if isLastVoting { - key = availblob1.LastVotingEndHeightKey + key = types.LastVotingEndHeightKey } return updateHeight(store, key, votingEndHeight) } @@ -121,31 +121,31 @@ func updateHeight(store storetypes2.KVStore, key collections.Prefix, height uint // GetProvenHeightFromStore retrieves the proven height from the KV store. func (k *Keeper) GetProvenHeightFromStore(ctx sdk.Context) uint64 { - return k.getHeight(ctx, availblob1.ProvenHeightKey) + return k.getHeight(ctx, types.ProvenHeightKey) } // GetAvailHeightFromStore retrieves the avail height from the KV store. func (k *Keeper) GetAvailHeightFromStore(ctx sdk.Context) uint64 { - return k.getHeight(ctx, availblob1.AvailHeightKey) + return k.getHeight(ctx, types.AvailHeightKey) } // GetVotingEndHeightFromStore retrieves the ending vote height from store func (k *Keeper) GetVotingEndHeightFromStore(ctx sdk.Context, isLastVoting bool) uint64 { - key := availblob1.VotingEndHeightKey + key := types.VotingEndHeightKey if isLastVoting { - key = availblob1.LastVotingEndHeightKey + key = types.LastVotingEndHeightKey } return k.getHeight(ctx, key) } // GetStartHeightFromStore retrieves the start height from store func (k *Keeper) GetStartHeightFromStore(ctx sdk.Context) uint64 { - return k.getHeight(ctx, availblob1.PrevHeightKey) + return k.getHeight(ctx, types.PrevHeightKey) } // GetEndHeightFromStore retrieves the end height from store func (k *Keeper) GetEndHeightFromStore(ctx sdk.Context) uint64 { - return k.getHeight(ctx, availblob1.NextHeightKey) + return k.getHeight(ctx, types.NextHeightKey) } // getHeight retrieves and decodes a height value from the KV store. diff --git a/keys.go b/keys.go deleted file mode 100644 index f90c0a0..0000000 --- a/keys.go +++ /dev/null @@ -1,74 +0,0 @@ -package availblob - -import ( - "encoding/binary" - - "cosmossdk.io/collections" - "github.com/vitwit/avail-da-module/types" -) - -var ( - - // ValidatorsKey saves the current validators. - ValidatorsKey = collections.NewPrefix(0) - - // ClientIDKey saves the current clientID. - ClientIDKey = collections.NewPrefix(1) - - // ProvenHeightKey saves the current proven height. - ProvenHeightKey = collections.NewPrefix(2) - - // PendingBlocksToTimeouts maps pending blocks to their timeout - // PendingBlocksToTimeouts = collections.NewPrefix(3) - - // TimeoutsToPendingBlocks maps timeouts to a set of pending blocks - // TimeoutsToPendingBlocks = collections.NewPrefix(4) - - // light client store key - // ClientStoreKey = []byte("client_store/") - - PendingBlobsKey = collections.NewPrefix(3) - - BlobStatusKey = collections.NewPrefix(4) - - PrevHeightKey = collections.NewPrefix(5) - - NextHeightKey = collections.NewPrefix(6) - - VotingEndHeightKey = collections.NewPrefix(7) - - LastVotingEndHeightKey = collections.NewPrefix(8) - - AvailHeightKey = collections.NewPrefix(9) -) - -const ( - // ModuleName is the name of the module - ModuleName = "cada" - - // StoreKey to be used when creating the KVStore - StoreKey = ModuleName - - // RouterKey to be used for routing msgs - RouterKey = ModuleName - - // QuerierRoute to be used for querier msgs - QuerierRoute = ModuleName -) - -// PendingBlobsStoreKey generates a store key for pending blobs based on the given block range. -// The key is constructed by appending the byte-encoded 'From' and 'To' values from the `blocksRange` -// to a base key (`PendingBlobsKey`). This unique key is used to store and retrieve pending blob data -// in a key-value store. -func PendingBlobsStoreKey(blocksRange types.Range) []byte { - fromBytes := make([]byte, 8) - binary.BigEndian.PutUint64(fromBytes, blocksRange.From) - - toBytes := make([]byte, 8) - binary.BigEndian.PutUint64(toBytes, blocksRange.To) - - key := PendingBlobsKey - key = append(key, fromBytes...) - key = append(key, toBytes...) - return key -} diff --git a/module/module.go b/module/module.go index 3eb4d1f..5367651 100644 --- a/module/module.go +++ b/module/module.go @@ -14,10 +14,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" - availblob "github.com/vitwit/avail-da-module" "github.com/vitwit/avail-da-module/client/cli" "github.com/vitwit/avail-da-module/keeper" - "github.com/vitwit/avail-da-module/types" + types "github.com/vitwit/avail-da-module/types" ) var ( @@ -37,7 +36,7 @@ type AppModuleBasic struct { // Name returns the params module's name. func (AppModuleBasic) Name() string { - return availblob.ModuleName + return types.ModuleName } // RegisterLegacyAminoCodec registers the params module's types on the given LegacyAmino codec. @@ -78,11 +77,11 @@ func NewAppModule(cdc codec.Codec, keeper *keeper.Keeper) AppModule { } func NewAppModuleBasic(m AppModule) module.AppModuleBasic { - return module.CoreAppModuleBasicAdaptor(availblob.ModuleName, m) + return module.CoreAppModuleBasicAdaptor(types.ModuleName, m) } // Name returns the rollchain module's name. -func (AppModule) Name() string { return availblob.ModuleName } +func (AppModule) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the rollchain module's types on the LegacyAmino codec. func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { @@ -117,12 +116,6 @@ func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(am.keeper)) - - // Register in place module state migration migrations - // m := keeper.NewMigrator(am.keeper) - // if err := cfg.RegisterMigration(rollchain.ModuleName, 1, m.Migrate1to2); err != nil { - // panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", rollchain.ModuleName, err)) - // } } // DefaultGenesis returns default genesis state as raw bytes for the module. @@ -134,7 +127,7 @@ func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", availblob.ModuleName, err) + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) } return data.Validate() diff --git a/relayer/client.go b/relayer/client.go deleted file mode 100644 index af26f6b..0000000 --- a/relayer/client.go +++ /dev/null @@ -1,151 +0,0 @@ -package relayer - -// import ( -// "fmt" - -// cometrpc "github.com/cometbft/cometbft/rpc/client/http" -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/client/tx" -// "github.com/cosmos/cosmos-sdk/codec" -// codectypes "github.com/cosmos/cosmos-sdk/codec/types" -// "github.com/cosmos/cosmos-sdk/crypto/hd" -// "github.com/cosmos/cosmos-sdk/crypto/keyring" -// "github.com/cosmos/cosmos-sdk/std" -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/cosmos/cosmos-sdk/types/module" -// "github.com/cosmos/cosmos-sdk/types/tx/signing" -// authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" -// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" -// "github.com/cosmos/go-bip39" -// ) - -// const ( -// defaultGasAdjustment = 1.0 -// defaultGasLimit = 300000 -// ) - -// // var availdHomePath = xfilepath.JoinFromHome(xfilepath.Path("availsdk")) - -// func NewClientCtx(kr keyring.Keyring, c *cometrpc.HTTP, chainID string, -// cdc codec.BinaryCodec, homepath string, fromAddress sdk.AccAddress, -// ) client.Context { -// encodingConfig := MakeEncodingConfig() - -// broadcastMode := flags.BroadcastSync - -// return client.Context{}. -// WithCodec(cdc.(codec.Codec)). -// WithChainID(chainID). -// WithFromAddress(fromAddress). -// WithFromName("testkey"). -// WithKeyringDir(homepath). -// WithBroadcastMode(broadcastMode). -// WithTxConfig(authTx.NewTxConfig(cdc.(codec.Codec), authTx.DefaultSignModes)). -// WithKeyring(kr). -// WithAccountRetriever(authtypes.AccountRetriever{}). -// WithClient(c).WithInterfaceRegistry(encodingConfig.InterfaceRegistry). -// WithSkipConfirmation(true) -// } - -// // NewFactory creates a new Factory. -// func NewFactory(clientCtx client.Context) tx.Factory { -// return tx.Factory{}. -// WithChainID(clientCtx.ChainID). -// WithKeybase(clientCtx.Keyring). -// WithGas(defaultGasLimit). -// WithGasAdjustment(defaultGasAdjustment). -// WithSignMode(signing.SignMode_SIGN_MODE_DIRECT). -// WithAccountRetriever(clientCtx.AccountRetriever). -// WithTxConfig(clientCtx.TxConfig) -// } - -// // MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. -// func MakeEncodingConfig(modules ...module.AppModuleBasic) EncodingConfig { -// aminoCodec := codec.NewLegacyAmino() -// interfaceRegistry := codectypes.NewInterfaceRegistry() -// codec := codec.NewProtoCodec(interfaceRegistry) -// txCfg := authTx.NewTxConfig(codec, authTx.DefaultSignModes) - -// encCfg := EncodingConfig{ -// InterfaceRegistry: interfaceRegistry, -// Codec: codec, -// TxConfig: txCfg, -// Amino: aminoCodec, -// } - -// mb := module.NewBasicManager(modules...) - -// std.RegisterLegacyAminoCodec(encCfg.Amino) -// std.RegisterInterfaces(encCfg.InterfaceRegistry) -// mb.RegisterLegacyAminoCodec(encCfg.Amino) -// mb.RegisterInterfaces(encCfg.InterfaceRegistry) - -// return encCfg -// } - -// // EncodingConfig specifies the concrete encoding types to use for a given app. -// // This is provided for compatibility between protobuf and amino implementations. -// type EncodingConfig struct { -// InterfaceRegistry codectypes.InterfaceRegistry -// Codec codec.Codec -// TxConfig client.TxConfig -// Amino *codec.LegacyAmino -// } - -// // ImportMnemonic is to import existing account mnemonic in keyring -// func ImportMnemonic(keyName, mnemonic, hdPath string, c client.Context) (*keyring.Record, error) { -// info, err := AccountCreate(keyName, mnemonic, hdPath, c) // return account also -// if err != nil { -// return nil, err -// } - -// return info, nil -// } - -// // AccountCreate creates an account by name and mnemonic (optional) in the keyring. -// func AccountCreate(accountName, mnemonic, _ string, c client.Context) (*keyring.Record, error) { -// if mnemonic == "" { -// entropySeed, err := bip39.NewEntropy(256) -// if err != nil { -// return nil, err -// } -// mnemonic, err = bip39.NewMnemonic(entropySeed) -// if err != nil { -// return nil, err -// } -// } - -// algos, _ := c.Keyring.SupportedAlgorithms() -// algo, err := keyring.NewSigningAlgoFromString(string(hd.Secp256k1Type), algos) -// if err != nil { -// return nil, err -// } - -// path := hd.CreateHDPath(118, 0, 0).String() -// // fmt.Println("pathhh......", path) - -// // record, str, err := c.Keyring.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) -// // fmt.Println("recorddddd.......", err, str, record) - -// // k, _, err = kb.NewMnemonic("test", English, types.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) -// info, err := c.Keyring.NewAccount(accountName, mnemonic, keyring.DefaultBIP39Passphrase, path, algo) -// fmt.Println("after creationnnn.........", info, err) -// if err != nil { -// return nil, err -// } -// // pk, err := info.GetPubKey() -// // if err != nil { -// // return nil, err -// // } - -// // addr := sdk.AccAddress(pk.Address()) -// // fmt.Println("address hereee...", addr) - -// // aa, err := info.GetAddress() -// // fmt.Println("here aa and err.......", aa, err) - -// // account := c.ToAccount(info) -// // account.Mnemonic = mnemonic -// return info, nil -// } diff --git a/relayer/init_test.go b/relayer/init_test.go index 1975c24..e6a0ce3 100644 --- a/relayer/init_test.go +++ b/relayer/init_test.go @@ -15,10 +15,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/stretchr/testify/suite" - cada "github.com/vitwit/avail-da-module" module "github.com/vitwit/avail-da-module/module" relayer "github.com/vitwit/avail-da-module/relayer" httpclient "github.com/vitwit/avail-da-module/relayer/http" + types "github.com/vitwit/avail-da-module/types" ) type RelayerTestSuite struct { @@ -38,7 +38,7 @@ func TestRelayerTestSuite(t *testing.T) { } func (s *RelayerTestSuite) SetupTest() { - key := storetypes.NewKVStoreKey(cada.ModuleName) + key := storetypes.NewKVStoreKey(types.ModuleName) testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) s.encCfg = moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{}) diff --git a/relayer/publish.go b/relayer/publish.go index 8789355..c8306f0 100644 --- a/relayer/publish.go +++ b/relayer/publish.go @@ -10,29 +10,6 @@ import ( "github.com/vitwit/avail-da-module/types" ) -// func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []int64 { -// height := ctx.BlockHeight() - -// if height <= 1 { -// return nil -// } - -// // only publish new blocks on interval -// if (height-1)%int64(r.AvailConfig.PublishBlobInterval) != 0 { -// return nil -// } - -// var blocks []int64 -// 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) -// } -// } - -// return blocks -// } - // PostBlocks is called in the PreBlocker. The proposer will publish the blocks at this point // once their block has been accepted. The method launches the posting process in a separate // goroutine to handle the submission of blocks asynchronously. @@ -98,7 +75,6 @@ func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCo From: uint64(blocks[0]), To: uint64(blocks[len(blocks)-1]), }, - // AvailHeight: uint64(blockInfo.BlockNumber), IsSuccess: false, }, cdc, r.AvailConfig, r.NodeDir) if err != nil { diff --git a/relayer/relayer.go b/relayer/relayer.go index 9ef7021..ac8fcb0 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -11,11 +11,6 @@ import ( "github.com/vitwit/avail-da-module/types" ) -// const ( -// DefaultMaxFlushSize = int(20) -// MaxMaxFlushSize = int(100) -// ) - // Relayer is responsible for posting new blocks to Avail type Relayer struct { logger log.Logger diff --git a/types/keys.go b/types/keys.go new file mode 100644 index 0000000..75d227c --- /dev/null +++ b/types/keys.go @@ -0,0 +1,45 @@ +package types + +import ( + "cosmossdk.io/collections" +) + +var ( + + // ValidatorsKey saves the current validators. + ValidatorsKey = collections.NewPrefix(0) + + // ClientIDKey saves the current clientID. + ClientIDKey = collections.NewPrefix(1) + + // ProvenHeightKey saves the current proven height. + ProvenHeightKey = collections.NewPrefix(2) + + PendingBlobsKey = collections.NewPrefix(3) + + BlobStatusKey = collections.NewPrefix(4) + + PrevHeightKey = collections.NewPrefix(5) + + NextHeightKey = collections.NewPrefix(6) + + VotingEndHeightKey = collections.NewPrefix(7) + + LastVotingEndHeightKey = collections.NewPrefix(8) + + AvailHeightKey = collections.NewPrefix(9) +) + +const ( + // ModuleName is the name of the module + ModuleName = "cada" + + // StoreKey to be used when creating the KVStore + StoreKey = ModuleName + + // RouterKey to be used for routing msgs + RouterKey = ModuleName + + // QuerierRoute to be used for querier msgs + QuerierRoute = ModuleName +) From 4b291197dd4d764dae88ce34b2279dc8b7293f56 Mon Sep 17 00:00:00 2001 From: NagaTulasi Date: Mon, 23 Sep 2024 14:36:11 +0530 Subject: [PATCH 09/14] fix build issue --- simapp/app/app.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/simapp/app/app.go b/simapp/app/app.go index 525fc1a..f3a969a 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -38,7 +38,7 @@ import ( ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cast" - availblob1 "github.com/vitwit/avail-da-module" + availtypes "github.com/vitwit/avail-da-module/types" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" @@ -143,7 +143,6 @@ import ( availblobrelayer "github.com/vitwit/avail-da-module/relayer" "github.com/vitwit/avail-da-module/relayer/avail" httpclient "github.com/vitwit/avail-da-module/relayer/http" - availblobmoduletypes "github.com/vitwit/avail-da-module/types" ) const ( @@ -343,7 +342,7 @@ func NewChainApp( icahosttypes.StoreKey, icacontrollertypes.StoreKey, packetforwardtypes.StoreKey, - availblob1.StoreKey, + availtypes.StoreKey, ) tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -687,7 +686,7 @@ func NewChainApp( httpClient := httpclient.NewHandler() // Avail-DA client - cfg := availblobmoduletypes.AvailConfigFromAppOpts(appOpts) + cfg := availtypes.AvailConfigFromAppOpts(appOpts) availDAClient := avail.NewLightClient(cfg.LightClientURL, httpClient) app.Availblobrelayer, err = availblobrelayer.NewRelayer( @@ -703,9 +702,9 @@ func NewChainApp( app.AvailBlobKeeper = availblobkeeper.NewKeeper( appCodec, - runtime.NewKVStoreService(keys[availblob1.StoreKey]), + runtime.NewKVStoreService(keys[availtypes.StoreKey]), app.UpgradeKeeper, - keys[availblob1.StoreKey], + keys[availtypes.StoreKey], appOpts, logger, app.Availblobrelayer, @@ -817,7 +816,7 @@ func NewChainApp( icatypes.ModuleName, ibcfeetypes.ModuleName, packetforwardtypes.ModuleName, - availblob1.ModuleName, + availtypes.ModuleName, ) app.ModuleManager.SetOrderEndBlockers( @@ -834,7 +833,7 @@ func NewChainApp( icatypes.ModuleName, ibcfeetypes.ModuleName, packetforwardtypes.ModuleName, - availblob1.ModuleName, + availtypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -859,7 +858,7 @@ func NewChainApp( icatypes.ModuleName, ibcfeetypes.ModuleName, packetforwardtypes.ModuleName, - availblob1.ModuleName, + availtypes.ModuleName, } app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...) From 5b982583614f195ae24a36f14e3ed7d2d31cfe39 Mon Sep 17 00:00:00 2001 From: NagaTulasi Date: Mon, 23 Sep 2024 14:59:33 +0530 Subject: [PATCH 10/14] upadte build.yml --- .github/workflows/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ae1627..45f22f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,5 +26,8 @@ jobs: - name: Display Go version run: go version - - name: Build cada - run: make build + # - name: Build cada + # run: make build + + - name: Build simapp + run: make -C simapp build From 0a2d8ebce8a427ccae8fb77d19d5879322e43faf Mon Sep 17 00:00:00 2001 From: NagaTulasi Date: Mon, 23 Sep 2024 15:07:03 +0530 Subject: [PATCH 11/14] fix lint & tests --- keeper/genesis.go | 4 ++-- keeper/msg_server_test.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/keeper/genesis.go b/keeper/genesis.go index 97ff7a0..368155c 100644 --- a/keeper/genesis.go +++ b/keeper/genesis.go @@ -6,11 +6,11 @@ import ( ) // InitGenesis initializes the module's state from a genesis state. -func (k *Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) error { +func (k *Keeper) InitGenesis(_ sdk.Context, _ *types.GenesisState) error { return nil } // ExportGenesis exports the module's state to a genesis state. -func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { +func (k *Keeper) ExportGenesis(_ sdk.Context) *types.GenesisState { return &types.GenesisState{} } diff --git a/keeper/msg_server_test.go b/keeper/msg_server_test.go index 6da59f4..047dba4 100644 --- a/keeper/msg_server_test.go +++ b/keeper/msg_server_test.go @@ -6,7 +6,6 @@ import ( ) func (s *TestSuite) TestMsgServer_UpdateBlobStatus() { - err := availkeeper.UpdateEndHeight(s.ctx, s.store, uint64(20)) s.Require().NoError(err) @@ -21,7 +20,7 @@ func (s *TestSuite) TestMsgServer_UpdateBlobStatus() { &types.MsgUpdateBlobStatusRequest{ ValidatorAddress: s.addrs[1].String(), BlocksRange: &types.Range{ - From: 11, + From: 1, To: 20, }, AvailHeight: 20, @@ -49,7 +48,7 @@ func (s *TestSuite) TestMsgServer_UpdateBlobStatus() { &types.MsgUpdateBlobStatusRequest{ ValidatorAddress: s.addrs[1].String(), BlocksRange: &types.Range{ - From: 11, + From: 1, To: 20, }, AvailHeight: 20, From 0265f3332512a5741490df89dad5fce3d6ad43ba Mon Sep 17 00:00:00 2001 From: NagaTulasi Date: Mon, 23 Sep 2024 16:12:28 +0530 Subject: [PATCH 12/14] rename availd to cada --- Makefile | 8 +-- chainclient/broadcast_tx.go | 6 +- client/cli/keys.go | 2 +- client/cli/query.go | 4 +- client/cli/tx.go | 2 +- keeper/msg_server_test.go | 6 +- proto/sdk/avail/v1beta1/tx.proto | 2 +- relayer/submit_data_test.go | 4 +- simapp/Makefile | 20 +++---- simapp/app/app.go | 61 +++++++++------------ simapp/cmd/{availd => cada}/commads.go | 12 ++-- simapp/cmd/{availd => cada}/main.go | 0 simapp/cmd/{availd => cada}/root.go | 4 +- simapp/cmd/{availd => cada}/testnet.go | 6 +- simapp/cmd/{availd => cada}/testnet_test.go | 0 simapp/init-simapp.sh | 4 +- 16 files changed, 67 insertions(+), 74 deletions(-) rename simapp/cmd/{availd => cada}/commads.go (96%) rename simapp/cmd/{availd => cada}/main.go (100%) rename simapp/cmd/{availd => cada}/root.go (97%) rename simapp/cmd/{availd => cada}/testnet.go (98%) rename simapp/cmd/{availd => cada}/testnet_test.go (100%) diff --git a/Makefile b/Makefile index 81c342a..82780b1 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ lint-fix: .PHONY: lint lint-fix GO := go -TARGET := availd +TARGET := cada BINDIR ?= $(GOPATH)/bin .PHONY: all build install clean @@ -100,9 +100,9 @@ clean: # Run this before testnet keys are added # chainid-1 is used in the testnet.json set-testnet-configs: - availd config set client chain-id chainid-1 - availd config set client keyring-backend test - availd config set client output text + cada config set client chain-id chainid-1 + cada config set client keyring-backend test + cada config set client output text ############################################################################### diff --git a/chainclient/broadcast_tx.go b/chainclient/broadcast_tx.go index 511076d..85c44fd 100644 --- a/chainclient/broadcast_tx.go +++ b/chainclient/broadcast_tx.go @@ -15,15 +15,15 @@ import ( "github.com/vitwit/avail-da-module/types" ) -// GetBinPath returns the path to the Avail SDK home directory within the user's home directory. +// GetBinPath returns the path to the cada home directory within the user's home directory. func GetBinPath(daemon string) string { homeDir, err := os.UserHomeDir() if err != nil { log.Fatal(err) } - availdHomePath := filepath.Join(homeDir, daemon) - return availdHomePath + cadaHomePath := filepath.Join(homeDir, daemon) + return cadaHomePath } // ExecuteTX handles the creation and submission of a transaction to update blob status on the chain. diff --git a/client/cli/keys.go b/client/cli/keys.go index d47fa14..9752073 100644 --- a/client/cli/keys.go +++ b/client/cli/keys.go @@ -13,7 +13,7 @@ const ( FlagCoinType = "coin-type" ) -// NewKeysCmd returns a root CLI command handler for all x/availblob keys commands. +// NewKeysCmd returns a root CLI command handler for all cada keys commands. func NewKeysCmd() *cobra.Command { keysCmd := &cobra.Command{ Use: types.ModuleName, diff --git a/client/cli/query.go b/client/cli/query.go index 6f7f646..d6d37cb 100644 --- a/client/cli/query.go +++ b/client/cli/query.go @@ -9,11 +9,11 @@ import ( types "github.com/vitwit/avail-da-module/types" ) -// GetQueryCmd returns the root query command for the avail-da module. +// GetQueryCmd returns the root query command for the cada module. func GetQueryCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the avail-da module", + Short: "Querying commands for the cada module", RunE: client.ValidateCmd, } diff --git a/client/cli/tx.go b/client/cli/tx.go index c154bad..b589c65 100644 --- a/client/cli/tx.go +++ b/client/cli/tx.go @@ -13,7 +13,7 @@ import ( types "github.com/vitwit/avail-da-module/types" ) -// NewTxCmd creates and returns a Cobra command for transaction subcommands related to the availblob module. +// NewTxCmd creates and returns a Cobra command for transaction subcommands related to the cada module. func NewTxCmd(_ *keeper.Keeper) *cobra.Command { txCmd := &cobra.Command{ Use: types.ModuleName, diff --git a/keeper/msg_server_test.go b/keeper/msg_server_test.go index 047dba4..64b1a8d 100644 --- a/keeper/msg_server_test.go +++ b/keeper/msg_server_test.go @@ -1,12 +1,12 @@ package keeper_test import ( - availkeeper "github.com/vitwit/avail-da-module/keeper" + cadakeeper "github.com/vitwit/avail-da-module/keeper" "github.com/vitwit/avail-da-module/types" ) func (s *TestSuite) TestMsgServer_UpdateBlobStatus() { - err := availkeeper.UpdateEndHeight(s.ctx, s.store, uint64(20)) + err := cadakeeper.UpdateEndHeight(s.ctx, s.store, uint64(20)) s.Require().NoError(err) testCases := []struct { @@ -75,7 +75,7 @@ func (s *TestSuite) TestMsgServer_UpdateBlobStatus() { for _, tc := range testCases { s.Run(tc.name, func() { - availkeeper.UpdateBlobStatus(s.ctx, s.store, tc.status) + cadakeeper.UpdateBlobStatus(s.ctx, s.store, tc.status) s.Require().NoError(err) _, err := s.msgserver.UpdateBlobStatus(s.ctx, tc.inputMsg) diff --git a/proto/sdk/avail/v1beta1/tx.proto b/proto/sdk/avail/v1beta1/tx.proto index a09bbbc..8b56279 100644 --- a/proto/sdk/avail/v1beta1/tx.proto +++ b/proto/sdk/avail/v1beta1/tx.proto @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/vitwit/avail-da-module/types"; -// Msg defines the Msg service for avail da module +// Msg defines the Msg service for cada module service Msg { option (cosmos.msg.v1.service) = true; diff --git a/relayer/submit_data_test.go b/relayer/submit_data_test.go index aad6e24..6c1c5d3 100644 --- a/relayer/submit_data_test.go +++ b/relayer/submit_data_test.go @@ -8,7 +8,7 @@ import ( relayer "github.com/vitwit/avail-da-module/relayer" "github.com/vitwit/avail-da-module/relayer/avail" mocks "github.com/vitwit/avail-da-module/relayer/avail/mocks" - availtypes "github.com/vitwit/avail-da-module/types" + cadatypes "github.com/vitwit/avail-da-module/types" ) func TestSubmitDataToAvailClient(t *testing.T) { @@ -19,7 +19,7 @@ func TestSubmitDataToAvailClient(t *testing.T) { relayer := &relayer.Relayer{ AvailDAClient: mockDAClient, Logger: logger, - AvailConfig: availtypes.AvailConfiguration{AppID: 1}, + AvailConfig: cadatypes.AvailConfiguration{AppID: 1}, } data := []byte("test data") diff --git a/simapp/Makefile b/simapp/Makefile index 479c3c9..bec3ba0 100644 --- a/simapp/Makefile +++ b/simapp/Makefile @@ -54,7 +54,7 @@ build_tags_comma_sep := $(subst $(empty),$(comma),$(build_tags)) # process linker flags ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=rollchain \ - -X github.com/cosmos/cosmos-sdk/version.AppName=availd \ + -X github.com/cosmos/cosmos-sdk/version.AppName=cada \ -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" @@ -77,11 +77,11 @@ ifeq ($(OS),Windows_NT) $(error wasmd server not supported. Use "make build-windows-client" for client) exit 1 else - go build -mod=readonly $(BUILD_FLAGS) -o build/availd ./cmd/availd + go build -mod=readonly $(BUILD_FLAGS) -o build/cada ./cmd/cada endif build-windows-client: go.sum - GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/availd.exe ./cmd/availd + GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o build/cada.exe ./cmd/cada build-contract-tests-hooks: ifeq ($(OS),Windows_NT) @@ -91,7 +91,7 @@ else endif install: go.sum - go install -mod=readonly $(BUILD_FLAGS) ./cmd/availd + go install -mod=readonly $(BUILD_FLAGS) ./cmd/cada ######################################## ### Tools & dependencies @@ -107,7 +107,7 @@ go.sum: go.mod draw-deps: @# requires brew install graphviz or apt-get install graphviz go install github.com/RobotsAndPencils/goviz@latest - @goviz -i ./cmd/availd -d 2 | dot -Tpng -o dependency-graph.png + @goviz -i ./cmd/cada -d 2 | dot -Tpng -o dependency-graph.png clean: rm -rf snapcraft-local.yaml build/ @@ -222,14 +222,14 @@ setup-testnet: is-localic-installed install local-image set-testnet-configs setu # Run this before testnet keys are added # chainid-1 is used in the testnet.json set-testnet-configs: - availd config set client chain-id chainid-1 - availd config set client keyring-backend test - availd config set client output text + cada config set client chain-id chainid-1 + cada config set client keyring-backend test + cada config set client output text # import keys from testnet.json into test keyring setup-testnet-keys: - -`echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry" | availd keys add acc0 --recover` - -`echo "wealth flavor believe regret funny network recall kiss grape useless pepper cram hint member few certain unveil rather brick bargain curious require crowd raise" | availd keys add acc1 --recover` + -`echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry" | cada keys add acc0 --recover` + -`echo "wealth flavor believe regret funny network recall kiss grape useless pepper cram hint member few certain unveil rather brick bargain curious require crowd raise" | cada keys add acc1 --recover` testnet: setup-testnet spawn local-ic start testnet diff --git a/simapp/app/app.go b/simapp/app/app.go index f3a969a..5801f7b 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -38,7 +38,6 @@ import ( ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/spf13/cast" - availtypes "github.com/vitwit/avail-da-module/types" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" @@ -138,16 +137,17 @@ import ( packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/keeper" packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/types" - availblobkeeper "github.com/vitwit/avail-da-module/keeper" - availblobmodule "github.com/vitwit/avail-da-module/module" - availblobrelayer "github.com/vitwit/avail-da-module/relayer" + cadakeeper "github.com/vitwit/avail-da-module/keeper" + cadamodule "github.com/vitwit/avail-da-module/module" + cadarelayer "github.com/vitwit/avail-da-module/relayer" "github.com/vitwit/avail-da-module/relayer/avail" httpclient "github.com/vitwit/avail-da-module/relayer/http" + cadatypes "github.com/vitwit/avail-da-module/types" ) const ( - appName = "avail-sdk" - NodeDir = ".availsdk" + appName = "cada-sdk" + NodeDir = ".cada" Bech32Prefix = "cosmos" ) @@ -231,8 +231,8 @@ type ChainApp struct { ICAHostKeeper icahostkeeper.Keeper TransferKeeper ibctransferkeeper.Keeper - AvailBlobKeeper *availblobkeeper.Keeper - Availblobrelayer *availblobrelayer.Relayer + CadaKeeper *cadakeeper.Keeper + Cadarelayer *cadarelayer.Relayer PacketForwardKeeper *packetforwardkeeper.Keeper @@ -342,7 +342,7 @@ func NewChainApp( icahosttypes.StoreKey, icacontrollertypes.StoreKey, packetforwardtypes.StoreKey, - availtypes.StoreKey, + cadatypes.StoreKey, ) tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -686,10 +686,10 @@ func NewChainApp( httpClient := httpclient.NewHandler() // Avail-DA client - cfg := availtypes.AvailConfigFromAppOpts(appOpts) + cfg := cadatypes.AvailConfigFromAppOpts(appOpts) availDAClient := avail.NewLightClient(cfg.LightClientURL, httpClient) - app.Availblobrelayer, err = availblobrelayer.NewRelayer( + app.Cadarelayer, err = cadarelayer.NewRelayer( logger, appCodec, cfg, @@ -700,33 +700,33 @@ func NewChainApp( panic(err) } - app.AvailBlobKeeper = availblobkeeper.NewKeeper( + app.CadaKeeper = cadakeeper.NewKeeper( appCodec, - runtime.NewKVStoreService(keys[availtypes.StoreKey]), + runtime.NewKVStoreService(keys[cadatypes.StoreKey]), app.UpgradeKeeper, - keys[availtypes.StoreKey], + keys[cadatypes.StoreKey], appOpts, logger, - app.Availblobrelayer, + app.Cadarelayer, ) // must be done after relayer is created - app.AvailBlobKeeper.SetRelayer(app.Availblobrelayer) + app.CadaKeeper.SetRelayer(app.Cadarelayer) - voteExtensionHandler := availblobkeeper.NewVoteExtHandler( + voteExtensionHandler := cadakeeper.NewVoteExtHandler( logger, - app.AvailBlobKeeper, + app.CadaKeeper, ) dph := baseapp.NewDefaultProposalHandler(bApp.Mempool(), bApp) - availBlobProposalHandler := availblobkeeper.NewProofOfBlobProposalHandler( - app.AvailBlobKeeper, + cadaProposalHandler := cadakeeper.NewProofOfBlobProposalHandler( + app.CadaKeeper, dph.PrepareProposalHandler(), dph.ProcessProposalHandler(), *voteExtensionHandler, ) - bApp.SetPrepareProposal(availBlobProposalHandler.PrepareProposal) - bApp.SetProcessProposal(availBlobProposalHandler.ProcessProposal) + bApp.SetPrepareProposal(cadaProposalHandler.PrepareProposal) + bApp.SetProcessProposal(cadaProposalHandler.ProcessProposal) bApp.SetExtendVoteHandler(voteExtensionHandler.ExtendVoteHandler()) bApp.SetVerifyVoteExtensionHandler(voteExtensionHandler.VerifyVoteExtensionHandler()) @@ -771,7 +771,7 @@ func NewChainApp( ibctm.NewAppModule(), crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // custom - availblobmodule.NewAppModule(appCodec, app.AvailBlobKeeper), + cadamodule.NewAppModule(appCodec, app.CadaKeeper), packetforward.NewAppModule(app.PacketForwardKeeper, app.GetSubspace(packetforwardtypes.ModuleName)), ) @@ -816,7 +816,7 @@ func NewChainApp( icatypes.ModuleName, ibcfeetypes.ModuleName, packetforwardtypes.ModuleName, - availtypes.ModuleName, + cadatypes.ModuleName, ) app.ModuleManager.SetOrderEndBlockers( @@ -833,7 +833,7 @@ func NewChainApp( icatypes.ModuleName, ibcfeetypes.ModuleName, packetforwardtypes.ModuleName, - availtypes.ModuleName, + cadatypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -858,7 +858,7 @@ func NewChainApp( icatypes.ModuleName, ibcfeetypes.ModuleName, packetforwardtypes.ModuleName, - availtypes.ModuleName, + cadatypes.ModuleName, } app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...) app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...) @@ -1016,9 +1016,6 @@ func (app *ChainApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.Respon return res, err } - //app.Availblobrelayer.NotifyCommitHeight(req.Height) - // app.Availblobrelayer.NotifyCommitHeight(req.Height) - return res, nil } @@ -1038,7 +1035,7 @@ func (app *ChainApp) Name() string { return app.BaseApp.Name() } // PreBlocker application updates every pre block func (app *ChainApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { - err := app.AvailBlobKeeper.PreBlocker(ctx, req) + err := app.CadaKeeper.PreBlocker(ctx, req) if err != nil { return nil, err } @@ -1222,10 +1219,6 @@ func (app *ChainApp) RegisterTendermintService(clientCtx client.Context) { func (app *ChainApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) - - // app.Availblobrelayer.SetClientContext(clientCtx) - - // go app.Availblobrelayer.Start() } // GetMaccPerms returns a copy of the module account permissions diff --git a/simapp/cmd/availd/commads.go b/simapp/cmd/cada/commads.go similarity index 96% rename from simapp/cmd/availd/commads.go rename to simapp/cmd/cada/commads.go index 9687111..61b3b8a 100644 --- a/simapp/cmd/availd/commads.go +++ b/simapp/cmd/cada/commads.go @@ -41,8 +41,8 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "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" - availtypes "github.com/vitwit/avail-da-module/types" + cadacli "github.com/vitwit/avail-da-module/client/cli" + cadatypes "github.com/vitwit/avail-da-module/types" ) // initCometBFTConfig helps to override default CometBFT Config values. @@ -65,7 +65,7 @@ func initAppConfig() (string, interface{}) { type CustomAppConfig struct { serverconfig.Config - Avail *availtypes.AvailConfiguration `mapstructure:"avail"` + Avail *cadatypes.AvailConfiguration `mapstructure:"avail"` } // Optionally allow the chain developer to overwrite the SDK's default @@ -88,10 +88,10 @@ func initAppConfig() (string, interface{}) { customAppConfig := CustomAppConfig{ Config: *srvCfg, - Avail: &availtypes.DefaultAvailConfig, + Avail: &cadatypes.DefaultAvailConfig, } - customAppTemplate := serverconfig.DefaultConfigTemplate + availtypes.DefaultConfigTemplate + customAppTemplate := serverconfig.DefaultConfigTemplate + cadatypes.DefaultConfigTemplate return customAppTemplate, customAppConfig } @@ -118,7 +118,7 @@ func initRootCmd( AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) keysCmd := keys.Commands() - keysCmd.AddCommand(availblobcli.NewKeysCmd()) + keysCmd.AddCommand(cadacli.NewKeysCmd()) // add keybase, RPC, query, genesis, and tx child commands rootCmd.AddCommand( diff --git a/simapp/cmd/availd/main.go b/simapp/cmd/cada/main.go similarity index 100% rename from simapp/cmd/availd/main.go rename to simapp/cmd/cada/main.go diff --git a/simapp/cmd/availd/root.go b/simapp/cmd/cada/root.go similarity index 97% rename from simapp/cmd/availd/root.go rename to simapp/cmd/cada/root.go index 23d0239..2274e6a 100644 --- a/simapp/cmd/availd/root.go +++ b/simapp/cmd/cada/root.go @@ -53,8 +53,8 @@ func NewRootCmd() *cobra.Command { WithViper("") rootCmd := &cobra.Command{ - Use: "availd", - Short: "availd blob", + Use: "cada", + Short: "Cada connects cosmos chains with Avail.", SilenceErrors: true, PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { // set the default command outputs diff --git a/simapp/cmd/availd/testnet.go b/simapp/cmd/cada/testnet.go similarity index 98% rename from simapp/cmd/availd/testnet.go rename to simapp/cmd/cada/testnet.go index bcb6008..5af1ec1 100644 --- a/simapp/cmd/availd/testnet.go +++ b/simapp/cmd/cada/testnet.go @@ -124,7 +124,7 @@ or a similar setup where each node has a manually configurable IP address. Note, strict routability for addresses is turned off in the config file. Example: - availd testnet init-files --v 4 --output-dir ./.testnets --starting-ip-address 192.168.10.2 + cada testnet init-files --v 4 --output-dir ./.testnets --starting-ip-address 192.168.10.2 `, RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -152,7 +152,7 @@ Example: addTestnetFlagsToCmd(cmd) cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)") - cmd.Flags().String(flagNodeDaemonHome, "availsdk", "Home directory of the node's daemon configuration") + cmd.Flags().String(flagNodeDaemonHome, "cada", "Home directory of the node's daemon configuration") cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)") cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") @@ -169,7 +169,7 @@ and generate "v" directories, populated with necessary validator configuration f (private validator, genesis, config, etc.). Example: - availd testnet --v 4 --output-dir ./.testnets + cada testnet --v 4 --output-dir ./.testnets `, RunE: func(cmd *cobra.Command, _ []string) error { args := startArgs{} diff --git a/simapp/cmd/availd/testnet_test.go b/simapp/cmd/cada/testnet_test.go similarity index 100% rename from simapp/cmd/availd/testnet_test.go rename to simapp/cmd/cada/testnet_test.go diff --git a/simapp/init-simapp.sh b/simapp/init-simapp.sh index 36ccbd1..b3e36e2 100755 --- a/simapp/init-simapp.sh +++ b/simapp/init-simapp.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -SIMD_BIN=${SIMD_BIN:=$(which availd 2>/dev/null)} +SIMD_BIN=${SIMD_BIN:=$(which cada 2>/dev/null)} ALICE_MNEMONIC="all soap kiwi cushion federal skirt tip shock exist tragic verify lunar shine rely torch please view future lizard garbage humble medal leisure mimic" BOB_MNEMONIC="remain then chuckle hockey protect sausage govern curve hobby aisle clinic decline rotate judge this sail broom debris minute buddy buffalo desk pizza invite" SAI_MNEMONIC="festival borrow upon ritual remind song execute chase toward fan neck subway canal throw nothing ticket frown leave thank become extend balcony strike fame" TEJA_MNEMONIC="claim infant gather cereal sentence general cheese float hero dwarf miracle oven tide virus question choice say relax similar rice surround deal smooth rival" UNKNOWN_MNOMONIC="purpose clutch ill track skate syrup cost among piano elegant close chaos come quit orchard acquire plunge hockey swift tongue salt supreme sting night" -DAEMON_HOME="/home/vitwit/.availsdk" +DAEMON_HOME="/home/vitwit/.cada" if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run make install before"; exit 1; fi echo "using $SIMD_BIN" From b6dd4a0a5c8a62413449da42db0d791e5323bc4e Mon Sep 17 00:00:00 2001 From: Teja2045 <106052623+Teja2045@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:57:04 +0530 Subject: [PATCH 13/14] docs: update integration docs (#49) * docs: integration guide * chore: fix format * chore: fix format * chore: fix format * chore: fix format * docs: change spawn integration * chore: change avail da module to cada module * chore: format fix --- integration_docs/config.md | 2 +- integration_docs/integration.md | 263 +++++++++++++++-------------- integration_docs/spawn.md | 283 ++++++++++++++++---------------- 3 files changed, 286 insertions(+), 262 deletions(-) diff --git a/integration_docs/config.md b/integration_docs/config.md index 2100bb8..a80165d 100644 --- a/integration_docs/config.md +++ b/integration_docs/config.md @@ -1,6 +1,6 @@ # Configuration -The CADA module configuration is located in config/app.toml and is used for connecting to the avail and cosmos networks to submit blocks data. +The cada module configuration is located in config/app.toml and is used for connecting to the avail and cosmos networks to submit blocks data. Below is the default configuration for integrating with Avail. You can customize these settings by modifying them to suit your specific requirements. diff --git a/integration_docs/integration.md b/integration_docs/integration.md index fd375b7..5064179 100644 --- a/integration_docs/integration.md +++ b/integration_docs/integration.md @@ -1,13 +1,12 @@ # Integration -Follow these steps to integrate the avail-da module into your Cosmos SDK-based application. +Follow these steps to integrate the cada module into your Cosmos SDK-based application. - -### app.go wiring +### app.go wiring In your application's simapp folder, integrate the following imports into the app.go file: -1. Imports +1. Imports ```sh @@ -15,52 +14,52 @@ import ( // ...... - "github.com/vitwit/avail-da-module" - availblobkeeper "github.com/vitwit/avail-da-module/keeper" - availblobmodule "github.com/vitwit/avail-da-module/module" - availblobrelayer "github.com/vitwit/avail-da-module/relayer" + cadakeeper "github.com/vitwit/avail-da-module/keeper" + cadamodule "github.com/vitwit/avail-da-module/module" + cadarelayer "github.com/vitwit/avail-da-module/relayer" + "github.com/vitwit/avail-da-module/relayer/avail" + httpclient "github.com/vitwit/avail-da-module/relayer/http" + cadatypes "github.com/vitwit/avail-da-module/types" ) ``` 2. Constants configuration -After importing the necessary packages for the avail-da module in your app.go file, the next step is to declare any constant variables that the module will use. These constants are essential for configuring and integrating the avail-da module with your application. +After importing the necessary packages for the cada in your app.go file, the next step is to declare any constant variables that the module will use. These constants are essential for configuring and integrating the cada module with your application. ```sh const ( - // TODO: Change me - AvailAppID = 1 - - // publish blocks to avail every n rollchain blocks. - publishToAvailBlockInterval = 5 // smaller size == faster testing + appName = "cada-sdk" + NodeDir = ".cada" ) ``` -3. Keeper and Relyer declaration +3. Keeper and Relayer declaration -Here's a step-by-step guide to integrating the avail-da module keeper and relayer into your Cosmos SDK application +Here's a step-by-step guide to integrating the cada module keeper and relayer into your Cosmos SDK application -Inside of the ChainApp struct, add the required avail-da module runtime fields. +Inside of the ChainApp struct, add the required cada module runtime fields. ```sh type SimApp struct { // ... - AvailBlobKeeper *availblobkeeper.Keeper - Availblobrelayer *availblobrelayer.Relayer + CadaKeeper *cadakeeper.Keeper + Cadarelayer *cadarelayer.Relayer // -}``` +} +``` -4. Initialize the `avail-da-module` Keeper and Relayer +4. Initialize the `Cada` Keeper and Relayer -Within the `NewSimApp` method, the constructor for the app, initialize the avail-da module components. +Within the `NewSimApp` method, the constructor for the app, initialize the cada module components. -```sh +```go func NewSimApp( - // -) *SimApp { + //... + ) *SimApp { // ... @@ -71,179 +70,195 @@ Within the `NewSimApp` method, the constructor for the app, initialize the avail keys := storetypes.NewKVStoreKeys( // ... - // Register avail-da module Store - availblob1.StoreKey, + // Register cada module Store + cadatypes.StoreKey, ) - app.AvailBlobKeeper = availblobkeeper.NewKeeper( - appCodec, - appOpts, - runtime.NewKVStoreService(keys[availblob1.StoreKey]), - app.UpgradeKeeper, - keys[availblob1.StoreKey], - publishToAvailBlockInterval, - AvailAppID, - ) + httpClient := httpclient.NewHandler() + + // Avail-DA client + cfg := cadatypes.AvailConfigFromAppOpts(appOpts) + availDAClient := avail.NewLightClient(cfg.LightClientURL, httpClient) - app.Availblobrelayer, err = availblobrelayer.NewRelayer( + app.Cadarelayer, err = cadarelayer.NewRelayer( logger, appCodec, - appOpts, - homePath, + cfg, + NodeDir, + availDAClient, ) if err != nil { panic(err) } - // must be done after relayer is created - app.AvailBlobKeeper.SetRelayer(app.Availblobrelayer) - - dph := baseapp.NewDefaultProposalHandler(bApp.Mempool(), bApp) - availBlobProposalHandler := availblobkeeper.NewProofOfBlobProposalHandler(app.AvailBlobKeeper, dph.PrepareProposalHandler(), dph.ProcessProposalHandler()) - bApp.SetPrepareProposal(availBlobProposalHandler.PrepareProposal) - bApp.SetProcessProposal(availBlobProposalHandler.ProcessProposal) + app.CadaKeeper = cadakeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[cadatypes.StoreKey]), + app.UpgradeKeeper, + keys[cadatypes.StoreKey], + appOpts, + logger, + app.Cadarelayer, + ) - // pre existing comments + // must be done after relayer is created + app.CadaKeeper.SetRelayer(app.Cadarelayer) - /**** Module Options ****/ + //... - // ...... +``` - // NOTE: pre-existing code, add parameter. - app.ModuleManager = module.NewManager( - // ... +5. Integrate Cada module\'s vote extensions and abci methods - availblobmodule.NewAppModule(appCodec, app.AvailBlobKeeper), + ```go + voteExtensionHandler := cadakeeper.NewVoteExtHandler( + logger, + app.CadaKeeper, ) - // NOTE: pre-existing code, add parameter. - app.ModuleManager.SetOrderBeginBlockers( - // ... - - // avail-da-module begin blocker can be last - availblob1.ModuleName, + dph := baseapp.NewDefaultProposalHandler(bApp.Mempool(), bApp) + cadaProposalHandler := cadakeeper.NewProofOfBlobProposalHandler( + app.CadaKeeper, + dph.PrepareProposalHandler(), + dph.ProcessProposalHandler(), + *voteExtensionHandler, ) + bApp.SetPrepareProposal(cadaProposalHandler.PrepareProposal) + bApp.SetProcessProposal(cadaProposalHandler.ProcessProposal) + bApp.SetExtendVoteHandler(voteExtensionHandler.ExtendVoteHandler()) + bApp.SetVerifyVoteExtensionHandler(voteExtensionHandler.VerifyVoteExtensionHandler()) + + ``` - // NOTE: pre-existing code, add parameter. - app.ModuleManager.SetOrderEndBlockers( - // ... + 6. Module manager - // avail-da-module end blocker can be last - availblob1.ModuleName, - ) + ```go - // NOTE: pre-existing code, add parameter. - genesisModuleOrder := []string{ - // ... + // pre existing comments - // avail-da genesis module order can be last - availblob1.ModuleName, - } + /**** Module Options ****/ - } -) + // ...... -5. Integrate `avail-da-module` PreBocker + // NOTE: pre-existing code, add parameter. + app.ModuleManager = module.NewManager( + // ... -```sh + cadamodule.NewAppModule(appCodec, app.CadaKeeper), + ) -// PreBlocker application updates every pre block -func (app *SimApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { - err := app.AvailBlobKeeper.PreBlocker(ctx, req) - if err != nil { - return nil, err - } - return app.ModuleManager.PreBlock(ctx) -} + // NOTE: pre-existing code, add parameter. + app.ModuleManager.SetOrderBeginBlockers( + // ... -``` + // cada begin blocker can be last + cadatypes.ModuleName, + ) -6. Integrate relayer startup + // NOTE: pre-existing code, add parameter. + app.ModuleManager.SetOrderEndBlockers( + // ... -To integrate the relayer startup into your Cosmos SDK application, you will need to query necessary values and initialize the relayer. Here’s how you can do it: + // cada end blocker can be last + cadatypes.ModuleName, + ) -* Modify RegisterNodeService Function : -In your app.go file, locate the RegisterNodeService function. You need to add code to initialize and start the relayer after your application has started. + // NOTE: pre-existing code, add parameter. + genesisModuleOrder := []string{ + // ... -* Add the Relayer Initialization: Inside the RegisterNodeService function, you will need to query necessary values from the application and initialize the relayer. + // cada genesis module order can be last + cadatypes.ModuleName, + } -Here’s how you can do it: + } -```sh + ) + ``` -func (app *SimApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) +6. Integrate `cada` PreBocker - app.Availblobrelayer.SetClientContext(clientCtx) +```go + + // PreBlocker application updates every pre block + func (app *SimApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + err := app.CadaKeeper.PreBlocker(ctx, req) + if err != nil { + return nil, err + } + return app.ModuleManager.PreBlock(ctx) + } - go app.Availblobrelayer.Start() -} ``` -### Commands.go wiring +### Commands.go wiring -In your simapp application commands file, incorporate the following to wire up the avail-da module CLI commands. +In your simapp application commands file, incorporate the following to wire up the cada module CLI commands. 1. Imports -Within the imported packages, add the avail-da module +Within the imported packages, add the cada module -```sh +```go import ( // ... "github.com/vitwit/avail-da-module/simapp/app" - availblobcli "github.com/vitwit/avail-da-module/client/cli" - "github.com/vitwit/avail-da-module/relayer" + cadacli "github.com/vitwit/avail-da-module/client/cli" + cadatypes "github.com/vitwit/avail-da-module/types" ) ``` 2. Init App Config -```sh +````go func initAppConfig() (string, interface{}) { type CustomAppConfig struct { serverconfig.Config - Avail *relayer.AvailConfig `mapstructure:"avail"` + Cada *cadatypes.AvailConfiguration `mapstructure:"avail"` } // ... customAppConfig := CustomAppConfig{ Config: *srvCfg, - Avail: &relayer.DefaultAvailConfig, + Avail: &cadatypes.DefaultAvailConfig, } - customAppTemplate := serverconfig.DefaultConfigTemplate + relayer.DefaultConfigTemplate + customAppTemplate := serverconfig.DefaultConfigTemplate + cadatypes.DefaultConfigTemplate return customAppTemplate, customAppConfig } +``` 3. Init Root Command -```sh +```go -func initRootCmd( - rootCmd *cobra.Command, - txConfig client.TxConfig, - interfaceRegistry codectypes.InterfaceRegistry, - appCodec codec.Codec, - basicManager module.BasicManager, -) { + func initRootCmd( + rootCmd *cobra.Command, + txConfig client.TxConfig, + _ codectypes.InterfaceRegistry, + _ codec.Codec, + basicManager module.BasicManager, + ) { // ...... - server.AddCommands(rootCmd, simapp.DefaultNodeHome, newApp, appExport, addModuleInitFlags) + AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) - keysCmd := keys.Commands() - keysCmd.AddCommand(availblobcli.NewKeysCmd()) + keysCmd := keys.Commands() + keysCmd.AddCommand(cadacli.NewKeysCmd()) + // add keybase, RPC, query, genesis, and tx child commands rootCmd.AddCommand( - server.StatusCommand(), - genesisCommand(txConfig, basicManager), - queryCommand(), - txCommand(), - keysCmd, - ) -``` \ No newline at end of file + server.StatusCommand(), + genesisCommand(txConfig, basicManager), + queryCommand(), + txCommand(), + keysCmd, + resetCommand(), + ) + } +``` diff --git a/integration_docs/spawn.md b/integration_docs/spawn.md index b716342..1cda805 100644 --- a/integration_docs/spawn.md +++ b/integration_docs/spawn.md @@ -27,252 +27,261 @@ for more details about spawn you can refer to this doc https://github.com/rollch ### app.go wiring -In your main application file, typically named `app.go` incorporate the following to wire up the avail-da module +In your application's simapp folder, integrate the following imports into the app.go file: 1. Imports -Within the imported packages, add the `avail-da-module` dependencies. - ```sh import ( // ...... - "github.com/vitwit/avail-da-module" - availblobkeeper "github.com/vitwit/avail-da-module/keeper" - availblobmodule "github.com/vitwit/avail-da-module/module" - availblobrelayer "github.com/vitwit/avail-da-module/relayer" + cadakeeper "github.com/vitwit/avail-da-module/keeper" + cadamodule "github.com/vitwit/avail-da-module/module" + cadarelayer "github.com/vitwit/avail-da-module/relayer" + "github.com/vitwit/avail-da-module/relayer/avail" + httpclient "github.com/vitwit/avail-da-module/relayer/http" + cadatypes "github.com/vitwit/avail-da-module/types" ) ``` -2.Configuration constants. +2. Constants configuration -After the imports, declare the constant variables required by `avail-da-module`. +After importing the necessary packages for the cada in your app.go file, the next step is to declare any constant variables that the module will use. These constants are essential for configuring and integrating the cada module with your application. ```sh const ( - // TODO: Change me - AvailAppID = 1 - - // publish blocks to avail every n rollchain blocks. - publishToAvailBlockInterval = 5 // smaller size == faster testing + appName = "cada-sdk" + NodeDir = ".cada" ) ``` -3. Keeper and Relyer declaration +3. Keeper and Relayer declaration -Inside of the ChainApp struct, the struct which satisfies the cosmos-sdk runtime.AppI interface, add the required avail-da module runtime fields. +Here's a step-by-step guide to integrating the cada module keeper and relayer into your Cosmos SDK application + +Inside of the ChainApp struct, add the required cada module runtime fields. ```sh +type SimApp struct { + // ... -type ChainApp struct { - // ... + CadaKeeper *cadakeeper.Keeper + Cadarelayer *cadarelayer.Relayer + // - AvailBlobKeeper *availblobkeeper.Keeper - Availblobrelayer *availblobrelayer.Relayer - // .... } ``` -4. Initialize the `avail-da-module` Keeper and Relayer -Within the `NewChainApp` method, the constructor for the app, initialize the avail-da module components. +4. Initialize the `Cada` Keeper and Relayer + +Within the `NewSimApp` method, the constructor for the app, initialize the cada module components. + +```go + func NewSimApp( + //... + ) *SimApp { -```sh -func NewChainApp( - // ... -) *ChainApp { // ... + // pre-existing code: remove optimistic execution in baseapp options + baseAppOptions = append(baseAppOptions, voteExtOp) + // NOTE: pre-existing code, add parameter. - keys := storetypes.NewKVStoreKeys( + keys := storetypes.NewKVStoreKeys( // ... - // Register avail-da module Store - availblob1.StoreKey, + // Register cada module Store + cadatypes.StoreKey, ) - app.AvailBlobKeeper = availblobkeeper.NewKeeper( - appCodec, - appOpts, - runtime.NewKVStoreService(keys[availblob1.StoreKey]), - app.UpgradeKeeper, - keys[availblob1.StoreKey], - publishToAvailBlockInterval, - AvailAppID, - ) + httpClient := httpclient.NewHandler() + + // Avail-DA client + cfg := cadatypes.AvailConfigFromAppOpts(appOpts) + availDAClient := avail.NewLightClient(cfg.LightClientURL, httpClient) - app.Availblobrelayer, err = availblobrelayer.NewRelayer( + app.Cadarelayer, err = cadarelayer.NewRelayer( logger, appCodec, - appOpts, - homePath, + cfg, + NodeDir, + availDAClient, ) if err != nil { panic(err) } - // Connect relayer to keeper. Must be done after relayer is created. - app.AvailBlobKeeper.SetRelayer(app.Availblobrelayer) - - // Rollchains avail-da-module proposal handling - availBlobProposalHandler := availblobkeeper.NewProofOfBlobProposalHandler(app.AvailBlobKeeper, - AppSpecificPrepareProposalHandler(), // i.e. baseapp.NoOpPrepareProposal() - AppSpecificProcessProposalHandler(), // i.e. baseapp.NoOpProcessProposal() + app.CadaKeeper = cadakeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[cadatypes.StoreKey]), + app.UpgradeKeeper, + keys[cadatypes.StoreKey], + appOpts, + logger, + app.Cadarelayer, ) - bApp.SetPrepareProposal(availBlobProposalHandler.PrepareProposal) - bApp.SetProcessProposal(availBlobProposalHandler.ProcessProposal) - // ... + // must be done after relayer is created + app.CadaKeeper.SetRelayer(app.Cadarelayer) - // NOTE: pre-existing code, add parameter. - app.ModuleManager = module.NewManager( - // ... + //... - availblobmodule.NewAppModule(appCodec, app.AvailBlobKeeper), - ) +``` - // NOTE: pre-existing code, add parameter. - app.ModuleManager.SetOrderBeginBlockers( - // ... +5. Integrate Cada module\'s vote extensions and abci methods - // avail-da module begin blocker can be last - availblob1.ModuleName, + ```go + voteExtensionHandler := cadakeeper.NewVoteExtHandler( + logger, + app.CadaKeeper, ) - // NOTE: pre-existing code, add parameter. - app.ModuleManager.SetOrderEndBlockers( - // ... - - // avail-da module end blocker can be last - availblob1.ModuleName, + dph := baseapp.NewDefaultProposalHandler(bApp.Mempool(), bApp) + cadaProposalHandler := cadakeeper.NewProofOfBlobProposalHandler( + app.CadaKeeper, + dph.PrepareProposalHandler(), + dph.ProcessProposalHandler(), + *voteExtensionHandler, ) + bApp.SetPrepareProposal(cadaProposalHandler.PrepareProposal) + bApp.SetProcessProposal(cadaProposalHandler.ProcessProposal) + bApp.SetExtendVoteHandler(voteExtensionHandler.ExtendVoteHandler()) + bApp.SetVerifyVoteExtensionHandler(voteExtensionHandler.VerifyVoteExtensionHandler()) + + ``` - // NOTE: pre-existing code, add parameter. - genesisModuleOrder := []string{ - // ... + 6. Module manager - // avail-da genesis module order can be last - availblob1.ModuleName, - } + ```go - } -) -``` + // pre existing comments -5. Integrate Relayer into FinalizeBlock + /**** Module Options ****/ -The `avail-da-module` relayer needs to be notified when the rollchain blocks are committed so that it is aware of the latest height of the chain. In `FinalizeBlock`, rather than returnig app.BaseApp.FinalizeBlock(req), add error handling to that call and notify the relayer afterward. + // ...... -```sh -func (app *ChainApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { - // ... + // NOTE: pre-existing code, add parameter. + app.ModuleManager = module.NewManager( + // ... - res, err := app.BaseApp.FinalizeBlock(req) - if err != nil { - return res, err - } + cadamodule.NewAppModule(appCodec, app.CadaKeeper), + ) - app.Availblobrelayer.NotifyCommitHeight(req.Height) + // NOTE: pre-existing code, add parameter. + app.ModuleManager.SetOrderBeginBlockers( + // ... - return res, nil -} -``` + // cada begin blocker can be last + cadatypes.ModuleName, + ) -6. Integrate `avail-da-module` PreBocker + // NOTE: pre-existing code, add parameter. + app.ModuleManager.SetOrderEndBlockers( + // ... -The `avail-da-module` PreBlocker must be called in the app's PreBlocker. + // cada end blocker can be last + cadatypes.ModuleName, + ) -```sh -func (app *ChainApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { - err := app.AvailBlobKeeper.PreBlocker(ctx, req) - if err != nil { - return nil, err - } - return app.ModuleManager.PreBlock(ctx) -} -``` + // NOTE: pre-existing code, add parameter. + genesisModuleOrder := []string{ + // ... -7. Integrate relayer startup + // cada genesis module order can be last + cadatypes.ModuleName, + } -The relayer needs to query blocks using the client context in order to package them and publish to Avail Light Client. The relayer also needs to be started with some initial values that must be queried from the app after the app has started. Add the following in RegisterNodeService. + } -```sh + ) + ``` -func (app *ChainApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { - nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) - app.Availblobrelayer.SetClientContext(clientCtx) +6. Integrate `cada` PreBocker - go app.Availblobrelayer.Start() -} +```go + + // PreBlocker application updates every pre block + func (app *SimApp) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { + err := app.CadaKeeper.PreBlocker(ctx, req) + if err != nil { + return nil, err + } + return app.ModuleManager.PreBlock(ctx) + } ``` ### Commands.go wiring -In your application commands file, incorporate the following to wire up the avail-da module CLI commands. +In your simapp application commands file, incorporate the following to wire up the cada module CLI commands. 1. Imports -Within the imported packages, add the avail-da module +Within the imported packages, add the cada module -```sh +```go import ( // ... "github.com/vitwit/avail-da-module/simapp/app" - availblobcli "github.com/vitwit/avail-da-module/client/cli" - "github.com/vitwit/avail-da-module/relayer" + cadacli "github.com/vitwit/avail-da-module/client/cli" + cadatypes "github.com/vitwit/avail-da-module/types" ) ``` 2. Init App Config - -```sh +````go func initAppConfig() (string, interface{}) { type CustomAppConfig struct { serverconfig.Config - Avail *relayer.AvailConfig `mapstructure:"avail"` + Cada *cadatypes.AvailConfiguration `mapstructure:"avail"` } // ... customAppConfig := CustomAppConfig{ Config: *srvCfg, - Avail: &relayer.DefaultAvailConfig, + Avail: &cadatypes.DefaultAvailConfig, } - customAppTemplate := serverconfig.DefaultConfigTemplate + relayer.DefaultConfigTemplate + customAppTemplate := serverconfig.DefaultConfigTemplate + cadatypes.DefaultConfigTemplate return customAppTemplate, customAppConfig } ``` -3.Init Root Command +3. Init Root Command -```sh +```go -func initRootCmd( - // ... -) { - // ... + func initRootCmd( + rootCmd *cobra.Command, + txConfig client.TxConfig, + _ codectypes.InterfaceRegistry, + _ codec.Codec, + basicManager module.BasicManager, + ) { + // ...... - keysCmd := keys.Commands() - keysCmd.AddCommand(availblobcli.NewKeysCmd()) + AddCommands(rootCmd, app.DefaultNodeHome, newApp, appExport, addModuleInitFlags) - // Existing code, only modifying one parameter. - rootCmd.AddCommand( - server.StatusCommand(), - genesisCommand(txConfig, basicManager), - queryCommand(), - txCommand(), - keysCmd, // replace keys.Commands() here with this - ) -} + keysCmd := keys.Commands() + keysCmd.AddCommand(cadacli.NewKeysCmd()) + // add keybase, RPC, query, genesis, and tx child commands + rootCmd.AddCommand( + server.StatusCommand(), + genesisCommand(txConfig, basicManager), + queryCommand(), + txCommand(), + keysCmd, + resetCommand(), + ) + } ``` - From 4873ef701ffdc6fc74d486f7cb0115097fa221d5 Mon Sep 17 00:00:00 2001 From: NagaTulasi Date: Mon, 23 Sep 2024 18:49:18 +0530 Subject: [PATCH 14/14] refactor: remove unused code --- keeper/collections.go | 40 --------------------------- relayer/availclient.go | 18 ------------- relayer/init_test.go | 61 ------------------------------------------ relayer/process.go | 52 ----------------------------------- relayer/relayer.go | 10 ++----- 5 files changed, 2 insertions(+), 179 deletions(-) delete mode 100644 keeper/collections.go delete mode 100644 relayer/availclient.go delete mode 100644 relayer/init_test.go delete mode 100644 relayer/process.go diff --git a/keeper/collections.go b/keeper/collections.go deleted file mode 100644 index 8b51247..0000000 --- a/keeper/collections.go +++ /dev/null @@ -1,40 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/vitwit/avail-da-module/types" -) - -func (k *Keeper) SetValidatorAvailAddress(ctx context.Context, validator types.Validator) error { - return k.Validators.Set(ctx, validator.ValidatorAddress, validator.AvailAddress) -} - -func (k *Keeper) GetValidatorAvailAddress(ctx context.Context, validatorAddress string) (string, error) { - return k.Validators.Get(ctx, validatorAddress) -} - -func (k *Keeper) GetAllValidators(ctx context.Context) (types.Validators, error) { - var validators types.Validators - it, err := k.Validators.Iterate(ctx, nil) - if err != nil { - return validators, err - } - - defer it.Close() - - for ; it.Valid(); it.Next() { - var validator types.Validator - validator.ValidatorAddress, err = it.Key() - if err != nil { - return validators, err - } - validator.AvailAddress, err = it.Value() - if err != nil { - return validators, err - } - validators.Validators = append(validators.Validators, validator) - } - - return validators, nil -} diff --git a/relayer/availclient.go b/relayer/availclient.go deleted file mode 100644 index 8ad7e81..0000000 --- a/relayer/availclient.go +++ /dev/null @@ -1,18 +0,0 @@ -package relayer - -// import "github.com/vitwit/avail-da-module/types" - -// // AvailClient is the client that handles data submission -// type AvailClient struct { -// config types.AvailConfiguration -// } - -// // NewAvailClient initializes a new AvailClient -// 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) -// // } - -// return &AvailClient{config: config}, nil -// } diff --git a/relayer/init_test.go b/relayer/init_test.go deleted file mode 100644 index e6a0ce3..0000000 --- a/relayer/init_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package relayer_test - -import ( - "testing" - - addresstypes "cosmossdk.io/core/address" - "cosmossdk.io/log" - storetypes "cosmossdk.io/store/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - cmttime "github.com/cometbft/cometbft/types/time" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec/address" - "github.com/cosmos/cosmos-sdk/testutil" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - "github.com/stretchr/testify/suite" - module "github.com/vitwit/avail-da-module/module" - relayer "github.com/vitwit/avail-da-module/relayer" - httpclient "github.com/vitwit/avail-da-module/relayer/http" - types "github.com/vitwit/avail-da-module/types" -) - -type RelayerTestSuite struct { - suite.Suite - - ctx sdk.Context - httpHandler *httpclient.Handler - addrs []sdk.AccAddress - encCfg moduletestutil.TestEncodingConfig - addressCodec addresstypes.Codec - baseApp *baseapp.BaseApp - relayer *relayer.Relayer -} - -func TestRelayerTestSuite(t *testing.T) { - suite.Run(t, new(RelayerTestSuite)) -} - -func (s *RelayerTestSuite) SetupTest() { - key := storetypes.NewKVStoreKey(types.ModuleName) - testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) - s.encCfg = moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{}) - s.addressCodec = address.NewBech32Codec("cosmos") - - s.baseApp = baseapp.NewBaseApp( - "cada", - log.NewNopLogger(), - testCtx.DB, - s.encCfg.TxConfig.TxDecoder(), - ) - - s.baseApp.SetCMS(testCtx.CMS) - s.baseApp.SetInterfaceRegistry(s.encCfg.InterfaceRegistry) - s.addrs = simtestutil.CreateIncrementalAccounts(7) - - s.httpHandler = httpclient.NewHandler() - - s.relayer = &relayer.Relayer{} -} diff --git a/relayer/process.go b/relayer/process.go deleted file mode 100644 index ec8381d..0000000 --- a/relayer/process.go +++ /dev/null @@ -1,52 +0,0 @@ -package relayer - -import ( - "context" - "time" -) - -// Start begins the relayer process -func (r *Relayer) Start() error { - ctx := context.Background() - - timer := time.NewTimer(r.pollInterval) - defer timer.Stop() - for { - select { - case <-ctx.Done(): - return nil - case height := <-r.commitHeights: - r.latestCommitHeight = height - case height := <-r.provenHeights: - r.updateHeight(height) - case <-timer.C: - } - } -} - -// NotifyCommitHeight is called by the app to notify the relayer of the latest commit height -// func (r *Relayer) NotifyCommitHeight(height int64) { -// r.commitHeights <- height -// } - -// NotifyProvenHeight is called by the app to notify the relayer of the latest proven height -// i.e. the height of the highest incremental block that was proven to be posted to Avail. -// func (r *Relayer) NotifyProvenHeight(height int64) { -// r.provenHeights <- height -// } - -// updateHeight is called when the provenHeight has changed -func (r *Relayer) updateHeight(height int64) { - if height > r.latestProvenHeight { - // fmt.Println("Latest proven height:", height) // TODO: remove, debug only - r.latestProvenHeight = height - r.pruneCache(height) - } -} - -// pruneCache will delete any headers or proofs that are no longer needed -func (r *Relayer) pruneCache(_ int64) { - // r.mu.Lock() - // // TODO: proofs deletions after completion - // r.mu.Unlock() -} diff --git a/relayer/relayer.go b/relayer/relayer.go index 9fa6209..2ff494a 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -1,8 +1,6 @@ package relayer import ( - "time" - "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -15,13 +13,9 @@ import ( type Relayer struct { Logger log.Logger - provenHeights chan int64 - latestProvenHeight int64 - - commitHeights chan int64 - latestCommitHeight int64 + provenHeights chan int64 - pollInterval time.Duration + commitHeights chan int64 submittedBlocksCache map[int64]bool