diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 2497a2a35..306482f31 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -515,26 +515,24 @@ paths: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant - information about a + BTCHeaderInfoResponse is a structure that contains all + relevant information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. - Total work spent on the header. This is the sum of the work corresponding to the header Bits field and the total work of the header. @@ -856,26 +854,24 @@ paths: items: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant - information about a + BTCHeaderInfoResponse is a structure that contains all + relevant information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. - Total work spent on the header. This is the sum of the work corresponding to the header Bits field and the total work of the header. @@ -1054,26 +1050,24 @@ paths: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant - information about a + BTCHeaderInfoResponse is a structure that contains all + relevant information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. - Total work spent on the header. This is the sum of the work corresponding to the header Bits field and the total work of the header. @@ -10299,29 +10293,27 @@ definitions: "@type": "type.googleapis.com/google.protobuf.Duration", "value": "1.212s" } - babylon.btclightclient.v1.BTCHeaderInfo: + babylon.btclightclient.v1.BTCHeaderInfoResponse: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information about - a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. - Total work spent on the header. This is the sum of the work corresponding to the header Bits field and the total work of the header. @@ -10344,26 +10336,24 @@ definitions: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information - about a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. - Total work spent on the header. This is the sum of the work corresponding to the header Bits field and the total work of the header. @@ -10440,26 +10430,24 @@ definitions: items: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information - about a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. - Total work spent on the header. This is the sum of the work corresponding to the header Bits field and the total work of the header. @@ -10515,26 +10503,24 @@ definitions: header: type: object properties: - header: + header_hex: type: string - format: byte - hash: + hash_hex: type: string - format: byte height: type: string format: uint64 work: type: string - format: byte + description: Work is the sdkmath.Uint as string. description: >- - BTCHeaderInfo is a structure that contains all relevant information - about a + BTCHeaderInfoResponse is a structure that contains all relevant + information about a - BTC header - - Full header bytes - - Header hash for easy retrieval - - Height of the header in the BTC chain + BTC header response + - Full header as string hex. + - Header hash for easy retrieval as string hex. + - Height of the header in the BTC chain. - Total work spent on the header. This is the sum of the work corresponding to the header Bits field and the total work of the header. @@ -14960,7 +14946,7 @@ definitions: epoch have signed `app_hash` of the sealer header - - The epoch medatata is committed to the `app_hash` of the sealer header + - The epoch metadata 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.ProofFinalizedChainInfo: diff --git a/proto/babylon/btclightclient/v1/query.proto b/proto/babylon/btclightclient/v1/query.proto index 146cbf601..60ae07cc2 100644 --- a/proto/babylon/btclightclient/v1/query.proto +++ b/proto/babylon/btclightclient/v1/query.proto @@ -2,9 +2,9 @@ syntax = "proto3"; package babylon.btclightclient.v1; import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -import "babylon/btclightclient/v1/btclightclient.proto"; import "babylon/btclightclient/v1/params.proto"; option go_package = "github.com/babylonchain/babylon/x/btclightclient/types"; @@ -108,7 +108,7 @@ message QueryMainChainRequest { // QueryMainChainResponse is response type for the Query/MainChain RPC method. message QueryMainChainResponse { - repeated BTCHeaderInfo headers = 1; + repeated BTCHeaderInfoResponse headers = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -117,7 +117,7 @@ message QueryMainChainResponse { message QueryTipRequest {} // QueryTipResponse is the response type for the Query/Tip RPC method. -message QueryTipResponse { BTCHeaderInfo header = 1; } +message QueryTipResponse { BTCHeaderInfoResponse header = 1; } // QueryBaseHeaderRequest is the request type for the Query/BaseHeader RPC // method. @@ -125,7 +125,7 @@ message QueryBaseHeaderRequest {} // QueryBaseHeaderResponse is the response type for the Query/BaseHeader RPC // method. -message QueryBaseHeaderResponse { BTCHeaderInfo header = 1; } +message QueryBaseHeaderResponse { BTCHeaderInfoResponse header = 1; } // QueryMainChainDepthRequest is the request type for the Query/MainChainDepth RPC // it contains hex encoded hash of btc block header as parameter @@ -134,3 +134,23 @@ message QueryHeaderDepthRequest { string hash = 1; } // QueryMainChainDepthResponse is the response type for the Query/MainChainDepth RPC // it contains depth of the block in main chain message QueryHeaderDepthResponse { uint64 depth = 1; } + +// BTCHeaderInfoResponse is a structure that contains all relevant information about a +// BTC header response +// - Full header as string hex. +// - Header hash for easy retrieval as string hex. +// - Height of the header in the BTC chain. +// - Total work spent on the header. This is the sum of the work corresponding +// to the header Bits field +// and the total work of the header. +message BTCHeaderInfoResponse { + string header_hex = 1; + string hash_hex = 2; + uint64 height = 3; + // Work is the sdkmath.Uint as string. + string work = 4 [ + (cosmos_proto.scalar) = "cosmos.Uint", + (gogoproto.customtype) = "cosmossdk.io/math.Uint", + (gogoproto.nullable) = false + ]; +} diff --git a/test/e2e/btc_staking_e2e_test.go b/test/e2e/btc_staking_e2e_test.go index e72f88682..04aa36010 100644 --- a/test/e2e/btc_staking_e2e_test.go +++ b/test/e2e/btc_staking_e2e_test.go @@ -16,6 +16,7 @@ import ( "github.com/babylonchain/babylon/crypto/eots" "github.com/babylonchain/babylon/test/e2e/configurer" + "github.com/babylonchain/babylon/test/e2e/configurer/chain" "github.com/babylonchain/babylon/test/e2e/initialization" "github.com/babylonchain/babylon/testutil/datagen" bbn "github.com/babylonchain/babylon/types" @@ -140,8 +141,11 @@ func (s *BTCStakingTestSuite) Test1CreateFinalityProviderAndDelegation() { s.NoError(err) // submit staking tx to Bitcoin and get inclusion proof - currentBtcTip, err := nonValidatorNode.QueryTip() + currentBtcTipResp, err := nonValidatorNode.QueryTip() + s.NoError(err) + currentBtcTip, err := chain.ParseBTCHeaderInfoResponseToInfo(currentBtcTipResp) s.NoError(err) + blockWithStakingTx := datagen.CreateBlockWithTransaction(r, currentBtcTip.Header.ToBlockHeader(), stakingMsgTx) nonValidatorNode.InsertHeader(&blockWithStakingTx.HeaderBytes) // make block k-deep diff --git a/test/e2e/btc_timestamping_e2e_test.go b/test/e2e/btc_timestamping_e2e_test.go index 0f7fb1804..db447f5d5 100644 --- a/test/e2e/btc_timestamping_e2e_test.go +++ b/test/e2e/btc_timestamping_e2e_test.go @@ -73,7 +73,7 @@ func (s *BTCTimestampingTestSuite) Test2BTCBaseHeader() { s.NoError(err) baseHeader, err := nonValidatorNode.QueryBtcBaseHeader() s.NoError(err) - s.True(baseHeader.Hash.Eq(hardcodedHeader.Hash())) + s.Equal(baseHeader.HeaderHex, hardcodedHeader.MarshalHex()) s.Equal(hardcodedHeaderHeight, baseHeader.Height) } @@ -94,11 +94,11 @@ func (s *BTCTimestampingTestSuite) Test3SendTx() { s.Equal(tip1.Height+1, tip2.Height) // check that light client properly updates its state - tip1Depth, err := nonValidatorNode.QueryHeaderDepth(tip1.Hash.MarshalHex()) + tip1Depth, err := nonValidatorNode.QueryHeaderDepth(tip1.HashHex) s.NoError(err) s.Equal(tip1Depth, uint64(1)) - tip2Depth, err := nonValidatorNode.QueryHeaderDepth(tip2.Hash.MarshalHex()) + tip2Depth, err := nonValidatorNode.QueryHeaderDepth(tip2.HashHex) s.NoError(err) // tip should have 0 depth s.Equal(tip2Depth, uint64(0)) diff --git a/test/e2e/configurer/chain/commands.go b/test/e2e/configurer/chain/commands.go index 94335bc60..90dae8a8d 100644 --- a/test/e2e/configurer/chain/commands.go +++ b/test/e2e/configurer/chain/commands.go @@ -86,12 +86,16 @@ func (n *NodeConfig) SendHeaderHex(headerHex string) { } func (n *NodeConfig) InsertNewEmptyBtcHeader(r *rand.Rand) *blc.BTCHeaderInfo { - tip, err := n.QueryTip() + tipResp, err := n.QueryTip() require.NoError(n.t, err) - n.t.Logf("Retrieved current tip of btc headerchain. Height: %d", tip.Height) + n.t.Logf("Retrieved current tip of btc headerchain. Height: %d", tipResp.Height) + + tip, err := ParseBTCHeaderInfoResponseToInfo(tipResp) + require.NoError(n.t, err) + child := datagen.GenRandomValidBTCHeaderInfoWithParent(r, *tip) n.SendHeaderHex(child.Header.MarshalHex()) - n.WaitUntilBtcHeight(tip.Height + 1) + n.WaitUntilBtcHeight(tipResp.Height + 1) return child } @@ -140,7 +144,7 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { for _, checkpoint := range resp.RawCheckpoints { require.Equal(n.t, checkpoint.Status, cttypes.Sealed) - currentBtcTip, err := n.QueryTip() + currentBtcTipResp, err := n.QueryTip() require.NoError(n.t, err) _, submitterAddr, err := bech32.DecodeAndConvert(n.PublicAddress) @@ -160,6 +164,9 @@ func (n *NodeConfig) FinalizeSealedEpochs(startEpoch uint64, lastEpoch uint64) { require.NoError(n.t, err) tx1 := datagen.CreatOpReturnTransaction(r, p1) + currentBtcTip, err := ParseBTCHeaderInfoResponseToInfo(currentBtcTipResp) + require.NoError(n.t, err) + opReturn1 := datagen.CreateBlockWithTransaction(r, currentBtcTip.Header.ToBlockHeader(), tx1) tx2 := datagen.CreatOpReturnTransaction(r, p2) opReturn2 := datagen.CreateBlockWithTransaction(r, opReturn1.HeaderBytes.ToBlockHeader(), tx2) @@ -224,3 +231,23 @@ func (n *NodeConfig) WithdrawReward(sType, from string) { require.NoError(n.t, err) n.LogActionF("successfully withdrawn") } + +// ParseBTCHeaderInfoResponseToInfo turns an BTCHeaderInfoResponse back to BTCHeaderInfo. +func ParseBTCHeaderInfoResponseToInfo(r *blc.BTCHeaderInfoResponse) (*blc.BTCHeaderInfo, error) { + header, err := bbn.NewBTCHeaderBytesFromHex(r.HeaderHex) + if err != nil { + return nil, err + } + + hash, err := bbn.NewBTCHeaderHashBytesFromHex(r.HashHex) + if err != nil { + return nil, err + } + + return &blc.BTCHeaderInfo{ + Header: &header, + Hash: &hash, + Height: r.Height, + Work: &r.Work, + }, nil +} diff --git a/test/e2e/configurer/chain/queries.go b/test/e2e/configurer/chain/queries.go index 48b5dba6a..26be927aa 100644 --- a/test/e2e/configurer/chain/queries.go +++ b/test/e2e/configurer/chain/queries.go @@ -206,7 +206,7 @@ func (n *NodeConfig) QueryRawCheckpoints(pagination *query.PageRequest) (*ct.Que return &checkpointingResponse, nil } -func (n *NodeConfig) QueryBtcBaseHeader() (*blc.BTCHeaderInfo, error) { +func (n *NodeConfig) QueryBtcBaseHeader() (*blc.BTCHeaderInfoResponse, error) { bz, err := n.QueryGRPCGateway("babylon/btclightclient/v1/baseheader", url.Values{}) require.NoError(n.t, err) @@ -218,7 +218,7 @@ func (n *NodeConfig) QueryBtcBaseHeader() (*blc.BTCHeaderInfo, error) { return blcResponse.Header, nil } -func (n *NodeConfig) QueryTip() (*blc.BTCHeaderInfo, error) { +func (n *NodeConfig) QueryTip() (*blc.BTCHeaderInfoResponse, error) { bz, err := n.QueryGRPCGateway("babylon/btclightclient/v1/tip", url.Values{}) require.NoError(n.t, err) diff --git a/x/btclightclient/keeper/grpc_query.go b/x/btclightclient/keeper/grpc_query.go index c3230435e..567c51b19 100644 --- a/x/btclightclient/keeper/grpc_query.go +++ b/x/btclightclient/keeper/grpc_query.go @@ -77,13 +77,12 @@ func (k Keeper) ContainsBytes(ctx context.Context, req *types.QueryContainsBytes return &types.QueryContainsBytesResponse{Contains: contains}, nil } -func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) (*types.QueryMainChainResponse, error) { +func (k Keeper) MainChain(c context.Context, req *types.QueryMainChainRequest) (*types.QueryMainChainResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - sdkCtx := sdk.UnwrapSDKContext(ctx) - + ctx := sdk.UnwrapSDKContext(c) if req.Pagination == nil { req.Pagination = &query.PageRequest{} } @@ -98,7 +97,7 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) if err != nil { return nil, status.Error(codes.InvalidArgument, "key does not correspond to a header hash") } - keyHeader, err = k.headersState(sdkCtx).GetHeaderByHash(&headerHash) + keyHeader, err = k.headersState(ctx).GetHeaderByHash(&headerHash) if err != nil { return nil, status.Error(codes.InvalidArgument, "header specified by key does not exist") } @@ -108,10 +107,10 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) var nextKey []byte if req.Pagination.Reverse { var start, end uint64 - baseHeader := k.headersState(sdkCtx).BaseHeader() + baseHeader := k.headersState(ctx).BaseHeader() // The base header is located at the end of the mainchain // which requires starting at the end - mainchain := k.GetMainChainFrom(sdkCtx, 0) + mainchain := k.GetMainChainFrom(ctx, 0) if keyHeader == nil { keyHeader = baseHeader @@ -135,7 +134,7 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) nextKey = mainchain[end].Hash.MustMarshal() } } else { - tip := k.headersState(sdkCtx).GetTip() + tip := k.headersState(ctx).GetTip() // If there is no starting key, then the starting header is the tip if keyHeader == nil { keyHeader = tip @@ -146,7 +145,7 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) // -1 because the depth denotes how many headers have been built on top of it depth := startHeaderDepth + req.Pagination.Limit - 1 // Retrieve the mainchain up to the depth - mainchain := k.GetMainChainUpTo(sdkCtx, depth) + mainchain := k.GetMainChainUpTo(ctx, depth) // Check whether the key provided is part of the mainchain if uint64(len(mainchain)) <= startHeaderDepth || !mainchain[startHeaderDepth].Eq(keyHeader) { return nil, status.Error(codes.InvalidArgument, "header specified by key is not a part of the mainchain") @@ -161,19 +160,17 @@ func (k Keeper) MainChain(ctx context.Context, req *types.QueryMainChainRequest) NextKey: nextKey, } // The headers that we should return start from the depth of the start header - return &types.QueryMainChainResponse{Headers: headers, Pagination: pageRes}, nil + return &types.QueryMainChainResponse{Headers: types.ParseBTCHeadersToResponse(headers), Pagination: pageRes}, nil } -func (k Keeper) Tip(ctx context.Context, req *types.QueryTipRequest) (*types.QueryTipResponse, error) { +func (k Keeper) Tip(c context.Context, req *types.QueryTipRequest) (*types.QueryTipResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - sdkCtx := sdk.UnwrapSDKContext(ctx) - - tip := k.headersState(sdkCtx).GetTip() - - return &types.QueryTipResponse{Header: tip}, nil + ctx := sdk.UnwrapSDKContext(c) + tip := k.headersState(ctx).GetTip() + return &types.QueryTipResponse{Header: tip.ToResponse()}, nil } func (k Keeper) BaseHeader(ctx context.Context, req *types.QueryBaseHeaderRequest) (*types.QueryBaseHeaderResponse, error) { @@ -185,7 +182,7 @@ func (k Keeper) BaseHeader(ctx context.Context, req *types.QueryBaseHeaderReques baseHeader := k.headersState(sdkCtx).BaseHeader() - return &types.QueryBaseHeaderResponse{Header: baseHeader}, nil + return &types.QueryBaseHeaderResponse{Header: baseHeader.ToResponse()}, nil } func (k Keeper) HeaderDepth(ctx context.Context, req *types.QueryHeaderDepthRequest) (*types.QueryHeaderDepthResponse, error) { diff --git a/x/btclightclient/keeper/grpc_query_test.go b/x/btclightclient/keeper/grpc_query_test.go index c5ea9e5f4..15289a490 100644 --- a/x/btclightclient/keeper/grpc_query_test.go +++ b/x/btclightclient/keeper/grpc_query_test.go @@ -300,7 +300,7 @@ func FuzzMainChainQuery(f *testing.F) { } if !resp.Headers[i].Eq(mainchain[idx]) { t.Errorf("%t", reverse) - t.Errorf("Response does not match mainchain. Expected %s got %s", mainchain[idx].Hash, resp.Headers[i].Hash) + t.Errorf("Response does not match mainchain. Expected %s got %s", mainchain[idx].Hash, resp.Headers[i].HashHex) } mcIdx += 1 } @@ -356,7 +356,7 @@ func FuzzTipQuery(f *testing.F) { t.Fatalf("Valid input led to nil response") } if !resp.Header.Eq(chain.GetTipInfo()) { - t.Errorf("Invalid header returned. Expected %s, got %s", chain.GetTipInfo().Hash, resp.Header.Hash) + t.Errorf("Invalid header returned. Expected %s, got %s", chain.GetTipInfo().Hash, resp.Header.HeaderHex) } }) } @@ -402,7 +402,7 @@ func FuzzBaseHeaderQuery(f *testing.F) { t.Fatalf("Valid input led to nil response") } if !resp.Header.Eq(base) { - t.Errorf("Invalid header returned. Expected %s, got %s", base.Hash, resp.Header.Hash) + t.Errorf("Invalid header returned. Expected %s, got %s", base.Hash, resp.Header.HashHex) } }) } diff --git a/x/btclightclient/types/query.go b/x/btclightclient/types/query.go new file mode 100644 index 000000000..a0deed675 --- /dev/null +++ b/x/btclightclient/types/query.go @@ -0,0 +1,25 @@ +package types + +// ToResponse parses one BTC Header Info to BTCHeaderInfoResp. +func (b *BTCHeaderInfo) ToResponse() *BTCHeaderInfoResponse { + return &BTCHeaderInfoResponse{ + HeaderHex: b.Header.MarshalHex(), + HashHex: b.Hash.MarshalHex(), + Height: b.Height, + Work: *b.Work, + } +} + +// ParseBTCHeadersToResponse parses the infos into resposes. +func ParseBTCHeadersToResponse(infos []*BTCHeaderInfo) (resp []*BTCHeaderInfoResponse) { + resp = make([]*BTCHeaderInfoResponse, len(infos)) + for i, info := range infos { + resp[i] = info.ToResponse() + } + return resp +} + +// Eq returns true if the hashes are equal. +func (m *BTCHeaderInfoResponse) Eq(other *BTCHeaderInfo) bool { + return m.HashHex == other.Hash.MarshalHex() +} diff --git a/x/btclightclient/types/query.pb.go b/x/btclightclient/types/query.pb.go index 65d640b56..6148e7143 100644 --- a/x/btclightclient/types/query.pb.go +++ b/x/btclightclient/types/query.pb.go @@ -5,8 +5,10 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_babylonchain_babylon_types "github.com/babylonchain/babylon/types" + _ "github.com/cosmos/cosmos-proto" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" @@ -430,8 +432,8 @@ func (m *QueryMainChainRequest) GetPagination() *query.PageRequest { // QueryMainChainResponse is response type for the Query/MainChain RPC method. type QueryMainChainResponse struct { - Headers []*BTCHeaderInfo `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + Headers []*BTCHeaderInfoResponse `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryMainChainResponse) Reset() { *m = QueryMainChainResponse{} } @@ -467,7 +469,7 @@ func (m *QueryMainChainResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryMainChainResponse proto.InternalMessageInfo -func (m *QueryMainChainResponse) GetHeaders() []*BTCHeaderInfo { +func (m *QueryMainChainResponse) GetHeaders() []*BTCHeaderInfoResponse { if m != nil { return m.Headers } @@ -520,7 +522,7 @@ var xxx_messageInfo_QueryTipRequest proto.InternalMessageInfo // QueryTipResponse is the response type for the Query/Tip RPC method. type QueryTipResponse struct { - Header *BTCHeaderInfo `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + Header *BTCHeaderInfoResponse `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` } func (m *QueryTipResponse) Reset() { *m = QueryTipResponse{} } @@ -556,7 +558,7 @@ func (m *QueryTipResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryTipResponse proto.InternalMessageInfo -func (m *QueryTipResponse) GetHeader() *BTCHeaderInfo { +func (m *QueryTipResponse) GetHeader() *BTCHeaderInfoResponse { if m != nil { return m.Header } @@ -604,7 +606,7 @@ var xxx_messageInfo_QueryBaseHeaderRequest proto.InternalMessageInfo // QueryBaseHeaderResponse is the response type for the Query/BaseHeader RPC // method. type QueryBaseHeaderResponse struct { - Header *BTCHeaderInfo `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + Header *BTCHeaderInfoResponse `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` } func (m *QueryBaseHeaderResponse) Reset() { *m = QueryBaseHeaderResponse{} } @@ -640,7 +642,7 @@ func (m *QueryBaseHeaderResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBaseHeaderResponse proto.InternalMessageInfo -func (m *QueryBaseHeaderResponse) GetHeader() *BTCHeaderInfo { +func (m *QueryBaseHeaderResponse) GetHeader() *BTCHeaderInfoResponse { if m != nil { return m.Header } @@ -739,6 +741,76 @@ func (m *QueryHeaderDepthResponse) GetDepth() uint64 { return 0 } +// BTCHeaderInfoResponse is a structure that contains all relevant information about a +// BTC header response +// - Full header as string hex. +// - Header hash for easy retrieval as string hex. +// - Height of the header in the BTC chain. +// - Total work spent on the header. This is the sum of the work corresponding +// to the header Bits field +// and the total work of the header. +type BTCHeaderInfoResponse struct { + HeaderHex string `protobuf:"bytes,1,opt,name=header_hex,json=headerHex,proto3" json:"header_hex,omitempty"` + HashHex string `protobuf:"bytes,2,opt,name=hash_hex,json=hashHex,proto3" json:"hash_hex,omitempty"` + Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + // Work is the sdkmath.Uint as string. + Work cosmossdk_io_math.Uint `protobuf:"bytes,4,opt,name=work,proto3,customtype=cosmossdk.io/math.Uint" json:"work"` +} + +func (m *BTCHeaderInfoResponse) Reset() { *m = BTCHeaderInfoResponse{} } +func (m *BTCHeaderInfoResponse) String() string { return proto.CompactTextString(m) } +func (*BTCHeaderInfoResponse) ProtoMessage() {} +func (*BTCHeaderInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3961270631e52721, []int{16} +} +func (m *BTCHeaderInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCHeaderInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCHeaderInfoResponse.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 *BTCHeaderInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCHeaderInfoResponse.Merge(m, src) +} +func (m *BTCHeaderInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *BTCHeaderInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_BTCHeaderInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCHeaderInfoResponse proto.InternalMessageInfo + +func (m *BTCHeaderInfoResponse) GetHeaderHex() string { + if m != nil { + return m.HeaderHex + } + return "" +} + +func (m *BTCHeaderInfoResponse) GetHashHex() string { + if m != nil { + return m.HashHex + } + return "" +} + +func (m *BTCHeaderInfoResponse) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "babylon.btclightclient.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "babylon.btclightclient.v1.QueryParamsResponse") @@ -756,6 +828,7 @@ func init() { proto.RegisterType((*QueryBaseHeaderResponse)(nil), "babylon.btclightclient.v1.QueryBaseHeaderResponse") proto.RegisterType((*QueryHeaderDepthRequest)(nil), "babylon.btclightclient.v1.QueryHeaderDepthRequest") proto.RegisterType((*QueryHeaderDepthResponse)(nil), "babylon.btclightclient.v1.QueryHeaderDepthResponse") + proto.RegisterType((*BTCHeaderInfoResponse)(nil), "babylon.btclightclient.v1.BTCHeaderInfoResponse") } func init() { @@ -763,59 +836,65 @@ func init() { } var fileDescriptor_3961270631e52721 = []byte{ - // 823 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x4f, 0x13, 0x4d, - 0x18, 0xc7, 0xbb, 0xfc, 0xe8, 0x0b, 0xc3, 0xfb, 0xe6, 0xd5, 0xb1, 0x6a, 0xd9, 0x98, 0x02, 0x8b, - 0x94, 0x02, 0xb2, 0x43, 0x8b, 0x1a, 0x0e, 0x26, 0x9a, 0x62, 0x14, 0x0f, 0x26, 0xb5, 0x69, 0x3c, - 0xa8, 0x89, 0x99, 0x96, 0x71, 0x77, 0x13, 0xba, 0xb3, 0x74, 0x17, 0x62, 0x63, 0xbc, 0x78, 0xf0, - 0x6c, 0xf4, 0xe6, 0xc1, 0x83, 0x89, 0xf1, 0xe6, 0xc9, 0x3f, 0x82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86, 0x7c, 0x52, 0xd0, 0x85, 0x6e, 0x07, 0xe0, 0x2a, 0xa2, - 0x7f, 0x4c, 0x31, 0x34, 0x79, 0x4b, 0x26, 0x0a, 0xb9, 0x3e, 0x97, 0xbb, 0x35, 0xe1, 0x7b, 0xf6, - 0x33, 0x5e, 0x0e, 0x84, 0xa7, 0x77, 0x25, 0xce, 0xa2, 0xff, 0x05, 0x66, 0xc5, 0x72, 0x82, 0x57, - 0xb2, 0x82, 0xce, 0xb4, 0x97, 0x80, 0xf9, 0x16, 0x4a, 0x4a, 0x6b, 0x18, 0x49, 0x7c, 0x64, 0xd0, - 0x69, 0x69, 0x98, 0x47, 0x91, 0xba, 0x4c, 0x6e, 0x07, 0x7e, 0x8f, 0xd1, 0xc5, 0x9e, 0x9d, 0x53, - 0xb3, 0x5d, 0x86, 0xe6, 0x72, 0xeb, 0x36, 0x73, 0x3c, 0xf3, 0xb8, 0x1b, 0x35, 0x0e, 0x37, 0x6a, - 0x05, 0xa5, 0x7b, 0xcb, 0x01, 0x26, 0x85, 0x46, 0x37, 0xfd, 0x05, 0x21, 0x18, 0x29, 0xcb, 0x87, - 0xc2, 0xef, 0x71, 0x34, 0x2a, 0x24, 0xf8, 0xad, 0x82, 0x92, 0x32, 0x8b, 0xf0, 0x72, 0x1f, 0xce, - 0xde, 0x10, 0x54, 0xf5, 0xb8, 0xe5, 0x92, 0x44, 0x5b, 0x78, 0xf5, 0xed, 0xd7, 0xbb, 0xa1, 0x59, - 0x3c, 0x43, 0xa2, 0xb2, 0x57, 0x40, 0xc9, 0x90, 0x8a, 0x86, 0x0a, 0x65, 0x65, 0x34, 0x54, 0x38, - 0xfb, 0x62, 0x41, 0x41, 0xa0, 0xbd, 0x57, 0xd0, 0x58, 0xf0, 0xce, 0x62, 0x12, 0xe5, 0xd3, 0x95, - 0x56, 0xea, 0x4a, 0x7c, 0x01, 0xa0, 0x2d, 0x09, 0xb4, 0x39, 0x3c, 0xdb, 0x07, 0x2d, 0x88, 0x06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 0xe2, 0xea, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x25, - 0x1e, 0x8e, 0x7d, 0x26, 0x0b, 0x00, 0x00, + // 920 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xc7, 0x33, 0x89, 0xeb, 0x26, 0x2f, 0x20, 0x60, 0x48, 0x83, 0xb3, 0x02, 0x27, 0xdd, 0x92, + 0x1f, 0x4d, 0xf1, 0x4e, 0x9c, 0x00, 0xea, 0x01, 0x09, 0xe1, 0x20, 0x30, 0x48, 0x48, 0xc6, 0x32, + 0x1c, 0x50, 0xa5, 0x68, 0xec, 0x0c, 0xbb, 0xab, 0xc6, 0x3b, 0x5b, 0xef, 0x26, 0xc4, 0x42, 0x5c, + 0x38, 0x70, 0x46, 0x70, 0xe3, 0xc0, 0x81, 0x0b, 0x17, 0xe0, 0xd4, 0x3f, 0xa2, 0xc7, 0x0a, 0x2e, + 0xa8, 0x87, 0x08, 0x25, 0xfc, 0x11, 0x1c, 0xd1, 0xcc, 0xbc, 0xb5, 0xbd, 0x76, 0xea, 0xb5, 0xd5, + 0x5c, 0xa2, 0xcc, 0xcc, 0x7b, 0xef, 0xfb, 0x79, 0xcf, 0xb3, 0xdf, 0x5d, 0x58, 0x6f, 0xf2, 0x66, + 0xf7, 0x48, 0x06, 0xac, 0x19, 0xb7, 0x8e, 0x7c, 0xd7, 0x53, 0x7f, 0x45, 0x10, 0xb3, 0x93, 0x32, + 0x7b, 0x70, 0x2c, 0x3a, 0x5d, 0x27, 0xec, 0xc8, 0x58, 0xd2, 0x15, 0x0c, 0x73, 0xd2, 0x61, 0xce, + 0x49, 0xd9, 0x5a, 0x72, 0xa5, 0x2b, 0x75, 0x14, 0x53, 0xff, 0x99, 0x04, 0x6b, 0xa5, 0x25, 0xa3, + 0xb6, 0x8c, 0x0e, 0xcc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57, 0xd0, 0xe9, + 0x70, 0x6d, 0xfd, 0x59, 0xd4, 0xcc, 0xeb, 0x2f, 0xde, 0xbd, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, + 0x93, 0xd5, 0xc3, 0x8e, 0xd8, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1705,6 +1784,58 @@ func (m *QueryHeaderDepthResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *BTCHeaderInfoResponse) 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 *BTCHeaderInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCHeaderInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Work.Size() + i -= size + if _, err := m.Work.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if len(m.HashHex) > 0 { + i -= len(m.HashHex) + copy(dAtA[i:], m.HashHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.HashHex))) + i-- + dAtA[i] = 0x12 + } + if len(m.HeaderHex) > 0 { + i -= len(m.HeaderHex) + copy(dAtA[i:], m.HeaderHex) + i = encodeVarintQuery(dAtA, i, uint64(len(m.HeaderHex))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1919,6 +2050,28 @@ func (m *QueryHeaderDepthResponse) Size() (n int) { return n } +func (m *BTCHeaderInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.HeaderHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.HashHex) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + l = m.Work.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2718,7 +2871,7 @@ func (m *QueryMainChainResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Headers = append(m.Headers, &BTCHeaderInfo{}) + m.Headers = append(m.Headers, &BTCHeaderInfoResponse{}) if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2889,7 +3042,7 @@ func (m *QueryTipResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Header == nil { - m.Header = &BTCHeaderInfo{} + m.Header = &BTCHeaderInfoResponse{} } if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3025,7 +3178,7 @@ func (m *QueryBaseHeaderResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Header == nil { - m.Header = &BTCHeaderInfo{} + m.Header = &BTCHeaderInfoResponse{} } if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3203,6 +3356,173 @@ func (m *QueryHeaderDepthResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *BTCHeaderInfoResponse) 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: BTCHeaderInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCHeaderInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderHex", 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.HeaderHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HashHex", 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.HashHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Work", 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 + } + if err := m.Work.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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0