diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 58561db06..b9301446d 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -11590,6 +11590,203 @@ definitions: - The validator set is committed to the `app_hash` of the sealer header babylon.zoneconcierge.v1.QueryChainInfoResponse: + type: object + properties: + chain_info: + title: chain_info is the info of the CZ + type: object + properties: + chain_id: + type: string + title: chain_id is the ID of the chain + latest_header: + title: latest_header is the latest header in the canonical chain of CZ + type: object + properties: + chain_id: + type: string + title: chain_id is the unique ID of the chain + hash: + type: string + format: byte + title: hash is the hash of this header + height: + type: string + format: uint64 + app: + type: string + format: uint64 + description: >- + Consensus captures the consensus rules for processing a block in + the blockchain, + + including all blockchain data structures and the rules of the + application's + + state transition machine. + chain_id: + type: string + height: + type: string + format: int64 + time: + type: string + format: date-time + last_block_id: + title: prev block info + type: object + properties: + hash: + type: string + format: byte + part_set_header: + type: object + properties: + total: + type: integer + format: int64 + hash: + type: string + format: byte + title: PartsetHeader + last_commit_hash: + type: string + format: byte + title: hashes of block data + data_hash: + type: string + format: byte + validators_hash: + type: string + format: byte + title: hashes from the app output from the prev block + next_validators_hash: + type: string + format: byte + consensus_hash: + type: string + format: byte + app_hash: + type: string + format: byte + last_results_hash: + type: string + format: byte + evidence_hash: + type: string + format: byte + title: consensus info + proposer_address: + type: string + format: byte + description: Header defines the structure of a Tendermint block header. + babylon_epoch: + type: string + format: uint64 + title: epoch is the epoch number of this header on Babylon ledger + babylon_tx_hash: + type: string + format: byte + title: >- + babylon_tx_hash is the hash of the tx that includes this header + + (babylon_block_height, babylon_tx_hash) jointly provides the position + of the header on Babylon ledger + title: IndexedHeader is the metadata of a CZ header + babylon.zoneconcierge.v1.Params: + type: object + description: Params defines the parameters for the module. + babylon.zoneconcierge.v1.ProofEpochSealed: + type: object + properties: + validator_set: + type: array + items: + type: object + properties: + validator_address: + type: string + bls_pub_key: + type: string + format: byte + voting_power: + type: string + format: uint64 + title: >- + ValidatorWithBlsKey couples validator address, voting power, and its + bls public key + title: >- + validator_set is the validator set of the sealed epoch + + This validator set has generated a BLS multisig on `last_commit_hash` + of the sealer header + proof_epoch_info: + title: >- + proof_epoch_info is the Merkle proof that the epoch's metadata is + committed to `app_hash` of the sealer header + type: object + properties: + ops: + type: array + items: + type: object + properties: + type: + type: string + key: + type: string + format: byte + data: + type: string + format: byte + title: |- + ProofOp defines an operation used for calculating Merkle root + The data could be arbitrary format, providing nessecary data + for example neighbouring node hash + proof_epoch_val_set: + title: >- + proof_epoch_info is the Merkle proof that the epoch's validator set is + committed to `app_hash` of the sealer header + type: object + properties: + ops: + type: array + items: + type: object + properties: + type: + type: string + key: + type: string + format: byte + data: + type: string + format: byte + title: |- + ProofOp defines an operation used for calculating Merkle root + The data could be arbitrary format, providing nessecary data + for example neighbouring node hash + title: >- + ProofEpochSealed is the proof that an epoch is sealed by the sealer + header, i.e., the 2nd header of the next epoch + + With the access of metadata + + - Metadata of this epoch, which includes the sealer header + + - Raw checkpoint of this epoch + + The verifier can perform the following verification rules: + + - The raw checkpoint's `last_commit_hash` is same as in the sealer header + + - More than 1/3 (in voting power) validators in the validator set of this + epoch have signed `last_commit_hash` of the sealer header + + - The epoch medatata is committed to the `app_hash` of the sealer header + + - The validator set is committed to the `app_hash` of the sealer header + babylon.zoneconcierge.v1.QueryChainInfoResponse: type: object properties: chain_info: @@ -12867,6 +13064,273 @@ definitions: description: >- QueryFinalizedChainInfoResponse is response type for the Query/FinalizedChainInfo RPC method. + babylon.zoneconcierge.v1.QueryListEpochHeadersResponse: + type: object + properties: + headers: + type: array + items: + type: object + properties: + chain_id: + type: string + title: chain_id is the unique ID of the chain + hash: + type: string + format: byte + title: hash is the hash of this header + height: + type: string + format: uint64 + title: >- + height is the height of this header on CZ ledger + + (hash, height) jointly provides the position of the header on CZ + ledger + babylon_header: + title: >- + babylon_header is the header of the babylon block that includes + this CZ header + type: object + properties: + version: + title: basic block info + type: object + properties: + block: + type: string + format: uint64 + app: + type: string + format: uint64 + description: >- + Consensus captures the consensus rules for processing a + block in the blockchain, + + including all blockchain data structures and the rules of + the application's + + state transition machine. + chain_id: + type: string + height: + type: string + format: int64 + time: + type: string + format: date-time + last_block_id: + title: prev block info + type: object + properties: + hash: + type: string + format: byte + part_set_header: + type: object + properties: + total: + type: integer + format: int64 + hash: + type: string + format: byte + title: PartsetHeader + last_commit_hash: + type: string + format: byte + title: hashes of block data + data_hash: + type: string + format: byte + validators_hash: + type: string + format: byte + title: hashes from the app output from the prev block + next_validators_hash: + type: string + format: byte + consensus_hash: + type: string + format: byte + app_hash: + type: string + format: byte + last_results_hash: + type: string + format: byte + evidence_hash: + type: string + format: byte + title: consensus info + proposer_address: + type: string + format: byte + description: Header defines the structure of a Tendermint block header. + babylon_epoch: + type: string + format: uint64 + title: epoch is the epoch number of this header on Babylon ledger + babylon_tx_hash: + type: string + format: byte + title: >- + babylon_tx_hash is the hash of the tx that includes this header + + (babylon_block_height, babylon_tx_hash) jointly provides the + position of the header on Babylon ledger + title: IndexedHeader is the metadata of a CZ header + title: headers is the list of headers + description: >- + QueryListEpochHeadersResponse is response type for the + Query/ListEpochHeaders RPC method. + babylon.zoneconcierge.v1.QueryListHeadersResponse: + type: object + properties: + headers: + type: array + items: + type: object + properties: + chain_id: + type: string + title: chain_id is the unique ID of the chain + hash: + type: string + format: byte + title: hash is the hash of this header + height: + type: string + format: uint64 + title: >- + height is the height of this header on CZ ledger + + (hash, height) jointly provides the position of the header on CZ + ledger + babylon_header: + title: >- + babylon_header is the header of the babylon block that includes + this CZ header + type: object + properties: + version: + title: basic block info + type: object + properties: + block: + type: string + format: uint64 + app: + type: string + format: uint64 + description: >- + Consensus captures the consensus rules for processing a + block in the blockchain, + + including all blockchain data structures and the rules of + the application's + + state transition machine. + chain_id: + type: string + height: + type: string + format: int64 + time: + type: string + format: date-time + last_block_id: + title: prev block info + type: object + properties: + hash: + type: string + format: byte + part_set_header: + type: object + properties: + total: + type: integer + format: int64 + hash: + type: string + format: byte + title: PartsetHeader + last_commit_hash: + type: string + format: byte + title: hashes of block data + data_hash: + type: string + format: byte + validators_hash: + type: string + format: byte + title: hashes from the app output from the prev block + next_validators_hash: + type: string + format: byte + consensus_hash: + type: string + format: byte + app_hash: + type: string + format: byte + last_results_hash: + type: string + format: byte + evidence_hash: + type: string + format: byte + title: consensus info + proposer_address: + type: string + format: byte + description: Header defines the structure of a Tendermint block header. + babylon_epoch: + type: string + format: uint64 + title: epoch is the epoch number of this header on Babylon ledger + babylon_tx_hash: + type: string + format: byte + title: >- + babylon_tx_hash is the hash of the tx that includes this header + + (babylon_block_height, babylon_tx_hash) jointly provides the + position of the header on Babylon ledger + title: IndexedHeader is the metadata of a CZ header + title: headers is the list of headers + pagination: + title: pagination defines the pagination in the response + type: object + properties: + next_key: + type: string + format: byte + description: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently. It will be empty if + there are no more results. + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + description: >- + QueryFinalizedChainInfoResponse is response type for the + Query/FinalizedChainInfo RPC method. babylon.zoneconcierge.v1.QueryListHeadersResponse: type: object properties: diff --git a/proto/babylon/zoneconcierge/query.proto b/proto/babylon/zoneconcierge/query.proto index 67342d490..374943457 100644 --- a/proto/babylon/zoneconcierge/query.proto +++ b/proto/babylon/zoneconcierge/query.proto @@ -38,6 +38,10 @@ service Query { rpc ListHeaders(QueryListHeadersRequest) returns (QueryListHeadersResponse) { option (google.api.http).get = "/babylon/zoneconcierge/v1/headers/{chain_id}"; } + // ListEpochHeaders queries the headers of a chain timestamped in a given epoch of Babylon, with pagination support + rpc ListEpochHeaders(QueryListEpochHeadersRequest) returns (QueryListEpochHeadersResponse) { + option (google.api.http).get = "/babylon/zoneconcierge/v1/headers/{chain_id}/epochs/{epoch_num}"; + } // FinalizedChainInfo queries the BTC-finalised info of a chain, with proofs rpc FinalizedChainInfo(QueryFinalizedChainInfoRequest) returns (QueryFinalizedChainInfoResponse) { option (google.api.http).get = "/babylon/zoneconcierge/v1/finalized_chain_info/{chain_id}"; @@ -99,6 +103,18 @@ message QueryListHeadersResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +// QueryListEpochHeadersRequest is request type for the Query/ListEpochHeaders RPC method. +message QueryListEpochHeadersRequest { + uint64 epoch_num = 1; + string chain_id = 2; +} + +// QueryListEpochHeadersResponse is response type for the Query/ListEpochHeaders RPC method. +message QueryListEpochHeadersResponse { + // headers is the list of headers + repeated babylon.zoneconcierge.v1.IndexedHeader headers = 1; +} + // QueryFinalizedChainInfoRequest is request type for the Query/FinalizedChainInfo RPC method. message QueryFinalizedChainInfoRequest { // chain_id is the ID of the CZ diff --git a/x/zoneconcierge/keeper/canonical_chain_indexer_test.go b/x/zoneconcierge/keeper/canonical_chain_indexer_test.go index d6041daf6..7f7d8f53a 100644 --- a/x/zoneconcierge/keeper/canonical_chain_indexer_test.go +++ b/x/zoneconcierge/keeper/canonical_chain_indexer_test.go @@ -14,7 +14,8 @@ func FuzzCanonicalChainIndexer(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, czChain, zcKeeper := SetupTest(t) + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper ctx := babylonChain.GetContext() hooks := zcKeeper.Hooks() diff --git a/x/zoneconcierge/keeper/epoch_chain_info_indexer.go b/x/zoneconcierge/keeper/epoch_chain_info_indexer.go index 6d1d550a0..121c8bcef 100644 --- a/x/zoneconcierge/keeper/epoch_chain_info_indexer.go +++ b/x/zoneconcierge/keeper/epoch_chain_info_indexer.go @@ -1,6 +1,7 @@ package keeper import ( + bbn "github.com/babylonchain/babylon/types" "github.com/babylonchain/babylon/x/zoneconcierge/types" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -19,6 +20,45 @@ func (k Keeper) GetEpochChainInfo(ctx sdk.Context, chainID string, epochNumber u return &chainInfo, nil } +// GetEpochHeaders gets the headers timestamped in a given epoch, in the ascending order +func (k Keeper) GetEpochHeaders(ctx sdk.Context, chainID string, epochNumber uint64) ([]*types.IndexedHeader, error) { + headers := []*types.IndexedHeader{} + + // find the last timestamped header of this chain in the epoch + epochChainInfo, err := k.GetEpochChainInfo(ctx, chainID, epochNumber) + if err != nil { + return nil, err + } + // it's possible that this epoch's snapshot is not updated for many epochs + // this implies that this epoch does not timestamp any header for this chain at all + if epochChainInfo.LatestHeader.BabylonEpoch < epochNumber { + return nil, types.ErrEpochHeadersNotFound + } + // now we have the last header in this epoch + headers = append(headers, epochChainInfo.LatestHeader) + + // append all previous headers until reaching the previous epoch + canonicalChainStore := k.canonicalChainStore(ctx, chainID) + lastHeaderKey := sdk.Uint64ToBigEndian(epochChainInfo.LatestHeader.Height) + // NOTE: even in ReverseIterator, start and end should still be specified in ascending order + canonicalChainIter := canonicalChainStore.ReverseIterator(nil, lastHeaderKey) + defer canonicalChainIter.Close() + for ; canonicalChainIter.Valid(); canonicalChainIter.Next() { + var prevHeader types.IndexedHeader + k.cdc.MustUnmarshal(canonicalChainIter.Value(), &prevHeader) + if prevHeader.BabylonEpoch < epochNumber { + // we have reached the previous epoch, break the loop + break + } + headers = append(headers, &prevHeader) + } + + // reverse the list so that it remains ascending order + bbn.Reverse(headers) + + return headers, nil +} + // recordEpochChainInfo records the chain info for a given epoch number of given chain ID // where the latest chain info is retrieved from the chain info indexer func (k Keeper) recordEpochChainInfo(ctx sdk.Context, chainID string, epochNumber uint64) { diff --git a/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go b/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go index dcc5bdd49..82ced134b 100644 --- a/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go +++ b/x/zoneconcierge/keeper/epoch_chain_info_indexer_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/babylonchain/babylon/testutil/datagen" + ibctmtypes "github.com/cosmos/ibc-go/v5/modules/light-clients/07-tendermint/types" "github.com/stretchr/testify/require" ) @@ -14,7 +15,8 @@ func FuzzEpochChainInfoIndexer(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, czChain, zcKeeper := SetupTest(t) + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper ctx := babylonChain.GetContext() hooks := zcKeeper.Hooks() @@ -35,3 +37,68 @@ func FuzzEpochChainInfoIndexer(f *testing.F) { require.Equal(t, numForkHeaders, uint64(len(chainInfo.LatestForks.Headers))) }) } + +func FuzzGetEpochHeaders(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + rand.Seed(seed) + + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper + epochingKeeper := babylonApp.EpochingKeeper + + ctx := babylonChain.GetContext() + hooks := zcKeeper.Hooks() + + numReqs := datagen.RandomInt(5) + 1 + + epochNumList := []uint64{datagen.RandomInt(10) + 1} + nextHeightList := []uint64{0} + numHeadersList := []uint64{} + expectedHeadersMap := map[uint64][]*ibctmtypes.Header{} + numForkHeadersList := []uint64{} + + // we test the scenario of ending an epoch for multiple times, in order to ensure that + // consecutive epoch infos do not affect each other. + for i := uint64(0); i < numReqs; i++ { + epochNum := epochNumList[i] + // enter a random epoch + if i == 0 { + for j := uint64(0); j < epochNum; j++ { + epochingKeeper.IncEpoch(ctx) + } + } else { + for j := uint64(0); j < epochNum-epochNumList[i-1]; j++ { + epochingKeeper.IncEpoch(ctx) + } + } + + // generate a random number of headers and fork headers + numHeadersList = append(numHeadersList, datagen.RandomInt(100)+1) + numForkHeadersList = append(numForkHeadersList, datagen.RandomInt(10)+1) + // trigger hooks to append these headers and fork headers + expectedHeaders, _ := SimulateHeadersAndForksViaHook(ctx, hooks, czChain.ChainID, nextHeightList[i], numHeadersList[i], numForkHeadersList[i]) + expectedHeadersMap[epochNum] = expectedHeaders + // prepare nextHeight for the next request + nextHeightList = append(nextHeightList, nextHeightList[i]+numHeadersList[i]) + + // simulate the scenario that a random epoch has ended + hooks.AfterEpochEnds(ctx, epochNum) + // prepare epochNum for the next request + epochNumList = append(epochNumList, epochNum+datagen.RandomInt(10)+1) + } + + // attest the correctness of epoch info for each tested epoch + for i := uint64(0); i < numReqs; i++ { + epochNum := epochNumList[i] + // check if the headers are same as expected + headers, err := zcKeeper.GetEpochHeaders(ctx, czChain.ChainID, epochNum) + require.NoError(t, err) + require.Equal(t, len(expectedHeadersMap[epochNum]), len(headers)) + for j := 0; j < len(expectedHeadersMap[epochNum]); j++ { + require.Equal(t, expectedHeadersMap[epochNum][j].Header.LastCommitHash, headers[j].Hash) + } + } + }) +} diff --git a/x/zoneconcierge/keeper/fork_indexer_test.go b/x/zoneconcierge/keeper/fork_indexer_test.go index 42c65f29e..1f48a4420 100644 --- a/x/zoneconcierge/keeper/fork_indexer_test.go +++ b/x/zoneconcierge/keeper/fork_indexer_test.go @@ -14,7 +14,8 @@ func FuzzForkIndexer(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, czChain, zcKeeper := SetupTest(t) + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper ctx := babylonChain.GetContext() hooks := zcKeeper.Hooks() diff --git a/x/zoneconcierge/keeper/grpc_query.go b/x/zoneconcierge/keeper/grpc_query.go index 205453dc9..ea8190fe4 100644 --- a/x/zoneconcierge/keeper/grpc_query.go +++ b/x/zoneconcierge/keeper/grpc_query.go @@ -97,6 +97,30 @@ func (k Keeper) ListHeaders(c context.Context, req *types.QueryListHeadersReques return resp, nil } +// ListEpochHeaders returns all headers of a chain with given ID +// TODO: support pagination in this RPC +func (k Keeper) ListEpochHeaders(c context.Context, req *types.QueryListEpochHeadersRequest) (*types.QueryListEpochHeadersResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + if len(req.ChainId) == 0 { + return nil, status.Error(codes.InvalidArgument, "chain ID cannot be empty") + } + + ctx := sdk.UnwrapSDKContext(c) + + headers, err := k.GetEpochHeaders(ctx, req.ChainId, req.EpochNum) + if err != nil { + return nil, err + } + + resp := &types.QueryListEpochHeadersResponse{ + Headers: headers, + } + return resp, nil +} + func (k Keeper) FinalizedChainInfo(c context.Context, req *types.QueryFinalizedChainInfoRequest) (*types.QueryFinalizedChainInfoResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") @@ -122,7 +146,7 @@ func (k Keeper) FinalizedChainInfo(c context.Context, req *types.QueryFinalizedC // It's possible that the chain info's epoch is way before the last finalised epoch // e.g., when there is no relayer for many epochs - // NOTE: if an epoch is finalisedm then all of its previous epochs are also finalised + // NOTE: if an epoch is finalised then all of its previous epochs are also finalised if chainInfo.LatestHeader.BabylonEpoch < finalizedEpoch { finalizedEpoch = chainInfo.LatestHeader.BabylonEpoch } diff --git a/x/zoneconcierge/keeper/grpc_query_test.go b/x/zoneconcierge/keeper/grpc_query_test.go index ad13d2a3f..8b13a9f5f 100644 --- a/x/zoneconcierge/keeper/grpc_query_test.go +++ b/x/zoneconcierge/keeper/grpc_query_test.go @@ -11,6 +11,7 @@ import ( checkpointingtypes "github.com/babylonchain/babylon/x/checkpointing/types" zctypes "github.com/babylonchain/babylon/x/zoneconcierge/types" "github.com/cosmos/cosmos-sdk/types/query" + ibctmtypes "github.com/cosmos/ibc-go/v5/modules/light-clients/07-tendermint/types" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" tmcrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" @@ -24,7 +25,8 @@ func FuzzChainList(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, _, zcKeeper := SetupTest(t) + _, babylonChain, _, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper ctx := babylonChain.GetContext() hooks := zcKeeper.Hooks() @@ -66,7 +68,8 @@ func FuzzChainInfo(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, czChain, zcKeeper := SetupTest(t) + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper ctx := babylonChain.GetContext() hooks := zcKeeper.Hooks() @@ -91,7 +94,8 @@ func FuzzEpochChainInfo(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, czChain, zcKeeper := SetupTest(t) + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper ctx := babylonChain.GetContext() hooks := zcKeeper.Hooks() @@ -137,7 +141,8 @@ func FuzzListHeaders(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, czChain, zcKeeper := SetupTest(t) + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper ctx := babylonChain.GetContext() hooks := zcKeeper.Hooks() @@ -164,6 +169,78 @@ func FuzzListHeaders(f *testing.F) { }) } +func FuzzListEpochHeaders(f *testing.F) { + datagen.AddRandomSeedsToFuzzer(f, 10) + + f.Fuzz(func(t *testing.T, seed int64) { + rand.Seed(seed) + + _, babylonChain, czChain, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper + epochingKeeper := babylonApp.EpochingKeeper + + ctx := babylonChain.GetContext() + hooks := zcKeeper.Hooks() + + numReqs := datagen.RandomInt(5) + 1 + + epochNumList := []uint64{datagen.RandomInt(10) + 1} + nextHeightList := []uint64{0} + numHeadersList := []uint64{} + expectedHeadersMap := map[uint64][]*ibctmtypes.Header{} + numForkHeadersList := []uint64{} + + // we test the scenario of ending an epoch for multiple times, in order to ensure that + // consecutive epoch infos do not affect each other. + for i := uint64(0); i < numReqs; i++ { + epochNum := epochNumList[i] + // enter a random epoch + if i == 0 { + for j := uint64(0); j < epochNum; j++ { + epochingKeeper.IncEpoch(ctx) + } + } else { + for j := uint64(0); j < epochNum-epochNumList[i-1]; j++ { + epochingKeeper.IncEpoch(ctx) + } + } + + // generate a random number of headers and fork headers + numHeadersList = append(numHeadersList, datagen.RandomInt(100)+1) + numForkHeadersList = append(numForkHeadersList, datagen.RandomInt(10)+1) + // trigger hooks to append these headers and fork headers + expectedHeaders, _ := SimulateHeadersAndForksViaHook(ctx, hooks, czChain.ChainID, nextHeightList[i], numHeadersList[i], numForkHeadersList[i]) + expectedHeadersMap[epochNum] = expectedHeaders + // prepare nextHeight for the next request + nextHeightList = append(nextHeightList, nextHeightList[i]+numHeadersList[i]) + + // simulate the scenario that a random epoch has ended + hooks.AfterEpochEnds(ctx, epochNum) + // prepare epochNum for the next request + epochNumList = append(epochNumList, epochNum+datagen.RandomInt(10)+1) + } + + // attest the correctness of epoch info for each tested epoch + for i := uint64(0); i < numReqs; i++ { + epochNum := epochNumList[i] + // make request + req := &zctypes.QueryListEpochHeadersRequest{ + ChainId: czChain.ChainID, + EpochNum: epochNum, + } + resp, err := zcKeeper.ListEpochHeaders(ctx, req) + require.NoError(t, err) + + // check if the headers are same as expected + headers := resp.Headers + require.Equal(t, len(expectedHeadersMap[epochNum]), len(headers)) + for j := 0; j < len(expectedHeadersMap[epochNum]); j++ { + require.Equal(t, expectedHeadersMap[epochNum][j].Header.LastCommitHash, headers[j].Hash) + } + } + }) +} + func FuzzFinalizedChainInfo(f *testing.F) { datagen.AddRandomSeedsToFuzzer(f, 10) diff --git a/x/zoneconcierge/keeper/keeper_test.go b/x/zoneconcierge/keeper/keeper_test.go index ff370bb88..1152d6cc8 100644 --- a/x/zoneconcierge/keeper/keeper_test.go +++ b/x/zoneconcierge/keeper/keeper_test.go @@ -13,13 +13,13 @@ import ( ) // SetupTest creates a coordinator with 2 test chains, and a ZoneConcierge keeper. -func SetupTest(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *ibctesting.TestChain, zckeeper.Keeper) { - var zcKeeper zckeeper.Keeper +func SetupTest(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *ibctesting.TestChain, *app.BabylonApp) { + var bbnApp *app.BabylonApp coordinator := ibctesting.NewCoordinator(t, 2) // replace the first test chain with a Babylon chain ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) { babylonApp := app.Setup(t, false) - zcKeeper = babylonApp.ZoneConciergeKeeper + bbnApp = babylonApp encCdc := app.MakeTestEncodingConfig() genesis := app.NewDefaultGenesisState(encCdc.Marshaler) return babylonApp, genesis @@ -30,7 +30,7 @@ func SetupTest(t *testing.T) (*ibctesting.Coordinator, *ibctesting.TestChain, *i babylonChain := coordinator.GetChain(ibctesting.GetChainID(1)) czChain := coordinator.GetChain(ibctesting.GetChainID(2)) - return coordinator, babylonChain, czChain, zcKeeper + return coordinator, babylonChain, czChain, bbnApp } // SimulateHeadersViaHook generates a non-zero number of canonical headers via the hook diff --git a/x/zoneconcierge/keeper/proof_tx_in_block_test.go b/x/zoneconcierge/keeper/proof_tx_in_block_test.go index 92e91e7a1..11944081a 100644 --- a/x/zoneconcierge/keeper/proof_tx_in_block_test.go +++ b/x/zoneconcierge/keeper/proof_tx_in_block_test.go @@ -31,7 +31,9 @@ func TestProveTxInBlock(t *testing.T) { err = testNetwork.WaitForNextBlock() require.NoError(t, err) - _, babylonChain, _, zcKeeper := SetupTest(t) + _, babylonChain, _, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper + ctx := babylonChain.GetContext() // construct client context diff --git a/x/zoneconcierge/keeper/query_kvstore_test.go b/x/zoneconcierge/keeper/query_kvstore_test.go index aaa730ebe..06f619831 100644 --- a/x/zoneconcierge/keeper/query_kvstore_test.go +++ b/x/zoneconcierge/keeper/query_kvstore_test.go @@ -17,7 +17,9 @@ func FuzzQueryStore(f *testing.F) { f.Fuzz(func(t *testing.T, seed int64) { rand.Seed(seed) - _, babylonChain, _, zcKeeper := SetupTest(t) + _, babylonChain, _, babylonApp := SetupTest(t) + zcKeeper := babylonApp.ZoneConciergeKeeper + babylonChain.NextBlock() babylonChain.NextBlock() diff --git a/x/zoneconcierge/types/errors.go b/x/zoneconcierge/types/errors.go index 71cba5771..416c02409 100644 --- a/x/zoneconcierge/types/errors.go +++ b/x/zoneconcierge/types/errors.go @@ -17,7 +17,8 @@ var ( ErrForkNotFound = sdkerrors.Register(ModuleName, 1106, "cannot find fork") ErrInvalidForks = sdkerrors.Register(ModuleName, 1107, "input forks is invalid") ErrEpochChainInfoNotFound = sdkerrors.Register(ModuleName, 1108, "no chain info exists at this epoch") - ErrFinalizedEpochNotFound = sdkerrors.Register(ModuleName, 1109, "cannot find a finalized epoch") - ErrInvalidProofEpochSealed = sdkerrors.Register(ModuleName, 1110, "invalid ProofEpochSealed") - ErrInvalidMerkleProof = sdkerrors.Register(ModuleName, 1111, "invalid Merkle inclusion proof") + ErrEpochHeadersNotFound = sdkerrors.Register(ModuleName, 1109, "no timestamped header exists at this epoch") + ErrFinalizedEpochNotFound = sdkerrors.Register(ModuleName, 1110, "cannot find a finalized epoch") + ErrInvalidProofEpochSealed = sdkerrors.Register(ModuleName, 1111, "invalid ProofEpochSealed") + ErrInvalidMerkleProof = sdkerrors.Register(ModuleName, 1112, "invalid Merkle inclusion proof") ) diff --git a/x/zoneconcierge/types/query.pb.go b/x/zoneconcierge/types/query.pb.go index 32252084d..1e6a5e6ce 100644 --- a/x/zoneconcierge/types/query.pb.go +++ b/x/zoneconcierge/types/query.pb.go @@ -499,6 +499,105 @@ func (m *QueryListHeadersResponse) GetPagination() *query.PageResponse { return nil } +// QueryListEpochHeadersRequest is request type for the Query/ListEpochHeaders RPC method. +type QueryListEpochHeadersRequest struct { + EpochNum uint64 `protobuf:"varint,1,opt,name=epoch_num,json=epochNum,proto3" json:"epoch_num,omitempty"` + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *QueryListEpochHeadersRequest) Reset() { *m = QueryListEpochHeadersRequest{} } +func (m *QueryListEpochHeadersRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListEpochHeadersRequest) ProtoMessage() {} +func (*QueryListEpochHeadersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2caab7ee15063236, []int{10} +} +func (m *QueryListEpochHeadersRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListEpochHeadersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListEpochHeadersRequest.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 *QueryListEpochHeadersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListEpochHeadersRequest.Merge(m, src) +} +func (m *QueryListEpochHeadersRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListEpochHeadersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListEpochHeadersRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListEpochHeadersRequest proto.InternalMessageInfo + +func (m *QueryListEpochHeadersRequest) GetEpochNum() uint64 { + if m != nil { + return m.EpochNum + } + return 0 +} + +func (m *QueryListEpochHeadersRequest) GetChainId() string { + if m != nil { + return m.ChainId + } + return "" +} + +// QueryListEpochHeadersResponse is response type for the Query/ListEpochHeaders RPC method. +type QueryListEpochHeadersResponse struct { + // headers is the list of headers + Headers []*IndexedHeader `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` +} + +func (m *QueryListEpochHeadersResponse) Reset() { *m = QueryListEpochHeadersResponse{} } +func (m *QueryListEpochHeadersResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListEpochHeadersResponse) ProtoMessage() {} +func (*QueryListEpochHeadersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2caab7ee15063236, []int{11} +} +func (m *QueryListEpochHeadersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListEpochHeadersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListEpochHeadersResponse.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 *QueryListEpochHeadersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListEpochHeadersResponse.Merge(m, src) +} +func (m *QueryListEpochHeadersResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListEpochHeadersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListEpochHeadersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListEpochHeadersResponse proto.InternalMessageInfo + +func (m *QueryListEpochHeadersResponse) GetHeaders() []*IndexedHeader { + if m != nil { + return m.Headers + } + return nil +} + // QueryFinalizedChainInfoRequest is request type for the Query/FinalizedChainInfo RPC method. type QueryFinalizedChainInfoRequest struct { // chain_id is the ID of the CZ @@ -511,7 +610,7 @@ func (m *QueryFinalizedChainInfoRequest) Reset() { *m = QueryFinalizedCh func (m *QueryFinalizedChainInfoRequest) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedChainInfoRequest) ProtoMessage() {} func (*QueryFinalizedChainInfoRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2caab7ee15063236, []int{10} + return fileDescriptor_2caab7ee15063236, []int{12} } func (m *QueryFinalizedChainInfoRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -579,7 +678,7 @@ func (m *QueryFinalizedChainInfoResponse) Reset() { *m = QueryFinalizedC func (m *QueryFinalizedChainInfoResponse) String() string { return proto.CompactTextString(m) } func (*QueryFinalizedChainInfoResponse) ProtoMessage() {} func (*QueryFinalizedChainInfoResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2caab7ee15063236, []int{11} + return fileDescriptor_2caab7ee15063236, []int{13} } func (m *QueryFinalizedChainInfoResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -675,6 +774,8 @@ func init() { proto.RegisterType((*QueryEpochChainInfoResponse)(nil), "babylon.zoneconcierge.v1.QueryEpochChainInfoResponse") proto.RegisterType((*QueryListHeadersRequest)(nil), "babylon.zoneconcierge.v1.QueryListHeadersRequest") proto.RegisterType((*QueryListHeadersResponse)(nil), "babylon.zoneconcierge.v1.QueryListHeadersResponse") + proto.RegisterType((*QueryListEpochHeadersRequest)(nil), "babylon.zoneconcierge.v1.QueryListEpochHeadersRequest") + proto.RegisterType((*QueryListEpochHeadersResponse)(nil), "babylon.zoneconcierge.v1.QueryListEpochHeadersResponse") proto.RegisterType((*QueryFinalizedChainInfoRequest)(nil), "babylon.zoneconcierge.v1.QueryFinalizedChainInfoRequest") proto.RegisterType((*QueryFinalizedChainInfoResponse)(nil), "babylon.zoneconcierge.v1.QueryFinalizedChainInfoResponse") } @@ -682,74 +783,77 @@ func init() { func init() { proto.RegisterFile("babylon/zoneconcierge/query.proto", fileDescriptor_2caab7ee15063236) } var fileDescriptor_2caab7ee15063236 = []byte{ - // 1064 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0xce, 0xb6, 0x4d, 0x62, 0x4f, 0x44, 0x54, 0xa6, 0x29, 0xdd, 0x6e, 0xc0, 0x0d, 0x8b, 0xd4, - 0xa6, 0x55, 0xd9, 0xc5, 0xa6, 0x11, 0x44, 0x48, 0x48, 0x75, 0x4b, 0xc1, 0x14, 0x95, 0x74, 0x9b, - 0x48, 0x08, 0x81, 0x56, 0xb3, 0xeb, 0xb1, 0xbd, 0x8a, 0x3d, 0xb3, 0xdd, 0x59, 0xbb, 0x76, 0x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x98, 0xb9, 0x84, 0x8c, 0xdd, 0x57, 0x40, 0xaa, 0x08, 0x6e, 0x43, 0x04, 0x1f, 0xe1, 0xdd, 0xd9, - 0x11, 0x4c, 0x5b, 0x45, 0x99, 0x70, 0xaa, 0x5f, 0xbe, 0x38, 0x2e, 0x69, 0x2f, 0x8f, 0x4b, 0xda, - 0xdf, 0xc7, 0x25, 0xed, 0xc7, 0x93, 0xd2, 0xd2, 0xcb, 0x93, 0xd2, 0xd2, 0x9f, 0x27, 0xa5, 0xa5, - 0xaf, 0x77, 0x9a, 0x41, 0xdc, 0xea, 0x7a, 0x96, 0xcf, 0x3b, 0x29, 0x3d, 0xc0, 0x86, 0xbe, 0xfa, - 0x63, 0xde, 0x60, 0x2e, 0x7b, 0x2b, 0xf0, 0xbf, 0xea, 0xfb, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, - 0x39, 0xca, 0xb6, 0x51, 0x90, 0x0c, 0x00, 0x00, + // 1116 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdd, 0x8e, 0xdb, 0x44, + 0x14, 0x5e, 0xb7, 0xfb, 0x97, 0x59, 0xb1, 0x5a, 0xa6, 0x5b, 0xea, 0x7a, 0xdb, 0x74, 0x31, 0x52, + 0xbb, 0xad, 0x8a, 0x4d, 0x42, 0x97, 0xb2, 0x42, 0x02, 0x6d, 0x5a, 0x5a, 0x42, 0x51, 0xd9, 0xba, + 0xbb, 0x08, 0x21, 0x90, 0x65, 0x3b, 0x93, 0xc4, 0xda, 0x64, 0xc6, 0xb5, 0x9d, 0x34, 0x69, 0xe9, + 0x0d, 0x2f, 0x00, 0x12, 0x37, 0x3c, 0x41, 0x91, 0x78, 0x92, 0x22, 0xf5, 0xa2, 0x12, 0x37, 0x5c, + 0x21, 0xb4, 0xcb, 0x2b, 0x70, 0x8f, 0x7c, 0x66, 0xec, 0xd8, 0x49, 0x4c, 0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0xa9, 0xdc, 0x9c, 0x19, 0x27, + 0xb4, 0xdf, 0x05, 0xed, 0xbb, 0xf8, 0x93, 0x59, 0xb4, 0x8f, 0xeb, 0xfd, 0x4b, 0x09, 0xe1, 0x51, + 0x33, 0xc3, 0x1f, 0x4e, 0x10, 0x96, 0xeb, 0xa9, 0xca, 0xce, 0x09, 0x90, 0xa2, 0xa8, 0x5d, 0x28, + 0xea, 0x23, 0xbc, 0x93, 0x5f, 0xd4, 0x38, 0x67, 0x4d, 0x55, 0x58, 0xf9, 0xf2, 0xc5, 0x51, 0x51, + 0x7a, 0x75, 0x54, 0x94, 0xfe, 0x3e, 0x2a, 0x4a, 0x3f, 0x1d, 0x17, 0xe7, 0x5e, 0x1d, 0x17, 0xe7, + 0xfe, 0x3c, 0x2e, 0xce, 0x7d, 0xb3, 0xdd, 0x70, 0xc3, 0x66, 0xc7, 0xd6, 0x1c, 0xd6, 0x8e, 0xe9, + 0x01, 0x96, 0xe4, 0xea, 0x0d, 0x65, 0x03, 0x9b, 0xb1, 0x17, 0xe1, 0xcf, 0x86, 0xf7, 0xff, 0x0b, + 0x00, 0x00, 0xff, 0xff, 0x20, 0x72, 0xc5, 0x73, 0x1b, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -774,6 +878,8 @@ type QueryClient interface { EpochChainInfo(ctx context.Context, in *QueryEpochChainInfoRequest, opts ...grpc.CallOption) (*QueryEpochChainInfoResponse, error) // ListHeaders queries the headers of a chain in Babylon's view, with pagination support ListHeaders(ctx context.Context, in *QueryListHeadersRequest, opts ...grpc.CallOption) (*QueryListHeadersResponse, error) + // ListEpochHeaders queries the headers of a chain timestamped in a given epoch of Babylon, with pagination support + ListEpochHeaders(ctx context.Context, in *QueryListEpochHeadersRequest, opts ...grpc.CallOption) (*QueryListEpochHeadersResponse, error) // FinalizedChainInfo queries the BTC-finalised info of a chain, with proofs FinalizedChainInfo(ctx context.Context, in *QueryFinalizedChainInfoRequest, opts ...grpc.CallOption) (*QueryFinalizedChainInfoResponse, error) } @@ -831,6 +937,15 @@ func (c *queryClient) ListHeaders(ctx context.Context, in *QueryListHeadersReque return out, nil } +func (c *queryClient) ListEpochHeaders(ctx context.Context, in *QueryListEpochHeadersRequest, opts ...grpc.CallOption) (*QueryListEpochHeadersResponse, error) { + out := new(QueryListEpochHeadersResponse) + err := c.cc.Invoke(ctx, "/babylon.zoneconcierge.v1.Query/ListEpochHeaders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) FinalizedChainInfo(ctx context.Context, in *QueryFinalizedChainInfoRequest, opts ...grpc.CallOption) (*QueryFinalizedChainInfoResponse, error) { out := new(QueryFinalizedChainInfoResponse) err := c.cc.Invoke(ctx, "/babylon.zoneconcierge.v1.Query/FinalizedChainInfo", in, out, opts...) @@ -852,6 +967,8 @@ type QueryServer interface { EpochChainInfo(context.Context, *QueryEpochChainInfoRequest) (*QueryEpochChainInfoResponse, error) // ListHeaders queries the headers of a chain in Babylon's view, with pagination support ListHeaders(context.Context, *QueryListHeadersRequest) (*QueryListHeadersResponse, error) + // ListEpochHeaders queries the headers of a chain timestamped in a given epoch of Babylon, with pagination support + ListEpochHeaders(context.Context, *QueryListEpochHeadersRequest) (*QueryListEpochHeadersResponse, error) // FinalizedChainInfo queries the BTC-finalised info of a chain, with proofs FinalizedChainInfo(context.Context, *QueryFinalizedChainInfoRequest) (*QueryFinalizedChainInfoResponse, error) } @@ -875,6 +992,9 @@ func (*UnimplementedQueryServer) EpochChainInfo(ctx context.Context, req *QueryE func (*UnimplementedQueryServer) ListHeaders(ctx context.Context, req *QueryListHeadersRequest) (*QueryListHeadersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListHeaders not implemented") } +func (*UnimplementedQueryServer) ListEpochHeaders(ctx context.Context, req *QueryListEpochHeadersRequest) (*QueryListEpochHeadersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListEpochHeaders not implemented") +} func (*UnimplementedQueryServer) FinalizedChainInfo(ctx context.Context, req *QueryFinalizedChainInfoRequest) (*QueryFinalizedChainInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method FinalizedChainInfo not implemented") } @@ -973,6 +1093,24 @@ func _Query_ListHeaders_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_ListEpochHeaders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListEpochHeadersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListEpochHeaders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/babylon.zoneconcierge.v1.Query/ListEpochHeaders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListEpochHeaders(ctx, req.(*QueryListEpochHeadersRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_FinalizedChainInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryFinalizedChainInfoRequest) if err := dec(in); err != nil { @@ -1015,6 +1153,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "ListHeaders", Handler: _Query_ListHeaders_Handler, }, + { + MethodName: "ListEpochHeaders", + Handler: _Query_ListEpochHeaders_Handler, + }, { MethodName: "FinalizedChainInfo", Handler: _Query_FinalizedChainInfo_Handler, @@ -1361,6 +1503,78 @@ func (m *QueryListHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *QueryListEpochHeadersRequest) 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 *QueryListEpochHeadersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListEpochHeadersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if m.EpochNum != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.EpochNum)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryListEpochHeadersResponse) 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 *QueryListEpochHeadersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListEpochHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Headers) > 0 { + for iNdEx := len(m.Headers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Headers[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 *QueryFinalizedChainInfoRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1668,6 +1882,37 @@ func (m *QueryListHeadersResponse) Size() (n int) { return n } +func (m *QueryListEpochHeadersRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EpochNum != 0 { + n += 1 + sovQuery(uint64(m.EpochNum)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryListEpochHeadersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Headers) > 0 { + for _, e := range m.Headers { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryFinalizedChainInfoRequest) Size() (n int) { if m == nil { return 0 @@ -2591,6 +2836,191 @@ func (m *QueryListHeadersResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryListEpochHeadersRequest) 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: QueryListEpochHeadersRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListEpochHeadersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochNum", wireType) + } + m.EpochNum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochNum |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", 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.ChainId = 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 *QueryListEpochHeadersResponse) 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: QueryListEpochHeadersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListEpochHeadersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Headers", 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.Headers = append(m.Headers, &IndexedHeader{}) + if err := m.Headers[len(m.Headers)-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 *QueryFinalizedChainInfoRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/zoneconcierge/types/query.pb.gw.go b/x/zoneconcierge/types/query.pb.gw.go index 96e69913c..4badc5d0f 100644 --- a/x/zoneconcierge/types/query.pb.gw.go +++ b/x/zoneconcierge/types/query.pb.gw.go @@ -271,6 +271,82 @@ func local_request_Query_ListHeaders_0(ctx context.Context, marshaler runtime.Ma } +func request_Query_ListEpochHeaders_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListEpochHeadersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + + val, ok = pathParams["epoch_num"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_num") + } + + protoReq.EpochNum, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_num", err) + } + + msg, err := client.ListEpochHeaders(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ListEpochHeaders_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListEpochHeadersRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + + val, ok = pathParams["epoch_num"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "epoch_num") + } + + protoReq.EpochNum, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "epoch_num", err) + } + + msg, err := server.ListEpochHeaders(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_FinalizedChainInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{"chain_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) @@ -464,6 +540,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_ListEpochHeaders_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_ListEpochHeaders_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_ListEpochHeaders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_FinalizedChainInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -628,6 +727,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_ListEpochHeaders_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_ListEpochHeaders_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_ListEpochHeaders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_FinalizedChainInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -662,6 +781,8 @@ var ( pattern_Query_ListHeaders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "zoneconcierge", "v1", "headers", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ListEpochHeaders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"babylon", "zoneconcierge", "v1", "headers", "chain_id", "epochs", "epoch_num"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_FinalizedChainInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"babylon", "zoneconcierge", "v1", "finalized_chain_info", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -676,5 +797,7 @@ var ( forward_Query_ListHeaders_0 = runtime.ForwardResponseMessage + forward_Query_ListEpochHeaders_0 = runtime.ForwardResponseMessage + forward_Query_FinalizedChainInfo_0 = runtime.ForwardResponseMessage )