From da99450ba7959eeb555a583f0724cc95e34110a2 Mon Sep 17 00:00:00 2001 From: Teja2045 <106052623+Teja2045@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:12:52 +0530 Subject: [PATCH] feat: enable data availiability verification via vote extensions (#25) * feat: added transactions * feat: implement client * fix tx issue * feat: pause previous code * adding client injection * custom txclient * fix: client issue debug * new chain client * debug client init * update create client * import mnemonic * docs * Update README.md * update docs * execute submit tx through client * fix keyring issue * import key * fix * refactor * update submitblob tx * new query * feat: changes * handle error * post data to da * execute update tx after da submission * fix * query and tx * update msg * feat: fixed range errors * feat: vote extensions * refactor core lgic * feat: enable vote extensions * feat: enable vote extensions * feat: fix vote extensions bug * feat: fix vote extensions bug * fix: config script for vote extension height * fix typo * fix client * feat: enable vote extensions * remove deadcode * feat: light client data verification * feat: enable light client verification * fix * refactor: review changes * remove unused code * refactor: review changes * feat: review changes --------- Co-authored-by: PrathyushaLakkireddy Co-authored-by: Prathyusha Lakkireddy --- README.md | 55 +- chainclient/broadcast_tx.go | 90 + chainclient/client.go | 29 + chainclient/create_client.go | 153 ++ client/cli/query.go | 34 + client/cli/tx.go | 76 +- go.mod | 2 +- keeper/abci.go | 157 +- keeper/abciTypes.go | 8 + keeper/collections.go | 30 +- keeper/genesis.go | 9 +- keeper/keeper.go | 31 +- keeper/msg_server.go | 41 +- keeper/preblocker_handle.go | 39 - keeper/prepare_handle.go | 26 +- keeper/process_handle.go | 61 +- keeper/query_server.go | 87 +- keeper/status.go | 33 + keeper/store.go | 127 ++ keeper/vote_extension.go | 98 + keys.go | 33 +- module/module.go | 8 +- proto/sdk/avail/v1beta1/genesis.proto | 4 +- proto/sdk/avail/v1beta1/query.proto | 79 +- proto/sdk/avail/v1beta1/tx.proto | 33 +- proto/sdk/avail/v1beta1/vote_extensions.proto | 13 + relayer/client.go | 153 ++ relayer/publish.go | 74 +- relayer/submit_data.go | 101 +- relayer/types.go | 10 + simapp/app/app.go | 16 +- simapp/init-simapp.sh | 3 + types/codec.go | 4 +- types/genesis.pb.go | 105 +- types/query.pb.go | 2031 +++-------------- types/query.pb.gw.go | 306 +-- types/tx.pb.go | 522 ++++- types/validation.go | 8 - types/vote_extensions.pb.go | 365 +++ 39 files changed, 2408 insertions(+), 2646 deletions(-) create mode 100644 chainclient/broadcast_tx.go create mode 100644 chainclient/client.go create mode 100644 chainclient/create_client.go create mode 100644 keeper/abciTypes.go delete mode 100644 keeper/preblocker_handle.go create mode 100644 keeper/status.go create mode 100644 keeper/store.go create mode 100644 keeper/vote_extension.go create mode 100644 proto/sdk/avail/v1beta1/vote_extensions.proto create mode 100644 relayer/client.go create mode 100644 relayer/types.go create mode 100644 types/vote_extensions.pb.go diff --git a/README.md b/README.md index f9b2b5c..f90fc06 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,59 @@ CADA is a module designed to connect Cosmos sovereign chains with the Avail network, making it easier for any Cosmos chain or rollapp to use Avail as their Data Availability (DA) layer. With CADA, developers can improve the scalability and security of their decentralized applications within the Cosmos ecosystem. It enables better data handling and availability, allowing Cosmos-based chains to tap into the strengths of Avail and build a more connected and resilient blockchain network. -For detailed instructions on how to integrate the module with a Cosmos SDK application, please refer to the [integration guide](./docs/integration.md). +For example: +Let blobInterval = 10, +- At height `11`, blocks from `1` to `10` are posted. +- At height `21`, blocks from `11` to `20` are posted. +#### Relayer +The `Relayer` acts as the transport layer, responsible for handling requests from the `prepareBlocker` and facilitating transactions between the Cosmos chain and the Avail DA network. It performs key functions such as submitting block data to Avail and updating block status on the Cosmos chain. Every validator in the network is required to run the relayer process. + +#### Proven Height +The `Proven Height` signifies the most recent block height of the Cosmos chain where data has been successfully transmitted to Avail and validated by the network. + +## Architecture + +![Screenshot from 2024-08-27 11-35-01](https://github.com/user-attachments/assets/1a8657f6-4c1b-418a-8295-05c039baa6d0) + + +1. **Block Interval Trigger**: + - At each block interval, a request is sent from `PrepareProposal` abci method to the relayer, specifying the range of block heights to be posted to the Avail DA network. This request should be made by the block proposer only. + +2. **MsgSubmitBlobRequest Transaction**: + - The relayer submits a `MsgSubmitBlobRequest` transaction on the Cosmos chain, signaling that the block data for the specified range is pending: + ``` + status[range] = pending + ``` + - The relayer monitors the transaction to confirm its successful inclusion and processing on the chain. + +3. **Data Submission to Avail DA**: + - Once the `MsgSubmitBlobRequest` transaction is confirmed, the relayer fetches the block data for the specified range and submits it to the Avail DA layer. + +4. **MsgUpdateBlobStatusRequest Transaction**: + - After confirming that the data is available on Avail, the relayer submits a `MsgUpdateBlobStatusRequest` transaction on the Cosmos chain, updating the block status to pre-verification: + ``` + status[range] = IN_VOTING + ``` + +5. **Validator Confirmation**: + - Within a preconfigured block limit, all validators are required to verify the data's availability on the Avail network using their Avail light clients and cast their votes. + + we could use voteExtension to cast the votes + +6. **Consensus and Proven Height Update**: + - If the number of votes exceeds the consensus threshold, the status of the block range is updated to success, and the `Proven Height` is advanced: + ``` + status[range] = success + + // Update the proven height + if range.from == provenHeight + 1 { + provenHeight = range.to + } + ``` + +7. **Failure Handling**: + - In case of any failures or expiration of the verification window, the data will be reposted following the same procedure. + +--- For detailed instructions on how to integrate the module with a spawn generated application, please refer to the [integration guide](./docs/spawn.md). diff --git a/chainclient/broadcast_tx.go b/chainclient/broadcast_tx.go new file mode 100644 index 0000000..d78e3d9 --- /dev/null +++ b/chainclient/broadcast_tx.go @@ -0,0 +1,90 @@ +package chainclient + +import ( + "fmt" + "log" + "os" + + cometrpc "github.com/cometbft/cometbft/rpc/client/http" + clitx "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/vitwit/avail-da-module/types" + + "path/filepath" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +func GetBinPath() string { + homeDir, err := os.UserHomeDir() + if err != nil { + log.Fatal(err) + } + + availdHomePath := filepath.Join(homeDir, ".availsdk") + return availdHomePath +} + +func ExecuteTX(ctx sdk.Context, msg types.MsgUpdateBlobStatusRequest, cdc codec.BinaryCodec) error { + // Define keyring and RPC client configuration + + // homePath := "/home/vitwit/.availsdk" + homePath := GetBinPath() + key := os.Getenv("KEY") + fmt.Println("get key namee.........", key) + if key == "" { //TODO : remove this later + key = "alice" + } + keyName := key + rpcAddress := "http://localhost:26657" + + // Create a keyring + kr, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, homePath, os.Stdin, cdc.(codec.Codec)) + if err != nil { + return fmt.Errorf("error creating keyring: %w", err) + } + + info, err := kr.Key(keyName) + valAddr, err := info.GetAddress() + fmt.Println("after address................", valAddr) + + // Create an RPC client + rpcClient, err := cometrpc.NewWithTimeout(rpcAddress, "/websocket", 3) + if err != nil { + return fmt.Errorf("error creating RPC client: %w", err) + } + + // Create a new client context + clientCtx := NewClientCtx(kr, rpcClient, ctx.ChainID(), cdc, homePath, valAddr) + + // Set the client context's from fields + clientCtx.FromName = keyName + clientCtx.FromAddress = valAddr + + // Fetch account number and sequence from the blockchain + accountRetriever := authtypes.AccountRetriever{} + account, err := accountRetriever.GetAccount(clientCtx, valAddr) + if err != nil { + return fmt.Errorf("error retrieving account: %w", err) + } + + fmt.Println("account details......", account.GetAccountNumber(), account.GetSequence()) + + // Set the correct account number and sequence + factory := NewFactory(clientCtx). + WithAccountNumber(account.GetAccountNumber()). + WithSequence(account.GetSequence()) + + // Create a transaction factory and set the validator address in the message + // factory := NewFactory(clientCtx) + msg.ValidatorAddress = valAddr.String() + + // Generate and broadcast the transaction + if err := clitx.GenerateOrBroadcastTxWithFactory(clientCtx, factory, &msg); err != nil { + return fmt.Errorf("error broadcasting transaction: %w", err) + } + + return nil +} diff --git a/chainclient/client.go b/chainclient/client.go new file mode 100644 index 0000000..3ba5df3 --- /dev/null +++ b/chainclient/client.go @@ -0,0 +1,29 @@ +package chainclient + +import ( + "bytes" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" +) + +const ( + KeyringBackendTest = "test" +) + +// ChainClient is client to interact with SPN. +type ChainClient struct { + factory tx.Factory + clientCtx client.Context + out *bytes.Buffer + 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/chainclient/create_client.go b/chainclient/create_client.go new file mode 100644 index 0000000..23addf6 --- /dev/null +++ b/chainclient/create_client.go @@ -0,0 +1,153 @@ +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" + "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/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" + + // "github.com/tendermint/starport/starport/pkg/xfilepath" + + "github.com/cosmos/cosmos-sdk/types/module" +) + +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, hdPath 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/client/cli/query.go b/client/cli/query.go index aa5160c..89b6f48 100644 --- a/client/cli/query.go +++ b/client/cli/query.go @@ -1,9 +1,13 @@ package cli import ( + "log" + "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" ) func GetQueryCmd() *cobra.Command { @@ -13,5 +17,35 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(GetLatestBlobStatusInfo()) + + return cmd +} + +func GetLatestBlobStatusInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-da-status", + Short: "Show what range of blocks are being submitted and thier status", + Long: `Show what range of blocks are being submitted and thier status, + `, + Example: "simd query cada get-da-status", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QuerySubmittedBlobStatusRequest{} + res, err := queryClient.SubmittedBlobStatus(cmd.Context(), req) + if err != nil { + log.Fatal(err) + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) return cmd } diff --git a/client/cli/tx.go b/client/cli/tx.go index e2d66ef..a3ae011 100644 --- a/client/cli/tx.go +++ b/client/cli/tx.go @@ -1,15 +1,23 @@ package cli import ( + "errors" + "strconv" + "strings" + "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" availblob "github.com/vitwit/avail-da-module" + "github.com/vitwit/avail-da-module/keeper" + "github.com/vitwit/avail-da-module/types" ) // NewTxCmd -func NewTxCmd() *cobra.Command { +func NewTxCmd(keeper *keeper.Keeper) *cobra.Command { txCmd := &cobra.Command{ Use: availblob.ModuleName, Short: availblob.ModuleName + " transaction subcommands", @@ -18,5 +26,71 @@ func NewTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + txCmd.AddCommand(NewUpdateBlobStatusCmd()) + return txCmd } + +// update status +func NewUpdateBlobStatusCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-blob [from_block] [to_block] [status] [avail_height]", + Short: `update blob status by giving blocks range and status(success|failure) + and the avail height at which the blob is stored`, + Example: "simd update-blob 11 15 success 120", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + fromBlock, err := strconv.Atoi(args[0]) + if err != nil { + return err + } + toBlock, err := strconv.Atoi(args[1]) + if err != nil { + return err + } + + isSuccess, err := ParseStatus(args[2]) + if err != nil { + return err + } + + availHeight, err := strconv.Atoi(args[3]) + if err != nil { + return err + } + + msg := types.MsgUpdateBlobStatusRequest{ + BlocksRange: &types.Range{ + From: uint64(fromBlock), + To: uint64(toBlock), + }, + ValidatorAddress: clientCtx.GetFromAddress().String(), + AvailHeight: uint64(availHeight), + IsSuccess: isSuccess, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func ParseStatus(status string) (bool, error) { + status = strings.ToUpper(status) + if status == "SUCCESS" { + return true, nil + } + + if status == "FAILURE" { + return false, nil + } + + return false, errors.New("invalid status") +} diff --git a/go.mod b/go.mod index 658077f..d0a8743 100644 --- a/go.mod +++ b/go.mod @@ -63,7 +63,7 @@ require ( github.com/cometbft/cometbft-db v0.9.1 // indirect github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-db v1.0.2 // indirect - github.com/cosmos/go-bip39 v1.0.0 // indirect + github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.1.2 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect diff --git a/keeper/abci.go b/keeper/abci.go index dc51578..2f28b36 100644 --- a/keeper/abci.go +++ b/keeper/abci.go @@ -1,9 +1,13 @@ package keeper import ( + "bytes" + "encoding/json" + "fmt" + abci "github.com/cometbft/cometbft/abci/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/vitwit/avail-da-module/types" ) type ProofOfBlobProposalHandler struct { @@ -11,70 +15,165 @@ type ProofOfBlobProposalHandler struct { prepareProposalHandler sdk.PrepareProposalHandler processProposalHandler sdk.ProcessProposalHandler + VoteExtHandler VoteExtHandler } func NewProofOfBlobProposalHandler( k *Keeper, prepareProposalHandler sdk.PrepareProposalHandler, processProposalHandler sdk.ProcessProposalHandler, + voteExtHandler VoteExtHandler, ) *ProofOfBlobProposalHandler { return &ProofOfBlobProposalHandler{ keeper: k, prepareProposalHandler: prepareProposalHandler, processProposalHandler: processProposalHandler, + VoteExtHandler: voteExtHandler, } } func (h *ProofOfBlobProposalHandler) PrepareProposal(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { h.keeper.proposerAddress = req.ProposerAddress + proposalTxs := req.Txs - resp, err := h.prepareProposalHandler(ctx, req) + votes, err := h.aggregateVotes(ctx, req.LocalLastCommit) if err != nil { + fmt.Println("error while aggregating votes", err) return nil, err } - var latestProvenHeight int64 = 1 - // TODO : set latestproven height in store - injectData := h.keeper.prepareInjectData(ctx, req.Time, latestProvenHeight) - injectDataBz := h.keeper.marshalMaxBytes(&injectData, req.MaxTxBytes, latestProvenHeight) - resp.Txs = h.keeper.addAvailblobDataToTxs(injectDataBz, req.MaxTxBytes, resp.Txs) + injectedVoteExtTx := StakeWeightedVotes{ + Votes: votes, + ExtendedCommitInfo: req.LocalLastCommit, + } + bz, err := json.Marshal(injectedVoteExtTx) + if err != nil { + fmt.Println("failed to encode injected vote extension tx", "err", err) + } - return resp, nil + proposalTxs = append(proposalTxs, bz) + return &abci.ResponsePrepareProposal{ + Txs: proposalTxs, + }, nil } func (h *ProofOfBlobProposalHandler) ProcessProposal(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { - // fmt.Println("length of transactions: ", len(req.Txs), ctx.BlockHeight()) - injectedData := h.keeper.getInjectedData(req.Txs) - if injectedData != nil { - req.Txs = req.Txs[1:] // Pop the injected data for the default handler + if len(req.Txs) == 0 { + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + } - if err := h.keeper.processPendingBlocks(ctx, req.Time, &injectedData.PendingBlocks); err != nil { - return nil, err - } + 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 } - return h.processProposalHandler(ctx, req) + + //TODO: write some validations + + return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil + } func (k *Keeper) PreBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock) error { - injectedData := k.prepareInjectData(ctx, req.Time, req.Height) - injectDataBz := k.marshalMaxBytes(&injectedData, int64(req.Size()), req.Height) - _ = k.addAvailblobDataToTxs(injectDataBz, int64(req.Size()), req.Txs) + votingEndHeight := k.GetVotingEndHeightFromStore(ctx) + blobStatus := k.GetBlobStatus(ctx) + currentHeight := ctx.BlockHeight() + + if len(req.Txs) > 0 && currentHeight == int64(votingEndHeight) && blobStatus == IN_VOTING_STATE { + 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 { + from := k.GetStartHeightFromStore(ctx) + to := k.GetEndHeightFromStore(ctx) + + pendingRangeKey := Key(from, to) + votingPower := injectedVoteExtTx.Votes[pendingRangeKey] + + state := FAILURE_STATE + + if votingPower > 0 { // TODO: calculate voting power properly + state = READY_STATE + } + + k.SetBlobStatus(ctx, state) + } + } + + currentBlockHeight := ctx.BlockHeight() + if !k.IsValidBlockToPostTODA(uint64(currentBlockHeight)) { + return nil + } + + provenHeight := k.GetProvenHeightFromStore(ctx) + fromHeight := provenHeight + 1 // Calcualte pending range of blocks to post data + endHeight := min(fromHeight+uint64(k.MaxBlocksForBlob), uint64(ctx.BlockHeight())) //exclusive i.e [fromHeight, endHeight) + + sdkCtx := sdk.UnwrapSDKContext(ctx) + ok := k.SetBlobStatusPending(sdkCtx, fromHeight, endHeight-1) + if !ok { + return nil + } + + var blocksToSumit []int64 + + for i := fromHeight; i < endHeight; i++ { + blocksToSumit = append(blocksToSumit, int64(i)) + } - if err := k.preblockerPendingBlocks(ctx, req.Time, req.ProposerAddress, &injectedData.PendingBlocks); err != nil { - return err + // only the proposer should be able to post the blocks + if bytes.Equal(req.ProposerAddress, k.proposerAddress) { + k.relayer.PostBlocks(ctx, blocksToSumit, k.cdc, req.ProposerAddress) } - // } + return nil } -func (k *Keeper) getInjectedData(txs [][]byte) *types.InjectedData { - if len(txs) != 0 { - var injectedData types.InjectedData - err := k.cdc.Unmarshal(txs[0], &injectedData) - if err == nil { - return &injectedData +func (k *Keeper) IsValidBlockToPostTODA(height uint64) bool { + if height <= uint64(1) { + return false + } + + if (height-1)%k.PublishToAvailBlockInterval != 0 { + return false + } + + return true +} + +func (h *ProofOfBlobProposalHandler) aggregateVotes(ctx sdk.Context, ci abci.ExtendedCommitInfo) (map[string]int64, error) { + from := h.keeper.GetStartHeightFromStore(ctx) + to := h.keeper.GetEndHeightFromStore(ctx) + + pendingRangeKey := Key(from, to) + votes := make(map[string]int64, 1) + + for _, v := range ci.Votes { + // Process only votes with BlockIDFlagCommit, indicating the validator committed to the block. + // Skip votes with other flags (e.g., BlockIDFlagUnknown, BlockIDFlagNil). + if v.BlockIdFlag != cmtproto.BlockIDFlagCommit { + continue + } + + var voteExt VoteExtension + if err := json.Unmarshal(v.VoteExtension, &voteExt); err != nil { + h.VoteExtHandler.logger.Error("failed to decode vote extension", "err", err, "validator", fmt.Sprintf("%x", v.Validator.Address)) + continue + } + + if voteExt.Votes == nil { + continue } + + for voteRange, isVoted := range voteExt.Votes { + if voteRange != pendingRangeKey || !isVoted { + continue + } + + votes[voteRange] += v.Validator.Power + } + } - return nil + return votes, nil } diff --git a/keeper/abciTypes.go b/keeper/abciTypes.go new file mode 100644 index 0000000..0be7947 --- /dev/null +++ b/keeper/abciTypes.go @@ -0,0 +1,8 @@ +package keeper + +import abci "github.com/cometbft/cometbft/abci/types" + +type StakeWeightedVotes struct { + Votes map[string]int64 + ExtendedCommitInfo abci.ExtendedCommitInfo +} diff --git a/keeper/collections.go b/keeper/collections.go index eec90c5..7d86cea 100644 --- a/keeper/collections.go +++ b/keeper/collections.go @@ -50,11 +50,11 @@ func (k *Keeper) GetAllValidators(ctx context.Context) (types.Validators, error) return validators, nil } -func (k *Keeper) SetProvenHeight(ctx context.Context, height int64) error { +func (k *Keeper) SetProvenHeight(ctx context.Context, height uint64) error { return k.ProvenHeight.Set(ctx, height) } -func (k *Keeper) GetProvenHeight(ctx context.Context) (int64, error) { +func (k *Keeper) GetProvenHeight(ctx context.Context) (uint64, error) { return k.ProvenHeight.Get(ctx) } @@ -193,29 +193,3 @@ func (k Keeper) GetExpiredBlocks(ctx context.Context, currentBlockTime time.Time } return expiredBlocks } - -func (k *Keeper) GetPendingBlocksWithExpiration(ctx context.Context) ([]*types.BlockWithExpiration, error) { - iterator, err := k.PendingBlocksToTimeouts.Iterate(ctx, nil) - if err != nil { - return nil, err - } - defer iterator.Close() - - var pendingBlocks []*types.BlockWithExpiration - for ; iterator.Valid(); iterator.Next() { - pendingBlock, err := iterator.Key() - if err != nil { - return nil, err - } - expiration, err := iterator.Value() - if err != nil { - return nil, err - } - pendingBlocks = append(pendingBlocks, &types.BlockWithExpiration{ - Height: pendingBlock, - Expiration: time.Unix(0, expiration), - }) - } - - return pendingBlocks, nil -} diff --git a/keeper/genesis.go b/keeper/genesis.go index 03f336b..3043656 100644 --- a/keeper/genesis.go +++ b/keeper/genesis.go @@ -14,9 +14,9 @@ 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 - } + // if err := k.SetProvenHeight(ctx, ctx.HeaderInfo().Height); err != nil { + // return err + // } k.relayer.NotifyProvenHeight(ctx.HeaderInfo().Height) @@ -38,7 +38,6 @@ func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { panic(err) } - pendingBlocks, err := k.GetPendingBlocksWithExpiration(ctx) if err != nil { panic(err) } @@ -46,8 +45,6 @@ func (k *Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return &types.GenesisState{ Validators: vals.Validators, ProvenHeight: provenHeight, - - PendingBlocks: pendingBlocks, } } diff --git a/keeper/keeper.go b/keeper/keeper.go index dc6281d..b4500a9 100644 --- a/keeper/keeper.go +++ b/keeper/keeper.go @@ -5,6 +5,9 @@ import ( storetypes2 "cosmossdk.io/store/types" upgradekeeper "cosmossdk.io/x/upgrade/keeper" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + 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" "github.com/vitwit/avail-da-module/types" @@ -23,28 +26,30 @@ type Keeper struct { Validators collections.Map[string, string] ClientID collections.Item[string] - ProvenHeight collections.Item[int64] + ProvenHeight collections.Item[uint64] PendingBlocksToTimeouts collections.Map[int64, int64] TimeoutsToPendingBlocks collections.Map[int64, types.PendingBlocks] + keyring keyring.Keyring storeKey storetypes2.StoreKey cdc codec.BinaryCodec - publishToAvailBlockInterval int - injectedProofsLimit int - app_id int + PublishToAvailBlockInterval uint64 + MaxBlocksForBlob uint + VotingInterval uint64 + appID int unprovenBlocks map[int64][]byte proposerAddress []byte + ClientCmd *cobra.Command } func NewKeeper( cdc codec.BinaryCodec, appOpts servertypes.AppOptions, storeService storetypes.KVStoreService, - // sk *stakingkeeper.Keeper, uk *upgradekeeper.Keeper, key storetypes2.StoreKey, publishToAvailBlockInterval int, @@ -54,12 +59,11 @@ func NewKeeper( sb := collections.NewSchemaBuilder(storeService) return &Keeper{ - // stakingKeeper: sk, 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.Int64Value), + 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)), @@ -67,13 +71,20 @@ func NewKeeper( cdc: cdc, - publishToAvailBlockInterval: publishToAvailBlockInterval, - app_id: appId, + appID: appId, - unprovenBlocks: make(map[int64][]byte), + unprovenBlocks: make(map[int64][]byte), + MaxBlocksForBlob: 20, //Todo: call this from app.go, later change to params + PublishToAvailBlockInterval: 5, //Todo: call this from app.go, later change to params + VotingInterval: 5, } } func (k *Keeper) SetRelayer(r *relayer.Relayer) { k.relayer = r } + +func (k *Keeper) GetBlobStatus(ctx sdk.Context) uint32 { + store := ctx.KVStore(k.storeKey) + return GetStatusFromStore(store) +} diff --git a/keeper/msg_server.go b/keeper/msg_server.go index 384ab3e..68df567 100644 --- a/keeper/msg_server.go +++ b/keeper/msg_server.go @@ -2,7 +2,10 @@ package keeper import ( "context" + "errors" + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/vitwit/avail-da-module/types" ) @@ -17,23 +20,35 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer { return &msgServer{k: keeper} } -func (s msgServer) SetAvailAddress(ctx context.Context, msg *types.MsgSetAvailAddress) (*types.MsgSetAvailAddressResponse, error) { - valAddr, err := msg.Validate(s.k.stakingKeeper.ValidatorAddressCodec()) - if err != nil { - return nil, err +func (s msgServer) UpdateBlobStatus(ctx context.Context, req *types.MsgUpdateBlobStatusRequest) (*types.MsgUpdateBlobStatusResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + // status should be changed to Voting or Ready, depending on the request + store := sdkCtx.KVStore(s.k.storeKey) + provenHeight := s.k.GetProvenHeightFromStore(sdkCtx) + endHeight := s.k.GetEndHeightFromStore(sdkCtx) + status := GetStatusFromStore(store) + + if req.BlocksRange.From != provenHeight+1 || req.BlocksRange.To != endHeight { + return nil, fmt.Errorf("invalid blocks range request: expected range [%d -> %d], got [%d -> %d]", + provenHeight+1, endHeight, req.BlocksRange.From, req.BlocksRange.To) } - // verify that the validator exists - if _, err := s.k.stakingKeeper.GetValidator(ctx, valAddr); err != nil { - return nil, err + if status != PENDING_STATE { + return nil, errors.New("can't update the status if it is not pending") } - if err = s.k.SetValidatorAvailAddress(ctx, types.Validator{ - ValidatorAddress: msg.ValidatorAddress, - AvailAddress: msg.AvailAddress, - }); err != nil { - return nil, err + newStatus := IN_VOTING_STATE + if !req.IsSuccess { + newStatus = FAILURE_STATE + } else { + currentHeight := sdkCtx.BlockHeight() + UpdateAvailHeight(sdkCtx, store, req.AvailHeight) // updates avail height at which the blocks got submitted to DA + UpdateVotingEndHeight(sdkCtx, store, uint64(currentHeight)+s.k.VotingInterval) } - return new(types.MsgSetAvailAddressResponse), nil + UpdateBlobStatus(sdkCtx, store, newStatus) + + return &types.MsgUpdateBlobStatusResponse{}, nil + } diff --git a/keeper/preblocker_handle.go b/keeper/preblocker_handle.go deleted file mode 100644 index 823ee86..0000000 --- a/keeper/preblocker_handle.go +++ /dev/null @@ -1,39 +0,0 @@ -package keeper - -import ( - "fmt" - "reflect" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/vitwit/avail-da-module/types" -) - -func (k *Keeper) preblockerPendingBlocks(ctx sdk.Context, blockTime time.Time, proposerAddr []byte, pendingBlocks *types.PendingBlocks) error { - if pendingBlocks != nil { - if reflect.DeepEqual(k.proposerAddress, proposerAddr) { - k.relayer.PostBlocks(ctx, pendingBlocks.BlockHeights) - } - - for _, pendingBlock := range pendingBlocks.BlockHeights { - if err := k.AddUpdatePendingBlock(ctx, pendingBlock, blockTime); err != nil { - return fmt.Errorf("preblocker pending blocks, %v", err) - } - } - } - - return nil -} - -func (k *Keeper) notifyProvenHeight(ctx sdk.Context, previousProvenHeight int64) { - - // TODO - // provenHeight, err := k.GetProvenHeight(ctx) - // if err != nil { - // fmt.Println("unable to get proven height", err) - // return - // } - - // //k.relayer.NotifyProvenHeight(provenHeight) - // go k.relayer.PruneBlockStore(previousProvenHeight) -} diff --git a/keeper/prepare_handle.go b/keeper/prepare_handle.go index 990a798..85232e5 100644 --- a/keeper/prepare_handle.go +++ b/keeper/prepare_handle.go @@ -11,9 +11,10 @@ import ( const DelayAfterUpgrade = int64(10) func (k *Keeper) prepareInjectData(ctx sdk.Context, currentBlockTime time.Time, latestProvenHeight int64) types.InjectedData { - return types.InjectedData{ - PendingBlocks: k.preparePostBlocks(ctx, currentBlockTime), - } + // return types.InjectedData{ + // PendingBlocks: k.preparePostBlocks(ctx, currentBlockTime), + // } + return types.InjectedData{} } func (k *Keeper) addAvailblobDataToTxs(injectDataBz []byte, maxTxBytes int64, txs [][]byte) [][]byte { @@ -36,11 +37,11 @@ func (k *Keeper) addAvailblobDataToTxs(injectDataBz []byte, maxTxBytes int64, tx } func (k *Keeper) preparePostBlocks(ctx sdk.Context, currentBlockTime time.Time) types.PendingBlocks { - provenHeight, err := k.GetProvenHeight(ctx) - if err != nil { - return types.PendingBlocks{} - } - newBlocks := k.relayer.ProposePostNextBlocks(ctx, provenHeight) + // provenHeight, err := k.GetProvenHeight(ctx) + // if err != nil { + // return types.PendingBlocks{} + // } + // newBlocks := k.relayer.ProposePostNextBlocks(ctx, provenHeight) // If there are no new blocks to propose, check for expired blocks // Additionally, if the block interval is 1, we need to also be able to re-publish an expired block @@ -58,9 +59,10 @@ func (k *Keeper) preparePostBlocks(ctx sdk.Context, currentBlockTime time.Time) // } // } - return types.PendingBlocks{ - BlockHeights: newBlocks, - } + // return types.PendingBlocks{ + // BlockHeights: newBlocks, + // } + return types.PendingBlocks{} } // shouldGetExpiredBlocks checks if this chain has recently upgraded. @@ -80,9 +82,7 @@ func (k *Keeper) marshalMaxBytes(injectData *types.InjectedData, maxBytes int64, return nil } - proofLimit := k.injectedProofsLimit for int64(len(injectDataBz)) > maxBytes { - proofLimit = proofLimit - 1 injectDataBz, err = k.cdc.Marshal(injectData) if err != nil { diff --git a/keeper/process_handle.go b/keeper/process_handle.go index f047188..8f23397 100644 --- a/keeper/process_handle.go +++ b/keeper/process_handle.go @@ -1,7 +1,6 @@ package keeper import ( - "fmt" "time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -9,36 +8,36 @@ import ( ) func (k Keeper) processPendingBlocks(ctx sdk.Context, currentBlockTime time.Time, pendingBlocks *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) - } - } - } + // 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/query_server.go b/keeper/query_server.go index 0ad3405..eeecbd1 100644 --- a/keeper/query_server.go +++ b/keeper/query_server.go @@ -2,9 +2,8 @@ package keeper import ( "context" - "time" - "cosmossdk.io/collections" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/vitwit/avail-da-module/types" ) @@ -19,73 +18,21 @@ type queryServer struct { k *Keeper } -// PendingValidators returns the pending validators. -func (qs queryServer) Validators(ctx context.Context, _ *types.QueryValidatorsRequest) (*types.QueryValidatorsResponse, error) { - vals, err := qs.k.GetAllValidators(ctx) - if err != nil { - return nil, err - } - - return &types.QueryValidatorsResponse{Validators: vals.Validators}, nil -} - -func (qs queryServer) AvailAddress(ctx context.Context, req *types.QueryAvailAddressRequest) (*types.QueryAvailAddressResponse, error) { - addr, err := qs.k.GetValidatorAvailAddress(ctx, req.ValidatorAddress) - if err != nil { - return nil, err - } - - return &types.QueryAvailAddressResponse{AvailAddress: addr}, nil -} - -func (qs queryServer) ProvenHeight(ctx context.Context, _ *types.QueryProvenHeightRequest) (*types.QueryProvenHeightResponse, error) { - provenHeight, err := qs.k.GetProvenHeight(ctx) - if err != nil { - return nil, err - } - return &types.QueryProvenHeightResponse{ - ProvenHeight: provenHeight, - }, nil -} - -func (qs queryServer) PendingBlocks(ctx context.Context, _ *types.QueryPendingBlocksRequest) (*types.QueryPendingBlocksResponse, error) { - pendingBlocks, err := qs.k.GetPendingBlocksWithExpiration(ctx) - if err != nil { - return nil, err - } - return &types.QueryPendingBlocksResponse{ - PendingBlocks: pendingBlocks, - }, nil -} - -func (qs queryServer) ExpiredBlocks(ctx context.Context, _ *types.QueryExpiredBlocksRequest) (*types.QueryExpiredBlocksResponse, error) { - currentTimeNs := time.Now().UnixNano() - iterator, err := qs.k.TimeoutsToPendingBlocks. - Iterate(ctx, (&collections.Range[int64]{}).StartInclusive(0).EndInclusive(currentTimeNs)) - if err != nil { - return nil, err - } - defer iterator.Close() - - var expiredBlocks []*types.BlockWithExpiration - for ; iterator.Valid(); iterator.Next() { - expiration, err := iterator.Key() - if err != nil { - return nil, err - } - blocks, err := iterator.Value() - if err != nil { - return nil, err - } - for _, block := range blocks.BlockHeights { - expiredBlocks = append(expiredBlocks, &types.BlockWithExpiration{ - Height: block, - Expiration: time.Unix(0, expiration), - }) - } - } - return &types.QueryExpiredBlocksResponse{ - CurrentTime: time.Unix(0, currentTimeNs), - ExpiredBlocks: expiredBlocks, +func (qs queryServer) SubmittedBlobStatus(ctx context.Context, req *types.QuerySubmittedBlobStatusRequest) (*types.QuerySubmittedBlobStatusResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + store := sdkCtx.KVStore(qs.k.storeKey) + startHeight := qs.k.GetStartHeightFromStore(sdkCtx) + endHeight := qs.k.GetEndHeightFromStore(sdkCtx) + status := GetStatusFromStore(store) + blobStatus := ParseStatus(status) + provenHeight := qs.k.GetProvenHeightFromStore(sdkCtx) + votingEndHeight := qs.k.GetVotingEndHeightFromStore(sdkCtx) + + return &types.QuerySubmittedBlobStatusResponse{ + Range: &types.Range{From: startHeight, To: endHeight}, + Status: blobStatus, + ProvenHeight: provenHeight, + LastBlobVotingEndsAt: votingEndHeight, }, nil } diff --git a/keeper/status.go b/keeper/status.go new file mode 100644 index 0000000..d874152 --- /dev/null +++ b/keeper/status.go @@ -0,0 +1,33 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +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 + return false + } + + UpdateBlobStatus(ctx, store, PENDING_STATE) + UpdateStartHeight(ctx, store, startHeight) + UpdateEndHeight(ctx, store, endHeight) + return true +} + +func (k *Keeper) SetBlobStatus(ctx sdk.Context, state uint32) error { + store := ctx.KVStore(k.storeKey) + + if state == READY_STATE { + endHeight := k.GetEndHeightFromStore(ctx) + err := UpdateProvenHeight(ctx, store, endHeight) + if err != nil { + return err + } + } + + return UpdateBlobStatus(ctx, store, state) +} diff --git a/keeper/store.go b/keeper/store.go new file mode 100644 index 0000000..46065a6 --- /dev/null +++ b/keeper/store.go @@ -0,0 +1,127 @@ +package keeper + +import ( + "encoding/binary" + + "cosmossdk.io/collections" + storetypes2 "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + availblob1 "github.com/vitwit/avail-da-module" +) + +const ( + READY_STATE uint32 = 0 + PENDING_STATE uint32 = 1 + IN_VOTING_STATE uint32 = 2 + FAILURE_STATE uint32 = 3 +) + +func ParseStatus(status uint32) string { + switch status { + case READY_STATE: + return "SUCCESS" + case PENDING_STATE: + return "PENDING" + case IN_VOTING_STATE: + return "IN_VOTING" + case FAILURE_STATE: + return "FAILURE" + default: + return "UNKNOWN" + } +} + +func CanUpdateStatusToPending(store storetypes2.KVStore) bool { + statusBytes := store.Get(availblob1.BlobStatusKey) + if statusBytes == nil || len(statusBytes) == 0 { + return true + } + + status := binary.BigEndian.Uint32(statusBytes) + + return status == READY_STATE || status == FAILURE_STATE +} + +func GetStatusFromStore(store storetypes2.KVStore) uint32 { + statusBytes := store.Get(availblob1.BlobStatusKey) + + if statusBytes == nil || len(statusBytes) == 0 { + return READY_STATE + } + + status := binary.BigEndian.Uint32(statusBytes) + + return status +} + +func UpdateBlobStatus(ctx sdk.Context, store storetypes2.KVStore, status uint32) error { + + statusBytes := make([]byte, 4) + + binary.BigEndian.PutUint32(statusBytes, status) + + store.Set(availblob1.BlobStatusKey, statusBytes) + return nil +} + +func UpdateStartHeight(ctx sdk.Context, store storetypes2.KVStore, startHeight uint64) error { + return updateHeight(store, availblob1.PrevHeightKey, startHeight) +} + +func UpdateEndHeight(ctx sdk.Context, store storetypes2.KVStore, endHeight uint64) error { + return updateHeight(store, availblob1.NextHeightKey, endHeight) +} + +func UpdateProvenHeight(ctx sdk.Context, store storetypes2.KVStore, provenHeight uint64) error { + return updateHeight(store, availblob1.ProvenHeightKey, provenHeight) +} + +func UpdateAvailHeight(ctx sdk.Context, store storetypes2.KVStore, availHeight uint64) error { + return updateHeight(store, availblob1.AvailHeightKey, availHeight) +} + +func UpdateVotingEndHeight(ctx sdk.Context, store storetypes2.KVStore, votingEndHeight uint64) error { + return updateHeight(store, availblob1.VotingEndHeightKey, votingEndHeight) +} + +func updateHeight(store storetypes2.KVStore, key collections.Prefix, height uint64) error { + heightBytes := make([]byte, 8) + + binary.BigEndian.PutUint64(heightBytes, height) + + store.Set(key, heightBytes) + return nil +} + +func (k *Keeper) GetProvenHeightFromStore(ctx sdk.Context) uint64 { + return k.getHeight(ctx, availblob1.ProvenHeightKey) +} + +func (k *Keeper) GetAvailHeightFromStore(ctx sdk.Context) uint64 { + return k.getHeight(ctx, availblob1.AvailHeightKey) +} + +func (k *Keeper) GetVotingEndHeightFromStore(ctx sdk.Context) uint64 { + return k.getHeight(ctx, availblob1.VotingEndHeightKey) +} + +func (k *Keeper) GetStartHeightFromStore(ctx sdk.Context) uint64 { + return k.getHeight(ctx, availblob1.PrevHeightKey) +} + +func (k *Keeper) GetEndHeightFromStore(ctx sdk.Context) uint64 { + + return k.getHeight(ctx, availblob1.NextHeightKey) +} + +func (k *Keeper) getHeight(ctx sdk.Context, key collections.Prefix) uint64 { + store := ctx.KVStore(k.storeKey) + heightBytes := store.Get(key) + + if heightBytes == nil || len(heightBytes) == 0 { + return 0 + } + + height := binary.BigEndian.Uint64(heightBytes) + return height +} diff --git a/keeper/vote_extension.go b/keeper/vote_extension.go new file mode 100644 index 0000000..c63e42b --- /dev/null +++ b/keeper/vote_extension.go @@ -0,0 +1,98 @@ +package keeper + +import ( + "encoding/json" + "fmt" + + "cosmossdk.io/log" + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type VoteExtHandler struct { + logger log.Logger + + Keeper *Keeper +} + +// TODO: add required parameters like avail light client url, etc.. +func NewVoteExtHandler( + logger log.Logger, + keeper *Keeper, +) *VoteExtHandler { + return &VoteExtHandler{ + logger: logger, + Keeper: keeper, + } +} + +func Key(from, to uint64) string { + return fmt.Sprintln(from, " ", to) +} + +type VoteExtension struct { + Votes map[string]bool +} + +func (h *VoteExtHandler) ExtendVoteHandler() sdk.ExtendVoteHandler { + + return func(ctx sdk.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { + + from := h.Keeper.GetStartHeightFromStore(ctx) + end := h.Keeper.GetEndHeightFromStore(ctx) + + availHeight := h.Keeper.GetAvailHeightFromStore(ctx) + + pendingRangeKey := Key(from, end) + + blobStatus := h.Keeper.GetBlobStatus(ctx) + currentHeight := ctx.BlockHeight() + voteEndHeight := h.Keeper.GetVotingEndHeightFromStore(ctx) + Votes := make(map[string]bool, 1) + + abciResponseVoteExt := &abci.ResponseExtendVote{} + + if currentHeight+1 != int64(voteEndHeight) || blobStatus != IN_VOTING_STATE { + voteExt := VoteExtension{ + Votes: Votes, + } + + //TODO: use better marshalling instead of json (eg: proto marshalling) + votesBytes, err := json.Marshal(voteExt) + if err != nil { + return nil, fmt.Errorf("failed to marshal vote extension: %w", err) + } + abciResponseVoteExt.VoteExtension = votesBytes + return abciResponseVoteExt, nil + } + + ok, err := h.Keeper.relayer.IsDataAvailable(ctx, from, end, availHeight, "http://localhost:8000") // TODO: read light client url from config + if ok { + h.logger.Info("submitted data to Avail verified successfully at", + "block_height", availHeight, + ) + } + + Votes[pendingRangeKey] = ok + voteExt := VoteExtension{ + Votes: Votes, + } + + //TODO: use proto marshalling instead + votesBytes, err := json.Marshal(voteExt) + if err != nil { + return nil, fmt.Errorf("failed to marshal vote extension: %w", err) + } + + return &abci.ResponseExtendVote{ + VoteExtension: votesBytes, + }, nil + } +} + +func (h *VoteExtHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteExtensionHandler { + return func(ctx sdk.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { + // TODO: write proper validation for the votes + return &abci.ResponseVerifyVoteExtension{Status: abci.ResponseVerifyVoteExtension_ACCEPT}, nil + } +} diff --git a/keys.go b/keys.go index a4d4219..0eaa2e3 100644 --- a/keys.go +++ b/keys.go @@ -1,7 +1,10 @@ package availblob import ( + "encoding/binary" + "cosmossdk.io/collections" + "github.com/vitwit/avail-da-module/types" ) var ( @@ -23,11 +26,23 @@ var ( // light client store key ClientStoreKey = []byte("client_store/") + + PendingBlobsKey = collections.NewPrefix(5) + + BlobStatusKey = collections.NewPrefix(6) + + PrevHeightKey = collections.NewPrefix(7) + + NextHeightKey = collections.NewPrefix(8) + + VotingEndHeightKey = collections.NewPrefix(9) + + AvailHeightKey = collections.NewPrefix(10) ) const ( // ModuleName is the name of the module - ModuleName = "availdamodule" + ModuleName = "cada" // StoreKey to be used when creating the KVStore StoreKey = ModuleName @@ -37,7 +52,17 @@ const ( // QuerierRoute to be used for querier msgs QuerierRoute = ModuleName - - // TransientStoreKey defines the transient store key - TransientStoreKey = "transient_" + ModuleName ) + +func PendingBlobsStoreKey(blocksRange types.Range) []byte { + fromBytes := make([]byte, 8) + binary.BigEndian.PutUint64(fromBytes, uint64(blocksRange.From)) + + toBytes := make([]byte, 8) + binary.BigEndian.PutUint64(toBytes, uint64(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 5c93ec5..1173edd 100644 --- a/module/module.go +++ b/module/module.go @@ -61,9 +61,13 @@ func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwrunt } } -// GetTxCmd returns the root tx command for the rollchain module. +// GetTxCmd returns the root tx command for the cada module. func (am AppModule) GetTxCmd() *cobra.Command { - return cli.NewTxCmd() + return cli.NewTxCmd(am.keeper) +} + +func (AppModule) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() } // RegisterInterfaces registers interfaces and implementations of the rollchain module. diff --git a/proto/sdk/avail/v1beta1/genesis.proto b/proto/sdk/avail/v1beta1/genesis.proto index 8c7bbe1..cc8e337 100644 --- a/proto/sdk/avail/v1beta1/genesis.proto +++ b/proto/sdk/avail/v1beta1/genesis.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package sdk.avail.v1beta1; import "gogoproto/gogo.proto"; import "sdk/avail/v1beta1/validator.proto"; -import "sdk/avail/v1beta1/query.proto"; option go_package = "github.com/vitwit/avail-da-module/types"; @@ -12,6 +11,5 @@ message GenesisState { // the height of the last block that was proven to be posted to Avail. // increment only, never skipping heights. - int64 proven_height = 2; - repeated BlockWithExpiration pending_blocks = 3; + uint64 proven_height = 2; } \ No newline at end of file diff --git a/proto/sdk/avail/v1beta1/query.proto b/proto/sdk/avail/v1beta1/query.proto index 8c7998a..3cc8f87 100644 --- a/proto/sdk/avail/v1beta1/query.proto +++ b/proto/sdk/avail/v1beta1/query.proto @@ -5,73 +5,28 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "sdk/avail/v1beta1/validator.proto"; import "google/protobuf/timestamp.proto"; +import "sdk/avail/v1beta1/tx.proto"; option go_package = "github.com/vitwit/avail-da-module/types"; -// Query defines the gRPC querier service. -service Query { - // Validators returns registered validators of the module. - rpc Validators(QueryValidatorsRequest) - returns (QueryValidatorsResponse) { - option (google.api.http).get = "/availblob/v1beta1/validators"; - } - - rpc AvailAddress(QueryAvailAddressRequest) returns (QueryAvailAddressResponse) { - option (google.api.http).get = "/availblob/v1beta1/avail_address"; - } - - rpc ProvenHeight(QueryProvenHeightRequest) returns (QueryProvenHeightResponse) { - option (google.api.http).get = "/availblob/v1beta1/proven_height"; - } - - rpc PendingBlocks(QueryPendingBlocksRequest) returns (QueryPendingBlocksResponse) { - option (google.api.http).get = "/availblob/v1beta1/pending_blocks"; - } - - rpc ExpiredBlocks(QueryExpiredBlocksRequest) returns (QueryExpiredBlocksResponse) { - option (google.api.http).get = "/availblob/v1beta1/expired_blocks"; - } -} - -// QueryValidatorsRequest is the request type for the Query/Validators RPC method. -message QueryValidatorsRequest {} - -// QueryValidatorResponse is the response type for the Query/Validators RPC method. -message QueryValidatorsResponse { - // validators is the returned validators from the module - repeated Validator validators = 1 [ (gogoproto.nullable) = false ]; +// query request +message QuerySubmittedBlobStatusRequest { } -// QueryAvailAddressRequest is the request type for the Query/AvailAddress RPC method. -message QueryAvailAddressRequest { - string validator_address = 1; +// query response +message QuerySubmittedBlobStatusResponse { + Range range = 1; + string status = 2; + uint64 proven_height = 3; + uint64 last_blob_voting_ends_at = 4; } -// QueryAvailAddressResponse is the response type for the Query/AvailAddress RPC method. -message QueryAvailAddressResponse { - string avail_address = 1; -} - -message QueryProvenHeightRequest {} - -message QueryProvenHeightResponse { - int64 proven_height = 1; -} - -message BlockWithExpiration { - int64 height = 1; - google.protobuf.Timestamp expiration = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; -} - -message QueryPendingBlocksRequest {} - -message QueryPendingBlocksResponse { - repeated BlockWithExpiration pending_blocks = 1; -} - -message QueryExpiredBlocksRequest {} +// Query defines the gRPC querier service. +service Query { -message QueryExpiredBlocksResponse { - google.protobuf.Timestamp current_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - repeated BlockWithExpiration expired_blocks = 2; -} + // submit Blob Status + rpc SubmittedBlobStatus(QuerySubmittedBlobStatusRequest) + returns (QuerySubmittedBlobStatusResponse) { + option (google.api.http).get = "/availblob/v1beta1/submitBlobStatus"; + } +} \ No newline at end of file diff --git a/proto/sdk/avail/v1beta1/tx.proto b/proto/sdk/avail/v1beta1/tx.proto index de7f4a3..fc87f9b 100644 --- a/proto/sdk/avail/v1beta1/tx.proto +++ b/proto/sdk/avail/v1beta1/tx.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package sdk.avail.v1beta1; import "cosmos/msg/v1/msg.proto"; +import "gogoproto/gogo.proto"; option go_package = "github.com/vitwit/avail-da-module/types"; @@ -9,18 +10,36 @@ option go_package = "github.com/vitwit/avail-da-module/types"; service Msg { option (cosmos.msg.v1.service) = true; - // SetAvailAddress - rpc SetAvailAddress(MsgSetAvailAddress) returns (MsgSetAvailAddressResponse); + // UpdateBlobStatus + rpc UpdateBlobStatus(MsgUpdateBlobStatusRequest) returns (MsgUpdateBlobStatusResponse); } -// MsgSetAvailAddress defines a SDK message for validators to set their Avail address -message MsgSetAvailAddress { +// blocks range from to to +message Range { + uint64 from = 1; + uint64 to = 2; +} + +// message update blob state response +message MsgUpdateBlobStatusRequest { option (cosmos.msg.v1.signer) = "validator_address"; string validator_address = 1; + Range blocks_range = 2; + uint64 avail_height = 3; + bool is_success = 4; +} - string avail_address = 2; +// status of submitblob +enum BlobStatus { + option (gogoproto.goproto_enum_prefix) = false; + BLOB_STATUS_UNSPECIFIED = 0; + BLOB_STATUS_FAILURE = 1; + BLOB_STATUS_SUCCESS = 2; + BLOB_STATUS_PENDING = 3; + } -// MsgSetAvailAddressResponse is the response type for the Msg/SetAvailAddress RPC method. -message MsgSetAvailAddressResponse {} \ No newline at end of file +// message update blob state response +message MsgUpdateBlobStatusResponse { +} \ No newline at end of file diff --git a/proto/sdk/avail/v1beta1/vote_extensions.proto b/proto/sdk/avail/v1beta1/vote_extensions.proto new file mode 100644 index 0000000..472ccf7 --- /dev/null +++ b/proto/sdk/avail/v1beta1/vote_extensions.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package sdk.avail.v1beta1; + +import "sdk/avail/v1beta1/tx.proto"; + +option go_package = "github.com/vitwit/avail-da-module/types"; + +// AvailVoteExtension +message AvailVoteExtension { + + int64 avail_height = 1; + Range range = 2; +} \ No newline at end of file diff --git a/relayer/client.go b/relayer/client.go new file mode 100644 index 0000000..bf6b648 --- /dev/null +++ b/relayer/client.go @@ -0,0 +1,153 @@ +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/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" + + // "github.com/tendermint/starport/starport/pkg/xfilepath" + + "github.com/cosmos/cosmos-sdk/types/module" +) + +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, hdPath 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/publish.go b/relayer/publish.go index 9f72505..8605188 100644 --- a/relayer/publish.go +++ b/relayer/publish.go @@ -1,12 +1,15 @@ package relayer import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/vitwit/avail-da-module/types" + + "github.com/cosmos/cosmos-sdk/codec" + dacli "github.com/vitwit/avail-da-module/chainclient" ) -// PostNextBlocks is called by the current proposing validator during PrepareProposal. -// If on the publish boundary, it will return the block heights that will be published -// It will not publish the block being proposed. func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []int64 { height := ctx.BlockHeight() @@ -31,16 +34,13 @@ func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []i } // PostBlocks is call in the preblocker, the proposer will publish at this point with their block accepted -func (r *Relayer) PostBlocks(ctx sdk.Context, blocks []int64) { - go r.postBlocks(ctx, blocks) +func (r *Relayer) PostBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCodec, proposer []byte) { + go r.postBlocks(ctx, blocks, cdc, proposer) } -// postBlocks will publish rollchain blocks to avail -// start height is inclusive, end height is exclusive -func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64) { - // process blocks instead of random data +func (r *Relayer) GetBlocksDataFromLocal(ctx sdk.Context, blocks []int64) []byte { if len(blocks) == 0 { - return + return []byte{} } var bb []byte @@ -49,30 +49,76 @@ func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64) { res, err := r.localProvider.GetBlockAtHeight(ctx, height) if err != nil { r.logger.Error("Error getting block", "height:", height, "error", err) - return + return []byte{} } blockProto, err := res.Block.ToProto() if err != nil { r.logger.Error("Error protoing block", "error", err) - return + return []byte{} } blockBz, err := blockProto.Marshal() if err != nil { r.logger.Error("Error marshaling block", "error", err) - return + return []byte{} } bb = append(bb, blockBz...) } - err := r.SubmitDataToClient(r.rpcClient.config.Seed, r.rpcClient.config.AppID, bb, blocks, r.rpcClient.config.LightClientURL) + return bb +} + +// postBlocks will publish rollchain blocks to avail +// start height is inclusive, end height is exclusive +func (r *Relayer) postBlocks(ctx sdk.Context, blocks []int64, cdc codec.BinaryCodec, proposer []byte) { + // process blocks instead of random data + if len(blocks) == 0 { + return + } + + bb := r.GetBlocksDataFromLocal(ctx, blocks) + + blockInfo, err := r.SubmitDataToAvailClient(r.rpcClient.config.Seed, r.rpcClient.config.AppID, bb, blocks, r.rpcClient.config.LightClientURL) + if err != nil { r.logger.Error("Error while submitting block(s) to Avail DA", "height_start", blocks[0], "height_end", blocks[len(blocks)-1], "appID", string(r.rpcClient.config.AppID), ) + + // execute tx about failure submission + err = dacli.ExecuteTX(ctx, types.MsgUpdateBlobStatusRequest{ + ValidatorAddress: sdk.AccAddress.String(proposer), + BlocksRange: &types.Range{ + From: uint64(blocks[0]), + To: uint64(blocks[len(blocks)-1]), + }, + // AvailHeight: uint64(blockInfo.BlockNumber), + IsSuccess: false, + }, cdc) + if err != nil { + fmt.Println("error while submitting tx...", err) + } + + return + } + + if blockInfo.BlockNumber != 0 { + msg := types.MsgUpdateBlobStatusRequest{ValidatorAddress: sdk.AccAddress.String(proposer), + BlocksRange: &types.Range{ + From: uint64(blocks[0]), + To: uint64(blocks[len(blocks)-1]), + }, + AvailHeight: uint64(blockInfo.BlockNumber), + IsSuccess: true} + + // TODO : execute tx about successfull submission + err = dacli.ExecuteTX(ctx, msg, cdc) + if err != nil { + fmt.Println("error while submitting tx...", err) + } } } diff --git a/relayer/submit_data.go b/relayer/submit_data.go index 7431770..84b77b6 100644 --- a/relayer/submit_data.go +++ b/relayer/submit_data.go @@ -1,9 +1,7 @@ package relayer import ( - "crypto/rand" "encoding/base64" - "encoding/hex" "encoding/json" "fmt" "time" @@ -14,36 +12,26 @@ import ( "github.com/centrifuge/go-substrate-rpc-client/v4/registry/state" "github.com/centrifuge/go-substrate-rpc-client/v4/signature" "github.com/centrifuge/go-substrate-rpc-client/v4/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) -func (r *Relayer) SubmitDataToClient(Seed string, AppID int, data []byte, blocks []int64, lightClientUrl string) error { - if r.submittedBlocksCache[blocks[0]] { - return nil - } - - r.submittedBlocksCache[blocks[0]] = true - delete(r.submittedBlocksCache, blocks[0]-int64(len(blocks))) +func (r *Relayer) SubmitDataToAvailClient(Seed string, AppID int, data []byte, blocks []int64, lightClientUrl string) (BlockInfo, error) { + var blockInfo BlockInfo handler := NewHTTPClientHandler() datab := base64.StdEncoding.EncodeToString(data) jsonData := []byte(fmt.Sprintf(`{"data":"%s"}`, datab)) - // Define the URL - //url := "http://127.0.0.1:8000/v2/submit" - url := fmt.Sprintf("%s/v2/submit", lightClientUrl) // Make the POST request responseBody, err := handler.Post(url, jsonData) if err != nil { fmt.Printf("Error: %v\n", err) - return err + return blockInfo, err } - // Create an instance of the struct - var blockInfo BlockInfo - // Unmarshal the JSON data into the struct err = json.Unmarshal(responseBody, &blockInfo) if err != nil { @@ -55,7 +43,7 @@ func (r *Relayer) SubmitDataToClient(Seed string, AppID int, data []byte, blocks } if err == nil { - r.logger.Info("Posted block(s) to Avail DA", + r.logger.Info("Successfully posted block(s) to Avail DA", "height_start", blocks[0], "height_end", blocks[len(blocks)-1], "appID", string(r.rpcClient.config.AppID), @@ -65,27 +53,59 @@ func (r *Relayer) SubmitDataToClient(Seed string, AppID int, data []byte, blocks ) } - return nil + return blockInfo, nil } -func (r *Relayer) GetSubmittedData(lightClientUrl string, blockNumber int) { +func (r *Relayer) GetSubmittedData(lightClientUrl string, blockNumber int) (BlockData, error) { handler := NewHTTPClientHandler() - // get submitted block data using light client api with avail block height - // time.Sleep(20 * time.Second) // wait upto data to be submitted data to be included in the avail blocks - url := fmt.Sprintf("%s/v2/blocks/%v/data?feilds=data", lightClientUrl) - url = fmt.Sprintf(url, blockNumber) + // Construct the URL with the block number + url := fmt.Sprintf("%s/v2/blocks/%v/data?fields=data", lightClientUrl, blockNumber) + // Perform the GET request, returning the body directly body, err := handler.Get(url) if err != nil { - return + return BlockData{}, fmt.Errorf("failed to fetch data from the avail: %w", err) } - if body != nil { - r.logger.Info("submitted data to Avail verfied successfully at", - "block_height", blockNumber, - ) + // Decode the response body into the BlockData struct + var blockData BlockData + err = json.Unmarshal(body, &blockData) + if err != nil { + return BlockData{}, fmt.Errorf("failed to decode block response: %w", err) + } + + return blockData, nil +} + +// IsDataAvailable is to query the avail light client and check if the data is made available at the given height +func (r *Relayer) IsDataAvailable(ctx sdk.Context, from, to uint64, availHeight uint64, lightClientUrl string) (bool, error) { + availBlock, err := r.GetSubmittedData(lightClientUrl, int(availHeight)) + if err != nil { + return false, err } + + var blocks []int64 + for i := from; i <= to; i++ { + blocks = append(blocks, int64(i)) + } + + cosmosBlocksData := r.GetBlocksDataFromLocal(ctx, blocks) + base64CosmosBlockData := base64.StdEncoding.EncodeToString(cosmosBlocksData) + + // TODO: any better / optimized way to check if data is really available? + return isDataIncludedInBlock(availBlock, base64CosmosBlockData), nil +} + +// bruteforce comparision check +func isDataIncludedInBlock(availBlock BlockData, base64cosmosData string) bool { + for _, data := range availBlock.Extrinsics { + if data.Data == base64cosmosData { + return true + } + } + + return false } // Define the struct that matches the JSON structure @@ -95,7 +115,7 @@ type GetBlock struct { } // submitData creates a transaction and makes a Avail data submission -func (r *Relayer) SubmitData1(ApiURL string, Seed string, AppID int, data []byte, blocks []int64) error { +func (r *Relayer) SubmitDataToAvailDA(ApiURL string, Seed string, AppID int, data []byte, blocks []int64) error { api, err := gsrpc.NewSubstrateAPI(ApiURL) if err != nil { r.logger.Error("cannot create api:%w", err) @@ -147,8 +167,6 @@ func (r *Relayer) SubmitData1(ApiURL string, Seed string, AppID int, data []byte return err } - // fmt.Println("keyring pair", keyringPair) - key, err := types.CreateStorageKey(meta, "System", "Account", keyringPair.PublicKey) if err != nil { r.logger.Error("cannot create storage key:%w", err) @@ -300,7 +318,7 @@ func (r *Relayer) SubmitData1(ApiURL string, Seed string, AppID int, data []byte } fmt.Printf("Txn inside finalized block\n") hash := status.AsFinalized - err = getData1(hash, api, string(data)) + err = GetDataFromAvailDA(hash, api, string(data)) if err != nil { r.logger.Error("cannot get data:%v", err) return err @@ -314,29 +332,12 @@ func (r *Relayer) SubmitData1(ApiURL string, Seed string, AppID int, data []byte } } -// RandToken generates a random hex value. -func RandToken1(n int) (string, error) { - bytes := make([]byte, n) - if _, err := rand.Read(bytes); err != nil { - return "", err - } - return hex.EncodeToString(bytes), nil -} - -func getData1(hash types.Hash, api *gsrpc.SubstrateAPI, data string) error { - +func GetDataFromAvailDA(hash types.Hash, api *gsrpc.SubstrateAPI, data string) error { block, err := api.RPC.Chain.GetBlock(hash) if err != nil { return fmt.Errorf("cannot get block by hash:%w", err) } - // Encode the struct to JSON - // jsonData, err := json.Marshal(block.Block.Header) - // if err != nil { - // log.Fatal(err) - // } - - // fmt.Println("length of extrinsics: ", len(block.Block.Extrinsics)) for _, ext := range block.Block.Extrinsics { // these values below are specific indexes only for data submission, differs with each extrinsic diff --git a/relayer/types.go b/relayer/types.go new file mode 100644 index 0000000..3e8b432 --- /dev/null +++ b/relayer/types.go @@ -0,0 +1,10 @@ +package relayer + +type BlockData struct { + Block int64 `json:"block_number"` + Extrinsics []ExtrinsicData `json:"data_transactions"` +} + +type ExtrinsicData struct { + Data string `json:"data"` +} diff --git a/simapp/app/app.go b/simapp/app/app.go index 5f4593d..0291ab3 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -146,7 +146,7 @@ import ( const ( appName = "avail-sdk" NodeDir = ".availsdk" - Bech32Prefix = "avail" + Bech32Prefix = "cosmos" // TODO: Change me AvailAppID = 1 @@ -709,10 +709,22 @@ func NewChainApp( // must be done after relayer is created app.AvailBlobKeeper.SetRelayer(app.Availblobrelayer) + voteExtensionHandler := availblobkeeper.NewVoteExtHandler( + logger, + app.AvailBlobKeeper, + ) + dph := baseapp.NewDefaultProposalHandler(bApp.Mempool(), bApp) - availBlobProposalHandler := availblobkeeper.NewProofOfBlobProposalHandler(app.AvailBlobKeeper, dph.PrepareProposalHandler(), dph.ProcessProposalHandler()) + availBlobProposalHandler := availblobkeeper.NewProofOfBlobProposalHandler( + app.AvailBlobKeeper, + dph.PrepareProposalHandler(), + dph.ProcessProposalHandler(), + *voteExtensionHandler, + ) bApp.SetPrepareProposal(availBlobProposalHandler.PrepareProposal) bApp.SetProcessProposal(availBlobProposalHandler.ProcessProposal) + bApp.SetExtendVoteHandler(voteExtensionHandler.ExtendVoteHandler()) + bApp.SetVerifyVoteExtensionHandler(voteExtensionHandler.VerifyVoteExtensionHandler()) // --- Module Options --- diff --git a/simapp/init-simapp.sh b/simapp/init-simapp.sh index 3a8767c..36ccbd1 100755 --- a/simapp/init-simapp.sh +++ b/simapp/init-simapp.sh @@ -6,6 +6,7 @@ BOB_MNEMONIC="remain then chuckle hockey protect sausage govern curve hobby aisl 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" 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" @@ -29,3 +30,5 @@ $SIMD_BIN genesis add-genesis-account unknown 5000000000stake --keyring-backend $SIMD_BIN genesis gentx alice 1000000stake --chain-id demo $SIMD_BIN genesis collect-gentxs + +sed -i "s/\"vote_extensions_enable_height\": \"0\"/\"vote_extensions_enable_height\": \"1\"/g" $DAEMON_HOME/config/genesis.json diff --git a/types/codec.go b/types/codec.go index 1424766..8050079 100644 --- a/types/codec.go +++ b/types/codec.go @@ -11,13 +11,13 @@ 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, &MsgSetAvailAddress{}, "availblob/MsgSetAvailAddress") + legacy.RegisterAminoMsg(cdc, &MsgUpdateBlobStatusRequest{}, "availblob/MsgUpdateBlobStatusRequest") } // RegisterInterfaces registers the interfaces types with the interface registry. func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgSetAvailAddress{}, + &MsgUpdateBlobStatusRequest{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/types/genesis.pb.go b/types/genesis.pb.go index e94ec58..72721eb 100644 --- a/types/genesis.pb.go +++ b/types/genesis.pb.go @@ -28,8 +28,7 @@ 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 int64 `protobuf:"varint,2,opt,name=proven_height,json=provenHeight,proto3" json:"proven_height,omitempty"` - PendingBlocks []*BlockWithExpiration `protobuf:"bytes,3,rep,name=pending_blocks,json=pendingBlocks,proto3" json:"pending_blocks,omitempty"` + ProvenHeight uint64 `protobuf:"varint,2,opt,name=proven_height,json=provenHeight,proto3" json:"proven_height,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -72,20 +71,13 @@ func (m *GenesisState) GetValidators() []Validator { return nil } -func (m *GenesisState) GetProvenHeight() int64 { +func (m *GenesisState) GetProvenHeight() uint64 { if m != nil { return m.ProvenHeight } return 0 } -func (m *GenesisState) GetPendingBlocks() []*BlockWithExpiration { - if m != nil { - return m.PendingBlocks - } - return nil -} - func init() { proto.RegisterType((*GenesisState)(nil), "sdk.avail.v1beta1.GenesisState") } @@ -93,26 +85,23 @@ func init() { func init() { proto.RegisterFile("sdk/avail/v1beta1/genesis.proto", fileDescriptor_b83d128538762178) } var fileDescriptor_b83d128538762178 = []byte{ - // 298 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x41, 0x4b, 0xc3, 0x30, - 0x1c, 0xc5, 0x1b, 0x27, 0x1e, 0xe2, 0x26, 0x58, 0x3c, 0x8c, 0xa1, 0xd9, 0x54, 0xd0, 0x5d, 0x96, - 0x30, 0xfd, 0x04, 0x16, 0x44, 0x2f, 0x5e, 0x26, 0x28, 0x78, 0x19, 0xe9, 0x12, 0xd2, 0xb0, 0xae, - 0xa9, 0xcd, 0x7f, 0xd5, 0x7d, 0x0b, 0x3f, 0x95, 0xec, 0xb8, 0xa3, 0x27, 0x91, 0xf5, 0x8b, 0xc8, - 0xd2, 0x2a, 0x42, 0xbd, 0x85, 0xff, 0xfb, 0xbd, 0xf7, 0xc2, 0xc3, 0x5d, 0x2b, 0xa6, 0x8c, 0xe7, - 0x5c, 0xc7, 0x2c, 0x1f, 0x86, 0x12, 0xf8, 0x90, 0x29, 0x99, 0x48, 0xab, 0x2d, 0x4d, 0x33, 0x03, - 0xc6, 0xdf, 0xb7, 0x62, 0x4a, 0x1d, 0x40, 0x2b, 0xa0, 0x73, 0xa0, 0x8c, 0x32, 0x4e, 0x65, 0x9b, - 0x57, 0x09, 0x76, 0x8e, 0xeb, 0x49, 0x39, 0x8f, 0xb5, 0xe0, 0x60, 0xb2, 0x0a, 0x39, 0xaa, 0x23, - 0xcf, 0x73, 0x99, 0x2d, 0x4a, 0xf9, 0xe4, 0x1d, 0xe1, 0xe6, 0x4d, 0x59, 0x7e, 0x0f, 0x1c, 0xa4, - 0x1f, 0x60, 0xfc, 0x1b, 0x61, 0xdb, 0xa8, 0xd7, 0xe8, 0xef, 0x5e, 0x1c, 0xd2, 0xda, 0x87, 0xe8, - 0xc3, 0x0f, 0x14, 0x6c, 0x2f, 0x3f, 0xbb, 0xde, 0xe8, 0x8f, 0xcb, 0x3f, 0xc5, 0xad, 0x34, 0x33, - 0xb9, 0x4c, 0xc6, 0x91, 0xd4, 0x2a, 0x82, 0xf6, 0x56, 0x0f, 0xf5, 0x1b, 0xa3, 0x66, 0x79, 0xbc, - 0x75, 0x37, 0xff, 0x0e, 0xef, 0xa5, 0x32, 0x11, 0x3a, 0x51, 0xe3, 0x30, 0x36, 0x93, 0xa9, 0x6d, - 0x37, 0x5c, 0xd9, 0xd9, 0x3f, 0x65, 0xc1, 0x06, 0x78, 0xd4, 0x10, 0x5d, 0xbf, 0xa6, 0x3a, 0xe3, - 0xa0, 0x4d, 0x32, 0x6a, 0x55, 0x6e, 0xa7, 0xd9, 0xe0, 0x6a, 0xb9, 0x26, 0x68, 0xb5, 0x26, 0xe8, - 0x6b, 0x4d, 0xd0, 0x5b, 0x41, 0xbc, 0x55, 0x41, 0xbc, 0x8f, 0x82, 0x78, 0x4f, 0xe7, 0x4a, 0x43, - 0x34, 0x0f, 0xe9, 0xc4, 0xcc, 0x58, 0xae, 0xe1, 0x45, 0x43, 0xb9, 0xc7, 0x40, 0xf0, 0xc1, 0xcc, - 0x88, 0x79, 0x2c, 0x19, 0x2c, 0x52, 0x69, 0xc3, 0x1d, 0x37, 0xc9, 0xe5, 0x77, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x66, 0x8c, 0xe9, 0x95, 0xa0, 0x01, 0x00, 0x00, + // 250 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, 0x95, 0xc8, 0x62, 0x2a, 0x29, 0x2c, 0x4d, 0x2d, 0xaa, 0x84, 0x48, 0x2b, 0x95, 0x73, 0xf1, + 0xb8, 0x43, 0xec, 0x0e, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0x72, 0xe2, 0xe2, 0x82, 0x9b, 0x50, 0x2c, + 0xc1, 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0xa3, 0x87, 0xe1, 0x1e, 0xbd, 0x30, 0x98, 0x22, 0x27, + 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x90, 0x74, 0x09, 0x29, 0x73, 0xf1, 0x16, 0x14, 0xe5, 0x97, + 0xa5, 0xe6, 0xc5, 0x67, 0xa4, 0x66, 0xa6, 0x67, 0x94, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xb0, 0x04, + 0xf1, 0x40, 0x04, 0x3d, 0xc0, 0x62, 0x4e, 0x8e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, + 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, + 0xc7, 0x10, 0xa5, 0x9e, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x5f, 0x96, + 0x59, 0x52, 0x9e, 0x59, 0x02, 0x71, 0xbf, 0x6e, 0x4a, 0xa2, 0x6e, 0x6e, 0x7e, 0x4a, 0x69, 0x4e, + 0xaa, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x0b, 0xc6, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x27, 0x7e, 0xd8, 0xcd, 0x50, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -135,20 +124,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PendingBlocks) > 0 { - for iNdEx := len(m.PendingBlocks) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PendingBlocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } if m.ProvenHeight != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.ProvenHeight)) i-- @@ -197,12 +172,6 @@ func (m *GenesisState) Size() (n int) { if m.ProvenHeight != 0 { n += 1 + sovGenesis(uint64(m.ProvenHeight)) } - if len(m.PendingBlocks) > 0 { - for _, e := range m.PendingBlocks { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -289,45 +258,11 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ProvenHeight |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PendingBlocks", 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 + m.ProvenHeight |= uint64(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.PendingBlocks = append(m.PendingBlocks, &BlockWithExpiration{}) - if err := m.PendingBlocks[len(m.PendingBlocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/types/query.pb.go b/types/query.pb.go index 44f985a..53814ce 100644 --- a/types/query.pb.go +++ b/types/query.pb.go @@ -10,7 +10,6 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" _ "github.com/cosmos/gogoproto/types" - github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -18,14 +17,12 @@ import ( io "io" math "math" math_bits "math/bits" - time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -33,22 +30,22 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryValidatorsRequest is the request type for the Query/Validators RPC method. -type QueryValidatorsRequest struct { +// query request +type QuerySubmittedBlobStatusRequest struct { } -func (m *QueryValidatorsRequest) Reset() { *m = QueryValidatorsRequest{} } -func (m *QueryValidatorsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryValidatorsRequest) ProtoMessage() {} -func (*QueryValidatorsRequest) Descriptor() ([]byte, []int) { +func (m *QuerySubmittedBlobStatusRequest) Reset() { *m = QuerySubmittedBlobStatusRequest{} } +func (m *QuerySubmittedBlobStatusRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySubmittedBlobStatusRequest) ProtoMessage() {} +func (*QuerySubmittedBlobStatusRequest) Descriptor() ([]byte, []int) { return fileDescriptor_30ff5d91ce731c68, []int{0} } -func (m *QueryValidatorsRequest) XXX_Unmarshal(b []byte) error { +func (m *QuerySubmittedBlobStatusRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryValidatorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QuerySubmittedBlobStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryValidatorsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QuerySubmittedBlobStatusRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -58,36 +55,38 @@ func (m *QueryValidatorsRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *QueryValidatorsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryValidatorsRequest.Merge(m, src) +func (m *QuerySubmittedBlobStatusRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySubmittedBlobStatusRequest.Merge(m, src) } -func (m *QueryValidatorsRequest) XXX_Size() int { +func (m *QuerySubmittedBlobStatusRequest) XXX_Size() int { return m.Size() } -func (m *QueryValidatorsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryValidatorsRequest.DiscardUnknown(m) +func (m *QuerySubmittedBlobStatusRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySubmittedBlobStatusRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryValidatorsRequest proto.InternalMessageInfo +var xxx_messageInfo_QuerySubmittedBlobStatusRequest proto.InternalMessageInfo -// QueryValidatorResponse is the response type for the Query/Validators RPC method. -type QueryValidatorsResponse struct { - // validators is the returned validators from the module - Validators []Validator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators"` +// query response +type QuerySubmittedBlobStatusResponse struct { + Range *Range `protobuf:"bytes,1,opt,name=range,proto3" json:"range,omitempty"` + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + ProvenHeight uint64 `protobuf:"varint,3,opt,name=proven_height,json=provenHeight,proto3" json:"proven_height,omitempty"` + LastBlobVotingEndsAt uint64 `protobuf:"varint,4,opt,name=last_blob_voting_ends_at,json=lastBlobVotingEndsAt,proto3" json:"last_blob_voting_ends_at,omitempty"` } -func (m *QueryValidatorsResponse) Reset() { *m = QueryValidatorsResponse{} } -func (m *QueryValidatorsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryValidatorsResponse) ProtoMessage() {} -func (*QueryValidatorsResponse) Descriptor() ([]byte, []int) { +func (m *QuerySubmittedBlobStatusResponse) Reset() { *m = QuerySubmittedBlobStatusResponse{} } +func (m *QuerySubmittedBlobStatusResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySubmittedBlobStatusResponse) ProtoMessage() {} +func (*QuerySubmittedBlobStatusResponse) Descriptor() ([]byte, []int) { return fileDescriptor_30ff5d91ce731c68, []int{1} } -func (m *QueryValidatorsResponse) XXX_Unmarshal(b []byte) error { +func (m *QuerySubmittedBlobStatusResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryValidatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QuerySubmittedBlobStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryValidatorsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QuerySubmittedBlobStatusResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -97,474 +96,81 @@ func (m *QueryValidatorsResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QueryValidatorsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryValidatorsResponse.Merge(m, src) +func (m *QuerySubmittedBlobStatusResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySubmittedBlobStatusResponse.Merge(m, src) } -func (m *QueryValidatorsResponse) XXX_Size() int { +func (m *QuerySubmittedBlobStatusResponse) XXX_Size() int { return m.Size() } -func (m *QueryValidatorsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryValidatorsResponse.DiscardUnknown(m) +func (m *QuerySubmittedBlobStatusResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySubmittedBlobStatusResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryValidatorsResponse proto.InternalMessageInfo +var xxx_messageInfo_QuerySubmittedBlobStatusResponse proto.InternalMessageInfo -func (m *QueryValidatorsResponse) GetValidators() []Validator { +func (m *QuerySubmittedBlobStatusResponse) GetRange() *Range { if m != nil { - return m.Validators + return m.Range } return nil } -// QueryAvailAddressRequest is the request type for the Query/AvailAddress RPC method. -type QueryAvailAddressRequest struct { - ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` -} - -func (m *QueryAvailAddressRequest) Reset() { *m = QueryAvailAddressRequest{} } -func (m *QueryAvailAddressRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAvailAddressRequest) ProtoMessage() {} -func (*QueryAvailAddressRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{2} -} -func (m *QueryAvailAddressRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAvailAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAvailAddressRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryAvailAddressRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAvailAddressRequest.Merge(m, src) -} -func (m *QueryAvailAddressRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAvailAddressRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAvailAddressRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAvailAddressRequest proto.InternalMessageInfo - -func (m *QueryAvailAddressRequest) GetValidatorAddress() string { - if m != nil { - return m.ValidatorAddress - } - return "" -} - -// QueryAvailAddressResponse is the response type for the Query/AvailAddress RPC method. -type QueryAvailAddressResponse struct { - AvailAddress string `protobuf:"bytes,1,opt,name=avail_address,json=availAddress,proto3" json:"avail_address,omitempty"` -} - -func (m *QueryAvailAddressResponse) Reset() { *m = QueryAvailAddressResponse{} } -func (m *QueryAvailAddressResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAvailAddressResponse) ProtoMessage() {} -func (*QueryAvailAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{3} -} -func (m *QueryAvailAddressResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAvailAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAvailAddressResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryAvailAddressResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAvailAddressResponse.Merge(m, src) -} -func (m *QueryAvailAddressResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAvailAddressResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAvailAddressResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAvailAddressResponse proto.InternalMessageInfo - -func (m *QueryAvailAddressResponse) GetAvailAddress() string { +func (m *QuerySubmittedBlobStatusResponse) GetStatus() string { if m != nil { - return m.AvailAddress + return m.Status } return "" } -type QueryProvenHeightRequest struct { -} - -func (m *QueryProvenHeightRequest) Reset() { *m = QueryProvenHeightRequest{} } -func (m *QueryProvenHeightRequest) String() string { return proto.CompactTextString(m) } -func (*QueryProvenHeightRequest) ProtoMessage() {} -func (*QueryProvenHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{4} -} -func (m *QueryProvenHeightRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryProvenHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryProvenHeightRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryProvenHeightRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryProvenHeightRequest.Merge(m, src) -} -func (m *QueryProvenHeightRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryProvenHeightRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryProvenHeightRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryProvenHeightRequest proto.InternalMessageInfo - -type QueryProvenHeightResponse struct { - ProvenHeight int64 `protobuf:"varint,1,opt,name=proven_height,json=provenHeight,proto3" json:"proven_height,omitempty"` -} - -func (m *QueryProvenHeightResponse) Reset() { *m = QueryProvenHeightResponse{} } -func (m *QueryProvenHeightResponse) String() string { return proto.CompactTextString(m) } -func (*QueryProvenHeightResponse) ProtoMessage() {} -func (*QueryProvenHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{5} -} -func (m *QueryProvenHeightResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryProvenHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryProvenHeightResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryProvenHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryProvenHeightResponse.Merge(m, src) -} -func (m *QueryProvenHeightResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryProvenHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryProvenHeightResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryProvenHeightResponse proto.InternalMessageInfo - -func (m *QueryProvenHeightResponse) GetProvenHeight() int64 { +func (m *QuerySubmittedBlobStatusResponse) GetProvenHeight() uint64 { if m != nil { return m.ProvenHeight } return 0 } -type BlockWithExpiration struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Expiration time.Time `protobuf:"bytes,2,opt,name=expiration,proto3,stdtime" json:"expiration"` -} - -func (m *BlockWithExpiration) Reset() { *m = BlockWithExpiration{} } -func (m *BlockWithExpiration) String() string { return proto.CompactTextString(m) } -func (*BlockWithExpiration) ProtoMessage() {} -func (*BlockWithExpiration) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{6} -} -func (m *BlockWithExpiration) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BlockWithExpiration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockWithExpiration.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *BlockWithExpiration) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockWithExpiration.Merge(m, src) -} -func (m *BlockWithExpiration) XXX_Size() int { - return m.Size() -} -func (m *BlockWithExpiration) XXX_DiscardUnknown() { - xxx_messageInfo_BlockWithExpiration.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockWithExpiration proto.InternalMessageInfo - -func (m *BlockWithExpiration) GetHeight() int64 { +func (m *QuerySubmittedBlobStatusResponse) GetLastBlobVotingEndsAt() uint64 { if m != nil { - return m.Height + return m.LastBlobVotingEndsAt } return 0 } -func (m *BlockWithExpiration) GetExpiration() time.Time { - if m != nil { - return m.Expiration - } - return time.Time{} -} - -type QueryPendingBlocksRequest struct { -} - -func (m *QueryPendingBlocksRequest) Reset() { *m = QueryPendingBlocksRequest{} } -func (m *QueryPendingBlocksRequest) String() string { return proto.CompactTextString(m) } -func (*QueryPendingBlocksRequest) ProtoMessage() {} -func (*QueryPendingBlocksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{7} -} -func (m *QueryPendingBlocksRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryPendingBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryPendingBlocksRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryPendingBlocksRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPendingBlocksRequest.Merge(m, src) -} -func (m *QueryPendingBlocksRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryPendingBlocksRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPendingBlocksRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryPendingBlocksRequest proto.InternalMessageInfo - -type QueryPendingBlocksResponse struct { - PendingBlocks []*BlockWithExpiration `protobuf:"bytes,1,rep,name=pending_blocks,json=pendingBlocks,proto3" json:"pending_blocks,omitempty"` -} - -func (m *QueryPendingBlocksResponse) Reset() { *m = QueryPendingBlocksResponse{} } -func (m *QueryPendingBlocksResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPendingBlocksResponse) ProtoMessage() {} -func (*QueryPendingBlocksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{8} -} -func (m *QueryPendingBlocksResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryPendingBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryPendingBlocksResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryPendingBlocksResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPendingBlocksResponse.Merge(m, src) -} -func (m *QueryPendingBlocksResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryPendingBlocksResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPendingBlocksResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryPendingBlocksResponse proto.InternalMessageInfo - -func (m *QueryPendingBlocksResponse) GetPendingBlocks() []*BlockWithExpiration { - if m != nil { - return m.PendingBlocks - } - return nil -} - -type QueryExpiredBlocksRequest struct { -} - -func (m *QueryExpiredBlocksRequest) Reset() { *m = QueryExpiredBlocksRequest{} } -func (m *QueryExpiredBlocksRequest) String() string { return proto.CompactTextString(m) } -func (*QueryExpiredBlocksRequest) ProtoMessage() {} -func (*QueryExpiredBlocksRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{9} -} -func (m *QueryExpiredBlocksRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryExpiredBlocksRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryExpiredBlocksRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryExpiredBlocksRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryExpiredBlocksRequest.Merge(m, src) -} -func (m *QueryExpiredBlocksRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryExpiredBlocksRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryExpiredBlocksRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryExpiredBlocksRequest proto.InternalMessageInfo - -type QueryExpiredBlocksResponse struct { - CurrentTime time.Time `protobuf:"bytes,1,opt,name=current_time,json=currentTime,proto3,stdtime" json:"current_time"` - ExpiredBlocks []*BlockWithExpiration `protobuf:"bytes,2,rep,name=expired_blocks,json=expiredBlocks,proto3" json:"expired_blocks,omitempty"` -} - -func (m *QueryExpiredBlocksResponse) Reset() { *m = QueryExpiredBlocksResponse{} } -func (m *QueryExpiredBlocksResponse) String() string { return proto.CompactTextString(m) } -func (*QueryExpiredBlocksResponse) ProtoMessage() {} -func (*QueryExpiredBlocksResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_30ff5d91ce731c68, []int{10} -} -func (m *QueryExpiredBlocksResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryExpiredBlocksResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryExpiredBlocksResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryExpiredBlocksResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryExpiredBlocksResponse.Merge(m, src) -} -func (m *QueryExpiredBlocksResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryExpiredBlocksResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryExpiredBlocksResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryExpiredBlocksResponse proto.InternalMessageInfo - -func (m *QueryExpiredBlocksResponse) GetCurrentTime() time.Time { - if m != nil { - return m.CurrentTime - } - return time.Time{} -} - -func (m *QueryExpiredBlocksResponse) GetExpiredBlocks() []*BlockWithExpiration { - if m != nil { - return m.ExpiredBlocks - } - return nil -} - func init() { - proto.RegisterType((*QueryValidatorsRequest)(nil), "sdk.avail.v1beta1.QueryValidatorsRequest") - proto.RegisterType((*QueryValidatorsResponse)(nil), "sdk.avail.v1beta1.QueryValidatorsResponse") - proto.RegisterType((*QueryAvailAddressRequest)(nil), "sdk.avail.v1beta1.QueryAvailAddressRequest") - proto.RegisterType((*QueryAvailAddressResponse)(nil), "sdk.avail.v1beta1.QueryAvailAddressResponse") - proto.RegisterType((*QueryProvenHeightRequest)(nil), "sdk.avail.v1beta1.QueryProvenHeightRequest") - proto.RegisterType((*QueryProvenHeightResponse)(nil), "sdk.avail.v1beta1.QueryProvenHeightResponse") - proto.RegisterType((*BlockWithExpiration)(nil), "sdk.avail.v1beta1.BlockWithExpiration") - proto.RegisterType((*QueryPendingBlocksRequest)(nil), "sdk.avail.v1beta1.QueryPendingBlocksRequest") - proto.RegisterType((*QueryPendingBlocksResponse)(nil), "sdk.avail.v1beta1.QueryPendingBlocksResponse") - proto.RegisterType((*QueryExpiredBlocksRequest)(nil), "sdk.avail.v1beta1.QueryExpiredBlocksRequest") - proto.RegisterType((*QueryExpiredBlocksResponse)(nil), "sdk.avail.v1beta1.QueryExpiredBlocksResponse") + proto.RegisterType((*QuerySubmittedBlobStatusRequest)(nil), "sdk.avail.v1beta1.QuerySubmittedBlobStatusRequest") + proto.RegisterType((*QuerySubmittedBlobStatusResponse)(nil), "sdk.avail.v1beta1.QuerySubmittedBlobStatusResponse") } func init() { proto.RegisterFile("sdk/avail/v1beta1/query.proto", fileDescriptor_30ff5d91ce731c68) } var fileDescriptor_30ff5d91ce731c68 = []byte{ - // 653 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x41, 0x6e, 0xd3, 0x40, - 0x14, 0x86, 0x33, 0x2d, 0xad, 0x60, 0x9a, 0x22, 0x3a, 0xa0, 0x12, 0x4c, 0x9b, 0xa4, 0xae, 0x80, - 0x94, 0x52, 0x5b, 0x2d, 0x17, 0xa0, 0x11, 0xa8, 0x6c, 0x90, 0x20, 0x42, 0x20, 0x21, 0xa1, 0x68, - 0x5c, 0x0f, 0xce, 0x28, 0x89, 0xc7, 0xf5, 0x8c, 0x03, 0xdd, 0xb2, 0x64, 0x55, 0xa9, 0x0b, 0x2e, - 0xc2, 0x21, 0xba, 0xac, 0xc4, 0x86, 0x15, 0xa0, 0x86, 0x23, 0x70, 0x00, 0xe4, 0xf1, 0xd8, 0xb5, - 0x9b, 0x71, 0x15, 0x76, 0x4d, 0xff, 0xff, 0xbd, 0xf7, 0xbd, 0x79, 0xfe, 0xe1, 0x2a, 0x77, 0xfb, - 0x36, 0x1e, 0x61, 0x3a, 0xb0, 0x47, 0xdb, 0x0e, 0x11, 0x78, 0xdb, 0x3e, 0x88, 0x48, 0x78, 0x68, - 0x05, 0x21, 0x13, 0x0c, 0x2d, 0x71, 0xb7, 0x6f, 0x49, 0xd9, 0x52, 0xb2, 0x71, 0xcb, 0x63, 0x1e, - 0x93, 0xaa, 0x1d, 0xff, 0x95, 0x18, 0x8d, 0x15, 0x8f, 0x31, 0x6f, 0x40, 0x6c, 0x1c, 0x50, 0x1b, - 0xfb, 0x3e, 0x13, 0x58, 0x50, 0xe6, 0x73, 0xa5, 0xae, 0x4d, 0x4e, 0x19, 0xe1, 0x01, 0x75, 0xb1, - 0x60, 0xa1, 0xb2, 0x34, 0x54, 0x03, 0xf9, 0xcb, 0x89, 0x3e, 0xd8, 0x82, 0x0e, 0x09, 0x17, 0x78, - 0x18, 0x24, 0x06, 0xb3, 0x06, 0x97, 0x5f, 0xc5, 0x64, 0x6f, 0xd2, 0x42, 0xde, 0x21, 0x07, 0x11, - 0xe1, 0xc2, 0x7c, 0x0f, 0x6f, 0x4f, 0x28, 0x3c, 0x60, 0x3e, 0x27, 0xa8, 0x0d, 0x61, 0x36, 0x88, - 0xd7, 0x40, 0x73, 0xb6, 0xb5, 0xb0, 0xb3, 0x62, 0x4d, 0x2c, 0x65, 0x65, 0xa5, 0xed, 0x2b, 0x27, - 0x3f, 0x1b, 0x95, 0x4e, 0xae, 0xca, 0xdc, 0x83, 0x35, 0xd9, 0x7e, 0x37, 0xae, 0xd8, 0x75, 0xdd, - 0x90, 0xf0, 0x74, 0x34, 0xda, 0x84, 0x4b, 0x99, 0xb3, 0x8b, 0x13, 0xad, 0x06, 0x9a, 0xa0, 0x75, - 0xad, 0x73, 0x23, 0x13, 0x54, 0x8d, 0xf9, 0x04, 0xde, 0xd1, 0x34, 0x52, 0xa4, 0xeb, 0x70, 0x51, - 0x22, 0x5d, 0xe8, 0x52, 0xc5, 0x39, 0xb3, 0x69, 0x28, 0x94, 0x97, 0x21, 0x1b, 0x11, 0xff, 0x39, - 0xa1, 0x5e, 0x4f, 0xa4, 0xaf, 0x90, 0x76, 0x2f, 0x6a, 0xe7, 0xdd, 0x03, 0xf9, 0xff, 0x6e, 0x4f, - 0x0a, 0xb2, 0xfb, 0x6c, 0xa7, 0x1a, 0xe4, 0xcc, 0x26, 0x87, 0x37, 0xdb, 0x03, 0xb6, 0xdf, 0x7f, - 0x4b, 0x45, 0xef, 0xd9, 0xa7, 0x80, 0x86, 0xf2, 0x86, 0x68, 0x19, 0xce, 0x17, 0x8a, 0xd4, 0x2f, - 0xf4, 0x14, 0x42, 0x92, 0xb9, 0x6a, 0x33, 0x4d, 0xd0, 0x5a, 0xd8, 0x31, 0xac, 0xe4, 0x8c, 0x56, - 0x7a, 0x46, 0xeb, 0x75, 0x7a, 0xc6, 0xf6, 0xd5, 0xf8, 0x65, 0x8f, 0x7e, 0x35, 0x40, 0x27, 0x57, - 0x67, 0xde, 0x4d, 0xb1, 0x89, 0xef, 0x52, 0xdf, 0x93, 0x00, 0xd9, 0x65, 0xfb, 0xd0, 0xd0, 0x89, - 0x6a, 0xa9, 0x17, 0xf0, 0x7a, 0x90, 0x08, 0x5d, 0x47, 0x2a, 0xea, 0xc0, 0xf7, 0x35, 0x07, 0xd6, - 0x2c, 0xd6, 0x59, 0x0c, 0xf2, 0x6d, 0x33, 0x12, 0xe9, 0x20, 0x6e, 0x91, 0xe4, 0x1b, 0x50, 0x28, - 0x17, 0x54, 0x85, 0xb2, 0x07, 0xab, 0xfb, 0x51, 0x18, 0x12, 0x5f, 0x74, 0xe3, 0xef, 0x56, 0xbe, - 0xd4, 0xb4, 0xaf, 0xb1, 0xa0, 0x2a, 0x63, 0x2d, 0xde, 0x89, 0x24, 0x13, 0xd2, 0x9d, 0x66, 0xfe, - 0x6f, 0x27, 0x92, 0xe7, 0xdb, 0xf9, 0x3b, 0x07, 0xe7, 0x24, 0x36, 0xfa, 0x02, 0x20, 0x3c, 0x0f, - 0x08, 0xda, 0xd0, 0xf4, 0xd3, 0xc7, 0xcb, 0x78, 0x38, 0x8d, 0x35, 0x79, 0x07, 0xf3, 0xde, 0xe7, - 0xef, 0x7f, 0x8e, 0x67, 0x1a, 0x68, 0x35, 0x49, 0xbb, 0x33, 0x60, 0xce, 0x64, 0xe2, 0x39, 0x3a, - 0x06, 0xb0, 0x9a, 0x4f, 0x01, 0xda, 0x2c, 0x9b, 0xa1, 0x09, 0x9d, 0xf1, 0x68, 0x3a, 0xb3, 0x42, - 0x6a, 0x49, 0x24, 0x13, 0x35, 0x35, 0x48, 0x85, 0xc4, 0x49, 0xaa, 0x7c, 0x7a, 0xca, 0xa9, 0x34, - 0xf9, 0x2b, 0xa7, 0xd2, 0x05, 0xf2, 0x52, 0xaa, 0x42, 0x52, 0xd1, 0x57, 0x00, 0x17, 0x0b, 0xdf, - 0x3f, 0x2a, 0x9f, 0xa4, 0xc9, 0x90, 0xb1, 0x35, 0xa5, 0x5b, 0x81, 0x6d, 0x48, 0xb0, 0x75, 0xb4, - 0xa6, 0x03, 0x2b, 0xa4, 0x4d, 0x92, 0x15, 0xe2, 0x50, 0x4e, 0xa6, 0xcb, 0x54, 0x39, 0x99, 0x36, - 0x63, 0x97, 0x92, 0x15, 0x33, 0xd3, 0xde, 0x3d, 0x39, 0xab, 0x83, 0xd3, 0xb3, 0x3a, 0xf8, 0x7d, - 0x56, 0x07, 0x47, 0xe3, 0x7a, 0xe5, 0x74, 0x5c, 0xaf, 0xfc, 0x18, 0xd7, 0x2b, 0xef, 0x1e, 0x78, - 0x54, 0xf4, 0x22, 0xc7, 0xda, 0x67, 0x43, 0x7b, 0x44, 0xc5, 0x47, 0x2a, 0x92, 0x6e, 0x5b, 0x2e, - 0xde, 0x1a, 0x32, 0x37, 0x1a, 0x10, 0x5b, 0x1c, 0x06, 0x84, 0x3b, 0xf3, 0x32, 0xb3, 0x8f, 0xff, - 0x05, 0x00, 0x00, 0xff, 0xff, 0x00, 0x17, 0x5c, 0x23, 0x21, 0x07, 0x00, 0x00, + // 413 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0xc7, 0x77, 0x6a, 0x5b, 0x70, 0xd4, 0x83, 0x63, 0x91, 0x10, 0x34, 0x4d, 0xb7, 0x88, 0x0b, + 0xd2, 0x0c, 0xdd, 0x82, 0xf7, 0x16, 0x04, 0xaf, 0xa6, 0xe0, 0xc1, 0x4b, 0x98, 0x71, 0xc6, 0xd9, + 0xa1, 0xc9, 0xbc, 0x34, 0xf3, 0x12, 0xed, 0xd5, 0x4f, 0x20, 0xf8, 0x31, 0x3c, 0xfb, 0x19, 0xf4, + 0x58, 0xf0, 0xe2, 0x51, 0x76, 0xfd, 0x20, 0x92, 0x49, 0xd0, 0xc3, 0xae, 0x88, 0xb7, 0xcc, 0xfb, + 0xfd, 0xdf, 0x3f, 0xef, 0xff, 0x1e, 0x7d, 0xe8, 0xd5, 0x05, 0x17, 0x9d, 0xb0, 0x25, 0xef, 0x8e, + 0xa5, 0x46, 0x71, 0xcc, 0x2f, 0x5b, 0xdd, 0x5c, 0x65, 0x75, 0x03, 0x08, 0xec, 0xae, 0x57, 0x17, + 0x59, 0xc0, 0xd9, 0x88, 0xe3, 0x3d, 0x03, 0x06, 0x02, 0xe5, 0xfd, 0xd7, 0x20, 0x8c, 0x1f, 0x18, + 0x00, 0x53, 0x6a, 0x2e, 0x6a, 0xcb, 0x85, 0x73, 0x80, 0x02, 0x2d, 0x38, 0x3f, 0xd2, 0x83, 0xf5, + 0xbf, 0x74, 0xa2, 0xb4, 0x4a, 0x20, 0x34, 0xa3, 0x64, 0x7f, 0x34, 0x08, 0x2f, 0xd9, 0xbe, 0xe1, + 0x68, 0x2b, 0xed, 0x51, 0x54, 0xf5, 0x28, 0x88, 0xd7, 0x3d, 0xf0, 0xdd, 0xc0, 0xa6, 0x07, 0x74, + 0xff, 0x45, 0x3f, 0xf5, 0x79, 0x2b, 0x2b, 0x8b, 0xa8, 0xd5, 0x59, 0x09, 0xf2, 0x1c, 0x05, 0xb6, + 0x3e, 0xd7, 0x97, 0xad, 0xf6, 0x38, 0xfd, 0x42, 0x68, 0xfa, 0x77, 0x8d, 0xaf, 0xc1, 0x79, 0xcd, + 0x32, 0xba, 0xd3, 0x08, 0x67, 0x74, 0x44, 0x52, 0x32, 0xbb, 0x35, 0x8f, 0xb2, 0xb5, 0xf8, 0x59, + 0xde, 0xf3, 0x7c, 0x90, 0xb1, 0xfb, 0x74, 0xd7, 0x07, 0x87, 0x68, 0x2b, 0x25, 0xb3, 0x9b, 0xf9, + 0xf8, 0x62, 0x87, 0xf4, 0x4e, 0xdd, 0x40, 0xa7, 0x5d, 0xb1, 0xd0, 0xd6, 0x2c, 0x30, 0xba, 0x91, + 0x92, 0xd9, 0x76, 0x7e, 0x7b, 0x28, 0x3e, 0x0f, 0x35, 0xf6, 0x94, 0x46, 0xa5, 0xf0, 0x58, 0xc8, + 0x12, 0x64, 0xd1, 0x01, 0x5a, 0x67, 0x0a, 0xed, 0x94, 0x2f, 0x04, 0x46, 0xdb, 0x41, 0xbf, 0xd7, + 0xf3, 0x7e, 0xcc, 0x97, 0x81, 0x3e, 0x73, 0xca, 0x9f, 0xe2, 0xfc, 0x33, 0xa1, 0x3b, 0x21, 0x09, + 0xfb, 0x44, 0xe8, 0xbd, 0x0d, 0x71, 0xd8, 0x7c, 0xc3, 0xdc, 0xff, 0xd8, 0x4f, 0x7c, 0xf2, 0x5f, + 0x3d, 0xc3, 0xbe, 0xa6, 0x4f, 0xde, 0x7f, 0xfb, 0xf9, 0x71, 0xeb, 0x11, 0x3b, 0x1c, 0x0e, 0xd3, + 0x27, 0xf9, 0x7d, 0x1c, 0x1f, 0xfa, 0xfe, 0x34, 0x9d, 0x9d, 0x7e, 0x5d, 0x26, 0xe4, 0x7a, 0x99, + 0x90, 0x1f, 0xcb, 0x84, 0x7c, 0x58, 0x25, 0x93, 0xeb, 0x55, 0x32, 0xf9, 0xbe, 0x4a, 0x26, 0xaf, + 0x1e, 0x1b, 0x8b, 0x8b, 0x56, 0x66, 0xaf, 0xa1, 0xe2, 0x9d, 0xc5, 0xb7, 0x16, 0x07, 0xbf, 0x23, + 0x25, 0x8e, 0x2a, 0x50, 0x6d, 0xa9, 0x39, 0x5e, 0xd5, 0xda, 0xcb, 0xdd, 0x70, 0xee, 0x93, 0x5f, + 0x01, 0x00, 0x00, 0xff, 0xff, 0xc3, 0x61, 0x4c, 0xe1, 0xb6, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -579,12 +185,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Validators returns registered validators of the module. - Validators(ctx context.Context, in *QueryValidatorsRequest, opts ...grpc.CallOption) (*QueryValidatorsResponse, error) - AvailAddress(ctx context.Context, in *QueryAvailAddressRequest, opts ...grpc.CallOption) (*QueryAvailAddressResponse, error) - ProvenHeight(ctx context.Context, in *QueryProvenHeightRequest, opts ...grpc.CallOption) (*QueryProvenHeightResponse, error) - PendingBlocks(ctx context.Context, in *QueryPendingBlocksRequest, opts ...grpc.CallOption) (*QueryPendingBlocksResponse, error) - ExpiredBlocks(ctx context.Context, in *QueryExpiredBlocksRequest, opts ...grpc.CallOption) (*QueryExpiredBlocksResponse, error) + // submit Blob Status + SubmittedBlobStatus(ctx context.Context, in *QuerySubmittedBlobStatusRequest, opts ...grpc.CallOption) (*QuerySubmittedBlobStatusResponse, error) } type queryClient struct { @@ -595,45 +197,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Validators(ctx context.Context, in *QueryValidatorsRequest, opts ...grpc.CallOption) (*QueryValidatorsResponse, error) { - out := new(QueryValidatorsResponse) - err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Query/Validators", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) AvailAddress(ctx context.Context, in *QueryAvailAddressRequest, opts ...grpc.CallOption) (*QueryAvailAddressResponse, error) { - out := new(QueryAvailAddressResponse) - err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Query/AvailAddress", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ProvenHeight(ctx context.Context, in *QueryProvenHeightRequest, opts ...grpc.CallOption) (*QueryProvenHeightResponse, error) { - out := new(QueryProvenHeightResponse) - err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Query/ProvenHeight", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) PendingBlocks(ctx context.Context, in *QueryPendingBlocksRequest, opts ...grpc.CallOption) (*QueryPendingBlocksResponse, error) { - out := new(QueryPendingBlocksResponse) - err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Query/PendingBlocks", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) ExpiredBlocks(ctx context.Context, in *QueryExpiredBlocksRequest, opts ...grpc.CallOption) (*QueryExpiredBlocksResponse, error) { - out := new(QueryExpiredBlocksResponse) - err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Query/ExpiredBlocks", in, out, opts...) +func (c *queryClient) SubmittedBlobStatus(ctx context.Context, in *QuerySubmittedBlobStatusRequest, opts ...grpc.CallOption) (*QuerySubmittedBlobStatusResponse, error) { + out := new(QuerySubmittedBlobStatusResponse) + err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Query/SubmittedBlobStatus", in, out, opts...) if err != nil { return nil, err } @@ -642,1164 +208,178 @@ func (c *queryClient) ExpiredBlocks(ctx context.Context, in *QueryExpiredBlocksR // QueryServer is the server API for Query service. type QueryServer interface { - // Validators returns registered validators of the module. - Validators(context.Context, *QueryValidatorsRequest) (*QueryValidatorsResponse, error) - AvailAddress(context.Context, *QueryAvailAddressRequest) (*QueryAvailAddressResponse, error) - ProvenHeight(context.Context, *QueryProvenHeightRequest) (*QueryProvenHeightResponse, error) - PendingBlocks(context.Context, *QueryPendingBlocksRequest) (*QueryPendingBlocksResponse, error) - ExpiredBlocks(context.Context, *QueryExpiredBlocksRequest) (*QueryExpiredBlocksResponse, error) + // submit Blob Status + SubmittedBlobStatus(context.Context, *QuerySubmittedBlobStatusRequest) (*QuerySubmittedBlobStatusResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Validators(ctx context.Context, req *QueryValidatorsRequest) (*QueryValidatorsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Validators not implemented") -} -func (*UnimplementedQueryServer) AvailAddress(ctx context.Context, req *QueryAvailAddressRequest) (*QueryAvailAddressResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AvailAddress not implemented") -} -func (*UnimplementedQueryServer) ProvenHeight(ctx context.Context, req *QueryProvenHeightRequest) (*QueryProvenHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProvenHeight not implemented") -} -func (*UnimplementedQueryServer) PendingBlocks(ctx context.Context, req *QueryPendingBlocksRequest) (*QueryPendingBlocksResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PendingBlocks not implemented") -} -func (*UnimplementedQueryServer) ExpiredBlocks(ctx context.Context, req *QueryExpiredBlocksRequest) (*QueryExpiredBlocksResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ExpiredBlocks not implemented") +func (*UnimplementedQueryServer) SubmittedBlobStatus(ctx context.Context, req *QuerySubmittedBlobStatusRequest) (*QuerySubmittedBlobStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmittedBlobStatus not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Validators_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryValidatorsRequest) +func _Query_SubmittedBlobStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySubmittedBlobStatusRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Validators(ctx, in) + return srv.(QueryServer).SubmittedBlobStatus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sdk.avail.v1beta1.Query/Validators", + FullMethod: "/sdk.avail.v1beta1.Query/SubmittedBlobStatus", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Validators(ctx, req.(*QueryValidatorsRequest)) + return srv.(QueryServer).SubmittedBlobStatus(ctx, req.(*QuerySubmittedBlobStatusRequest)) } - return interceptor(ctx, in, info, handler) -} - -func _Query_AvailAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAvailAddressRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).AvailAddress(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/sdk.avail.v1beta1.Query/AvailAddress", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AvailAddress(ctx, req.(*QueryAvailAddressRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ProvenHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryProvenHeightRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ProvenHeight(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/sdk.avail.v1beta1.Query/ProvenHeight", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ProvenHeight(ctx, req.(*QueryProvenHeightRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_PendingBlocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPendingBlocksRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).PendingBlocks(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/sdk.avail.v1beta1.Query/PendingBlocks", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).PendingBlocks(ctx, req.(*QueryPendingBlocksRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_ExpiredBlocks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryExpiredBlocksRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ExpiredBlocks(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/sdk.avail.v1beta1.Query/ExpiredBlocks", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ExpiredBlocks(ctx, req.(*QueryExpiredBlocksRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "sdk.avail.v1beta1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Validators", - Handler: _Query_Validators_Handler, - }, - { - MethodName: "AvailAddress", - Handler: _Query_AvailAddress_Handler, - }, - { - MethodName: "ProvenHeight", - Handler: _Query_ProvenHeight_Handler, - }, - { - MethodName: "PendingBlocks", - Handler: _Query_PendingBlocks_Handler, - }, - { - MethodName: "ExpiredBlocks", - Handler: _Query_ExpiredBlocks_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "sdk/avail/v1beta1/query.proto", -} - -func (m *QueryValidatorsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryValidatorsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryValidatorsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryValidatorsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryValidatorsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryValidatorsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - 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 = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryAvailAddressRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryAvailAddressRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAvailAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryAvailAddressResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryAvailAddressResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAvailAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.AvailAddress) > 0 { - i -= len(m.AvailAddress) - copy(dAtA[i:], m.AvailAddress) - i = encodeVarintQuery(dAtA, i, uint64(len(m.AvailAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryProvenHeightRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryProvenHeightRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryProvenHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryProvenHeightResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryProvenHeightResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryProvenHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ProvenHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ProvenHeight)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *BlockWithExpiration) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BlockWithExpiration) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockWithExpiration) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n1, err1 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Expiration, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Expiration):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintQuery(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x12 - if m.Height != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryPendingBlocksRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryPendingBlocksRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryPendingBlocksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryPendingBlocksResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryPendingBlocksResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryPendingBlocksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PendingBlocks) > 0 { - for iNdEx := len(m.PendingBlocks) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PendingBlocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryExpiredBlocksRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryExpiredBlocksRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryExpiredBlocksRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryExpiredBlocksResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryExpiredBlocksResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryExpiredBlocksResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ExpiredBlocks) > 0 { - for iNdEx := len(m.ExpiredBlocks) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ExpiredBlocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.CurrentTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentTime):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintQuery(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QueryValidatorsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryValidatorsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Validators) > 0 { - for _, e := range m.Validators { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryAvailAddressRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAvailAddressResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.AvailAddress) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryProvenHeightRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryProvenHeightResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ProvenHeight != 0 { - n += 1 + sovQuery(uint64(m.ProvenHeight)) - } - return n -} - -func (m *BlockWithExpiration) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Expiration) - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryPendingBlocksRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryPendingBlocksResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.PendingBlocks) > 0 { - for _, e := range m.PendingBlocks { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryExpiredBlocksRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryExpiredBlocksResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.CurrentTime) - n += 1 + l + sovQuery(uint64(l)) - if len(m.ExpiredBlocks) > 0 { - for _, e := range m.ExpiredBlocks { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryValidatorsRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryValidatorsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryValidatorsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryValidatorsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryValidatorsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryValidatorsResponse: 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 ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - 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 - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryAvailAddressRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryAvailAddressRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAvailAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryAvailAddressResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryAvailAddressResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAvailAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AvailAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AvailAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryProvenHeightRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryProvenHeightRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProvenHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryProvenHeightResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryProvenHeightResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProvenHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ProvenHeight |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BlockWithExpiration) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BlockWithExpiration: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockWithExpiration: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.Expiration, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "sdk.avail.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SubmittedBlobStatus", + Handler: _Query_SubmittedBlobStatus_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "sdk/avail/v1beta1/query.proto", +} + +func (m *QuerySubmittedBlobStatusRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySubmittedBlobStatusRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySubmittedBlobStatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QuerySubmittedBlobStatusResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySubmittedBlobStatusResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySubmittedBlobStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LastBlobVotingEndsAt != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.LastBlobVotingEndsAt)) + i-- + dAtA[i] = 0x20 + } + if m.ProvenHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ProvenHeight)) + i-- + dAtA[i] = 0x18 + } + if len(m.Status) > 0 { + i -= len(m.Status) + copy(dAtA[i:], m.Status) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Status))) + i-- + dAtA[i] = 0x12 + } + if m.Range != nil { + { + size, err := m.Range.MarshalToSizedBuffer(dAtA[:i]) if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery + return 0, err } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa } + return len(dAtA) - i, nil +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return nil + dAtA[offset] = uint8(v) + return base +} +func (m *QuerySubmittedBlobStatusRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QuerySubmittedBlobStatusResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Range != nil { + l = m.Range.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Status) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.ProvenHeight != 0 { + n += 1 + sovQuery(uint64(m.ProvenHeight)) + } + if m.LastBlobVotingEndsAt != 0 { + n += 1 + sovQuery(uint64(m.LastBlobVotingEndsAt)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 } -func (m *QueryPendingBlocksRequest) Unmarshal(dAtA []byte) error { +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QuerySubmittedBlobStatusRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1822,10 +402,10 @@ func (m *QueryPendingBlocksRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPendingBlocksRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySubmittedBlobStatusRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPendingBlocksRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySubmittedBlobStatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1849,7 +429,7 @@ func (m *QueryPendingBlocksRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPendingBlocksResponse) Unmarshal(dAtA []byte) error { +func (m *QuerySubmittedBlobStatusResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1872,15 +452,15 @@ func (m *QueryPendingBlocksResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPendingBlocksResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QuerySubmittedBlobStatusResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPendingBlocksResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QuerySubmittedBlobStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PendingBlocks", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Range", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1907,116 +487,18 @@ func (m *QueryPendingBlocksResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PendingBlocks = append(m.PendingBlocks, &BlockWithExpiration{}) - if err := m.PendingBlocks[len(m.PendingBlocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryExpiredBlocksRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if m.Range == nil { + m.Range = &Range{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryExpiredBlocksRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryExpiredBlocksRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { + if err := m.Range.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryExpiredBlocksResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryExpiredBlocksResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryExpiredBlocksResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentTime", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2026,30 +508,29 @@ func (m *QueryExpiredBlocksResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.CurrentTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Status = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExpiredBlocks", wireType) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ProvenHeight", wireType) } - var msglen int + m.ProvenHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -2059,26 +540,30 @@ func (m *QueryExpiredBlocksResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.ProvenHeight |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastBlobVotingEndsAt", wireType) } - m.ExpiredBlocks = append(m.ExpiredBlocks, &BlockWithExpiration{}) - if err := m.ExpiredBlocks[len(m.ExpiredBlocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.LastBlobVotingEndsAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastBlobVotingEndsAt |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/types/query.pb.gw.go b/types/query.pb.gw.go index a10c610..5c782c5 100644 --- a/types/query.pb.gw.go +++ b/types/query.pb.gw.go @@ -33,110 +33,20 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Validators_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryValidatorsRequest +func request_Query_SubmittedBlobStatus_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySubmittedBlobStatusRequest var metadata runtime.ServerMetadata - msg, err := client.Validators(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.SubmittedBlobStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Validators_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryValidatorsRequest +func local_request_Query_SubmittedBlobStatus_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySubmittedBlobStatusRequest var metadata runtime.ServerMetadata - msg, err := server.Validators(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_AvailAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_AvailAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAvailAddressRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AvailAddress_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.AvailAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AvailAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAvailAddressRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AvailAddress_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.AvailAddress(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_ProvenHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryProvenHeightRequest - var metadata runtime.ServerMetadata - - msg, err := client.ProvenHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ProvenHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryProvenHeightRequest - var metadata runtime.ServerMetadata - - msg, err := server.ProvenHeight(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_PendingBlocks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPendingBlocksRequest - var metadata runtime.ServerMetadata - - msg, err := client.PendingBlocks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_PendingBlocks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPendingBlocksRequest - var metadata runtime.ServerMetadata - - msg, err := server.PendingBlocks(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_ExpiredBlocks_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryExpiredBlocksRequest - var metadata runtime.ServerMetadata - - msg, err := client.ExpiredBlocks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ExpiredBlocks_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryExpiredBlocksRequest - var metadata runtime.ServerMetadata - - msg, err := server.ExpiredBlocks(ctx, &protoReq) + msg, err := server.SubmittedBlobStatus(ctx, &protoReq) return msg, metadata, err } @@ -147,7 +57,7 @@ func local_request_Query_ExpiredBlocks_0(ctx context.Context, marshaler runtime. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Validators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_SubmittedBlobStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -158,7 +68,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Validators_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_SubmittedBlobStatus_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -166,99 +76,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_Validators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AvailAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_AvailAddress_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AvailAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ProvenHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ProvenHeight_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ProvenHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_PendingBlocks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_PendingBlocks_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_PendingBlocks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ExpiredBlocks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ExpiredBlocks_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ExpiredBlocks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_SubmittedBlobStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -303,47 +121,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Validators_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Validators_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Validators_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AvailAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_AvailAddress_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AvailAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ProvenHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_SubmittedBlobStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -352,54 +130,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_ProvenHeight_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_SubmittedBlobStatus_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_ProvenHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_PendingBlocks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_PendingBlocks_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_PendingBlocks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_ExpiredBlocks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ExpiredBlocks_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ExpiredBlocks_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_SubmittedBlobStatus_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -407,25 +145,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Validators_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"availblob", "v1beta1", "validators"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_AvailAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"availblob", "v1beta1", "avail_address"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ProvenHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"availblob", "v1beta1", "proven_height"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_PendingBlocks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"availblob", "v1beta1", "pending_blocks"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_ExpiredBlocks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"availblob", "v1beta1", "expired_blocks"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_SubmittedBlobStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"availblob", "v1beta1", "submitBlobStatus"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Validators_0 = runtime.ForwardResponseMessage - - forward_Query_AvailAddress_0 = runtime.ForwardResponseMessage - - forward_Query_ProvenHeight_0 = runtime.ForwardResponseMessage - - forward_Query_PendingBlocks_0 = runtime.ForwardResponseMessage - - forward_Query_ExpiredBlocks_0 = runtime.ForwardResponseMessage + forward_Query_SubmittedBlobStatus_0 = runtime.ForwardResponseMessage ) diff --git a/types/tx.pb.go b/types/tx.pb.go index 6224a55..4f01415 100644 --- a/types/tx.pb.go +++ b/types/tx.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" @@ -28,24 +29,56 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgSetAvailAddress defines a SDK message for validators to set their Avail address -type MsgSetAvailAddress struct { - ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` - AvailAddress string `protobuf:"bytes,2,opt,name=avail_address,json=availAddress,proto3" json:"avail_address,omitempty"` +// status of submitblob +type BlobStatus int32 + +const ( + BLOB_STATUS_UNSPECIFIED BlobStatus = 0 + BLOB_STATUS_FAILURE BlobStatus = 1 + BLOB_STATUS_SUCCESS BlobStatus = 2 + BLOB_STATUS_PENDING BlobStatus = 3 +) + +var BlobStatus_name = map[int32]string{ + 0: "BLOB_STATUS_UNSPECIFIED", + 1: "BLOB_STATUS_FAILURE", + 2: "BLOB_STATUS_SUCCESS", + 3: "BLOB_STATUS_PENDING", +} + +var BlobStatus_value = map[string]int32{ + "BLOB_STATUS_UNSPECIFIED": 0, + "BLOB_STATUS_FAILURE": 1, + "BLOB_STATUS_SUCCESS": 2, + "BLOB_STATUS_PENDING": 3, +} + +func (x BlobStatus) String() string { + return proto.EnumName(BlobStatus_name, int32(x)) } -func (m *MsgSetAvailAddress) Reset() { *m = MsgSetAvailAddress{} } -func (m *MsgSetAvailAddress) String() string { return proto.CompactTextString(m) } -func (*MsgSetAvailAddress) ProtoMessage() {} -func (*MsgSetAvailAddress) Descriptor() ([]byte, []int) { +func (BlobStatus) EnumDescriptor() ([]byte, []int) { return fileDescriptor_7f88203cb33986bc, []int{0} } -func (m *MsgSetAvailAddress) XXX_Unmarshal(b []byte) error { + +// blocks range from to to +type Range struct { + From uint64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` + To uint64 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` +} + +func (m *Range) Reset() { *m = Range{} } +func (m *Range) String() string { return proto.CompactTextString(m) } +func (*Range) ProtoMessage() {} +func (*Range) Descriptor() ([]byte, []int) { + return fileDescriptor_7f88203cb33986bc, []int{0} +} +func (m *Range) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetAvailAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetAvailAddress.Marshal(b, m, deterministic) + return xxx_messageInfo_Range.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,48 +88,117 @@ func (m *MsgSetAvailAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgSetAvailAddress) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetAvailAddress.Merge(m, src) +func (m *Range) XXX_Merge(src proto.Message) { + xxx_messageInfo_Range.Merge(m, src) } -func (m *MsgSetAvailAddress) XXX_Size() int { +func (m *Range) XXX_Size() int { return m.Size() } -func (m *MsgSetAvailAddress) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetAvailAddress.DiscardUnknown(m) +func (m *Range) XXX_DiscardUnknown() { + xxx_messageInfo_Range.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetAvailAddress proto.InternalMessageInfo +var xxx_messageInfo_Range proto.InternalMessageInfo + +func (m *Range) GetFrom() uint64 { + if m != nil { + return m.From + } + return 0 +} -func (m *MsgSetAvailAddress) GetValidatorAddress() string { +func (m *Range) GetTo() uint64 { + if m != nil { + return m.To + } + return 0 +} + +// message update blob state response +type MsgUpdateBlobStatusRequest struct { + ValidatorAddress string `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + BlocksRange *Range `protobuf:"bytes,2,opt,name=blocks_range,json=blocksRange,proto3" json:"blocks_range,omitempty"` + AvailHeight uint64 `protobuf:"varint,3,opt,name=avail_height,json=availHeight,proto3" json:"avail_height,omitempty"` + IsSuccess bool `protobuf:"varint,4,opt,name=is_success,json=isSuccess,proto3" json:"is_success,omitempty"` +} + +func (m *MsgUpdateBlobStatusRequest) Reset() { *m = MsgUpdateBlobStatusRequest{} } +func (m *MsgUpdateBlobStatusRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateBlobStatusRequest) ProtoMessage() {} +func (*MsgUpdateBlobStatusRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_7f88203cb33986bc, []int{1} +} +func (m *MsgUpdateBlobStatusRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateBlobStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateBlobStatusRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateBlobStatusRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateBlobStatusRequest.Merge(m, src) +} +func (m *MsgUpdateBlobStatusRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateBlobStatusRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateBlobStatusRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateBlobStatusRequest proto.InternalMessageInfo + +func (m *MsgUpdateBlobStatusRequest) GetValidatorAddress() string { if m != nil { return m.ValidatorAddress } return "" } -func (m *MsgSetAvailAddress) GetAvailAddress() string { +func (m *MsgUpdateBlobStatusRequest) GetBlocksRange() *Range { if m != nil { - return m.AvailAddress + return m.BlocksRange } - return "" + return nil } -// MsgSetAvailAddressResponse is the response type for the Msg/SetAvailAddress RPC method. -type MsgSetAvailAddressResponse struct { +func (m *MsgUpdateBlobStatusRequest) GetAvailHeight() uint64 { + if m != nil { + return m.AvailHeight + } + return 0 } -func (m *MsgSetAvailAddressResponse) Reset() { *m = MsgSetAvailAddressResponse{} } -func (m *MsgSetAvailAddressResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetAvailAddressResponse) ProtoMessage() {} -func (*MsgSetAvailAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7f88203cb33986bc, []int{1} +func (m *MsgUpdateBlobStatusRequest) GetIsSuccess() bool { + if m != nil { + return m.IsSuccess + } + return false +} + +// message update blob state response +type MsgUpdateBlobStatusResponse struct { +} + +func (m *MsgUpdateBlobStatusResponse) Reset() { *m = MsgUpdateBlobStatusResponse{} } +func (m *MsgUpdateBlobStatusResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateBlobStatusResponse) ProtoMessage() {} +func (*MsgUpdateBlobStatusResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7f88203cb33986bc, []int{2} } -func (m *MsgSetAvailAddressResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateBlobStatusResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetAvailAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateBlobStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetAvailAddressResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateBlobStatusResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -106,44 +208,59 @@ func (m *MsgSetAvailAddressResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgSetAvailAddressResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetAvailAddressResponse.Merge(m, src) +func (m *MsgUpdateBlobStatusResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateBlobStatusResponse.Merge(m, src) } -func (m *MsgSetAvailAddressResponse) XXX_Size() int { +func (m *MsgUpdateBlobStatusResponse) XXX_Size() int { return m.Size() } -func (m *MsgSetAvailAddressResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetAvailAddressResponse.DiscardUnknown(m) +func (m *MsgUpdateBlobStatusResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateBlobStatusResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetAvailAddressResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateBlobStatusResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgSetAvailAddress)(nil), "sdk.avail.v1beta1.MsgSetAvailAddress") - proto.RegisterType((*MsgSetAvailAddressResponse)(nil), "sdk.avail.v1beta1.MsgSetAvailAddressResponse") + proto.RegisterEnum("sdk.avail.v1beta1.BlobStatus", BlobStatus_name, BlobStatus_value) + proto.RegisterType((*Range)(nil), "sdk.avail.v1beta1.Range") + proto.RegisterType((*MsgUpdateBlobStatusRequest)(nil), "sdk.avail.v1beta1.MsgUpdateBlobStatusRequest") + proto.RegisterType((*MsgUpdateBlobStatusResponse)(nil), "sdk.avail.v1beta1.MsgUpdateBlobStatusResponse") } func init() { proto.RegisterFile("sdk/avail/v1beta1/tx.proto", fileDescriptor_7f88203cb33986bc) } var fileDescriptor_7f88203cb33986bc = []byte{ - // 272 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x4e, 0xc9, 0xd6, - 0x4f, 0x2c, 0x4b, 0xcc, 0xcc, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, - 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2c, 0x4e, 0xc9, 0xd6, 0x03, 0xcb, 0xe9, 0x41, - 0xe5, 0xa4, 0xc4, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, - 0x41, 0x14, 0x44, 0xad, 0x52, 0x1d, 0x97, 0x90, 0x6f, 0x71, 0x7a, 0x70, 0x6a, 0x89, 0x23, 0x48, - 0xbd, 0x63, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0xb1, 0x90, 0x36, 0x97, 0x60, 0x59, 0x62, 0x4e, 0x66, - 0x4a, 0x62, 0x49, 0x7e, 0x51, 0x7c, 0x22, 0x44, 0x50, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x48, - 0x00, 0x2e, 0x01, 0x53, 0xac, 0xcc, 0xc5, 0x0b, 0xb6, 0x0c, 0xae, 0x90, 0x09, 0xac, 0x90, 0x27, - 0x11, 0xc9, 0x44, 0x2b, 0xb1, 0xa6, 0xe7, 0x1b, 0xb4, 0x30, 0x0d, 0x55, 0x92, 0xe1, 0x92, 0xc2, - 0xb4, 0x3f, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0xd5, 0xa8, 0x94, 0x8b, 0xd9, 0xb7, 0x38, - 0x5d, 0x28, 0x9d, 0x8b, 0x1f, 0xdd, 0x85, 0xaa, 0x7a, 0x18, 0x9e, 0xd4, 0xc3, 0x34, 0x48, 0x4a, - 0x97, 0x28, 0x65, 0x30, 0xfb, 0xa4, 0x58, 0x1b, 0x9e, 0x6f, 0xd0, 0x62, 0x74, 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, 0x48, 0x24, 0xe8, 0xa6, 0x24, - 0xea, 0xe6, 0xe6, 0xa7, 0x94, 0xe6, 0xa4, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, - 0x83, 0xd7, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x90, 0xc2, 0xec, 0xc5, 0xa8, 0x01, 0x00, 0x00, + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xbd, 0x49, 0x8a, 0xe8, 0xa6, 0x42, 0xee, 0x82, 0x48, 0xe4, 0xaa, 0x56, 0xc9, 0x85, + 0x2a, 0x55, 0x6c, 0xa5, 0xdc, 0xe0, 0x94, 0xa4, 0x2e, 0x44, 0x6a, 0x43, 0x65, 0xd7, 0x17, 0x2e, + 0xd6, 0xda, 0x5e, 0x1c, 0x2b, 0x76, 0x37, 0xf5, 0xac, 0xcd, 0x9f, 0x0b, 0x88, 0x13, 0x47, 0xde, + 0x81, 0x17, 0xe8, 0x63, 0x70, 0xec, 0x91, 0x63, 0x95, 0x1c, 0xfa, 0x1a, 0xc8, 0x6b, 0x04, 0x28, + 0x2d, 0x52, 0x4f, 0x3b, 0xfa, 0x7d, 0x9f, 0x76, 0xbe, 0xd9, 0x1d, 0xac, 0x41, 0x38, 0x33, 0x69, + 0x41, 0xe3, 0xc4, 0x2c, 0xfa, 0x3e, 0x13, 0xb4, 0x6f, 0x8a, 0xf7, 0xc6, 0x3c, 0xe3, 0x82, 0x93, + 0x4d, 0x08, 0x67, 0x86, 0xd4, 0x8c, 0xdf, 0x9a, 0xd6, 0x0a, 0x38, 0xa4, 0x1c, 0xcc, 0x14, 0x22, + 0xb3, 0xe8, 0x97, 0x47, 0xe5, 0xd5, 0x1e, 0x45, 0x3c, 0xe2, 0xb2, 0x34, 0xcb, 0xaa, 0xa2, 0x9d, + 0x3d, 0xbc, 0x66, 0xd3, 0xb3, 0x88, 0x11, 0x82, 0x1b, 0x6f, 0x33, 0x9e, 0xb6, 0xd1, 0x0e, 0xda, + 0x6d, 0xd8, 0xb2, 0x26, 0x0f, 0x70, 0x4d, 0xf0, 0x76, 0x4d, 0x92, 0x9a, 0xe0, 0x9d, 0x2b, 0x84, + 0xb5, 0x63, 0x88, 0xdc, 0x79, 0x48, 0x05, 0x1b, 0x26, 0xdc, 0x77, 0x04, 0x15, 0x39, 0xd8, 0xec, + 0x3c, 0x67, 0x20, 0xc8, 0x1e, 0xde, 0x2c, 0x68, 0x12, 0x87, 0x54, 0xf0, 0xcc, 0xa3, 0x61, 0x98, + 0x31, 0x00, 0x79, 0xdf, 0xba, 0xad, 0xfe, 0x11, 0x06, 0x15, 0x27, 0x2f, 0xf0, 0x86, 0x9f, 0xf0, + 0x60, 0x06, 0x5e, 0x56, 0xf6, 0x97, 0x5d, 0x9a, 0xfb, 0x6d, 0xe3, 0xc6, 0x44, 0x86, 0xcc, 0x67, + 0x37, 0x2b, 0x77, 0x15, 0xf6, 0x09, 0xde, 0x90, 0x1e, 0x6f, 0xca, 0xe2, 0x68, 0x2a, 0xda, 0x75, + 0x19, 0xb1, 0x29, 0xd9, 0x2b, 0x89, 0xc8, 0x36, 0xc6, 0x31, 0x78, 0x90, 0x07, 0x41, 0x99, 0xa2, + 0xb1, 0x83, 0x76, 0xef, 0xdb, 0xeb, 0x31, 0x38, 0x15, 0x78, 0xfe, 0xf8, 0xcb, 0xf5, 0x45, 0xf7, + 0x66, 0xdc, 0xce, 0x36, 0xde, 0xba, 0x75, 0x42, 0x98, 0xf3, 0x33, 0x60, 0xdd, 0x8f, 0x18, 0xff, + 0xa5, 0x64, 0x0b, 0xb7, 0x86, 0x47, 0xaf, 0x87, 0x9e, 0x73, 0x3a, 0x38, 0x75, 0x1d, 0xcf, 0x9d, + 0x38, 0x27, 0xd6, 0x68, 0x7c, 0x38, 0xb6, 0x0e, 0x54, 0x85, 0xb4, 0xf0, 0xc3, 0x7f, 0xc5, 0xc3, + 0xc1, 0xf8, 0xc8, 0xb5, 0x2d, 0x15, 0xad, 0x0a, 0x8e, 0x3b, 0x1a, 0x59, 0x8e, 0xa3, 0xd6, 0x56, + 0x85, 0x13, 0x6b, 0x72, 0x30, 0x9e, 0xbc, 0x54, 0xeb, 0x5a, 0xe3, 0xeb, 0x77, 0x5d, 0xd9, 0xff, + 0x84, 0xeb, 0xc7, 0x10, 0x91, 0x73, 0xac, 0xae, 0xc6, 0x23, 0xbd, 0x5b, 0x9e, 0xed, 0xff, 0x1f, + 0xa5, 0x19, 0x77, 0xb5, 0x57, 0x53, 0x6b, 0x6b, 0x9f, 0xaf, 0x2f, 0xba, 0x68, 0x38, 0xf8, 0xb1, + 0xd0, 0xd1, 0xe5, 0x42, 0x47, 0x57, 0x0b, 0x1d, 0x7d, 0x5b, 0xea, 0xca, 0xe5, 0x52, 0x57, 0x7e, + 0x2e, 0x75, 0xe5, 0xcd, 0xd3, 0x28, 0x16, 0xd3, 0xdc, 0x37, 0x02, 0x9e, 0x9a, 0x45, 0x2c, 0xde, + 0xc5, 0xa2, 0xda, 0xd8, 0x5e, 0x48, 0x7b, 0x29, 0x0f, 0xf3, 0x84, 0x99, 0xe2, 0xc3, 0x9c, 0x81, + 0x7f, 0x4f, 0x6e, 0xdd, 0xb3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x5d, 0xb6, 0xfa, 0xd5, + 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -158,8 +275,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // SetAvailAddress - SetAvailAddress(ctx context.Context, in *MsgSetAvailAddress, opts ...grpc.CallOption) (*MsgSetAvailAddressResponse, error) + // UpdateBlobStatus + UpdateBlobStatus(ctx context.Context, in *MsgUpdateBlobStatusRequest, opts ...grpc.CallOption) (*MsgUpdateBlobStatusResponse, error) } type msgClient struct { @@ -170,9 +287,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) SetAvailAddress(ctx context.Context, in *MsgSetAvailAddress, opts ...grpc.CallOption) (*MsgSetAvailAddressResponse, error) { - out := new(MsgSetAvailAddressResponse) - err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Msg/SetAvailAddress", in, out, opts...) +func (c *msgClient) UpdateBlobStatus(ctx context.Context, in *MsgUpdateBlobStatusRequest, opts ...grpc.CallOption) (*MsgUpdateBlobStatusResponse, error) { + out := new(MsgUpdateBlobStatusResponse) + err := c.cc.Invoke(ctx, "/sdk.avail.v1beta1.Msg/UpdateBlobStatus", in, out, opts...) if err != nil { return nil, err } @@ -181,36 +298,36 @@ func (c *msgClient) SetAvailAddress(ctx context.Context, in *MsgSetAvailAddress, // MsgServer is the server API for Msg service. type MsgServer interface { - // SetAvailAddress - SetAvailAddress(context.Context, *MsgSetAvailAddress) (*MsgSetAvailAddressResponse, error) + // UpdateBlobStatus + UpdateBlobStatus(context.Context, *MsgUpdateBlobStatusRequest) (*MsgUpdateBlobStatusResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) SetAvailAddress(ctx context.Context, req *MsgSetAvailAddress) (*MsgSetAvailAddressResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetAvailAddress not implemented") +func (*UnimplementedMsgServer) UpdateBlobStatus(ctx context.Context, req *MsgUpdateBlobStatusRequest) (*MsgUpdateBlobStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateBlobStatus not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_SetAvailAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetAvailAddress) +func _Msg_UpdateBlobStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateBlobStatusRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).SetAvailAddress(ctx, in) + return srv.(MsgServer).UpdateBlobStatus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sdk.avail.v1beta1.Msg/SetAvailAddress", + FullMethod: "/sdk.avail.v1beta1.Msg/UpdateBlobStatus", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetAvailAddress(ctx, req.(*MsgSetAvailAddress)) + return srv.(MsgServer).UpdateBlobStatus(ctx, req.(*MsgUpdateBlobStatusRequest)) } return interceptor(ctx, in, info, handler) } @@ -220,15 +337,15 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "SetAvailAddress", - Handler: _Msg_SetAvailAddress_Handler, + MethodName: "UpdateBlobStatus", + Handler: _Msg_UpdateBlobStatus_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "sdk/avail/v1beta1/tx.proto", } -func (m *MsgSetAvailAddress) Marshal() (dAtA []byte, err error) { +func (m *Range) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -238,20 +355,73 @@ func (m *MsgSetAvailAddress) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetAvailAddress) MarshalTo(dAtA []byte) (int, error) { +func (m *Range) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetAvailAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Range) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.AvailAddress) > 0 { - i -= len(m.AvailAddress) - copy(dAtA[i:], m.AvailAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.AvailAddress))) + if m.To != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.To)) + i-- + dAtA[i] = 0x10 + } + if m.From != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.From)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateBlobStatusRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateBlobStatusRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateBlobStatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsSuccess { + i-- + if m.IsSuccess { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.AvailHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.AvailHeight)) + i-- + dAtA[i] = 0x18 + } + if m.BlocksRange != nil { + { + size, err := m.BlocksRange.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x12 } @@ -265,7 +435,7 @@ func (m *MsgSetAvailAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgSetAvailAddressResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateBlobStatusResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -275,12 +445,12 @@ func (m *MsgSetAvailAddressResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetAvailAddressResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateBlobStatusResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetAvailAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateBlobStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -299,7 +469,22 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgSetAvailAddress) Size() (n int) { +func (m *Range) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.From != 0 { + n += 1 + sovTx(uint64(m.From)) + } + if m.To != 0 { + n += 1 + sovTx(uint64(m.To)) + } + return n +} + +func (m *MsgUpdateBlobStatusRequest) Size() (n int) { if m == nil { return 0 } @@ -309,14 +494,20 @@ func (m *MsgSetAvailAddress) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.AvailAddress) - if l > 0 { + if m.BlocksRange != nil { + l = m.BlocksRange.Size() n += 1 + l + sovTx(uint64(l)) } + if m.AvailHeight != 0 { + n += 1 + sovTx(uint64(m.AvailHeight)) + } + if m.IsSuccess { + n += 2 + } return n } -func (m *MsgSetAvailAddressResponse) Size() (n int) { +func (m *MsgUpdateBlobStatusResponse) Size() (n int) { if m == nil { return 0 } @@ -331,7 +522,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgSetAvailAddress) Unmarshal(dAtA []byte) error { +func (m *Range) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -354,10 +545,98 @@ func (m *MsgSetAvailAddress) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetAvailAddress: wiretype end group for non-group") + return fmt.Errorf("proto: Range: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetAvailAddress: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Range: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + m.From = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.From |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) + } + m.To = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.To |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateBlobStatusRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateBlobStatusRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateBlobStatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -394,9 +673,9 @@ func (m *MsgSetAvailAddress) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AvailAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BlocksRange", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -406,24 +685,67 @@ func (m *MsgSetAvailAddress) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.AvailAddress = string(dAtA[iNdEx:postIndex]) + if m.BlocksRange == nil { + m.BlocksRange = &Range{} + } + if err := m.BlocksRange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AvailHeight", wireType) + } + m.AvailHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AvailHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSuccess", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSuccess = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -445,7 +767,7 @@ func (m *MsgSetAvailAddress) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetAvailAddressResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateBlobStatusResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -468,10 +790,10 @@ func (m *MsgSetAvailAddressResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetAvailAddressResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateBlobStatusResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetAvailAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateBlobStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/types/validation.go b/types/validation.go index 03f693c..ab1254f 100644 --- a/types/validation.go +++ b/types/validation.go @@ -1,9 +1 @@ package types - -import ( - "cosmossdk.io/core/address" -) - -func (msg *MsgSetAvailAddress) Validate(ac address.Codec) ([]byte, error) { - return ac.StringToBytes(msg.ValidatorAddress) -} diff --git a/types/vote_extensions.pb.go b/types/vote_extensions.pb.go new file mode 100644 index 0000000..9a98901 --- /dev/null +++ b/types/vote_extensions.pb.go @@ -0,0 +1,365 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: sdk/avail/v1beta1/vote_extensions.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// AvailVoteExtension +type AvailVoteExtension struct { + AvailHeight int64 `protobuf:"varint,1,opt,name=avail_height,json=availHeight,proto3" json:"avail_height,omitempty"` + Range *Range `protobuf:"bytes,2,opt,name=range,proto3" json:"range,omitempty"` +} + +func (m *AvailVoteExtension) Reset() { *m = AvailVoteExtension{} } +func (m *AvailVoteExtension) String() string { return proto.CompactTextString(m) } +func (*AvailVoteExtension) ProtoMessage() {} +func (*AvailVoteExtension) Descriptor() ([]byte, []int) { + return fileDescriptor_007bc07f2f11afa0, []int{0} +} +func (m *AvailVoteExtension) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AvailVoteExtension) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AvailVoteExtension.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AvailVoteExtension) XXX_Merge(src proto.Message) { + xxx_messageInfo_AvailVoteExtension.Merge(m, src) +} +func (m *AvailVoteExtension) XXX_Size() int { + return m.Size() +} +func (m *AvailVoteExtension) XXX_DiscardUnknown() { + xxx_messageInfo_AvailVoteExtension.DiscardUnknown(m) +} + +var xxx_messageInfo_AvailVoteExtension proto.InternalMessageInfo + +func (m *AvailVoteExtension) GetAvailHeight() int64 { + if m != nil { + return m.AvailHeight + } + return 0 +} + +func (m *AvailVoteExtension) GetRange() *Range { + if m != nil { + return m.Range + } + return nil +} + +func init() { + proto.RegisterType((*AvailVoteExtension)(nil), "sdk.avail.v1beta1.AvailVoteExtension") +} + +func init() { + proto.RegisterFile("sdk/avail/v1beta1/vote_extensions.proto", fileDescriptor_007bc07f2f11afa0) +} + +var fileDescriptor_007bc07f2f11afa0 = []byte{ + // 221 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2f, 0x4e, 0xc9, 0xd6, + 0x4f, 0x2c, 0x4b, 0xcc, 0xcc, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xcb, + 0x2f, 0x49, 0x8d, 0x4f, 0xad, 0x28, 0x49, 0xcd, 0x2b, 0xce, 0xcc, 0xcf, 0x2b, 0xd6, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2c, 0x4e, 0xc9, 0xd6, 0x03, 0x2b, 0xd4, 0x83, 0x2a, 0x94, 0x92, + 0xc2, 0xd4, 0x5b, 0x52, 0x01, 0x51, 0xae, 0x94, 0xce, 0x25, 0xe4, 0x08, 0x92, 0x09, 0xcb, 0x2f, + 0x49, 0x75, 0x85, 0x99, 0x25, 0xa4, 0xc8, 0xc5, 0x03, 0x56, 0x1f, 0x9f, 0x91, 0x9a, 0x99, 0x9e, + 0x51, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x1c, 0xc4, 0x0d, 0x16, 0xf3, 0x00, 0x0b, 0x09, 0xe9, + 0x71, 0xb1, 0x16, 0x25, 0xe6, 0xa5, 0xa7, 0x4a, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x49, 0xe8, + 0x61, 0xd8, 0xab, 0x17, 0x04, 0x92, 0x0f, 0x82, 0x28, 0x73, 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, 0x63, 0x75, 0x53, 0x12, 0x75, 0x73, 0xf3, + 0x53, 0x4a, 0x73, 0x52, 0xf5, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x4e, 0x36, 0x06, + 0x04, 0x00, 0x00, 0xff, 0xff, 0x54, 0x29, 0xaf, 0xb7, 0x0c, 0x01, 0x00, 0x00, +} + +func (m *AvailVoteExtension) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AvailVoteExtension) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AvailVoteExtension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Range != nil { + { + size, err := m.Range.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintVoteExtensions(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.AvailHeight != 0 { + i = encodeVarintVoteExtensions(dAtA, i, uint64(m.AvailHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintVoteExtensions(dAtA []byte, offset int, v uint64) int { + offset -= sovVoteExtensions(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AvailVoteExtension) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AvailHeight != 0 { + n += 1 + sovVoteExtensions(uint64(m.AvailHeight)) + } + if m.Range != nil { + l = m.Range.Size() + n += 1 + l + sovVoteExtensions(uint64(l)) + } + return n +} + +func sovVoteExtensions(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozVoteExtensions(x uint64) (n int) { + return sovVoteExtensions(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AvailVoteExtension) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVoteExtensions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AvailVoteExtension: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AvailVoteExtension: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AvailHeight", wireType) + } + m.AvailHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVoteExtensions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AvailHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Range", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVoteExtensions + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthVoteExtensions + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthVoteExtensions + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Range == nil { + m.Range = &Range{} + } + if err := m.Range.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipVoteExtensions(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVoteExtensions + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipVoteExtensions(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVoteExtensions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVoteExtensions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVoteExtensions + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthVoteExtensions + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupVoteExtensions + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthVoteExtensions + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthVoteExtensions = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowVoteExtensions = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupVoteExtensions = fmt.Errorf("proto: unexpected end of group") +)