From 5e3834b295ae0435676167f5300e835de45a9021 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Wed, 17 Jul 2024 16:42:30 +0800 Subject: [PATCH 01/19] support staking btc by bnb chain --- proto/lorenzo/bnblightclient/v1/client.proto | 23 ++++++++ proto/lorenzo/bnblightclient/v1/genesis.proto | 17 ++++++ proto/lorenzo/bnblightclient/v1/params.proto | 18 ++++++ proto/lorenzo/bnblightclient/v1/query.proto | 57 +++++++++++++++++++ proto/lorenzo/bnblightclient/v1/tx.proto | 51 +++++++++++++++++ proto/lorenzo/btcstaking/v1/tx.proto | 14 +++++ 6 files changed, 180 insertions(+) create mode 100644 proto/lorenzo/bnblightclient/v1/client.proto create mode 100644 proto/lorenzo/bnblightclient/v1/genesis.proto create mode 100644 proto/lorenzo/bnblightclient/v1/params.proto create mode 100644 proto/lorenzo/bnblightclient/v1/query.proto create mode 100644 proto/lorenzo/bnblightclient/v1/tx.proto diff --git a/proto/lorenzo/bnblightclient/v1/client.proto b/proto/lorenzo/bnblightclient/v1/client.proto new file mode 100644 index 00000000..017ecc6d --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/client.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; + +message Header { + message Header { + option (gogoproto.goproto_getters) = false; + + // header defines the bnb header bytes + bytes raw_header = 1; + // hash defines the bnb header hash + bytes hash = 2; + // number defines the block number + uint64 number = 3; + // tx_root defines the transactions merkle root hash + bytes tx_root = 4; + // receipt_root defines the receipts merkle root hash + bytes receipt_root = 5; + } +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/genesis.proto b/proto/lorenzo/bnblightclient/v1/genesis.proto new file mode 100644 index 00000000..a09a900d --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/genesis.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "lorenzo/bnblightclient/v1/client.proto"; +import "lorenzo/bnblightclient/v1/params.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; + +// GenesisState defines the bnb light client state +message GenesisState { + // params defines the bnb light client parameters + lorenzo.bnblightclient.v1.Params params = 1; + // headers defines the bnb light client headers + repeated lorenzo.bnblightclient.v1.Header headers = 2; + // tx_hashes defines the transactions that the bnb chain has successfully processed + repeated string tx_hashes = 3; +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/params.proto b/proto/lorenzo/bnblightclient/v1/params.proto new file mode 100644 index 00000000..f1910c7b --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/params.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.equal) = true; + + // escrow btcb contract address + string escrow_contract_address = 1; + // the maximum number of bnb block headers to retain + uint64 retained_blocks = 2; + // list of people who can upload bnb block header information + repeated string allow_list = 3; +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/query.proto b/proto/lorenzo/bnblightclient/v1/query.proto new file mode 100644 index 00000000..fdab0551 --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/query.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "lorenzo/bnblightclient/v1/client.proto"; +import "lorenzo/bnblightclient/v1/params.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; + +// Query defines the gRPC querier service. +service Query { + // Params queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/params"; + } + + // Header returns the header in bnb chain by number + rpc Header(QueryHeaderRequest) returns (QueryHeaderResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/header/{number}"; + } + + // LatestedHeader returns the latested header in bnb chain + rpc LatestedHeader(QueryLatestedHeaderRequest) + returns (QueryLatestedHeaderResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/latested_header"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + lorenzo.bnblightclient.v1.Params params = 1 [ (gogoproto.nullable) = false ]; +} + +// QueryHeaderRequest is the request type for the Query/Header RPC method. +message QueryHeaderRequest { uint64 number = 1; } + +// QueryParamsResponse is the response type for the Query/Header RPC method. +message QueryHeaderResponse { + // params holds all the parameters of this module. + lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = true ]; +} + +// QueryLatestedHeaderRequest is the request type for the Query/LatestedHeader +// RPC method. +message QueryLatestedHeaderRequest {} + +// QueryLatestedHeaderResponse is the response type for the Query/LatestedHeader +// RPC method. +message QueryLatestedHeaderResponse { + // header holds the bnb light client header. + lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/tx.proto b/proto/lorenzo/bnblightclient/v1/tx.proto new file mode 100644 index 00000000..5ee6175b --- /dev/null +++ b/proto/lorenzo/bnblightclient/v1/tx.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package lorenzo.bnblightclient.v1; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; +import "lorenzo/bnblightclient/v1/client.proto"; +import "lorenzo/bnblightclient/v1/params.proto"; + +option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; + +// Msg defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // UploadHeaders adds a batch of headers to the BNB light client chain + rpc UploadHeaders(MsgUploadHeaders) returns (MsgUploadHeadersResponse) {}; + + // UpdateParams defines a method for updating btc light client module + // parameters. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); +} + +// MsgUploadHeaders defines the message for multiple incoming header bytes +message MsgUploadHeaders { + option (cosmos.msg.v1.signer) = "signer"; + + repeated lorenzo.bnblightclient.v1.Header headers = 1; + string signer = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} +// MsgUploadHeadersResponse defines the response for the UploadHeaders transaction +message MsgUploadHeadersResponse {} + +// MsgUpdateParams defines a message for updating fee module parameters. +message MsgUpdateParams { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + // just FYI: cosmos.AddressString marks that this field should use type alias + // for AddressString instead of string, but the functionality is not yet + // implemented in cosmos-proto + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // params defines the bnb light client parameters. + // + // NOTE: All parameters must be supplied. + lorenzo.bnblightclient.v1.Params params = 2 [ (gogoproto.nullable) = false ]; +} + +// MsgUpdateParamsResponse is the response to the MsgUpdateParams message. +message MsgUpdateParamsResponse {} \ No newline at end of file diff --git a/proto/lorenzo/btcstaking/v1/tx.proto b/proto/lorenzo/btcstaking/v1/tx.proto index 3f4f09b8..53ba945e 100644 --- a/proto/lorenzo/btcstaking/v1/tx.proto +++ b/proto/lorenzo/btcstaking/v1/tx.proto @@ -15,6 +15,9 @@ service Msg { rpc CreateBTCStaking(MsgCreateBTCStaking) returns (MsgCreateBTCStakingResponse); + rpc CreateBTCStakingFromBNB(MsgCreateBTCStakingFromBNB) + returns (MsgCreateBTCStakingFromBNBResponse); + rpc Burn(MsgBurnRequest) returns (MsgBurnResponse); rpc AddReceiver(MsgAddReceiver) returns (MsgAddReceiverResponse); @@ -58,6 +61,17 @@ message MsgCreateBTCStaking { message MsgCreateBTCStakingResponse {} +message MsgCreateBTCStakingFromBNB { + option (cosmos.msg.v1.signer) = "signer"; + + string signer = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + bytes transaction = 2; + bytes receipt = 3; + bytes proof = 4; +} + +message MsgCreateBTCStakingFromBNBResponse {} + message MsgBurnRequest { option (cosmos.msg.v1.signer) = "signer"; string signer = 1; From 183abae0dbaa90ceb2de141119a4a5d54589bbf4 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 18 Jul 2024 10:05:23 +0800 Subject: [PATCH 02/19] add chain-id to params --- proto/lorenzo/bnblightclient/v1/params.proto | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/proto/lorenzo/bnblightclient/v1/params.proto b/proto/lorenzo/bnblightclient/v1/params.proto index f1910c7b..33b937f1 100644 --- a/proto/lorenzo/bnblightclient/v1/params.proto +++ b/proto/lorenzo/bnblightclient/v1/params.proto @@ -9,10 +9,13 @@ option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" message Params { option (gogoproto.equal) = true; - // escrow btcb contract address - string escrow_contract_address = 1; + bytes chain_id = 1 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; + // the stake plan hub contract address + string stake_plan_hub_address = 2; + // the stake plan hub contract method id + string stake_plan_hub_method_id = 3; // the maximum number of bnb block headers to retain - uint64 retained_blocks = 2; + uint64 retained_blocks = 4; // list of people who can upload bnb block header information - repeated string allow_list = 3; + repeated string allow_list = 5; } \ No newline at end of file From 56285254bf0ccebe7a41129e3cd80791a7395496 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 18 Jul 2024 10:50:09 +0800 Subject: [PATCH 03/19] generate proto --- proto/lorenzo/bnblightclient/v1/client.proto | 4 +- proto/lorenzo/bnblightclient/v1/tx.proto | 18 +- proto/lorenzo/btcstaking/v1/tx.proto | 5 +- x/bnblightclient/types/client.pb.go | 561 +++++++ x/bnblightclient/types/genesis.pb.go | 452 ++++++ x/bnblightclient/types/params.pb.go | 573 ++++++++ x/bnblightclient/types/query.pb.go | 1255 ++++++++++++++++ x/bnblightclient/types/query.pb.gw.go | 319 ++++ x/bnblightclient/types/tx.pb.go | 1389 ++++++++++++++++++ x/btcstaking/types/tx.pb.go | 549 ++++++- 10 files changed, 5060 insertions(+), 65 deletions(-) create mode 100644 x/bnblightclient/types/client.pb.go create mode 100644 x/bnblightclient/types/genesis.pb.go create mode 100644 x/bnblightclient/types/params.pb.go create mode 100644 x/bnblightclient/types/query.pb.go create mode 100644 x/bnblightclient/types/query.pb.gw.go create mode 100644 x/bnblightclient/types/tx.pb.go diff --git a/proto/lorenzo/bnblightclient/v1/client.proto b/proto/lorenzo/bnblightclient/v1/client.proto index 017ecc6d..a464aa13 100644 --- a/proto/lorenzo/bnblightclient/v1/client.proto +++ b/proto/lorenzo/bnblightclient/v1/client.proto @@ -15,9 +15,7 @@ message Header { bytes hash = 2; // number defines the block number uint64 number = 3; - // tx_root defines the transactions merkle root hash - bytes tx_root = 4; // receipt_root defines the receipts merkle root hash - bytes receipt_root = 5; + bytes receipt_root = 4; } } \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/tx.proto b/proto/lorenzo/bnblightclient/v1/tx.proto index 5ee6175b..f7d7f9d4 100644 --- a/proto/lorenzo/bnblightclient/v1/tx.proto +++ b/proto/lorenzo/bnblightclient/v1/tx.proto @@ -13,12 +13,15 @@ option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" service Msg { option (cosmos.msg.v1.service) = true; - // UploadHeaders adds a batch of headers to the BNB light client chain + // UploadHeaders adds a batch of headers to the bnb light client chain rpc UploadHeaders(MsgUploadHeaders) returns (MsgUploadHeadersResponse) {}; - // UpdateParams defines a method for updating btc light client module + // UpdateParams defines a method for updating bnb light client module // parameters. rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // UpdateHeader defines a method for updating bnb light client header. + rpc UpdateHeader(MsgUpdateHeader) returns (MsgUpdateHeaderResponse); } // MsgUploadHeaders defines the message for multiple incoming header bytes @@ -31,6 +34,17 @@ message MsgUploadHeaders { // MsgUploadHeadersResponse defines the response for the UploadHeaders transaction message MsgUploadHeadersResponse {} +// MsgUpdateHeader defines the message for updating bnb light client header. +message MsgUpdateHeader { + option (cosmos.msg.v1.signer) = "signer"; + + lorenzo.bnblightclient.v1.Header headers = 1; + string signer = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; +} +// MsgUpdateHeaderResponse defines the response for the UpdateHeader +// transaction +message MsgUpdateHeaderResponse {} + // MsgUpdateParams defines a message for updating fee module parameters. message MsgUpdateParams { option (cosmos.msg.v1.signer) = "authority"; diff --git a/proto/lorenzo/btcstaking/v1/tx.proto b/proto/lorenzo/btcstaking/v1/tx.proto index 53ba945e..bdaa9720 100644 --- a/proto/lorenzo/btcstaking/v1/tx.proto +++ b/proto/lorenzo/btcstaking/v1/tx.proto @@ -65,9 +65,8 @@ message MsgCreateBTCStakingFromBNB { option (cosmos.msg.v1.signer) = "signer"; string signer = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - bytes transaction = 2; - bytes receipt = 3; - bytes proof = 4; + bytes receipt = 2; + bytes proof = 3; } message MsgCreateBTCStakingFromBNBResponse {} diff --git a/x/bnblightclient/types/client.pb.go b/x/bnblightclient/types/client.pb.go new file mode 100644 index 00000000..f63d960e --- /dev/null +++ b/x/bnblightclient/types/client.pb.go @@ -0,0 +1,561 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/client.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Header struct { +} + +func (m *Header) Reset() { *m = Header{} } +func (m *Header) String() string { return proto.CompactTextString(m) } +func (*Header) ProtoMessage() {} +func (*Header) Descriptor() ([]byte, []int) { + return fileDescriptor_30c005374b948758, []int{0} +} +func (m *Header) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Header.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 *Header) XXX_Merge(src proto.Message) { + xxx_messageInfo_Header.Merge(m, src) +} +func (m *Header) XXX_Size() int { + return m.Size() +} +func (m *Header) XXX_DiscardUnknown() { + xxx_messageInfo_Header.DiscardUnknown(m) +} + +var xxx_messageInfo_Header proto.InternalMessageInfo + +type Header_Header struct { + // header defines the bnb header bytes + RawHeader []byte `protobuf:"bytes,1,opt,name=raw_header,json=rawHeader,proto3" json:"raw_header,omitempty"` + // hash defines the bnb header hash + Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` + // number defines the block number + Number uint64 `protobuf:"varint,3,opt,name=number,proto3" json:"number,omitempty"` + // receipt_root defines the receipts merkle root hash + ReceiptRoot []byte `protobuf:"bytes,4,opt,name=receipt_root,json=receiptRoot,proto3" json:"receipt_root,omitempty"` +} + +func (m *Header_Header) Reset() { *m = Header_Header{} } +func (m *Header_Header) String() string { return proto.CompactTextString(m) } +func (*Header_Header) ProtoMessage() {} +func (*Header_Header) Descriptor() ([]byte, []int) { + return fileDescriptor_30c005374b948758, []int{0, 0} +} +func (m *Header_Header) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Header_Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Header_Header.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 *Header_Header) XXX_Merge(src proto.Message) { + xxx_messageInfo_Header_Header.Merge(m, src) +} +func (m *Header_Header) XXX_Size() int { + return m.Size() +} +func (m *Header_Header) XXX_DiscardUnknown() { + xxx_messageInfo_Header_Header.DiscardUnknown(m) +} + +var xxx_messageInfo_Header_Header proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Header)(nil), "lorenzo.bnblightclient.v1.Header") + proto.RegisterType((*Header_Header)(nil), "lorenzo.bnblightclient.v1.Header.Header") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/client.proto", fileDescriptor_30c005374b948758) +} + +var fileDescriptor_30c005374b948758 = []byte{ + // 254 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0xc9, 0x2f, 0x4a, + 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x87, 0xb0, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x24, + 0xa1, 0xea, 0xf4, 0x50, 0xd5, 0xe9, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, + 0xe9, 0x83, 0x58, 0x10, 0x0d, 0x4a, 0x6d, 0x8c, 0x5c, 0x6c, 0x1e, 0xa9, 0x89, 0x29, 0xa9, 0x45, + 0x52, 0x35, 0x30, 0x96, 0x90, 0x2c, 0x17, 0x57, 0x51, 0x62, 0x79, 0x7c, 0x06, 0x98, 0x27, 0xc1, + 0xa8, 0xc0, 0xa8, 0xc1, 0x13, 0xc4, 0x59, 0x94, 0x58, 0x0e, 0x95, 0x16, 0xe2, 0x62, 0xc9, 0x48, + 0x2c, 0xce, 0x90, 0x60, 0x02, 0x4b, 0x80, 0xd9, 0x42, 0x62, 0x5c, 0x6c, 0x79, 0xa5, 0xb9, 0x49, + 0xa9, 0x45, 0x12, 0xcc, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x50, 0x9e, 0x90, 0x22, 0x17, 0x4f, 0x51, + 0x6a, 0x72, 0x6a, 0x66, 0x41, 0x49, 0x7c, 0x51, 0x7e, 0x7e, 0x89, 0x04, 0x0b, 0x58, 0x0f, 0x37, + 0x54, 0x2c, 0x28, 0x3f, 0xbf, 0xc4, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x53, 0xc8, 0x89, 0x47, + 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, + 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x40, 0xbc, 0xa7, 0x1b, 0x00, 0x72, 0x7c, 0x72, 0x7e, 0x8e, 0x3e, + 0x2c, 0x5c, 0x2a, 0xd0, 0x43, 0xa6, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x4b, 0x63, + 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x37, 0x85, 0x42, 0x8d, 0x40, 0x01, 0x00, 0x00, +} + +func (m *Header) 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 *Header) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *Header_Header) 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 *Header_Header) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Header_Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ReceiptRoot) > 0 { + i -= len(m.ReceiptRoot) + copy(dAtA[i:], m.ReceiptRoot) + i = encodeVarintClient(dAtA, i, uint64(len(m.ReceiptRoot))) + i-- + dAtA[i] = 0x22 + } + if m.Number != 0 { + i = encodeVarintClient(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x18 + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintClient(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + if len(m.RawHeader) > 0 { + i -= len(m.RawHeader) + copy(dAtA[i:], m.RawHeader) + i = encodeVarintClient(dAtA, i, uint64(len(m.RawHeader))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintClient(dAtA []byte, offset int, v uint64) int { + offset -= sovClient(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Header) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *Header_Header) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RawHeader) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + if m.Number != 0 { + n += 1 + sovClient(uint64(m.Number)) + } + l = len(m.ReceiptRoot) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } + return n +} + +func sovClient(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozClient(x uint64) (n int) { + return sovClient(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Header) 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 ErrIntOverflowClient + } + 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: Header: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipClient(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Header_Header) 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 ErrIntOverflowClient + } + 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: Header: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawHeader", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawHeader = append(m.RawHeader[:0], dAtA[iNdEx:postIndex]...) + if m.RawHeader == nil { + m.RawHeader = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReceiptRoot", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthClient + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReceiptRoot = append(m.ReceiptRoot[:0], dAtA[iNdEx:postIndex]...) + if m.ReceiptRoot == nil { + m.ReceiptRoot = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipClient(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthClient + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipClient(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClient + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClient + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowClient + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthClient + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupClient + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthClient + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthClient = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowClient = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupClient = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/genesis.pb.go b/x/bnblightclient/types/genesis.pb.go new file mode 100644 index 00000000..5fbc4e94 --- /dev/null +++ b/x/bnblightclient/types/genesis.pb.go @@ -0,0 +1,452 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/genesis.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the bnb light client state +type GenesisState struct { + // params defines the bnb light client parameters + Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` + // headers defines the bnb light client headers + Headers []*Header `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"` + // tx_hashes defines the transactions that the bnb chain has successfully processed + TxHashes []string `protobuf:"bytes,3,rep,name=tx_hashes,json=txHashes,proto3" json:"tx_hashes,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_4f928fb205bb2cf6, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() *Params { + if m != nil { + return m.Params + } + return nil +} + +func (m *GenesisState) GetHeaders() []*Header { + if m != nil { + return m.Headers + } + return nil +} + +func (m *GenesisState) GetTxHashes() []string { + if m != nil { + return m.TxHashes + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "lorenzo.bnblightclient.v1.GenesisState") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/genesis.proto", fileDescriptor_4f928fb205bb2cf6) +} + +var fileDescriptor_4f928fb205bb2cf6 = []byte{ + // 248 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcf, 0xc9, 0x2f, 0x4a, + 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x84, 0x2a, 0xd4, 0x43, 0x55, 0xa8, 0x57, 0x66, 0x28, 0xa5, 0x86, + 0xdb, 0x0c, 0xa8, 0x22, 0xb0, 0x11, 0xf8, 0xd4, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x42, 0xad, 0x52, + 0x5a, 0xcc, 0xc8, 0xc5, 0xe3, 0x0e, 0xb1, 0x3c, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x92, 0x8b, + 0x0d, 0xa2, 0x40, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x51, 0x0f, 0xa7, 0x63, 0xf4, 0x02, + 0xc0, 0x0a, 0x83, 0xa0, 0x1a, 0x84, 0xac, 0xb9, 0xd8, 0x33, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, + 0x25, 0x98, 0x14, 0x98, 0x09, 0xe8, 0xf5, 0x00, 0xab, 0x0c, 0x82, 0xe9, 0x10, 0x92, 0xe6, 0xe2, + 0x2c, 0xa9, 0x88, 0xcf, 0x48, 0x2c, 0xce, 0x48, 0x2d, 0x96, 0x60, 0x56, 0x60, 0xd6, 0xe0, 0x0c, + 0xe2, 0x28, 0xa9, 0xf0, 0x00, 0xf3, 0x9d, 0x42, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, + 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, + 0x8e, 0x21, 0xca, 0x2a, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x07, + 0x62, 0x99, 0x6e, 0x00, 0xc8, 0x67, 0xc9, 0xf9, 0x39, 0xfa, 0xb0, 0x30, 0xa8, 0x40, 0x0f, 0x85, + 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x10, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, + 0xab, 0x14, 0xb3, 0xbf, 0x98, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TxHashes) > 0 { + for iNdEx := len(m.TxHashes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.TxHashes[iNdEx]) + copy(dAtA[i:], m.TxHashes[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.TxHashes[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + 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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.Params != nil { + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Params != nil { + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + if len(m.Headers) > 0 { + for _, e := range m.Headers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.TxHashes) > 0 { + for _, s := range m.TxHashes { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Params == nil { + m.Params = &Params{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Headers = append(m.Headers, &Header{}) + if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxHashes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxHashes = append(m.TxHashes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/params.pb.go b/x/bnblightclient/types/params.pb.go new file mode 100644 index 00000000..2f3ecf3a --- /dev/null +++ b/x/bnblightclient/types/params.pb.go @@ -0,0 +1,573 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/params.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + ChainId *cosmossdk_io_math.Uint `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=cosmossdk.io/math.Uint" json:"chain_id,omitempty"` + // the stake plan hub contract address + StakePlanHubAddress string `protobuf:"bytes,2,opt,name=stake_plan_hub_address,json=stakePlanHubAddress,proto3" json:"stake_plan_hub_address,omitempty"` + // the stake plan hub contract method id + StakePlanHubMethodId string `protobuf:"bytes,3,opt,name=stake_plan_hub_method_id,json=stakePlanHubMethodId,proto3" json:"stake_plan_hub_method_id,omitempty"` + // the maximum number of bnb block headers to retain + RetainedBlocks uint64 `protobuf:"varint,4,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` + // list of people who can upload bnb block header information + AllowList []string `protobuf:"bytes,5,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3608f71b6e08ae9c, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetStakePlanHubAddress() string { + if m != nil { + return m.StakePlanHubAddress + } + return "" +} + +func (m *Params) GetStakePlanHubMethodId() string { + if m != nil { + return m.StakePlanHubMethodId + } + return "" +} + +func (m *Params) GetRetainedBlocks() uint64 { + if m != nil { + return m.RetainedBlocks + } + return 0 +} + +func (m *Params) GetAllowList() []string { + if m != nil { + return m.AllowList + } + return nil +} + +func init() { + proto.RegisterType((*Params)(nil), "lorenzo.bnblightclient.v1.Params") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/params.proto", fileDescriptor_3608f71b6e08ae9c) +} + +var fileDescriptor_3608f71b6e08ae9c = []byte{ + // 347 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xcf, 0x4a, 0xeb, 0x40, + 0x18, 0xc5, 0x3b, 0xb7, 0xbd, 0xbd, 0xb7, 0xc3, 0xe5, 0x0a, 0xb1, 0x94, 0x58, 0x30, 0x0d, 0x2e, + 0x34, 0x1b, 0x13, 0x4a, 0xd1, 0x45, 0x77, 0x76, 0x65, 0xa1, 0x42, 0x09, 0xba, 0x71, 0x13, 0x26, + 0x99, 0x21, 0x19, 0x3a, 0x99, 0x2f, 0x64, 0xa6, 0xf5, 0xcf, 0x53, 0xf8, 0x08, 0x3e, 0x8e, 0xcb, + 0x2e, 0xc5, 0x85, 0x48, 0xbb, 0xf1, 0x19, 0x5c, 0x49, 0xa7, 0x16, 0xb4, 0xbb, 0xe1, 0x9c, 0xf3, + 0x9b, 0x0f, 0xce, 0xc1, 0x87, 0x02, 0x4a, 0x26, 0xef, 0x21, 0x88, 0x65, 0x2c, 0x78, 0x9a, 0xe9, + 0x44, 0x70, 0x26, 0x75, 0x30, 0xeb, 0x06, 0x05, 0x29, 0x49, 0xae, 0xfc, 0xa2, 0x04, 0x0d, 0xd6, + 0xde, 0x57, 0xce, 0xff, 0x99, 0xf3, 0x67, 0xdd, 0x76, 0x33, 0x85, 0x14, 0x4c, 0x2a, 0x58, 0xbd, + 0xd6, 0xc0, 0xc1, 0x07, 0xc2, 0xf5, 0xb1, 0xf9, 0xc1, 0x3a, 0xc1, 0x7f, 0x93, 0x8c, 0x70, 0x19, + 0x71, 0x6a, 0x23, 0x17, 0x79, 0xff, 0x06, 0xed, 0x97, 0xd7, 0x4e, 0x2b, 0x01, 0x95, 0x83, 0x52, + 0x74, 0xe2, 0x73, 0x08, 0x72, 0xa2, 0x33, 0xff, 0x8a, 0x4b, 0x1d, 0xfe, 0x31, 0xd9, 0x21, 0xb5, + 0x7a, 0xb8, 0xa5, 0x34, 0x99, 0xb0, 0xa8, 0x10, 0x44, 0x46, 0xd9, 0x34, 0x8e, 0x08, 0xa5, 0x25, + 0x53, 0xca, 0xfe, 0xe5, 0x22, 0xaf, 0x11, 0xee, 0x1a, 0x77, 0x2c, 0x88, 0x3c, 0x9f, 0xc6, 0x67, + 0x6b, 0xcb, 0x3a, 0xc5, 0xf6, 0x16, 0x94, 0x33, 0x9d, 0x01, 0x5d, 0xdd, 0xae, 0x1a, 0xac, 0xf9, + 0x1d, 0xbb, 0x30, 0xe6, 0x90, 0x5a, 0x47, 0x78, 0xa7, 0x64, 0x9a, 0x70, 0xc9, 0x68, 0x14, 0x0b, + 0x48, 0x26, 0xca, 0xae, 0xb9, 0xc8, 0xab, 0x85, 0xff, 0x37, 0xf2, 0xc0, 0xa8, 0xd6, 0x3e, 0xc6, + 0x44, 0x08, 0xb8, 0x89, 0x04, 0x57, 0xda, 0xfe, 0xed, 0x56, 0xbd, 0x46, 0xd8, 0x30, 0xca, 0x88, + 0x2b, 0xdd, 0xaf, 0xbd, 0x3f, 0x76, 0xd0, 0xe0, 0xf2, 0x69, 0xe1, 0xa0, 0xf9, 0xc2, 0x41, 0x6f, + 0x0b, 0x07, 0x3d, 0x2c, 0x9d, 0xca, 0x7c, 0xe9, 0x54, 0x9e, 0x97, 0x4e, 0xe5, 0xba, 0x9f, 0x72, + 0x9d, 0x4d, 0x63, 0x3f, 0x81, 0x3c, 0x18, 0xad, 0x2b, 0x3d, 0x1e, 0xaf, 0x0a, 0x4b, 0x40, 0x04, + 0x9b, 0x2d, 0x6e, 0xb7, 0xd7, 0xd0, 0x77, 0x05, 0x53, 0x71, 0xdd, 0x34, 0xdb, 0xfb, 0x0c, 0x00, + 0x00, 0xff, 0xff, 0x1a, 0x89, 0xae, 0x99, 0xb4, 0x01, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if that1.ChainId == nil { + if this.ChainId != nil { + return false + } + } else if !this.ChainId.Equal(*that1.ChainId) { + return false + } + if this.StakePlanHubAddress != that1.StakePlanHubAddress { + return false + } + if this.StakePlanHubMethodId != that1.StakePlanHubMethodId { + return false + } + if this.RetainedBlocks != that1.RetainedBlocks { + return false + } + if len(this.AllowList) != len(that1.AllowList) { + return false + } + for i := range this.AllowList { + if this.AllowList[i] != that1.AllowList[i] { + return false + } + } + return true +} +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AllowList) > 0 { + for iNdEx := len(m.AllowList) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowList[iNdEx]) + copy(dAtA[i:], m.AllowList[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.AllowList[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if m.RetainedBlocks != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.RetainedBlocks)) + i-- + dAtA[i] = 0x20 + } + if len(m.StakePlanHubMethodId) > 0 { + i -= len(m.StakePlanHubMethodId) + copy(dAtA[i:], m.StakePlanHubMethodId) + i = encodeVarintParams(dAtA, i, uint64(len(m.StakePlanHubMethodId))) + i-- + dAtA[i] = 0x1a + } + if len(m.StakePlanHubAddress) > 0 { + i -= len(m.StakePlanHubAddress) + copy(dAtA[i:], m.StakePlanHubAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.StakePlanHubAddress))) + i-- + dAtA[i] = 0x12 + } + if m.ChainId != nil { + { + size := m.ChainId.Size() + i -= size + if _, err := m.ChainId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChainId != nil { + l = m.ChainId.Size() + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.StakePlanHubAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.StakePlanHubMethodId) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.RetainedBlocks != 0 { + n += 1 + sovParams(uint64(m.RetainedBlocks)) + } + if len(m.AllowList) > 0 { + for _, s := range m.AllowList { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v cosmossdk_io_math.Uint + m.ChainId = &v + if err := m.ChainId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakePlanHubAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakePlanHubAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakePlanHubMethodId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakePlanHubMethodId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RetainedBlocks", wireType) + } + m.RetainedBlocks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RetainedBlocks |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowList", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowList = append(m.AllowList, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/query.pb.go b/x/bnblightclient/types/query.pb.go new file mode 100644 index 00000000..4266d9ab --- /dev/null +++ b/x/bnblightclient/types/query.pb.go @@ -0,0 +1,1255 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryHeaderRequest is the request type for the Query/Header RPC method. +type QueryHeaderRequest struct { + Number uint64 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` +} + +func (m *QueryHeaderRequest) Reset() { *m = QueryHeaderRequest{} } +func (m *QueryHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderRequest) ProtoMessage() {} +func (*QueryHeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{2} +} +func (m *QueryHeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderRequest.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 *QueryHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderRequest.Merge(m, src) +} +func (m *QueryHeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderRequest proto.InternalMessageInfo + +func (m *QueryHeaderRequest) GetNumber() uint64 { + if m != nil { + return m.Number + } + return 0 +} + +// QueryParamsResponse is the response type for the Query/Header RPC method. +type QueryHeaderResponse struct { + // params holds all the parameters of this module. + Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` +} + +func (m *QueryHeaderResponse) Reset() { *m = QueryHeaderResponse{} } +func (m *QueryHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderResponse) ProtoMessage() {} +func (*QueryHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{3} +} +func (m *QueryHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderResponse.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 *QueryHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderResponse.Merge(m, src) +} +func (m *QueryHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderResponse proto.InternalMessageInfo + +func (m *QueryHeaderResponse) GetHeader() *Header { + if m != nil { + return m.Header + } + return nil +} + +// QueryLatestedHeaderRequest is the request type for the Query/LatestedHeader +// RPC method. +type QueryLatestedHeaderRequest struct { +} + +func (m *QueryLatestedHeaderRequest) Reset() { *m = QueryLatestedHeaderRequest{} } +func (m *QueryLatestedHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryLatestedHeaderRequest) ProtoMessage() {} +func (*QueryLatestedHeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{4} +} +func (m *QueryLatestedHeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLatestedHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLatestedHeaderRequest.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 *QueryLatestedHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestedHeaderRequest.Merge(m, src) +} +func (m *QueryLatestedHeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryLatestedHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestedHeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLatestedHeaderRequest proto.InternalMessageInfo + +// QueryLatestedHeaderResponse is the response type for the Query/LatestedHeader +// RPC method. +type QueryLatestedHeaderResponse struct { + // header holds the bnb light client header. + Header Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` +} + +func (m *QueryLatestedHeaderResponse) Reset() { *m = QueryLatestedHeaderResponse{} } +func (m *QueryLatestedHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryLatestedHeaderResponse) ProtoMessage() {} +func (*QueryLatestedHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{5} +} +func (m *QueryLatestedHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryLatestedHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryLatestedHeaderResponse.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 *QueryLatestedHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestedHeaderResponse.Merge(m, src) +} +func (m *QueryLatestedHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryLatestedHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestedHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryLatestedHeaderResponse proto.InternalMessageInfo + +func (m *QueryLatestedHeaderResponse) GetHeader() Header { + if m != nil { + return m.Header + } + return Header{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "lorenzo.bnblightclient.v1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "lorenzo.bnblightclient.v1.QueryParamsResponse") + proto.RegisterType((*QueryHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryHeaderRequest") + proto.RegisterType((*QueryHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryHeaderResponse") + proto.RegisterType((*QueryLatestedHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryLatestedHeaderRequest") + proto.RegisterType((*QueryLatestedHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryLatestedHeaderResponse") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/query.proto", fileDescriptor_f139d6422d3b3b56) +} + +var fileDescriptor_f139d6422d3b3b56 = []byte{ + // 434 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcd, 0xc9, 0x2f, 0x4a, + 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x92, 0x84, 0x2a, 0xd3, 0x43, 0x55, 0xa6, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, + 0x9e, 0x0f, 0x56, 0xa5, 0x0f, 0x62, 0x41, 0x34, 0x48, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, + 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, + 0x43, 0x65, 0xd5, 0x70, 0xdb, 0x0a, 0x35, 0x98, 0xa0, 0xba, 0x82, 0xc4, 0xa2, 0xc4, 0x5c, 0xa8, + 0x79, 0x4a, 0x22, 0x5c, 0x42, 0x81, 0x20, 0xd7, 0x06, 0x80, 0x05, 0x83, 0x52, 0x0b, 0x4b, 0x53, + 0x8b, 0x4b, 0x94, 0xc2, 0xb8, 0x84, 0x51, 0x44, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0xec, + 0xb9, 0xd8, 0x20, 0x9a, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x14, 0xf5, 0x70, 0x7a, 0x4e, + 0x0f, 0xa2, 0xd5, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x36, 0x25, 0x1d, 0xa8, 0x6d, + 0x1e, 0xa9, 0x89, 0x29, 0xa9, 0x45, 0x50, 0xdb, 0x84, 0xc4, 0xb8, 0xd8, 0xf2, 0x4a, 0x73, 0x93, + 0x52, 0x8b, 0xc0, 0xc6, 0xb2, 0x04, 0x41, 0x79, 0x70, 0x57, 0xc0, 0x54, 0x23, 0x5c, 0x91, 0x01, + 0x16, 0x21, 0xc2, 0x15, 0x10, 0xad, 0x60, 0x57, 0x30, 0x06, 0x41, 0xb5, 0x29, 0xc9, 0x70, 0x49, + 0x81, 0xcd, 0xf5, 0x49, 0x2c, 0x49, 0x2d, 0x2e, 0x49, 0x4d, 0x41, 0x71, 0x8d, 0x52, 0x1c, 0x97, + 0x34, 0x56, 0x59, 0xca, 0x6c, 0x67, 0x80, 0xd9, 0x6e, 0xf4, 0x81, 0x99, 0x8b, 0x15, 0x6c, 0x81, + 0xd0, 0x24, 0x46, 0x2e, 0x36, 0x48, 0x30, 0x09, 0xe9, 0xe2, 0x31, 0x05, 0x33, 0x7e, 0xa4, 0xf4, + 0x88, 0x55, 0x0e, 0x71, 0xb4, 0x92, 0x66, 0xd3, 0xe5, 0x27, 0x93, 0x99, 0x94, 0x85, 0x14, 0xf5, + 0x09, 0x25, 0x0b, 0xa1, 0xd9, 0x8c, 0x5c, 0x6c, 0x10, 0x77, 0x13, 0x76, 0x14, 0x4a, 0xc0, 0x11, + 0x76, 0x14, 0x6a, 0x48, 0x2a, 0x19, 0x81, 0x1d, 0xa5, 0x23, 0xa4, 0x85, 0xc7, 0x51, 0x90, 0x30, + 0xd3, 0xaf, 0x86, 0xa4, 0x88, 0x5a, 0xa1, 0xcd, 0x8c, 0x5c, 0x7c, 0xa8, 0x11, 0x23, 0x64, 0x4a, + 0xc8, 0x5a, 0xac, 0xd1, 0x2c, 0x65, 0x46, 0xaa, 0x36, 0x12, 0x5c, 0x9d, 0x03, 0xd5, 0x1a, 0x0f, + 0x71, 0xbe, 0x53, 0xc8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, + 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa5, + 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x40, 0xcc, 0xd3, 0x0d, 0x00, + 0x65, 0xcc, 0xe4, 0xfc, 0x1c, 0xb8, 0x05, 0x15, 0xe8, 0x56, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, + 0xb1, 0x81, 0x73, 0xb0, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x08, 0x79, 0xbc, 0x89, 0x04, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Header returns the header in bnb chain by number + Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) + // LatestedHeader returns the latested header in bnb chain + LatestedHeader(ctx context.Context, in *QueryLatestedHeaderRequest, opts ...grpc.CallOption) (*QueryLatestedHeaderResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) { + out := new(QueryHeaderResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/Header", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) LatestedHeader(ctx context.Context, in *QueryLatestedHeaderRequest, opts ...grpc.CallOption) (*QueryLatestedHeaderResponse, error) { + out := new(QueryLatestedHeaderResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/LatestedHeader", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Header returns the header in bnb chain by number + Header(context.Context, *QueryHeaderRequest) (*QueryHeaderResponse, error) + // LatestedHeader returns the latested header in bnb chain + LatestedHeader(context.Context, *QueryLatestedHeaderRequest) (*QueryLatestedHeaderResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Header(ctx context.Context, req *QueryHeaderRequest) (*QueryHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Header not implemented") +} +func (*UnimplementedQueryServer) LatestedHeader(ctx context.Context, req *QueryLatestedHeaderRequest) (*QueryLatestedHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LatestedHeader not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Header_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Header(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/Header", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Header(ctx, req.(*QueryHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_LatestedHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryLatestedHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).LatestedHeader(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/LatestedHeader", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).LatestedHeader(ctx, req.(*QueryLatestedHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lorenzo.bnblightclient.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Header", + Handler: _Query_Header_Handler, + }, + { + MethodName: "LatestedHeader", + Handler: _Query_LatestedHeader_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lorenzo/bnblightclient/v1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.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 *QueryHeaderRequest) 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 *QueryHeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Number != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Number)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryHeaderResponse) 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 *QueryHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Header != nil { + { + size, err := m.Header.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 *QueryLatestedHeaderRequest) 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 *QueryLatestedHeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLatestedHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryLatestedHeaderResponse) 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 *QueryLatestedHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryLatestedHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Header.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 encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Number != 0 { + n += 1 + sovQuery(uint64(m.Number)) + } + return n +} + +func (m *QueryHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryLatestedHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryLatestedHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Header.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.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 *QueryHeaderRequest) 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: QueryHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) + } + m.Number = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Number |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryHeaderResponse) 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: QueryHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &Header{} + } + if err := m.Header.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 *QueryLatestedHeaderRequest) 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: QueryLatestedHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLatestedHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryLatestedHeaderResponse) 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: QueryLatestedHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryLatestedHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Header.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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/bnblightclient/types/query.pb.gw.go b/x/bnblightclient/types/query.pb.gw.go new file mode 100644 index 00000000..9596e8e1 --- /dev/null +++ b/x/bnblightclient/types/query.pb.gw.go @@ -0,0 +1,319 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Header_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "number") + } + + protoReq.Number, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "number", err) + } + + msg, err := client.Header(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Header_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["number"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "number") + } + + protoReq.Number, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "number", err) + } + + msg, err := server.Header(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_LatestedHeader_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestedHeaderRequest + var metadata runtime.ServerMetadata + + msg, err := client.LatestedHeader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_LatestedHeader_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestedHeaderRequest + var metadata runtime.ServerMetadata + + msg, err := server.LatestedHeader(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Header_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_Header_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_Header_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LatestedHeader_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_LatestedHeader_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_LatestedHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Header_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_Header_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_Header_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_LatestedHeader_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_LatestedHeader_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_LatestedHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lorenzo", "bnblightclient", "v1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Header_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lorenzo", "bnblightclient", "v1", "header", "number"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_LatestedHeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lorenzo", "bnblightclient", "v1", "latested_header"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Header_0 = runtime.ForwardResponseMessage + + forward_Query_LatestedHeader_0 = runtime.ForwardResponseMessage +) diff --git a/x/bnblightclient/types/tx.pb.go b/x/bnblightclient/types/tx.pb.go new file mode 100644 index 00000000..a31573e5 --- /dev/null +++ b/x/bnblightclient/types/tx.pb.go @@ -0,0 +1,1389 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lorenzo/bnblightclient/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgUploadHeaders defines the message for multiple incoming header bytes +type MsgUploadHeaders struct { + Headers []*Header `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgUploadHeaders) Reset() { *m = MsgUploadHeaders{} } +func (m *MsgUploadHeaders) String() string { return proto.CompactTextString(m) } +func (*MsgUploadHeaders) ProtoMessage() {} +func (*MsgUploadHeaders) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{0} +} +func (m *MsgUploadHeaders) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUploadHeaders) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUploadHeaders.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 *MsgUploadHeaders) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUploadHeaders.Merge(m, src) +} +func (m *MsgUploadHeaders) XXX_Size() int { + return m.Size() +} +func (m *MsgUploadHeaders) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUploadHeaders.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUploadHeaders proto.InternalMessageInfo + +func (m *MsgUploadHeaders) GetHeaders() []*Header { + if m != nil { + return m.Headers + } + return nil +} + +func (m *MsgUploadHeaders) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +// MsgUploadHeadersResponse defines the response for the UploadHeaders transaction +type MsgUploadHeadersResponse struct { +} + +func (m *MsgUploadHeadersResponse) Reset() { *m = MsgUploadHeadersResponse{} } +func (m *MsgUploadHeadersResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUploadHeadersResponse) ProtoMessage() {} +func (*MsgUploadHeadersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{1} +} +func (m *MsgUploadHeadersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUploadHeadersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUploadHeadersResponse.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 *MsgUploadHeadersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUploadHeadersResponse.Merge(m, src) +} +func (m *MsgUploadHeadersResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUploadHeadersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUploadHeadersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUploadHeadersResponse proto.InternalMessageInfo + +// MsgUpdateHeader defines the message for updating bnb light client header. +type MsgUpdateHeader struct { + Headers *Header `protobuf:"bytes,1,opt,name=headers,proto3" json:"headers,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgUpdateHeader) Reset() { *m = MsgUpdateHeader{} } +func (m *MsgUpdateHeader) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateHeader) ProtoMessage() {} +func (*MsgUpdateHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{2} +} +func (m *MsgUpdateHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateHeader.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 *MsgUpdateHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateHeader.Merge(m, src) +} +func (m *MsgUpdateHeader) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateHeader) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateHeader proto.InternalMessageInfo + +func (m *MsgUpdateHeader) GetHeaders() *Header { + if m != nil { + return m.Headers + } + return nil +} + +func (m *MsgUpdateHeader) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +// MsgUpdateHeaderResponse defines the response for the UpdateHeader +// transaction +type MsgUpdateHeaderResponse struct { +} + +func (m *MsgUpdateHeaderResponse) Reset() { *m = MsgUpdateHeaderResponse{} } +func (m *MsgUpdateHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateHeaderResponse) ProtoMessage() {} +func (*MsgUpdateHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{3} +} +func (m *MsgUpdateHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateHeaderResponse.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 *MsgUpdateHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateHeaderResponse.Merge(m, src) +} +func (m *MsgUpdateHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateHeaderResponse proto.InternalMessageInfo + +// MsgUpdateParams defines a message for updating fee module parameters. +type MsgUpdateParams struct { + // authority is the address of the governance account. + // just FYI: cosmos.AddressString marks that this field should use type alias + // for AddressString instead of string, but the functionality is not yet + // implemented in cosmos-proto + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the bnb light client parameters. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{4} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// MsgUpdateParamsResponse is the response to the MsgUpdateParams message. +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7077a7889346cb20, []int{5} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUploadHeaders)(nil), "lorenzo.bnblightclient.v1.MsgUploadHeaders") + proto.RegisterType((*MsgUploadHeadersResponse)(nil), "lorenzo.bnblightclient.v1.MsgUploadHeadersResponse") + proto.RegisterType((*MsgUpdateHeader)(nil), "lorenzo.bnblightclient.v1.MsgUpdateHeader") + proto.RegisterType((*MsgUpdateHeaderResponse)(nil), "lorenzo.bnblightclient.v1.MsgUpdateHeaderResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "lorenzo.bnblightclient.v1.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "lorenzo.bnblightclient.v1.MsgUpdateParamsResponse") +} + +func init() { + proto.RegisterFile("lorenzo/bnblightclient/v1/tx.proto", fileDescriptor_7077a7889346cb20) +} + +var fileDescriptor_7077a7889346cb20 = []byte{ + // 460 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0xc9, 0x2f, 0x4a, + 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, + 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, + 0x84, 0xaa, 0xd1, 0x43, 0x55, 0xa3, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, + 0xa5, 0x0f, 0x62, 0x41, 0x34, 0x48, 0x49, 0x26, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0xc7, 0x43, 0x24, + 0x20, 0x1c, 0xa8, 0x94, 0x38, 0x84, 0xa7, 0x9f, 0x5b, 0x9c, 0x0e, 0xb2, 0x23, 0xb7, 0x38, 0x1d, + 0x2a, 0xa1, 0x86, 0xdb, 0x21, 0x50, 0xeb, 0x08, 0xaa, 0x2b, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x5a, + 0xa4, 0xd4, 0xc7, 0xc8, 0x25, 0xe0, 0x5b, 0x9c, 0x1e, 0x5a, 0x90, 0x93, 0x9f, 0x98, 0xe2, 0x91, + 0x9a, 0x98, 0x92, 0x5a, 0x54, 0x2c, 0x64, 0xcd, 0xc5, 0x9e, 0x01, 0x61, 0x4a, 0x30, 0x2a, 0x30, + 0x6b, 0x70, 0x1b, 0x29, 0xea, 0xe1, 0xf4, 0x9b, 0x1e, 0x44, 0x53, 0x10, 0x4c, 0x87, 0x90, 0x01, + 0x17, 0x5b, 0x71, 0x66, 0x7a, 0x5e, 0x6a, 0x91, 0x04, 0x93, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, + 0xa5, 0x2d, 0xba, 0x22, 0x50, 0xcf, 0x39, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x07, 0x97, 0x14, + 0x65, 0xe6, 0xa5, 0x07, 0x41, 0xd5, 0x59, 0x71, 0x37, 0x3d, 0xdf, 0xa0, 0x05, 0xe5, 0x28, 0x49, + 0x71, 0x49, 0xa0, 0xbb, 0x27, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xa9, 0x97, 0x91, + 0x8b, 0x1f, 0x2c, 0x99, 0x92, 0x58, 0x92, 0x0a, 0x91, 0x44, 0x75, 0x2b, 0x23, 0x7d, 0xdd, 0x2a, + 0xc9, 0x25, 0x8e, 0xe6, 0x1c, 0xb8, 0x53, 0x67, 0x21, 0x3b, 0x35, 0x00, 0x1c, 0xe2, 0x42, 0x66, + 0x5c, 0x9c, 0x89, 0xa5, 0x25, 0x19, 0xf9, 0x45, 0x99, 0x25, 0x95, 0x60, 0xc7, 0xe2, 0xb3, 0x10, + 0xa1, 0x54, 0xc8, 0x9e, 0x8b, 0x0d, 0x12, 0x67, 0x60, 0x57, 0xe2, 0xf7, 0x21, 0xc4, 0x2a, 0x27, + 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0xda, 0xac, 0xf8, 0x40, 0x8e, 0x46, 0x18, 0x88, 0xe2, + 0x6e, 0x88, 0x06, 0x98, 0xbb, 0x8d, 0x1e, 0x32, 0x71, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x15, 0x73, + 0xf1, 0xa2, 0xa6, 0x09, 0x6d, 0x3c, 0x96, 0xa2, 0x47, 0x98, 0x94, 0x31, 0x09, 0x8a, 0xe1, 0x41, + 0xc6, 0x20, 0x94, 0xc7, 0xc5, 0x83, 0x12, 0x60, 0x5a, 0x84, 0x8c, 0x41, 0xa8, 0x95, 0x32, 0x22, + 0x5e, 0x2d, 0xcc, 0x46, 0x84, 0x7d, 0xd0, 0xb4, 0x44, 0x94, 0x7d, 0x10, 0xb5, 0xc4, 0xd9, 0x87, + 0x9a, 0x28, 0xa4, 0x58, 0x1b, 0x9e, 0x6f, 0xd0, 0x62, 0x74, 0x0a, 0x39, 0xf1, 0x48, 0x8e, 0xf1, + 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, + 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xab, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, + 0x5c, 0x7d, 0x1f, 0x88, 0xf1, 0xba, 0x01, 0xa0, 0x7c, 0x9a, 0x9c, 0x9f, 0xa3, 0x0f, 0xcb, 0xd1, + 0x15, 0xe8, 0x79, 0xba, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x9c, 0xa1, 0x8d, 0x01, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x14, 0xa8, 0x29, 0x75, 0xab, 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // UploadHeaders adds a batch of headers to the bnb light client chain + UploadHeaders(ctx context.Context, in *MsgUploadHeaders, opts ...grpc.CallOption) (*MsgUploadHeadersResponse, error) + // UpdateParams defines a method for updating bnb light client module + // parameters. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // UpdateHeader defines a method for updating bnb light client header. + UpdateHeader(ctx context.Context, in *MsgUpdateHeader, opts ...grpc.CallOption) (*MsgUpdateHeaderResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UploadHeaders(ctx context.Context, in *MsgUploadHeaders, opts ...grpc.CallOption) (*MsgUploadHeadersResponse, error) { + out := new(MsgUploadHeadersResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Msg/UploadHeaders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateHeader(ctx context.Context, in *MsgUpdateHeader, opts ...grpc.CallOption) (*MsgUpdateHeaderResponse, error) { + out := new(MsgUpdateHeaderResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Msg/UpdateHeader", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // UploadHeaders adds a batch of headers to the bnb light client chain + UploadHeaders(context.Context, *MsgUploadHeaders) (*MsgUploadHeadersResponse, error) + // UpdateParams defines a method for updating bnb light client module + // parameters. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // UpdateHeader defines a method for updating bnb light client header. + UpdateHeader(context.Context, *MsgUpdateHeader) (*MsgUpdateHeaderResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UploadHeaders(ctx context.Context, req *MsgUploadHeaders) (*MsgUploadHeadersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UploadHeaders not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} +func (*UnimplementedMsgServer) UpdateHeader(ctx context.Context, req *MsgUpdateHeader) (*MsgUpdateHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateHeader not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UploadHeaders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUploadHeaders) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UploadHeaders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Msg/UploadHeaders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UploadHeaders(ctx, req.(*MsgUploadHeaders)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateHeader) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateHeader(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Msg/UpdateHeader", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateHeader(ctx, req.(*MsgUpdateHeader)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "lorenzo.bnblightclient.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UploadHeaders", + Handler: _Msg_UploadHeaders_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + { + MethodName: "UpdateHeader", + Handler: _Msg_UpdateHeader_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lorenzo/bnblightclient/v1/tx.proto", +} + +func (m *MsgUploadHeaders) 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 *MsgUploadHeaders) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUploadHeaders) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + 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 = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgUploadHeadersResponse) 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 *MsgUploadHeadersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUploadHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateHeader) 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 *MsgUpdateHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x12 + } + if m.Headers != nil { + { + size, err := m.Headers.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateHeaderResponse) 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 *MsgUpdateHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUploadHeaders) 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 + sovTx(uint64(l)) + } + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUploadHeadersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Headers != nil { + l = m.Headers.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUploadHeaders) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUploadHeaders: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUploadHeaders: 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Headers = append(m.Headers, &Header{}) + if err := m.Headers[len(m.Headers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUploadHeadersResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUploadHeadersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUploadHeadersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateHeader: 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 ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Headers == nil { + m.Headers = &Header{} + } + if err := m.Headers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateHeaderResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/btcstaking/types/tx.pb.go b/x/btcstaking/types/tx.pb.go index b631aba9..7abdb314 100644 --- a/x/btcstaking/types/tx.pb.go +++ b/x/btcstaking/types/tx.pb.go @@ -245,6 +245,102 @@ func (m *MsgCreateBTCStakingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateBTCStakingResponse proto.InternalMessageInfo +type MsgCreateBTCStakingFromBNB struct { + Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` + Receipt []byte `protobuf:"bytes,2,opt,name=receipt,proto3" json:"receipt,omitempty"` + Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *MsgCreateBTCStakingFromBNB) Reset() { *m = MsgCreateBTCStakingFromBNB{} } +func (m *MsgCreateBTCStakingFromBNB) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBTCStakingFromBNB) ProtoMessage() {} +func (*MsgCreateBTCStakingFromBNB) Descriptor() ([]byte, []int) { + return fileDescriptor_6be51bab5db52b8e, []int{4} +} +func (m *MsgCreateBTCStakingFromBNB) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBTCStakingFromBNB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBTCStakingFromBNB.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 *MsgCreateBTCStakingFromBNB) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBTCStakingFromBNB.Merge(m, src) +} +func (m *MsgCreateBTCStakingFromBNB) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBTCStakingFromBNB) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBTCStakingFromBNB.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBTCStakingFromBNB proto.InternalMessageInfo + +func (m *MsgCreateBTCStakingFromBNB) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +func (m *MsgCreateBTCStakingFromBNB) GetReceipt() []byte { + if m != nil { + return m.Receipt + } + return nil +} + +func (m *MsgCreateBTCStakingFromBNB) GetProof() []byte { + if m != nil { + return m.Proof + } + return nil +} + +type MsgCreateBTCStakingFromBNBResponse struct { +} + +func (m *MsgCreateBTCStakingFromBNBResponse) Reset() { *m = MsgCreateBTCStakingFromBNBResponse{} } +func (m *MsgCreateBTCStakingFromBNBResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateBTCStakingFromBNBResponse) ProtoMessage() {} +func (*MsgCreateBTCStakingFromBNBResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_6be51bab5db52b8e, []int{5} +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse.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 *MsgCreateBTCStakingFromBNBResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse.Merge(m, src) +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateBTCStakingFromBNBResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateBTCStakingFromBNBResponse proto.InternalMessageInfo + type MsgBurnRequest struct { Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` BtcTargetAddress string `protobuf:"bytes,2,opt,name=btc_target_address,json=btcTargetAddress,proto3" json:"btc_target_address,omitempty"` @@ -255,7 +351,7 @@ func (m *MsgBurnRequest) Reset() { *m = MsgBurnRequest{} } func (m *MsgBurnRequest) String() string { return proto.CompactTextString(m) } func (*MsgBurnRequest) ProtoMessage() {} func (*MsgBurnRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{4} + return fileDescriptor_6be51bab5db52b8e, []int{6} } func (m *MsgBurnRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -305,7 +401,7 @@ func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} } func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) } func (*MsgBurnResponse) ProtoMessage() {} func (*MsgBurnResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{5} + return fileDescriptor_6be51bab5db52b8e, []int{7} } func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -343,7 +439,7 @@ func (m *MsgAddReceiver) Reset() { *m = MsgAddReceiver{} } func (m *MsgAddReceiver) String() string { return proto.CompactTextString(m) } func (*MsgAddReceiver) ProtoMessage() {} func (*MsgAddReceiver) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{6} + return fileDescriptor_6be51bab5db52b8e, []int{8} } func (m *MsgAddReceiver) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -393,7 +489,7 @@ func (m *MsgAddReceiverResponse) Reset() { *m = MsgAddReceiverResponse{} func (m *MsgAddReceiverResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddReceiverResponse) ProtoMessage() {} func (*MsgAddReceiverResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{7} + return fileDescriptor_6be51bab5db52b8e, []int{9} } func (m *MsgAddReceiverResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -431,7 +527,7 @@ func (m *MsgRemoveReceiver) Reset() { *m = MsgRemoveReceiver{} } func (m *MsgRemoveReceiver) String() string { return proto.CompactTextString(m) } func (*MsgRemoveReceiver) ProtoMessage() {} func (*MsgRemoveReceiver) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{8} + return fileDescriptor_6be51bab5db52b8e, []int{10} } func (m *MsgRemoveReceiver) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -481,7 +577,7 @@ func (m *MsgRemoveReceiverResponse) Reset() { *m = MsgRemoveReceiverResp func (m *MsgRemoveReceiverResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveReceiverResponse) ProtoMessage() {} func (*MsgRemoveReceiverResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{9} + return fileDescriptor_6be51bab5db52b8e, []int{11} } func (m *MsgRemoveReceiverResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -519,7 +615,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{10} + return fileDescriptor_6be51bab5db52b8e, []int{12} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -569,7 +665,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6be51bab5db52b8e, []int{11} + return fileDescriptor_6be51bab5db52b8e, []int{13} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -603,6 +699,8 @@ func init() { proto.RegisterType((*TransactionInfo)(nil), "lorenzo.btcstaking.v1.TransactionInfo") proto.RegisterType((*MsgCreateBTCStaking)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStaking") proto.RegisterType((*MsgCreateBTCStakingResponse)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStakingResponse") + proto.RegisterType((*MsgCreateBTCStakingFromBNB)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStakingFromBNB") + proto.RegisterType((*MsgCreateBTCStakingFromBNBResponse)(nil), "lorenzo.btcstaking.v1.MsgCreateBTCStakingFromBNBResponse") proto.RegisterType((*MsgBurnRequest)(nil), "lorenzo.btcstaking.v1.MsgBurnRequest") proto.RegisterType((*MsgBurnResponse)(nil), "lorenzo.btcstaking.v1.MsgBurnResponse") proto.RegisterType((*MsgAddReceiver)(nil), "lorenzo.btcstaking.v1.MsgAddReceiver") @@ -616,55 +714,59 @@ func init() { func init() { proto.RegisterFile("lorenzo/btcstaking/v1/tx.proto", fileDescriptor_6be51bab5db52b8e) } var fileDescriptor_6be51bab5db52b8e = []byte{ - // 754 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x41, 0x4f, 0x13, 0x41, - 0x14, 0xc7, 0xbb, 0x52, 0x1a, 0xfb, 0x8a, 0x05, 0x46, 0x84, 0xb2, 0x84, 0x96, 0x34, 0x81, 0x10, - 0x62, 0xb7, 0x52, 0x13, 0x4c, 0xd4, 0x83, 0x2c, 0xd1, 0x40, 0xb4, 0x09, 0x59, 0xca, 0xc5, 0x4b, - 0xb3, 0xdd, 0x1d, 0xb6, 0x0d, 0x74, 0xa7, 0xce, 0x4c, 0x6b, 0x6b, 0x3c, 0x18, 0x3e, 0x81, 0xf1, - 0xe0, 0xc5, 0xf8, 0x09, 0xbc, 0x70, 0xf0, 0x43, 0x70, 0x24, 0x9e, 0x0c, 0x07, 0x62, 0xe0, 0xc0, - 0xd7, 0x30, 0xbb, 0x33, 0x6d, 0xb7, 0xd0, 0x42, 0xa3, 0xa7, 0xf6, 0xcd, 0x7b, 0xf3, 0xfe, 0xbf, - 0xf7, 0xe6, 0xcd, 0x0e, 0x24, 0x0f, 0x08, 0xc5, 0xee, 0x07, 0x92, 0x2d, 0x71, 0x8b, 0x71, 0x73, - 0xbf, 0xe2, 0x3a, 0xd9, 0xc6, 0x6a, 0x96, 0x37, 0xb5, 0x1a, 0x25, 0x9c, 0xa0, 0x07, 0xd2, 0xaf, - 0x75, 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0x3b, 0x6a, 0x7b, 0x30, 0xd6, 0x33, 0x55, 0x37, 0xb4, 0x22, 0x18, 0xa7, 0x6a, - 0xc3, 0xc5, 0xb5, 0x75, 0xd4, 0xd1, 0x4f, 0x97, 0x47, 0x2b, 0x8a, 0xbe, 0x7d, 0x7c, 0x9e, 0x54, - 0x4e, 0xce, 0x93, 0xca, 0x9f, 0xf3, 0xa4, 0xf2, 0xf9, 0x22, 0x19, 0x3a, 0xb9, 0x48, 0x86, 0x7e, - 0x5f, 0x24, 0x43, 0x6f, 0xd7, 0x86, 0x79, 0x79, 0x9a, 0xc1, 0x57, 0xcf, 0xff, 0x28, 0x95, 0x22, - 0xfe, 0x93, 0xf7, 0xf8, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0xca, 0x56, 0xe8, 0x99, 0x07, - 0x00, 0x00, + // 817 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0xcf, 0x4f, 0xeb, 0x46, + 0x10, 0xc7, 0xe3, 0x02, 0x69, 0x33, 0x79, 0xcd, 0x7b, 0x6c, 0x29, 0x04, 0x23, 0x12, 0x64, 0x15, + 0x84, 0x50, 0xe3, 0x40, 0x2a, 0x51, 0xf5, 0xc7, 0xa1, 0x18, 0x15, 0x81, 0xda, 0x54, 0xc8, 0x84, + 0x4b, 0x2f, 0x91, 0x63, 0x2f, 0x4e, 0x04, 0xf6, 0xa6, 0xbb, 0x9b, 0x34, 0xa9, 0x7a, 0xa8, 0xb8, + 0xf4, 0xd0, 0x4b, 0x4f, 0xbd, 0xb4, 0xfd, 0x0b, 0x7a, 0xe1, 0xd0, 0x3f, 0x82, 0x23, 0xea, 0xa9, + 0xe2, 0x80, 0x2a, 0x38, 0xf0, 0x6f, 0x54, 0xf6, 0x6e, 0x1c, 0x07, 0x62, 0x48, 0xfb, 0x4e, 0x30, + 0x3b, 0xb3, 0xf3, 0xfd, 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 0x80, 0x6b, 0xc0, 0x5c, 0xf9, 0x6d, 0x06, 0xa6, 0xaa, 0xcc, + 0x45, 0x14, 0x5e, 0x3d, 0x7a, 0x39, 0x36, 0x12, 0x34, 0xc7, 0x6c, 0x86, 0x5a, 0x99, 0x3c, 0x76, + 0xa0, 0x8d, 0x7e, 0x54, 0x60, 0x21, 0x69, 0xdf, 0xb7, 0x26, 0xcf, 0x27, 0xaf, 0xa8, 0x1f, 0xfd, + 0xe7, 0x2b, 0x11, 0xc9, 0x31, 0x4c, 0x07, 0x7b, 0x81, 0x56, 0x93, 0x53, 0xc4, 0x96, 0x5c, 0x5d, + 0x7b, 0x2e, 0x4c, 0xa6, 0xb5, 0x21, 0x1b, 0x5f, 0xad, 0x27, 0xb2, 0xc7, 0xc2, 0xd4, 0xd2, 0x44, + 0x61, 0x91, 0xc8, 0x19, 0xe4, 0x1e, 0x2c, 0xc2, 0x7a, 0x72, 0x82, 0xd1, 0x48, 0x75, 0x73, 0xd2, + 0xc8, 0x48, 0xed, 0x04, 0x5e, 0x8c, 0xcc, 0xf7, 0x13, 0xad, 0x88, 0xc7, 0xa9, 0xfa, 0x64, 0x71, + 0x03, 0x1d, 0x75, 0xe6, 0x87, 0xfb, 0x8b, 0x0d, 0xc5, 0x38, 0xbc, 0xbc, 0x2d, 0x28, 0x57, 0xb7, + 0x05, 0xe5, 0x9f, 0xdb, 0x82, 0xf2, 0xf3, 0x5d, 0x21, 0x75, 0x75, 0x57, 0x48, 0xfd, 0x7d, 0x57, + 0x48, 0x7d, 0xbd, 0x3d, 0xc9, 0xff, 0xed, 0x5e, 0xfc, 0x9b, 0x21, 0x7c, 0x1e, 0x1b, 0xe9, 0xf0, + 0x83, 0xe1, 0x83, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x22, 0x0e, 0x06, 0x0c, 0xd7, 0x08, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -680,6 +782,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { CreateBTCStaking(ctx context.Context, in *MsgCreateBTCStaking, opts ...grpc.CallOption) (*MsgCreateBTCStakingResponse, error) + CreateBTCStakingFromBNB(ctx context.Context, in *MsgCreateBTCStakingFromBNB, opts ...grpc.CallOption) (*MsgCreateBTCStakingFromBNBResponse, error) Burn(ctx context.Context, in *MsgBurnRequest, opts ...grpc.CallOption) (*MsgBurnResponse, error) AddReceiver(ctx context.Context, in *MsgAddReceiver, opts ...grpc.CallOption) (*MsgAddReceiverResponse, error) RemoveReceiver(ctx context.Context, in *MsgRemoveReceiver, opts ...grpc.CallOption) (*MsgRemoveReceiverResponse, error) @@ -703,6 +806,15 @@ func (c *msgClient) CreateBTCStaking(ctx context.Context, in *MsgCreateBTCStakin return out, nil } +func (c *msgClient) CreateBTCStakingFromBNB(ctx context.Context, in *MsgCreateBTCStakingFromBNB, opts ...grpc.CallOption) (*MsgCreateBTCStakingFromBNBResponse, error) { + out := new(MsgCreateBTCStakingFromBNBResponse) + err := c.cc.Invoke(ctx, "/lorenzo.btcstaking.v1.Msg/CreateBTCStakingFromBNB", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) Burn(ctx context.Context, in *MsgBurnRequest, opts ...grpc.CallOption) (*MsgBurnResponse, error) { out := new(MsgBurnResponse) err := c.cc.Invoke(ctx, "/lorenzo.btcstaking.v1.Msg/Burn", in, out, opts...) @@ -742,6 +854,7 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { CreateBTCStaking(context.Context, *MsgCreateBTCStaking) (*MsgCreateBTCStakingResponse, error) + CreateBTCStakingFromBNB(context.Context, *MsgCreateBTCStakingFromBNB) (*MsgCreateBTCStakingFromBNBResponse, error) Burn(context.Context, *MsgBurnRequest) (*MsgBurnResponse, error) AddReceiver(context.Context, *MsgAddReceiver) (*MsgAddReceiverResponse, error) RemoveReceiver(context.Context, *MsgRemoveReceiver) (*MsgRemoveReceiverResponse, error) @@ -755,6 +868,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) CreateBTCStaking(ctx context.Context, req *MsgCreateBTCStaking) (*MsgCreateBTCStakingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBTCStaking not implemented") } +func (*UnimplementedMsgServer) CreateBTCStakingFromBNB(ctx context.Context, req *MsgCreateBTCStakingFromBNB) (*MsgCreateBTCStakingFromBNBResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateBTCStakingFromBNB not implemented") +} func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurnRequest) (*MsgBurnResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented") } @@ -790,6 +906,24 @@ func _Msg_CreateBTCStaking_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Msg_CreateBTCStakingFromBNB_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateBTCStakingFromBNB) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateBTCStakingFromBNB(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.btcstaking.v1.Msg/CreateBTCStakingFromBNB", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateBTCStakingFromBNB(ctx, req.(*MsgCreateBTCStakingFromBNB)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgBurnRequest) if err := dec(in); err != nil { @@ -870,6 +1004,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateBTCStaking", Handler: _Msg_CreateBTCStaking_Handler, }, + { + MethodName: "CreateBTCStakingFromBNB", + Handler: _Msg_CreateBTCStakingFromBNB_Handler, + }, { MethodName: "Burn", Handler: _Msg_Burn_Handler, @@ -1052,6 +1190,73 @@ func (m *MsgCreateBTCStakingResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } +func (m *MsgCreateBTCStakingFromBNB) 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 *MsgCreateBTCStakingFromBNB) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBTCStakingFromBNB) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x1a + } + if len(m.Receipt) > 0 { + i -= len(m.Receipt) + copy(dAtA[i:], m.Receipt) + i = encodeVarintTx(dAtA, i, uint64(len(m.Receipt))) + i-- + dAtA[i] = 0x12 + } + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateBTCStakingFromBNBResponse) 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 *MsgCreateBTCStakingFromBNBResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateBTCStakingFromBNBResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgBurnRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1386,6 +1591,36 @@ func (m *MsgCreateBTCStakingResponse) Size() (n int) { return n } +func (m *MsgCreateBTCStakingFromBNB) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Receipt) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateBTCStakingFromBNBResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgBurnRequest) Size() (n int) { if m == nil { return 0 @@ -1952,6 +2187,206 @@ func (m *MsgCreateBTCStakingResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreateBTCStakingFromBNB) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateBTCStakingFromBNB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBTCStakingFromBNB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipt", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Receipt = append(m.Receipt[:0], dAtA[iNdEx:postIndex]...) + if m.Receipt == nil { + m.Receipt = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateBTCStakingFromBNBResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateBTCStakingFromBNBResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateBTCStakingFromBNBResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MsgBurnRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 63dcf7c76a7886277727dff8eeb96f40b7251ac1 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 18 Jul 2024 11:03:54 +0800 Subject: [PATCH 04/19] add msgServer&grpcQuery --- x/bnblightclient/keeper/grpc_query.go | 29 +++++++++++++++++++++ x/bnblightclient/keeper/keeper.go | 5 ++++ x/bnblightclient/keeper/msg_server.go | 36 +++++++++++++++++++++++++++ x/btcstaking/keeper/msg_server.go | 7 ++++++ 4 files changed, 77 insertions(+) create mode 100644 x/bnblightclient/keeper/grpc_query.go create mode 100644 x/bnblightclient/keeper/keeper.go create mode 100644 x/bnblightclient/keeper/msg_server.go diff --git a/x/bnblightclient/keeper/grpc_query.go b/x/bnblightclient/keeper/grpc_query.go new file mode 100644 index 00000000..823b2866 --- /dev/null +++ b/x/bnblightclient/keeper/grpc_query.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "context" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +var _ types.QueryServer = Querier{} + +// Querier defines a wrapper around the x/bnblightclient keeper providing gRPC method +type Querier struct { + k Keeper +} + +// Header implements types.QueryServer. +func (q Querier) Header(context.Context, *types.QueryHeaderRequest) (*types.QueryHeaderResponse, error) { + panic("unimplemented") +} + +// LatestedHeader implements types.QueryServer. +func (q Querier) LatestedHeader(context.Context, *types.QueryLatestedHeaderRequest) (*types.QueryLatestedHeaderResponse, error) { + panic("unimplemented") +} + +// Params implements types.QueryServer. +func (q Querier) Params(context.Context, *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + panic("unimplemented") +} diff --git a/x/bnblightclient/keeper/keeper.go b/x/bnblightclient/keeper/keeper.go new file mode 100644 index 00000000..f1ffc873 --- /dev/null +++ b/x/bnblightclient/keeper/keeper.go @@ -0,0 +1,5 @@ +package keeper + +type Keeper struct { + // Your definitions here. +} \ No newline at end of file diff --git a/x/bnblightclient/keeper/msg_server.go b/x/bnblightclient/keeper/msg_server.go new file mode 100644 index 00000000..8120ad64 --- /dev/null +++ b/x/bnblightclient/keeper/msg_server.go @@ -0,0 +1,36 @@ +package keeper + +import ( + "context" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +type msgServer struct { + k Keeper +} + +var _ types.MsgServer = msgServer{} + +// UpdateHeader implements types.MsgServer. +func (m msgServer) UpdateHeader(context.Context, *types.MsgUpdateHeader) (*types.MsgUpdateHeaderResponse, error) { + panic("unimplemented") +} + +// UpdateParams implements types.MsgServer. +func (m msgServer) UpdateParams(context.Context, *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + panic("unimplemented") +} + +// UploadHeaders implements types.MsgServer. +func (m msgServer) UploadHeaders(context.Context, *types.MsgUploadHeaders) (*types.MsgUploadHeadersResponse, error) { + panic("unimplemented") +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{k: keeper} +} + + diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index 1e0cc0a4..0ea40636 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -31,6 +31,8 @@ type msgServer struct { *Keeper } + + // NewMsgServerImpl returns an implementation of the MsgServer interface // for the provided Keeper. func NewMsgServerImpl(keeper *Keeper) types.MsgServer { @@ -259,6 +261,11 @@ func (ms msgServer) Burn(goCtx context.Context, req *types.MsgBurnRequest) (*typ return &types.MsgBurnResponse{}, nil } +// CreateBTCStakingFromBNB implements types.MsgServer. +func (ms msgServer) CreateBTCStakingFromBNB(context.Context, *types.MsgCreateBTCStakingFromBNB) (*types.MsgCreateBTCStakingFromBNBResponse, error) { + panic("unimplemented") +} + func findReceiver(receivers []*types.Receiver, name string) (int, *types.Receiver) { var receiver *types.Receiver = nil idx := -1 From 1f44bc73bdfec4dec41b4ef471767c7832d93457 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 18 Jul 2024 11:13:40 +0800 Subject: [PATCH 05/19] implement eth proof --- x/bnblightclient/types/keys.go | 1 + x/bnblightclient/types/proof.go | 171 ++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 x/bnblightclient/types/keys.go create mode 100644 x/bnblightclient/types/proof.go diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go new file mode 100644 index 00000000..7193a74c --- /dev/null +++ b/x/bnblightclient/types/keys.go @@ -0,0 +1 @@ +package types \ No newline at end of file diff --git a/x/bnblightclient/types/proof.go b/x/bnblightclient/types/proof.go new file mode 100644 index 00000000..6d045316 --- /dev/null +++ b/x/bnblightclient/types/proof.go @@ -0,0 +1,171 @@ +package types + +import ( + "bytes" + "encoding/base64" + "errors" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" +) + +// Proof is a struct that contains the index, value, and proof. +type Proof struct { + Index []byte `json:"index"` + Value []byte `json:"value"` + Path ProofPath `json:"path"` +} + +// ProofPath is a struct that contains the keys and values of the proof. +type ProofPath struct { + Keys []string `json:"keys"` + Values [][]byte `json:"values"` +} + +// NewProofPath creates a new ProofPath. +func NewProofPath() ProofPath { + return ProofPath{ + Keys: make([]string, 0), + Values: make([][]byte, 0), + } +} + +// Put adds a new key-value pair to the ProofPath. +func (pm *ProofPath) Put(key []byte, value []byte) error { + if pm.Keys == nil || pm.Values == nil { + return errors.New("proofMap db is nil") + } + + vIdx := pm.valueIdx(key) + if vIdx != -1 { + pm.Values[vIdx] = value + return nil + } + + pm.Keys = append(pm.Keys, pm.encodeKey(key)) + pm.Values = append(pm.Values, value) + return nil +} + +// Delete removes a key-value pair from the ProofPath. +func (pm *ProofPath) Delete(key []byte) error { + if pm.Keys == nil || pm.Values == nil { + return errors.New("proofMap db is nil") + } + + vIdx := pm.valueIdx(key) + if vIdx == -1 { + return errors.New("key not found") + } + + pm.Keys = append(pm.Keys[:vIdx], pm.Keys[vIdx+1:]...) + pm.Values = append(pm.Values[:vIdx], pm.Values[vIdx+1:]...) + + return nil +} + +// Has checks if a key exists in the ProofPath. +func (pm *ProofPath) Has(key []byte) (bool, error) { + if pm.Keys == nil || pm.Values == nil { + return false, errors.New("proofMap db is nil") + } + vIdx := pm.valueIdx(key) + if vIdx == -1 { + return false, nil + } + return true, nil +} + +// Get returns the value of a key in the ProofPath. +func (pm *ProofPath) Get(key []byte) ([]byte, error) { + if pm.Keys == nil || pm.Values == nil { + return nil, errors.New("proofMap db is nil") + } + + vIdx := pm.valueIdx(key) + if vIdx == -1 { + return nil, errors.New("value not found") + } + return pm.Values[vIdx], nil +} + +func (pm *ProofPath) encodeKey(key []byte) string { + return base64.StdEncoding.EncodeToString(key) +} + +func (pm *ProofPath) valueIdx(key []byte) int { + encodedKey := pm.encodeKey(key) + for i, k := range pm.Keys { + if k == encodedKey { + return i + } + } + return -1 +} + +// GenReceiptProof generates a Merkle Patricia Trie (MPT) proof for a specific transaction index in a list of receipts. +// +// Parameters: +// - txIndex: the index of the transaction for which the proof is generated. +// - root: the root hash of the MPT. +// - receipts: a list of receipts. +// +// Returns: +// - *mptproof.MPTProof: a pointer to an MPTProof struct containing the index, value, and proof of the transaction. +// - error: an error if the proof generation fails. +func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*types.Receipt) (*Proof, error) { + db := trie.NewDatabase(rawdb.NewMemoryDatabase()) + mpt := trie.NewEmpty(db) + receiptHash := types.DeriveSha(types.Receipts(receipts), mpt) + if receiptHash != root { + return nil, errors.New("root hash mismatch") + } + + var indexBuf []byte + indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(txIndex)) + valueTarget := mpt.Get(indexBuf) + + proof := NewProofPath() + err := mpt.Prove(indexBuf, 0, &proof) + if err != nil { + return nil, err + } + + res := Proof{ + Index: indexBuf, + Value: valueTarget, + Path: proof, + } + + return &res, nil +} + + +// VerifyReceiptProof verifies the proof of a receipt in a Merkle Patricia Trie (MPT). +// +// Parameters: +// - receipt: a pointer to a Receipt struct representing the receipt to verify. +// - root: a common.Hash representing the root hash of the MPT. +// - proof: a Proof struct representing the proof to verify. +// +// Returns: +// - bool: true if the proof is valid, false otherwise. +func VerifyReceiptProof(receipt *types.Receipt, root common.Hash, proof Proof) bool { + db := trie.NewDatabase(rawdb.NewMemoryDatabase()) + mpt := trie.NewEmpty(db) + _ = types.DeriveSha(types.Receipts{receipt}, mpt) + + var indexBuf []byte + indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(0)) + receiptValue := mpt.Get(indexBuf) + + val, err := trie.VerifyProof(root, proof.Index, &proof.Path) + + if err == nil && bytes.Equal(val, proof.Value) && bytes.Equal(val, receiptValue) { + return true + } + return false +} From 7a0dd9495e9b418f44c3fd21b35642d2ae650ad4 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 18 Jul 2024 18:31:09 +0800 Subject: [PATCH 06/19] implement logic code --- go.mod | 2 +- proto/lorenzo/bnblightclient/v1/client.proto | 22 +- proto/lorenzo/bnblightclient/v1/params.proto | 8 +- proto/lorenzo/bnblightclient/v1/query.proto | 17 + proto/lorenzo/bnblightclient/v1/tx.proto | 2 +- x/bnblightclient/keeper/grpc_query.go | 39 +- x/bnblightclient/keeper/header.go | 141 ++++++ x/bnblightclient/keeper/keeper.go | 59 ++- x/bnblightclient/keeper/msg_server.go | 60 ++- x/bnblightclient/keeper/params.go | 37 ++ x/bnblightclient/types/client.pb.go | 216 +++------ x/bnblightclient/types/errors.go | 17 + x/bnblightclient/types/header.go | 158 +++++++ x/bnblightclient/types/keys.go | 60 ++- x/bnblightclient/types/params.go | 50 ++ x/bnblightclient/types/params.pb.go | 110 ++--- x/bnblightclient/types/proof.go | 28 -- x/bnblightclient/types/query.pb.go | 460 +++++++++++++++++-- x/bnblightclient/types/query.pb.gw.go | 101 ++++ x/bnblightclient/types/tx.pb.go | 85 ++-- 20 files changed, 1305 insertions(+), 367 deletions(-) create mode 100644 x/bnblightclient/keeper/header.go create mode 100644 x/bnblightclient/keeper/params.go create mode 100644 x/bnblightclient/types/errors.go create mode 100644 x/bnblightclient/types/header.go create mode 100644 x/bnblightclient/types/params.go diff --git a/go.mod b/go.mod index 85c4de6a..5151831f 100644 --- a/go.mod +++ b/go.mod @@ -40,6 +40,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 + golang.org/x/crypto v0.21.0 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 ) @@ -208,7 +209,6 @@ require ( go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect golang.org/x/sync v0.6.0 // indirect diff --git a/proto/lorenzo/bnblightclient/v1/client.proto b/proto/lorenzo/bnblightclient/v1/client.proto index a464aa13..7be17b2a 100644 --- a/proto/lorenzo/bnblightclient/v1/client.proto +++ b/proto/lorenzo/bnblightclient/v1/client.proto @@ -6,16 +6,16 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; message Header { - message Header { - option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_getters) = false; - // header defines the bnb header bytes - bytes raw_header = 1; - // hash defines the bnb header hash - bytes hash = 2; - // number defines the block number - uint64 number = 3; - // receipt_root defines the receipts merkle root hash - bytes receipt_root = 4; - } + // header defines the bnb header bytes + bytes raw_header = 1; + // parent_hash defines the previous bnb header hash + bytes parent_hash = 2; + // hash defines the bnb header hash + bytes hash = 3; + // number defines the block number + uint64 number = 4; + // receipt_root defines the receipts merkle root hash + bytes receipt_root = 5; } \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/params.proto b/proto/lorenzo/bnblightclient/v1/params.proto index 33b937f1..6a1973f5 100644 --- a/proto/lorenzo/bnblightclient/v1/params.proto +++ b/proto/lorenzo/bnblightclient/v1/params.proto @@ -9,13 +9,11 @@ option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" message Params { option (gogoproto.equal) = true; - bytes chain_id = 1 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; + bytes chain_id = 1 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; // the stake plan hub contract address string stake_plan_hub_address = 2; - // the stake plan hub contract method id - string stake_plan_hub_method_id = 3; // the maximum number of bnb block headers to retain - uint64 retained_blocks = 4; + uint64 retained_blocks = 3; // list of people who can upload bnb block header information - repeated string allow_list = 5; + repeated string allow_list = 4; } \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/query.proto b/proto/lorenzo/bnblightclient/v1/query.proto index fdab0551..a3de81e7 100644 --- a/proto/lorenzo/bnblightclient/v1/query.proto +++ b/proto/lorenzo/bnblightclient/v1/query.proto @@ -20,6 +20,12 @@ service Query { option (google.api.http).get = "/lorenzo/bnblightclient/v1/header/{number}"; } + // HeaderByHash returns the header in bnb chain by hash + rpc HeaderByHash(QueryHeaderByHashRequest) + returns (QueryHeaderByHashResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/header/{hash}/hash"; + } + // LatestedHeader returns the latested header in bnb chain rpc LatestedHeader(QueryLatestedHeaderRequest) returns (QueryLatestedHeaderResponse) { @@ -45,6 +51,17 @@ message QueryHeaderResponse { lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = true ]; } +// QueryHeaderByHashRequest is the request type for the Query/HeaderByHash RPC +// method. +message QueryHeaderByHashRequest { bytes hash = 1; } + +// QueryHeaderByHashResponse is the response type for the Query/HeaderByHash RPC +// method. +message QueryHeaderByHashResponse { + // params holds all the parameters of this module. + lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = true ]; +} + // QueryLatestedHeaderRequest is the request type for the Query/LatestedHeader // RPC method. message QueryLatestedHeaderRequest {} diff --git a/proto/lorenzo/bnblightclient/v1/tx.proto b/proto/lorenzo/bnblightclient/v1/tx.proto index f7d7f9d4..91b8e5ca 100644 --- a/proto/lorenzo/bnblightclient/v1/tx.proto +++ b/proto/lorenzo/bnblightclient/v1/tx.proto @@ -38,7 +38,7 @@ message MsgUploadHeadersResponse {} message MsgUpdateHeader { option (cosmos.msg.v1.signer) = "signer"; - lorenzo.bnblightclient.v1.Header headers = 1; + lorenzo.bnblightclient.v1.Header header = 1; string signer = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; } // MsgUpdateHeaderResponse defines the response for the UpdateHeader diff --git a/x/bnblightclient/keeper/grpc_query.go b/x/bnblightclient/keeper/grpc_query.go index 823b2866..df6dbf18 100644 --- a/x/bnblightclient/keeper/grpc_query.go +++ b/x/bnblightclient/keeper/grpc_query.go @@ -3,6 +3,9 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" ) @@ -14,16 +17,40 @@ type Querier struct { } // Header implements types.QueryServer. -func (q Querier) Header(context.Context, *types.QueryHeaderRequest) (*types.QueryHeaderResponse, error) { - panic("unimplemented") +func (q Querier) Header(goCtx context.Context, req *types.QueryHeaderRequest) (*types.QueryHeaderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + header, found := q.k.GetHeader(ctx, req.Number) + if !found { + return nil, errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found", req.Number) + } + return &types.QueryHeaderResponse{Header: header}, nil +} + +// HeaderByHash implements types.QueryServer. +func (q Querier) HeaderByHash(goCtx context.Context, req *types.QueryHeaderByHashRequest) (*types.QueryHeaderByHashResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + header, found := q.k.GetHeaderByHash(ctx, req.Hash) + if !found { + return nil, errorsmod.Wrapf(types.ErrHeaderNotFound, "header %x not found", req.Hash) + } + return &types.QueryHeaderByHashResponse{Header: header}, nil } // LatestedHeader implements types.QueryServer. -func (q Querier) LatestedHeader(context.Context, *types.QueryLatestedHeaderRequest) (*types.QueryLatestedHeaderResponse, error) { - panic("unimplemented") +func (q Querier) LatestedHeader(goCtx context.Context, req *types.QueryLatestedHeaderRequest) (*types.QueryLatestedHeaderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + header, found := q.k.GetLatestedHeader(ctx) + if !found { + return nil, errorsmod.Wrap(types.ErrHeaderNotFound, "latested header not found") + } + return &types.QueryLatestedHeaderResponse{Header: *header}, nil } // Params implements types.QueryServer. -func (q Querier) Params(context.Context, *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - panic("unimplemented") +func (q Querier) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + params := q.k.GetParams(ctx) + return &types.QueryParamsResponse{Params: params}, nil } diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go new file mode 100644 index 00000000..a71b25f5 --- /dev/null +++ b/x/bnblightclient/keeper/header.go @@ -0,0 +1,141 @@ +package keeper + +import ( + "slices" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +// UploadHeaders adds a batch of headers to the bnb light client chain +func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { + slices.SortFunc(headers, func(a, b *types.Header) int { + return int(a.Number - b.Number) + }) + + vHeader := headers + latestedHeader, exist := k.GetLatestedHeader(ctx) + if exist { + vHeader = append([]*types.Header{latestedHeader}, headers...) + } + + // verify headers + if err := types.VeryHeaders(vHeader); err != nil { + return err + } + + for _, header := range headers { + k.setHeader(ctx, header) + } + k.setLatestedHeaderNumber(ctx, headers[len(headers) - 1].Number) + return nil +} + +// UpdateHeader updates the header in the Keeper. +// +// Parameters: +// - ctx: the context object. +// - header: the header to be updated. +// +// Returns: +// - error: an error if the header update fails. +func(k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { + if err := types.VeryHeaders([]*types.Header{header}); err != nil { + return err + } + + if !k.HasHeader(ctx, header.Number) { + return errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found, cannot update", header.Number) + } + + k.setHeader(ctx, header) + return nil +} + + +// GetLatestedHeader retrieves the latested header from the store. +// +// Parameters: +// - ctx: the context object +// +// Returns: +// - types.Header: the latested header +// - bool: true if the header was found, false otherwise +func(k Keeper) GetLatestedHeader(ctx sdk.Context) (*types.Header, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyLatestedHeaderNumber()) + if bz == nil { + return nil, false + } + + number := sdk.BigEndianToUint64(bz) + return k.GetHeader(ctx, number) +} + +// GetHeader retrieves the header for a specific number from the store. +// +// Parameters: +// - ctx: the context object +// - number: the number of the header to retrieve +// +// Returns: +// - types.Header: the header object +// - bool: true if the header was found, false otherwise +func(k Keeper) GetHeader(ctx sdk.Context, number uint64) (*types.Header, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyHeader(number)) + if bz == nil { + return nil, false + } + var header types.Header + k.cdc.MustUnmarshal(bz, &header) + return &header, true +} + +// GetHeaderByHash retrieves a header from the store based on its hash. +// +// Parameters: +// - ctx: the context object +// - hash: the hash of the header to retrieve +// +// Returns: +// - *types.Header: the header object, or nil if not found +// - bool: true if the header was found, false otherwise +func(k Keeper) GetHeaderByHash(ctx sdk.Context, hash []byte) (*types.Header, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyHeaderHash(hash)) + if bz == nil { + return nil, false + } + + number := sdk.BigEndianToUint64(bz) + return k.GetHeader(ctx, number) +} + +// HasHeader checks if a header with the given number exists in the store. +// +// Parameters: +// - ctx: the context object +// - number: the number of the header to check +// Return type: bool +func(k Keeper) HasHeader(ctx sdk.Context, number uint64) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.KeyHeader(number)) +} + +func(k Keeper) setHeader(ctx sdk.Context, header *types.Header) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(header) + store.Set(types.KeyHeader(header.Number), bz) + + numberBz := sdk.Uint64ToBigEndian(header.Number) + store.Set(types.KeyHeaderHash(header.Hash), numberBz) +} + +func(k Keeper) setLatestedHeaderNumber(ctx sdk.Context, number uint64) { + store := ctx.KVStore(k.storeKey) + bz := sdk.Uint64ToBigEndian(number) + store.Set(types.KeyLatestedHeaderNumber(), bz) +} \ No newline at end of file diff --git a/x/bnblightclient/keeper/keeper.go b/x/bnblightclient/keeper/keeper.go index f1ffc873..0f0c1471 100644 --- a/x/bnblightclient/keeper/keeper.go +++ b/x/bnblightclient/keeper/keeper.go @@ -1,5 +1,60 @@ package keeper +import ( + "bytes" + + errorsmod "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + evmtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + type Keeper struct { - // Your definitions here. -} \ No newline at end of file + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + + // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. + authority string +} + +// VerifyReceiptProof verifies the proof of a receipt in the Ethereum blockchain. +// +// Parameters: +// - ctx: the SDK context. +// - receipt: the Ethereum receipt to verify. +// - proof: the proof of the receipt. +// +// Returns: +// - error: an error if the proof verification fails. +func (k Keeper) VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof types.Proof) error { + db := trie.NewDatabase(rawdb.NewMemoryDatabase()) + mpt := trie.NewEmpty(db) + _ = evmtypes.DeriveSha(evmtypes.Receipts{receipt}, mpt) + + var indexBuf []byte + indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(0)) + txValue := mpt.Get(indexBuf) + + header, exist := k.GetHeader(ctx, receipt.BlockNumber.Uint64()) + if !exist { + return errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found", header.Number) + } + + val, err := trie.VerifyProof(common.Hash(header.ReceiptRoot), proof.Index, &proof.Path) + if err != nil { + return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") + } + + if bytes.Equal(val, proof.Value) && bytes.Equal(val, txValue) { + return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") + } + + return nil +} diff --git a/x/bnblightclient/keeper/msg_server.go b/x/bnblightclient/keeper/msg_server.go index 8120ad64..b96c9020 100644 --- a/x/bnblightclient/keeper/msg_server.go +++ b/x/bnblightclient/keeper/msg_server.go @@ -2,6 +2,11 @@ package keeper import ( "context" + "slices" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" ) @@ -12,25 +17,54 @@ type msgServer struct { var _ types.MsgServer = msgServer{} +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{k: keeper} +} + // UpdateHeader implements types.MsgServer. -func (m msgServer) UpdateHeader(context.Context, *types.MsgUpdateHeader) (*types.MsgUpdateHeaderResponse, error) { - panic("unimplemented") +func (m msgServer) UpdateHeader(goCtx context.Context, req *types.MsgUpdateHeader) (*types.MsgUpdateHeaderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + params := m.k.GetParams(ctx) + if !slices.Contains(params.AllowList, req.Signer) { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "signer %s is not in allowlist", req.Signer) + } + + if err := m.k.UpdateHeader(ctx, req.Header); err != nil { + return nil, err + } + return &types.MsgUpdateHeaderResponse{}, nil } // UpdateParams implements types.MsgServer. -func (m msgServer) UpdateParams(context.Context, *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { - panic("unimplemented") -} +func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if m.k.authority != req.Authority { + return nil, errorsmod.Wrapf( + govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", m.k.authority, req.Authority) + } -// UploadHeaders implements types.MsgServer. -func (m msgServer) UploadHeaders(context.Context, *types.MsgUploadHeaders) (*types.MsgUploadHeadersResponse, error) { - panic("unimplemented") -} + if err := req.Params.Validate(); err != nil { + return nil, govtypes.ErrInvalidProposalMsg.Wrapf("invalid parameter: %v", err) + } -// NewMsgServerImpl returns an implementation of the MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{k: keeper} + ctx := sdk.UnwrapSDKContext(goCtx) + if err := m.k.SetParams(ctx, req.Params); err != nil { + return nil, err + } + return &types.MsgUpdateParamsResponse{}, nil } +// UploadHeaders implements types.MsgServer. +func (m msgServer) UploadHeaders(goCtx context.Context, req *types.MsgUploadHeaders) (*types.MsgUploadHeadersResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + params := m.k.GetParams(ctx) + if !slices.Contains(params.AllowList, req.Signer) { + return nil, errorsmod.Wrapf(types.ErrUnauthorized, "signer %s is not in allowlist", req.Signer) + } + if err := m.k.UploadHeaders(ctx, req.Headers); err != nil { + return nil, err + } + return &types.MsgUploadHeadersResponse{}, nil +} diff --git a/x/bnblightclient/keeper/params.go b/x/bnblightclient/keeper/params.go new file mode 100644 index 00000000..65043ffd --- /dev/null +++ b/x/bnblightclient/keeper/params.go @@ -0,0 +1,37 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +// SetParams sets the parameters for the given context. +// +// ctx - Context object. +// p - Params object to be set. +// error - Returns an error if validation fails. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + if err := params.Validate(); err != nil { + return err + } + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsKey, bz) + return nil +} + +// GetParams retrieves the parameters of the Keeper. +// +// ctx sdk.Context - Context +// types.Params - Parameters +// returns p types.Params - Parameters +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} \ No newline at end of file diff --git a/x/bnblightclient/types/client.pb.go b/x/bnblightclient/types/client.pb.go index f63d960e..d0ee797c 100644 --- a/x/bnblightclient/types/client.pb.go +++ b/x/bnblightclient/types/client.pb.go @@ -24,6 +24,16 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Header struct { + // header defines the bnb header bytes + RawHeader []byte `protobuf:"bytes,1,opt,name=raw_header,json=rawHeader,proto3" json:"raw_header,omitempty"` + // parent_hash defines the previous bnb header hash + ParentHash []byte `protobuf:"bytes,2,opt,name=parent_hash,json=parentHash,proto3" json:"parent_hash,omitempty"` + // hash defines the bnb header hash + Hash []byte `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty"` + // number defines the block number + Number uint64 `protobuf:"varint,4,opt,name=number,proto3" json:"number,omitempty"` + // receipt_root defines the receipts merkle root hash + ReceiptRoot []byte `protobuf:"bytes,5,opt,name=receipt_root,json=receiptRoot,proto3" json:"receipt_root,omitempty"` } func (m *Header) Reset() { *m = Header{} } @@ -59,53 +69,8 @@ func (m *Header) XXX_DiscardUnknown() { var xxx_messageInfo_Header proto.InternalMessageInfo -type Header_Header struct { - // header defines the bnb header bytes - RawHeader []byte `protobuf:"bytes,1,opt,name=raw_header,json=rawHeader,proto3" json:"raw_header,omitempty"` - // hash defines the bnb header hash - Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` - // number defines the block number - Number uint64 `protobuf:"varint,3,opt,name=number,proto3" json:"number,omitempty"` - // receipt_root defines the receipts merkle root hash - ReceiptRoot []byte `protobuf:"bytes,4,opt,name=receipt_root,json=receiptRoot,proto3" json:"receipt_root,omitempty"` -} - -func (m *Header_Header) Reset() { *m = Header_Header{} } -func (m *Header_Header) String() string { return proto.CompactTextString(m) } -func (*Header_Header) ProtoMessage() {} -func (*Header_Header) Descriptor() ([]byte, []int) { - return fileDescriptor_30c005374b948758, []int{0, 0} -} -func (m *Header_Header) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Header_Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Header_Header.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 *Header_Header) XXX_Merge(src proto.Message) { - xxx_messageInfo_Header_Header.Merge(m, src) -} -func (m *Header_Header) XXX_Size() int { - return m.Size() -} -func (m *Header_Header) XXX_DiscardUnknown() { - xxx_messageInfo_Header_Header.DiscardUnknown(m) -} - -var xxx_messageInfo_Header_Header proto.InternalMessageInfo - func init() { proto.RegisterType((*Header)(nil), "lorenzo.bnblightclient.v1.Header") - proto.RegisterType((*Header_Header)(nil), "lorenzo.bnblightclient.v1.Header.Header") } func init() { @@ -113,23 +78,25 @@ func init() { } var fileDescriptor_30c005374b948758 = []byte{ - // 254 bytes of a gzipped FileDescriptorProto + // 273 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0xc9, 0x2f, 0x4a, 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x87, 0xb0, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x24, 0xa1, 0xea, 0xf4, 0x50, 0xd5, 0xe9, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, - 0xe9, 0x83, 0x58, 0x10, 0x0d, 0x4a, 0x6d, 0x8c, 0x5c, 0x6c, 0x1e, 0xa9, 0x89, 0x29, 0xa9, 0x45, - 0x52, 0x35, 0x30, 0x96, 0x90, 0x2c, 0x17, 0x57, 0x51, 0x62, 0x79, 0x7c, 0x06, 0x98, 0x27, 0xc1, - 0xa8, 0xc0, 0xa8, 0xc1, 0x13, 0xc4, 0x59, 0x94, 0x58, 0x0e, 0x95, 0x16, 0xe2, 0x62, 0xc9, 0x48, - 0x2c, 0xce, 0x90, 0x60, 0x02, 0x4b, 0x80, 0xd9, 0x42, 0x62, 0x5c, 0x6c, 0x79, 0xa5, 0xb9, 0x49, - 0xa9, 0x45, 0x12, 0xcc, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x50, 0x9e, 0x90, 0x22, 0x17, 0x4f, 0x51, - 0x6a, 0x72, 0x6a, 0x66, 0x41, 0x49, 0x7c, 0x51, 0x7e, 0x7e, 0x89, 0x04, 0x0b, 0x58, 0x0f, 0x37, - 0x54, 0x2c, 0x28, 0x3f, 0xbf, 0xc4, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x53, 0xc8, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, - 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, - 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x40, 0xbc, 0xa7, 0x1b, 0x00, 0x72, 0x7c, 0x72, 0x7e, 0x8e, 0x3e, - 0x2c, 0x5c, 0x2a, 0xd0, 0x43, 0xa6, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x4b, 0x63, - 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x37, 0x85, 0x42, 0x8d, 0x40, 0x01, 0x00, 0x00, + 0xe9, 0x83, 0x58, 0x10, 0x0d, 0x4a, 0x73, 0x19, 0xb9, 0xd8, 0x3c, 0x52, 0x13, 0x53, 0x52, 0x8b, + 0x84, 0x64, 0xb9, 0xb8, 0x8a, 0x12, 0xcb, 0xe3, 0x33, 0xc0, 0x3c, 0x09, 0x46, 0x05, 0x46, 0x0d, + 0x9e, 0x20, 0xce, 0xa2, 0xc4, 0x72, 0xa8, 0xb4, 0x3c, 0x17, 0x77, 0x41, 0x62, 0x51, 0x6a, 0x5e, + 0x49, 0x7c, 0x46, 0x62, 0x71, 0x86, 0x04, 0x13, 0x58, 0x9e, 0x0b, 0x22, 0xe4, 0x91, 0x58, 0x9c, + 0x21, 0x24, 0xc4, 0xc5, 0x02, 0x96, 0x61, 0x06, 0xcb, 0x80, 0xd9, 0x42, 0x62, 0x5c, 0x6c, 0x79, + 0xa5, 0xb9, 0x49, 0xa9, 0x45, 0x12, 0x2c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x50, 0x9e, 0x90, 0x22, + 0x17, 0x4f, 0x51, 0x6a, 0x72, 0x6a, 0x66, 0x41, 0x49, 0x7c, 0x51, 0x7e, 0x7e, 0x89, 0x04, 0x2b, + 0x58, 0x0f, 0x37, 0x54, 0x2c, 0x28, 0x3f, 0xbf, 0xc4, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x53, + 0xc8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, + 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa5, 0x67, 0x96, 0x64, + 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x40, 0x7c, 0xad, 0x1b, 0x00, 0xf2, 0x53, 0x72, + 0x7e, 0x8e, 0x3e, 0x2c, 0xb8, 0x2a, 0xd0, 0x03, 0xac, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, + 0xec, 0x79, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x41, 0x31, 0x4a, 0x57, 0x01, 0x00, + 0x00, } func (m *Header) Marshal() (dAtA []byte, err error) { @@ -148,29 +115,6 @@ func (m *Header) MarshalTo(dAtA []byte) (int, error) { } func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *Header_Header) 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 *Header_Header) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header_Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -180,18 +124,25 @@ func (m *Header_Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.ReceiptRoot) i = encodeVarintClient(dAtA, i, uint64(len(m.ReceiptRoot))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if m.Number != 0 { i = encodeVarintClient(dAtA, i, uint64(m.Number)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.Hash) > 0 { i -= len(m.Hash) copy(dAtA[i:], m.Hash) i = encodeVarintClient(dAtA, i, uint64(len(m.Hash))) i-- + dAtA[i] = 0x1a + } + if len(m.ParentHash) > 0 { + i -= len(m.ParentHash) + copy(dAtA[i:], m.ParentHash) + i = encodeVarintClient(dAtA, i, uint64(len(m.ParentHash))) + i-- dAtA[i] = 0x12 } if len(m.RawHeader) > 0 { @@ -216,15 +167,6 @@ func encodeVarintClient(dAtA []byte, offset int, v uint64) int { return base } func (m *Header) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *Header_Header) Size() (n int) { if m == nil { return 0 } @@ -234,6 +176,10 @@ func (m *Header_Header) Size() (n int) { if l > 0 { n += 1 + l + sovClient(uint64(l)) } + l = len(m.ParentHash) + if l > 0 { + n += 1 + l + sovClient(uint64(l)) + } l = len(m.Hash) if l > 0 { n += 1 + l + sovClient(uint64(l)) @@ -283,59 +229,43 @@ func (m *Header) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipClient(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawHeader", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthClient + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowClient + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if byteLen < 0 { + return ErrInvalidLengthClient } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Header_Header) 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 ErrIntOverflowClient + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthClient } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.RawHeader = append(m.RawHeader[:0], dAtA[iNdEx:postIndex]...) + if m.RawHeader == nil { + m.RawHeader = []byte{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Header: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RawHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ParentHash", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -362,12 +292,12 @@ func (m *Header_Header) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RawHeader = append(m.RawHeader[:0], dAtA[iNdEx:postIndex]...) - if m.RawHeader == nil { - m.RawHeader = []byte{} + m.ParentHash = append(m.ParentHash[:0], dAtA[iNdEx:postIndex]...) + if m.ParentHash == nil { + m.ParentHash = []byte{} } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) } @@ -401,7 +331,7 @@ func (m *Header_Header) Unmarshal(dAtA []byte) error { m.Hash = []byte{} } iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Number", wireType) } @@ -420,7 +350,7 @@ func (m *Header_Header) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ReceiptRoot", wireType) } diff --git a/x/bnblightclient/types/errors.go b/x/bnblightclient/types/errors.go new file mode 100644 index 00000000..0fff883c --- /dev/null +++ b/x/bnblightclient/types/errors.go @@ -0,0 +1,17 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +var ( + // ErrHeaderNotFound is returned when header is not found + ErrHeaderNotFound = errorsmod.Register(ModuleName, 2, "header not found") + + // ErrInvalidHeader is returned when header is not valid + ErrInvalidHeader = errorsmod.Register(ModuleName, 3, "header not found") + // ErrUnauthorized is returned when tx is not authorized + ErrUnauthorized = errorsmod.Register(ModuleName, 4, "tx unauthorized") + // ErrInvalidProof is returned when proof is not valid + ErrInvalidProof = errorsmod.Register(ModuleName, 5, "invalid proof") +) diff --git a/x/bnblightclient/types/header.go b/x/bnblightclient/types/header.go new file mode 100644 index 00000000..aafa5158 --- /dev/null +++ b/x/bnblightclient/types/header.go @@ -0,0 +1,158 @@ +package types + +import ( + "math/big" + "sync" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/rlp" + "golang.org/x/crypto/sha3" + + errorsmod "cosmossdk.io/errors" +) + +// hasherPool holds LegacyKeccak256 hashers for rlpHash. +var hasherPool = sync.Pool{ + New: func() interface{} { return sha3.NewLegacyKeccak256() }, +} + +//go:generate go run github.com/fjl/gencodec -type Header -field-override headerMarshaling -out gen_header_json.go +//go:generate go run ../../rlp/rlpgen -type Header -out gen_header_rlp.go + +// BNBHeader represents a block header in the Ethereum blockchain. +type BNBHeader struct { + ParentHash common.Hash `json:"parentHash" gencodec:"required"` + UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` + Coinbase common.Address `json:"miner"` + Root common.Hash `json:"stateRoot" gencodec:"required"` + TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` + ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` + Bloom types.Bloom `json:"logsBloom" gencodec:"required"` + Difficulty *big.Int `json:"difficulty" gencodec:"required"` + Number *big.Int `json:"number" gencodec:"required"` + GasLimit uint64 `json:"gasLimit" gencodec:"required"` + GasUsed uint64 `json:"gasUsed" gencodec:"required"` + Time uint64 `json:"timestamp" gencodec:"required"` + Extra []byte `json:"extraData" gencodec:"required"` + MixDigest common.Hash `json:"mixHash"` + Nonce types.BlockNonce `json:"nonce"` + + // BaseFee was added by EIP-1559 and is ignored in legacy headers. + BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"` + + // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. + WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` + + // BlobGasUsed was added by EIP-4844 and is ignored in legacy headers. + BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"` + + // ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers. + ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"` + + // ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers. + ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"` +} + +// Hash returns the block hash of the header, which is simply the keccak256 hash of its +// RLP encoding. +func (h *BNBHeader) Hash() common.Hash { + return rlpHash(h) +} + + +// ConvertToBNBHeader decodes the input data into a BNBHeader struct and validates it against the provided Header. +// +// It takes a pointer to a Header struct as input and returns a pointer to a BNBHeader struct and an error. +// The function decodes the RawHeader field of the Header struct into a BNBHeader struct using the rlp package. +// It then checks if the Number field of the BNBHeader struct is equal to the Number field of the Header struct. +// If not, it returns an ErrInvalidHeader error with the message "number not equal". +// It also checks if the Hash() method of the BNBHeader struct is equal to the Hash field of the Header struct. +// If not, it returns an ErrInvalidHeader error with the message "hash not equal". +// It also checks if the ReceiptHash field of the BNBHeader struct is equal to the ReceiptRoot field of the Header struct. +// If not, it returns an ErrInvalidHeader error with the message "receipt hash not equal". +// If all checks pass, it returns the BNBHeader struct and a nil error. +func ConvertToBNBHeader(header *Header) (*BNBHeader, error) { + bnbHeader,err := UnmarshalBNBHeader(header.RawHeader) + if err != nil { + return nil, err + } + + if bnbHeader.Number.Uint64() != header.Number { + return nil,errorsmod.Wrap(ErrInvalidHeader, "number not equal") + } + + if bnbHeader.Hash() != common.Hash(header.Hash) { + return nil,errorsmod.Wrap(ErrInvalidHeader, "hash not equal") + } + + if bnbHeader.ParentHash != common.Hash(header.ParentHash) { + return nil,errorsmod.Wrap(ErrInvalidHeader, "parentHash not equal") + } + + if bnbHeader.ReceiptHash != common.Hash(header.ReceiptRoot) { + return nil,errorsmod.Wrap(ErrInvalidHeader, "receipt hash not equal") + } + return bnbHeader, nil +} + +// UnmarshalBNBHeader decodes the input data into a BNBHeader struct. +// +// It takes a byte slice data as input and returns a BNBHeader pointer and an error. +func UnmarshalBNBHeader(rawHeader []byte) (*BNBHeader, error) { + bnbHeader := new(BNBHeader) + if err := rlp.DecodeBytes(rawHeader, bnbHeader); err != nil { + return nil, err + } + return bnbHeader, nil +} + +// VeryHeaders checks the validity of a sequence of BNBHeaders. +// +// It takes a slice of Header pointers as input and returns an error. +// The function iterates over the headers and checks if the current header's +// hash is equal to the next header's parent hash. It also checks if the +// current header's number is one less than the next header's number. +// If any of these conditions are not met, the function returns an +// ErrInvalidHeader error. +func VeryHeaders(headers []*Header) error { + if len(headers) == 0 { + return errorsmod.Wrap(ErrInvalidHeader, "empty headers") + } + + if len(headers) == 1 { + _,err := ConvertToBNBHeader(headers[0]) + return err + } + + for i := 0; i < len(headers)-1; i++ { + preHeader, err := ConvertToBNBHeader(headers[i]) + if err != nil { + return err + } + + nextHeader, err := ConvertToBNBHeader(headers[i+1]) + if err != nil { + return err + } + + if preHeader.Hash() != nextHeader.ParentHash { + return errorsmod.Wrap(ErrInvalidHeader, "hash not equal") + } + + if preHeader.Number.Uint64()+1 != nextHeader.Number.Uint64() { + return errorsmod.Wrap(ErrInvalidHeader, "hash not equal") + } + } + return nil +} + +func rlpHash(x interface{}) (h common.Hash) { + sha := hasherPool.Get().(crypto.KeccakState) + defer hasherPool.Put(sha) + sha.Reset() + rlp.Encode(sha, x) + sha.Read(h[:]) + return h +} diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go index 7193a74c..32eba230 100644 --- a/x/bnblightclient/types/keys.go +++ b/x/bnblightclient/types/keys.go @@ -1 +1,59 @@ -package types \ No newline at end of file +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + +const ( + // ModuleName is the name of the module + ModuleName = "bnblightclient" + + // StoreKey is the string store representation + StoreKey = ModuleName +) + +var ( + // Delimiter is the delimiter for the keys + Delimiter = []byte{0x00} + // ParamsKey defines the key to store the Params object + ParamsKey = []byte{0x01} + // KeyPrefixHeader defines the prefix to retrieve all headers + KeyPrefixHeader = []byte{0x02} + // KeyPrefixLatestedNumber defines the prefix to retrieve the latest header number + KeyPrefixLatestedNumber = []byte{0x03} + + // KeyPrefixHeadHash defines the prefix to retrieve the head hash + KeyPrefixHeadHash = []byte{0x04} + // KeyPrefixTxHash defines the prefix to retrieve the tx hash + KeyPrefixTxHash = []byte{0x05} +) + +// KeyHeader returns the key for a header +func KeyHeader(blockNumber uint64) []byte { + bz := sdk.Uint64ToBigEndian(blockNumber) + return append(KeyPrefixHeader, bz...) +} + +// KeyHeaderHash returns the key for the header hash +func KeyHeaderHash(hash []byte) []byte { + return append(KeyPrefixHeadHash, hash...) +} + +// KeyLatestedHeaderNumber returns the key for the latest header number +func KeyLatestedHeaderNumber() []byte { + return KeyPrefixLatestedNumber +} + +// KeyTxHash returns the key for the tx hash +func KeyTxHash(blockNumber uint64, txHash common.Hash) []byte { + key := make([]byte, 0) + copy(key, KeyPrefixTxHash) + + bumberBz := sdk.Uint64ToBigEndian(blockNumber) + key = append(key, bumberBz...) + + txHashBz := txHash.Bytes() + key = append(key, txHashBz...) + return key +} diff --git a/x/bnblightclient/types/params.go b/x/bnblightclient/types/params.go new file mode 100644 index 00000000..6989c3b9 --- /dev/null +++ b/x/bnblightclient/types/params.go @@ -0,0 +1,50 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + +// Validate validates the Params struct. +// +// It does not take any parameters. +// It returns an error if the validation fails. +func (p Params) Validate() error { + if p.ChainId == nil { + return fmt.Errorf("chain id cannot be nil") + } + + if len(p.StakePlanHubAddress) == 0 { + return fmt.Errorf("stake plan hub address cannot be empty") + } + + if !common.IsHexAddress(p.StakePlanHubAddress) { + return fmt.Errorf("invalid stake plan hub address: %s", p.StakePlanHubAddress) + } + if err := ValidateAllowList(p.AllowList); err != nil { + return err + } + return nil +} + +// ValidateAllowList validates a list of addresses. +// +// It takes a list of strings representing addresses as a parameter. +// It returns an error if any address is invalid. +func ValidateAllowList(allowList []string) error { + seenAddr := make(map[string]bool) + for _, addr := range allowList { + if seenAddr[addr] { + return fmt.Errorf("duplicate address: %s", addr) + } + + // check that the address is valid + if _, err := sdk.AccAddressFromBech32(addr); err != nil { + return fmt.Errorf("invalid address: %s", addr) + } + seenAddr[addr] = true + } + return nil +} \ No newline at end of file diff --git a/x/bnblightclient/types/params.pb.go b/x/bnblightclient/types/params.pb.go index 2f3ecf3a..50db2d31 100644 --- a/x/bnblightclient/types/params.pb.go +++ b/x/bnblightclient/types/params.pb.go @@ -29,12 +29,10 @@ type Params struct { ChainId *cosmossdk_io_math.Uint `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=cosmossdk.io/math.Uint" json:"chain_id,omitempty"` // the stake plan hub contract address StakePlanHubAddress string `protobuf:"bytes,2,opt,name=stake_plan_hub_address,json=stakePlanHubAddress,proto3" json:"stake_plan_hub_address,omitempty"` - // the stake plan hub contract method id - StakePlanHubMethodId string `protobuf:"bytes,3,opt,name=stake_plan_hub_method_id,json=stakePlanHubMethodId,proto3" json:"stake_plan_hub_method_id,omitempty"` // the maximum number of bnb block headers to retain - RetainedBlocks uint64 `protobuf:"varint,4,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` + RetainedBlocks uint64 `protobuf:"varint,3,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` // list of people who can upload bnb block header information - AllowList []string `protobuf:"bytes,5,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` + AllowList []string `protobuf:"bytes,4,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -77,13 +75,6 @@ func (m *Params) GetStakePlanHubAddress() string { return "" } -func (m *Params) GetStakePlanHubMethodId() string { - if m != nil { - return m.StakePlanHubMethodId - } - return "" -} - func (m *Params) GetRetainedBlocks() uint64 { if m != nil { return m.RetainedBlocks @@ -107,29 +98,28 @@ func init() { } var fileDescriptor_3608f71b6e08ae9c = []byte{ - // 347 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xcf, 0x4a, 0xeb, 0x40, - 0x18, 0xc5, 0x3b, 0xb7, 0xbd, 0xbd, 0xb7, 0xc3, 0xe5, 0x0a, 0xb1, 0x94, 0x58, 0x30, 0x0d, 0x2e, - 0x34, 0x1b, 0x13, 0x4a, 0xd1, 0x45, 0x77, 0x76, 0x65, 0xa1, 0x42, 0x09, 0xba, 0x71, 0x13, 0x26, - 0x99, 0x21, 0x19, 0x3a, 0x99, 0x2f, 0x64, 0xa6, 0xf5, 0xcf, 0x53, 0xf8, 0x08, 0x3e, 0x8e, 0xcb, - 0x2e, 0xc5, 0x85, 0x48, 0xbb, 0xf1, 0x19, 0x5c, 0x49, 0xa7, 0x16, 0xb4, 0xbb, 0xe1, 0x9c, 0xf3, - 0x9b, 0x0f, 0xce, 0xc1, 0x87, 0x02, 0x4a, 0x26, 0xef, 0x21, 0x88, 0x65, 0x2c, 0x78, 0x9a, 0xe9, - 0x44, 0x70, 0x26, 0x75, 0x30, 0xeb, 0x06, 0x05, 0x29, 0x49, 0xae, 0xfc, 0xa2, 0x04, 0x0d, 0xd6, - 0xde, 0x57, 0xce, 0xff, 0x99, 0xf3, 0x67, 0xdd, 0x76, 0x33, 0x85, 0x14, 0x4c, 0x2a, 0x58, 0xbd, - 0xd6, 0xc0, 0xc1, 0x07, 0xc2, 0xf5, 0xb1, 0xf9, 0xc1, 0x3a, 0xc1, 0x7f, 0x93, 0x8c, 0x70, 0x19, - 0x71, 0x6a, 0x23, 0x17, 0x79, 0xff, 0x06, 0xed, 0x97, 0xd7, 0x4e, 0x2b, 0x01, 0x95, 0x83, 0x52, - 0x74, 0xe2, 0x73, 0x08, 0x72, 0xa2, 0x33, 0xff, 0x8a, 0x4b, 0x1d, 0xfe, 0x31, 0xd9, 0x21, 0xb5, - 0x7a, 0xb8, 0xa5, 0x34, 0x99, 0xb0, 0xa8, 0x10, 0x44, 0x46, 0xd9, 0x34, 0x8e, 0x08, 0xa5, 0x25, - 0x53, 0xca, 0xfe, 0xe5, 0x22, 0xaf, 0x11, 0xee, 0x1a, 0x77, 0x2c, 0x88, 0x3c, 0x9f, 0xc6, 0x67, - 0x6b, 0xcb, 0x3a, 0xc5, 0xf6, 0x16, 0x94, 0x33, 0x9d, 0x01, 0x5d, 0xdd, 0xae, 0x1a, 0xac, 0xf9, - 0x1d, 0xbb, 0x30, 0xe6, 0x90, 0x5a, 0x47, 0x78, 0xa7, 0x64, 0x9a, 0x70, 0xc9, 0x68, 0x14, 0x0b, - 0x48, 0x26, 0xca, 0xae, 0xb9, 0xc8, 0xab, 0x85, 0xff, 0x37, 0xf2, 0xc0, 0xa8, 0xd6, 0x3e, 0xc6, - 0x44, 0x08, 0xb8, 0x89, 0x04, 0x57, 0xda, 0xfe, 0xed, 0x56, 0xbd, 0x46, 0xd8, 0x30, 0xca, 0x88, - 0x2b, 0xdd, 0xaf, 0xbd, 0x3f, 0x76, 0xd0, 0xe0, 0xf2, 0x69, 0xe1, 0xa0, 0xf9, 0xc2, 0x41, 0x6f, - 0x0b, 0x07, 0x3d, 0x2c, 0x9d, 0xca, 0x7c, 0xe9, 0x54, 0x9e, 0x97, 0x4e, 0xe5, 0xba, 0x9f, 0x72, - 0x9d, 0x4d, 0x63, 0x3f, 0x81, 0x3c, 0x18, 0xad, 0x2b, 0x3d, 0x1e, 0xaf, 0x0a, 0x4b, 0x40, 0x04, - 0x9b, 0x2d, 0x6e, 0xb7, 0xd7, 0xd0, 0x77, 0x05, 0x53, 0x71, 0xdd, 0x34, 0xdb, 0xfb, 0x0c, 0x00, - 0x00, 0xff, 0xff, 0x1a, 0x89, 0xae, 0x99, 0xb4, 0x01, 0x00, 0x00, + // 322 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x3f, 0x4b, 0xc3, 0x40, + 0x18, 0xc6, 0x7b, 0xb6, 0x54, 0x7b, 0x88, 0x42, 0x94, 0x12, 0x0b, 0xa6, 0xc1, 0x41, 0xb3, 0x98, + 0xa3, 0x14, 0x97, 0x6e, 0x76, 0x52, 0xe8, 0x50, 0x82, 0x2e, 0x2e, 0xe1, 0x2e, 0x39, 0x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0x39, 0xc6, 0x98, 0x4a, 0x09, 0xf7, 0xb1, 0x14, 0xda, 0xb8, 0x0d, + 0xbf, 0x1e, 0xb4, 0xa2, 0x96, 0x4d, 0x46, 0x42, 0x9b, 0x41, 0xe3, 0xfb, 0xa5, 0x8b, 0x86, 0x37, + 0x6f, 0x0b, 0x0f, 0xcd, 0x17, 0x1e, 0xfa, 0x5a, 0x78, 0xe8, 0x79, 0xe9, 0xd5, 0xe6, 0x4b, 0xaf, + 0xf6, 0xbe, 0xf4, 0x6a, 0x77, 0x83, 0x4c, 0x98, 0x7c, 0xca, 0xc2, 0x04, 0x0a, 0x32, 0x5a, 0xab, + 0x39, 0x1f, 0xaf, 0x1e, 0x4f, 0x40, 0x92, 0x8d, 0xd3, 0x87, 0xff, 0x56, 0xcd, 0x63, 0xc9, 0x35, + 0x6b, 0x5a, 0x43, 0xfd, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xbe, 0x16, 0x9c, 0x7c, 0x01, + 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -161,9 +151,6 @@ func (this *Params) Equal(that interface{}) bool { if this.StakePlanHubAddress != that1.StakePlanHubAddress { return false } - if this.StakePlanHubMethodId != that1.StakePlanHubMethodId { - return false - } if this.RetainedBlocks != that1.RetainedBlocks { return false } @@ -203,20 +190,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.AllowList[iNdEx]) i = encodeVarintParams(dAtA, i, uint64(len(m.AllowList[iNdEx]))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } } if m.RetainedBlocks != 0 { i = encodeVarintParams(dAtA, i, uint64(m.RetainedBlocks)) i-- - dAtA[i] = 0x20 - } - if len(m.StakePlanHubMethodId) > 0 { - i -= len(m.StakePlanHubMethodId) - copy(dAtA[i:], m.StakePlanHubMethodId) - i = encodeVarintParams(dAtA, i, uint64(len(m.StakePlanHubMethodId))) - i-- - dAtA[i] = 0x1a + dAtA[i] = 0x18 } if len(m.StakePlanHubAddress) > 0 { i -= len(m.StakePlanHubAddress) @@ -265,10 +245,6 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - l = len(m.StakePlanHubMethodId) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } if m.RetainedBlocks != 0 { n += 1 + sovParams(uint64(m.RetainedBlocks)) } @@ -384,38 +360,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.StakePlanHubAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakePlanHubMethodId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakePlanHubMethodId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RetainedBlocks", wireType) } @@ -434,7 +378,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AllowList", wireType) } diff --git a/x/bnblightclient/types/proof.go b/x/bnblightclient/types/proof.go index 6d045316..84d3b30e 100644 --- a/x/bnblightclient/types/proof.go +++ b/x/bnblightclient/types/proof.go @@ -1,7 +1,6 @@ package types import ( - "bytes" "encoding/base64" "errors" @@ -142,30 +141,3 @@ func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*types.Receipt return &res, nil } - - -// VerifyReceiptProof verifies the proof of a receipt in a Merkle Patricia Trie (MPT). -// -// Parameters: -// - receipt: a pointer to a Receipt struct representing the receipt to verify. -// - root: a common.Hash representing the root hash of the MPT. -// - proof: a Proof struct representing the proof to verify. -// -// Returns: -// - bool: true if the proof is valid, false otherwise. -func VerifyReceiptProof(receipt *types.Receipt, root common.Hash, proof Proof) bool { - db := trie.NewDatabase(rawdb.NewMemoryDatabase()) - mpt := trie.NewEmpty(db) - _ = types.DeriveSha(types.Receipts{receipt}, mpt) - - var indexBuf []byte - indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(0)) - receiptValue := mpt.Get(indexBuf) - - val, err := trie.VerifyProof(root, proof.Index, &proof.Path) - - if err == nil && bytes.Equal(val, proof.Value) && bytes.Equal(val, receiptValue) { - return true - } - return false -} diff --git a/x/bnblightclient/types/query.pb.go b/x/bnblightclient/types/query.pb.go index 4266d9ab..a2586554 100644 --- a/x/bnblightclient/types/query.pb.go +++ b/x/bnblightclient/types/query.pb.go @@ -203,6 +203,99 @@ func (m *QueryHeaderResponse) GetHeader() *Header { return nil } +// QueryHeaderByHashRequest is the request type for the Query/HeaderByHash RPC +// method. +type QueryHeaderByHashRequest struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *QueryHeaderByHashRequest) Reset() { *m = QueryHeaderByHashRequest{} } +func (m *QueryHeaderByHashRequest) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderByHashRequest) ProtoMessage() {} +func (*QueryHeaderByHashRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{4} +} +func (m *QueryHeaderByHashRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderByHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderByHashRequest.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 *QueryHeaderByHashRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderByHashRequest.Merge(m, src) +} +func (m *QueryHeaderByHashRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderByHashRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderByHashRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderByHashRequest proto.InternalMessageInfo + +func (m *QueryHeaderByHashRequest) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +// QueryHeaderByHashResponse is the response type for the Query/HeaderByHash RPC +// method. +type QueryHeaderByHashResponse struct { + // params holds all the parameters of this module. + Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` +} + +func (m *QueryHeaderByHashResponse) Reset() { *m = QueryHeaderByHashResponse{} } +func (m *QueryHeaderByHashResponse) String() string { return proto.CompactTextString(m) } +func (*QueryHeaderByHashResponse) ProtoMessage() {} +func (*QueryHeaderByHashResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f139d6422d3b3b56, []int{5} +} +func (m *QueryHeaderByHashResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryHeaderByHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryHeaderByHashResponse.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 *QueryHeaderByHashResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryHeaderByHashResponse.Merge(m, src) +} +func (m *QueryHeaderByHashResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryHeaderByHashResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryHeaderByHashResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryHeaderByHashResponse proto.InternalMessageInfo + +func (m *QueryHeaderByHashResponse) GetHeader() *Header { + if m != nil { + return m.Header + } + return nil +} + // QueryLatestedHeaderRequest is the request type for the Query/LatestedHeader // RPC method. type QueryLatestedHeaderRequest struct { @@ -212,7 +305,7 @@ func (m *QueryLatestedHeaderRequest) Reset() { *m = QueryLatestedHeaderR func (m *QueryLatestedHeaderRequest) String() string { return proto.CompactTextString(m) } func (*QueryLatestedHeaderRequest) ProtoMessage() {} func (*QueryLatestedHeaderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f139d6422d3b3b56, []int{4} + return fileDescriptor_f139d6422d3b3b56, []int{6} } func (m *QueryLatestedHeaderRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,7 +345,7 @@ func (m *QueryLatestedHeaderResponse) Reset() { *m = QueryLatestedHeader func (m *QueryLatestedHeaderResponse) String() string { return proto.CompactTextString(m) } func (*QueryLatestedHeaderResponse) ProtoMessage() {} func (*QueryLatestedHeaderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f139d6422d3b3b56, []int{5} + return fileDescriptor_f139d6422d3b3b56, []int{7} } func (m *QueryLatestedHeaderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -293,6 +386,8 @@ func init() { proto.RegisterType((*QueryParamsResponse)(nil), "lorenzo.bnblightclient.v1.QueryParamsResponse") proto.RegisterType((*QueryHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryHeaderRequest") proto.RegisterType((*QueryHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryHeaderResponse") + proto.RegisterType((*QueryHeaderByHashRequest)(nil), "lorenzo.bnblightclient.v1.QueryHeaderByHashRequest") + proto.RegisterType((*QueryHeaderByHashResponse)(nil), "lorenzo.bnblightclient.v1.QueryHeaderByHashResponse") proto.RegisterType((*QueryLatestedHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryLatestedHeaderRequest") proto.RegisterType((*QueryLatestedHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryLatestedHeaderResponse") } @@ -302,35 +397,39 @@ func init() { } var fileDescriptor_f139d6422d3b3b56 = []byte{ - // 434 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcd, 0xc9, 0x2f, 0x4a, - 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, - 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x92, 0x84, 0x2a, 0xd3, 0x43, 0x55, 0xa6, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, - 0x9e, 0x0f, 0x56, 0xa5, 0x0f, 0x62, 0x41, 0x34, 0x48, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, - 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, - 0x43, 0x65, 0xd5, 0x70, 0xdb, 0x0a, 0x35, 0x98, 0xa0, 0xba, 0x82, 0xc4, 0xa2, 0xc4, 0x5c, 0xa8, - 0x79, 0x4a, 0x22, 0x5c, 0x42, 0x81, 0x20, 0xd7, 0x06, 0x80, 0x05, 0x83, 0x52, 0x0b, 0x4b, 0x53, - 0x8b, 0x4b, 0x94, 0xc2, 0xb8, 0x84, 0x51, 0x44, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0xec, - 0xb9, 0xd8, 0x20, 0x9a, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x14, 0xf5, 0x70, 0x7a, 0x4e, - 0x0f, 0xa2, 0xd5, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x36, 0x25, 0x1d, 0xa8, 0x6d, - 0x1e, 0xa9, 0x89, 0x29, 0xa9, 0x45, 0x50, 0xdb, 0x84, 0xc4, 0xb8, 0xd8, 0xf2, 0x4a, 0x73, 0x93, - 0x52, 0x8b, 0xc0, 0xc6, 0xb2, 0x04, 0x41, 0x79, 0x70, 0x57, 0xc0, 0x54, 0x23, 0x5c, 0x91, 0x01, - 0x16, 0x21, 0xc2, 0x15, 0x10, 0xad, 0x60, 0x57, 0x30, 0x06, 0x41, 0xb5, 0x29, 0xc9, 0x70, 0x49, - 0x81, 0xcd, 0xf5, 0x49, 0x2c, 0x49, 0x2d, 0x2e, 0x49, 0x4d, 0x41, 0x71, 0x8d, 0x52, 0x1c, 0x97, - 0x34, 0x56, 0x59, 0xca, 0x6c, 0x67, 0x80, 0xd9, 0x6e, 0xf4, 0x81, 0x99, 0x8b, 0x15, 0x6c, 0x81, - 0xd0, 0x24, 0x46, 0x2e, 0x36, 0x48, 0x30, 0x09, 0xe9, 0xe2, 0x31, 0x05, 0x33, 0x7e, 0xa4, 0xf4, - 0x88, 0x55, 0x0e, 0x71, 0xb4, 0x92, 0x66, 0xd3, 0xe5, 0x27, 0x93, 0x99, 0x94, 0x85, 0x14, 0xf5, - 0x09, 0x25, 0x0b, 0xa1, 0xd9, 0x8c, 0x5c, 0x6c, 0x10, 0x77, 0x13, 0x76, 0x14, 0x4a, 0xc0, 0x11, - 0x76, 0x14, 0x6a, 0x48, 0x2a, 0x19, 0x81, 0x1d, 0xa5, 0x23, 0xa4, 0x85, 0xc7, 0x51, 0x90, 0x30, - 0xd3, 0xaf, 0x86, 0xa4, 0x88, 0x5a, 0xa1, 0xcd, 0x8c, 0x5c, 0x7c, 0xa8, 0x11, 0x23, 0x64, 0x4a, - 0xc8, 0x5a, 0xac, 0xd1, 0x2c, 0x65, 0x46, 0xaa, 0x36, 0x12, 0x5c, 0x9d, 0x03, 0xd5, 0x1a, 0x0f, - 0x71, 0xbe, 0x53, 0xc8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, - 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa5, - 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x40, 0xcc, 0xd3, 0x0d, 0x00, - 0x65, 0xcc, 0xe4, 0xfc, 0x1c, 0xb8, 0x05, 0x15, 0xe8, 0x56, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, - 0xb1, 0x81, 0x73, 0xb0, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xb3, 0x08, 0x79, 0xbc, 0x89, 0x04, - 0x00, 0x00, + // 503 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6a, 0xd4, 0x40, + 0x1c, 0xc6, 0x33, 0xb2, 0xcd, 0x61, 0x2c, 0x1e, 0xc6, 0x22, 0x6d, 0x2c, 0xd1, 0x8e, 0x28, 0x2a, + 0xdd, 0x19, 0xba, 0xb5, 0x1e, 0xbc, 0x08, 0x7b, 0xea, 0xa1, 0x87, 0x1a, 0xc4, 0x83, 0x88, 0x32, + 0xd9, 0x0e, 0x49, 0x20, 0x3b, 0x93, 0x66, 0x66, 0x8b, 0xab, 0xf4, 0xe2, 0x13, 0x88, 0x1e, 0x3d, + 0xfa, 0x02, 0x82, 0x2f, 0xd1, 0x63, 0xc1, 0x8b, 0x27, 0x91, 0x5d, 0x1f, 0x44, 0x32, 0x33, 0x5b, + 0x1b, 0xdd, 0x36, 0xbb, 0xd8, 0xcb, 0x92, 0x9d, 0xfc, 0xbf, 0xef, 0xfb, 0xe5, 0x9f, 0x8f, 0xc0, + 0xdb, 0xb9, 0x2c, 0xb9, 0x78, 0x23, 0x69, 0x2c, 0xe2, 0x3c, 0x4b, 0x52, 0xdd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5b, 0x7d, 0xd9, 0x7a, 0x32, 0x3f, 0x09, 0x78, 0xfd, 0x77, + 0x84, 0x1e, 0x16, 0x5c, 0xc5, 0xbe, 0xf9, 0x04, 0x6e, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x24, + 0xe1, 0xb4, 0xfe, 0xca, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -349,6 +448,8 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // Header returns the header in bnb chain by number Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) + // HeaderByHash returns the header in bnb chain by hash + HeaderByHash(ctx context.Context, in *QueryHeaderByHashRequest, opts ...grpc.CallOption) (*QueryHeaderByHashResponse, error) // LatestedHeader returns the latested header in bnb chain LatestedHeader(ctx context.Context, in *QueryLatestedHeaderRequest, opts ...grpc.CallOption) (*QueryLatestedHeaderResponse, error) } @@ -379,6 +480,15 @@ func (c *queryClient) Header(ctx context.Context, in *QueryHeaderRequest, opts . return out, nil } +func (c *queryClient) HeaderByHash(ctx context.Context, in *QueryHeaderByHashRequest, opts ...grpc.CallOption) (*QueryHeaderByHashResponse, error) { + out := new(QueryHeaderByHashResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/HeaderByHash", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) LatestedHeader(ctx context.Context, in *QueryLatestedHeaderRequest, opts ...grpc.CallOption) (*QueryLatestedHeaderResponse, error) { out := new(QueryLatestedHeaderResponse) err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/LatestedHeader", in, out, opts...) @@ -394,6 +504,8 @@ type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // Header returns the header in bnb chain by number Header(context.Context, *QueryHeaderRequest) (*QueryHeaderResponse, error) + // HeaderByHash returns the header in bnb chain by hash + HeaderByHash(context.Context, *QueryHeaderByHashRequest) (*QueryHeaderByHashResponse, error) // LatestedHeader returns the latested header in bnb chain LatestedHeader(context.Context, *QueryLatestedHeaderRequest) (*QueryLatestedHeaderResponse, error) } @@ -408,6 +520,9 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsReq func (*UnimplementedQueryServer) Header(ctx context.Context, req *QueryHeaderRequest) (*QueryHeaderResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Header not implemented") } +func (*UnimplementedQueryServer) HeaderByHash(ctx context.Context, req *QueryHeaderByHashRequest) (*QueryHeaderByHashResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method HeaderByHash not implemented") +} func (*UnimplementedQueryServer) LatestedHeader(ctx context.Context, req *QueryLatestedHeaderRequest) (*QueryLatestedHeaderResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method LatestedHeader not implemented") } @@ -452,6 +567,24 @@ func _Query_Header_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_HeaderByHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryHeaderByHashRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).HeaderByHash(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/lorenzo.bnblightclient.v1.Query/HeaderByHash", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).HeaderByHash(ctx, req.(*QueryHeaderByHashRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_LatestedHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryLatestedHeaderRequest) if err := dec(in); err != nil { @@ -482,6 +615,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Header", Handler: _Query_Header_Handler, }, + { + MethodName: "HeaderByHash", + Handler: _Query_HeaderByHash_Handler, + }, { MethodName: "LatestedHeader", Handler: _Query_LatestedHeader_Handler, @@ -610,6 +747,71 @@ func (m *QueryHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryHeaderByHashRequest) 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 *QueryHeaderByHashRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderByHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryHeaderByHashResponse) 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 *QueryHeaderByHashResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Header != nil { + { + size, err := m.Header.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 *QueryLatestedHeaderRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -722,6 +924,32 @@ func (m *QueryHeaderResponse) Size() (n int) { return n } +func (m *QueryHeaderByHashRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryHeaderByHashResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Header != nil { + l = m.Header.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryLatestedHeaderRequest) Size() (n int) { if m == nil { return 0 @@ -1036,6 +1264,176 @@ func (m *QueryHeaderResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryHeaderByHashRequest) 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: QueryHeaderByHashRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderByHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + 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 *QueryHeaderByHashResponse) 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: QueryHeaderByHashResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryHeaderByHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Header == nil { + m.Header = &Header{} + } + if err := m.Header.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 *QueryLatestedHeaderRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/bnblightclient/types/query.pb.gw.go b/x/bnblightclient/types/query.pb.gw.go index 9596e8e1..6f69e6d3 100644 --- a/x/bnblightclient/types/query.pb.gw.go +++ b/x/bnblightclient/types/query.pb.gw.go @@ -105,6 +105,60 @@ func local_request_Query_Header_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_HeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.HeaderByHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_HeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryHeaderByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.HeaderByHash(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_LatestedHeader_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryLatestedHeaderRequest var metadata runtime.ServerMetadata @@ -175,6 +229,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_HeaderByHash_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_HeaderByHash_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_HeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_LatestedHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -279,6 +356,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_HeaderByHash_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_HeaderByHash_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_HeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_LatestedHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -307,6 +404,8 @@ var ( pattern_Query_Header_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"lorenzo", "bnblightclient", "v1", "header", "number"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_HeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 4}, []string{"lorenzo", "bnblightclient", "v1", "header", "hash"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_LatestedHeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lorenzo", "bnblightclient", "v1", "latested_header"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -315,5 +414,7 @@ var ( forward_Query_Header_0 = runtime.ForwardResponseMessage + forward_Query_HeaderByHash_0 = runtime.ForwardResponseMessage + forward_Query_LatestedHeader_0 = runtime.ForwardResponseMessage ) diff --git a/x/bnblightclient/types/tx.pb.go b/x/bnblightclient/types/tx.pb.go index a31573e5..87461d52 100644 --- a/x/bnblightclient/types/tx.pb.go +++ b/x/bnblightclient/types/tx.pb.go @@ -122,8 +122,8 @@ var xxx_messageInfo_MsgUploadHeadersResponse proto.InternalMessageInfo // MsgUpdateHeader defines the message for updating bnb light client header. type MsgUpdateHeader struct { - Headers *Header `protobuf:"bytes,1,opt,name=headers,proto3" json:"headers,omitempty"` - Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` + Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgUpdateHeader) Reset() { *m = MsgUpdateHeader{} } @@ -159,9 +159,9 @@ func (m *MsgUpdateHeader) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateHeader proto.InternalMessageInfo -func (m *MsgUpdateHeader) GetHeaders() *Header { +func (m *MsgUpdateHeader) GetHeader() *Header { if m != nil { - return m.Headers + return m.Header } return nil } @@ -322,36 +322,37 @@ func init() { } var fileDescriptor_7077a7889346cb20 = []byte{ - // 460 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xca, 0xc9, 0x2f, 0x4a, - 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, - 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, - 0x84, 0xaa, 0xd1, 0x43, 0x55, 0xa3, 0x57, 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, - 0xa5, 0x0f, 0x62, 0x41, 0x34, 0x48, 0x49, 0x26, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0xc7, 0x43, 0x24, - 0x20, 0x1c, 0xa8, 0x94, 0x38, 0x84, 0xa7, 0x9f, 0x5b, 0x9c, 0x0e, 0xb2, 0x23, 0xb7, 0x38, 0x1d, - 0x2a, 0xa1, 0x86, 0xdb, 0x21, 0x50, 0xeb, 0x08, 0xaa, 0x2b, 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x5a, - 0xa4, 0xd4, 0xc7, 0xc8, 0x25, 0xe0, 0x5b, 0x9c, 0x1e, 0x5a, 0x90, 0x93, 0x9f, 0x98, 0xe2, 0x91, - 0x9a, 0x98, 0x92, 0x5a, 0x54, 0x2c, 0x64, 0xcd, 0xc5, 0x9e, 0x01, 0x61, 0x4a, 0x30, 0x2a, 0x30, - 0x6b, 0x70, 0x1b, 0x29, 0xea, 0xe1, 0xf4, 0x9b, 0x1e, 0x44, 0x53, 0x10, 0x4c, 0x87, 0x90, 0x01, - 0x17, 0x5b, 0x71, 0x66, 0x7a, 0x5e, 0x6a, 0x91, 0x04, 0x93, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, - 0xa5, 0x2d, 0xba, 0x22, 0x50, 0xcf, 0x39, 0xa6, 0xa4, 0x14, 0xa5, 0x16, 0x17, 0x07, 0x97, 0x14, - 0x65, 0xe6, 0xa5, 0x07, 0x41, 0xd5, 0x59, 0x71, 0x37, 0x3d, 0xdf, 0xa0, 0x05, 0xe5, 0x28, 0x49, - 0x71, 0x49, 0xa0, 0xbb, 0x27, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xa9, 0x97, 0x91, - 0x8b, 0x1f, 0x2c, 0x99, 0x92, 0x58, 0x92, 0x0a, 0x91, 0x44, 0x75, 0x2b, 0x23, 0x7d, 0xdd, 0x2a, - 0xc9, 0x25, 0x8e, 0xe6, 0x1c, 0xb8, 0x53, 0x67, 0x21, 0x3b, 0x35, 0x00, 0x1c, 0xe2, 0x42, 0x66, - 0x5c, 0x9c, 0x89, 0xa5, 0x25, 0x19, 0xf9, 0x45, 0x99, 0x25, 0x95, 0x60, 0xc7, 0xe2, 0xb3, 0x10, - 0xa1, 0x54, 0xc8, 0x9e, 0x8b, 0x0d, 0x12, 0x67, 0x60, 0x57, 0xe2, 0xf7, 0x21, 0xc4, 0x2a, 0x27, - 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0xda, 0xac, 0xf8, 0x40, 0x8e, 0x46, 0x18, 0x88, 0xe2, - 0x6e, 0x88, 0x06, 0x98, 0xbb, 0x8d, 0x1e, 0x32, 0x71, 0x31, 0xfb, 0x16, 0xa7, 0x0b, 0x15, 0x73, - 0xf1, 0xa2, 0xa6, 0x09, 0x6d, 0x3c, 0x96, 0xa2, 0x47, 0x98, 0x94, 0x31, 0x09, 0x8a, 0xe1, 0x41, - 0xc6, 0x20, 0x94, 0xc7, 0xc5, 0x83, 0x12, 0x60, 0x5a, 0x84, 0x8c, 0x41, 0xa8, 0x95, 0x32, 0x22, - 0x5e, 0x2d, 0xcc, 0x46, 0x84, 0x7d, 0xd0, 0xb4, 0x44, 0x94, 0x7d, 0x10, 0xb5, 0xc4, 0xd9, 0x87, - 0x9a, 0x28, 0xa4, 0x58, 0x1b, 0x9e, 0x6f, 0xd0, 0x62, 0x74, 0x0a, 0x39, 0xf1, 0x48, 0x8e, 0xf1, - 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, - 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xab, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, - 0x5c, 0x7d, 0x1f, 0x88, 0xf1, 0xba, 0x01, 0xa0, 0x7c, 0x9a, 0x9c, 0x9f, 0xa3, 0x0f, 0xcb, 0xd1, - 0x15, 0xe8, 0x79, 0xba, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x9c, 0xa1, 0x8d, 0x01, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x14, 0xa8, 0x29, 0x75, 0xab, 0x04, 0x00, 0x00, + // 471 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x33, 0xad, 0x46, 0x3a, 0xf5, 0x1f, 0x43, 0xa1, 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 0x6b, 0x37, 0x85, 0x79, 0xfd, 0xc3, 0xe5, 0xd9, 0x08, + 0x4c, 0x5f, 0x9f, 0xcf, 0x2c, 0x70, 0x31, 0xb3, 0xc0, 0xaf, 0x99, 0x05, 0xbe, 0xcc, 0x2d, 0xed, + 0x62, 0x6e, 0x69, 0x3f, 0xe6, 0x96, 0xf6, 0x76, 0x42, 0x12, 0x11, 0x1f, 0x05, 0x4e, 0x48, 0x33, + 0xf7, 0xa5, 0x3c, 0x7e, 0xf7, 0xb0, 0x9c, 0xd2, 0x90, 0xa6, 0x6e, 0x3d, 0xcf, 0x27, 0xdd, 0x89, + 0x16, 0xa7, 0x05, 0xe6, 0x81, 0x5e, 0x8d, 0xf3, 0xfe, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2f, + 0x1a, 0x0d, 0xb0, 0xa9, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -608,9 +609,9 @@ func (m *MsgUpdateHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if m.Headers != nil { + if m.Header != nil { { - size, err := m.Headers.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -754,8 +755,8 @@ func (m *MsgUpdateHeader) Size() (n int) { } var l int _ = l - if m.Headers != nil { - l = m.Headers.Size() + if m.Header != nil { + l = m.Header.Size() n += 1 + l + sovTx(uint64(l)) } l = len(m.Signer) @@ -1001,7 +1002,7 @@ func (m *MsgUpdateHeader) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Headers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1028,10 +1029,10 @@ func (m *MsgUpdateHeader) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Headers == nil { - m.Headers = &Header{} + if m.Header == nil { + m.Header = &Header{} } - if err := m.Headers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From 053f8506354764d1e434f5ba8078c24d99310760 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Fri, 19 Jul 2024 16:29:06 +0800 Subject: [PATCH 07/19] add receipt verify --- .github/workflows/codeql.yml | 2 +- .github/workflows/golangci_lint.yml | 2 +- .github/workflows/release_binary.yml | 2 +- .github/workflows/test.yml | 2 +- go.mod | 2 +- proto/lorenzo/bnblightclient/v1/genesis.proto | 10 +- proto/lorenzo/bnblightclient/v1/params.proto | 12 +- x/bnblightclient/keeper/keeper.go | 47 +-- x/bnblightclient/keeper/proof.go | 192 +++++++++++ x/bnblightclient/types/errors.go | 4 + x/bnblightclient/types/events.go | 26 ++ x/bnblightclient/types/genesis.pb.go | 325 ++++++++++++++++-- x/bnblightclient/types/keys.go | 20 +- x/bnblightclient/types/params.go | 4 - x/bnblightclient/types/params.pb.go | 182 ++++++---- x/bnblightclient/types/proof.go | 3 +- 16 files changed, 666 insertions(+), 169 deletions(-) create mode 100644 x/bnblightclient/keeper/proof.go create mode 100644 x/bnblightclient/types/events.go diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1b427152..3e9d810b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: "1.20" + go-version: "1.21" # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/golangci_lint.yml b/.github/workflows/golangci_lint.yml index 8bf57462..9ea6d315 100644 --- a/.github/workflows/golangci_lint.yml +++ b/.github/workflows/golangci_lint.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: "1.20" + go-version: "1.21" check-latest: true - uses: technote-space/get-diff-action@v6.1.2 id: git_diff diff --git a/.github/workflows/release_binary.yml b/.github/workflows/release_binary.yml index 3c0e3892..e99d6468 100644 --- a/.github/workflows/release_binary.yml +++ b/.github/workflows/release_binary.yml @@ -21,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' check-latest: true - name: release dry run diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ec5e16e..334125e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' check-latest: true - uses: actions/checkout@v4 - uses: technote-space/get-diff-action@v6.1.2 diff --git a/go.mod b/go.mod index 5151831f..77ac1d9d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Lorenzo-Protocol/lorenzo -go 1.20 +go 1.21 require ( cosmossdk.io/errors v1.0.1 diff --git a/proto/lorenzo/bnblightclient/v1/genesis.proto b/proto/lorenzo/bnblightclient/v1/genesis.proto index a09a900d..8a0cbf3d 100644 --- a/proto/lorenzo/bnblightclient/v1/genesis.proto +++ b/proto/lorenzo/bnblightclient/v1/genesis.proto @@ -12,6 +12,12 @@ message GenesisState { lorenzo.bnblightclient.v1.Params params = 1; // headers defines the bnb light client headers repeated lorenzo.bnblightclient.v1.Header headers = 2; - // tx_hashes defines the transactions that the bnb chain has successfully processed - repeated string tx_hashes = 3; + // records defines the bnb light client event records + repeated EventRecord records = 3; +} + +message EventRecord { + uint64 block_number = 1; + bytes contract = 2; + uint64 index = 3; } \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/params.proto b/proto/lorenzo/bnblightclient/v1/params.proto index 6a1973f5..e7f5f53b 100644 --- a/proto/lorenzo/bnblightclient/v1/params.proto +++ b/proto/lorenzo/bnblightclient/v1/params.proto @@ -9,11 +9,15 @@ option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" message Params { option (gogoproto.equal) = true; - bytes chain_id = 1 [ (gogoproto.customtype) = "cosmossdk.io/math.Uint" ]; // the stake plan hub contract address - string stake_plan_hub_address = 2; + string stake_plan_hub_address = 1; + // event_index defines index of generated the event in the contract + repeated string event_indices = 2; + // event_name defines the event name + string event_name = 3; // the maximum number of bnb block headers to retain - uint64 retained_blocks = 3; + uint64 retained_blocks = 4; // list of people who can upload bnb block header information - repeated string allow_list = 4; + repeated string allow_list = 5; + } \ No newline at end of file diff --git a/x/bnblightclient/keeper/keeper.go b/x/bnblightclient/keeper/keeper.go index 0f0c1471..c33ef01b 100644 --- a/x/bnblightclient/keeper/keeper.go +++ b/x/bnblightclient/keeper/keeper.go @@ -1,21 +1,11 @@ package keeper import ( - "bytes" - - errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" - evmtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rlp" - "github.com/ethereum/go-ethereum/trie" - - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" ) +// Keeper is the keeper struct for the x/bnblightclient module type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec @@ -23,38 +13,3 @@ type Keeper struct { // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. authority string } - -// VerifyReceiptProof verifies the proof of a receipt in the Ethereum blockchain. -// -// Parameters: -// - ctx: the SDK context. -// - receipt: the Ethereum receipt to verify. -// - proof: the proof of the receipt. -// -// Returns: -// - error: an error if the proof verification fails. -func (k Keeper) VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof types.Proof) error { - db := trie.NewDatabase(rawdb.NewMemoryDatabase()) - mpt := trie.NewEmpty(db) - _ = evmtypes.DeriveSha(evmtypes.Receipts{receipt}, mpt) - - var indexBuf []byte - indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(0)) - txValue := mpt.Get(indexBuf) - - header, exist := k.GetHeader(ctx, receipt.BlockNumber.Uint64()) - if !exist { - return errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found", header.Number) - } - - val, err := trie.VerifyProof(common.Hash(header.ReceiptRoot), proof.Index, &proof.Path) - if err != nil { - return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") - } - - if bytes.Equal(val, proof.Value) && bytes.Equal(val, txValue) { - return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") - } - - return nil -} diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go new file mode 100644 index 00000000..1322e3c4 --- /dev/null +++ b/x/bnblightclient/keeper/proof.go @@ -0,0 +1,192 @@ +package keeper + +import ( + "bytes" + "math/big" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + evmtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +// VerifyReceiptProof verifies the receipt proof for a BNB cross-chain event. +// +// ctx - context in which the verification is done +// receipt - the EVM transaction receipt to verify +// proof - the proof object containing the necessary data for verification +// Returns an array of BNBCrossChainEvent and an error if the verification fails. +func (k Keeper) VerifyReceiptProof( + ctx sdk.Context, + receipt *evmtypes.Receipt, + proof types.Proof, +) ([]types.BNBCrossChainEvent, error) { + if err := k.verifyProof(ctx, receipt, proof); err != nil { + return nil, err + } + + events, err := k.parseEvents(ctx, receipt) + if err != nil { + return nil, err + } + + if len(events) == 0 { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "invalid receipt, no events found") + } + return events, nil +} + +// GetAllEventRecord retrieves all event records stored in the context. +// +// ctx - The context object. +// []*types.EventRecord - A slice of event records. +func (k Keeper) GetAllEventRecord(ctx sdk.Context) (events []*types.EventRecord) { + store := ctx.KVStore(k.storeKey) + + it := sdk.KVStorePrefixIterator(store, types.KeyPrefixEventRecord) + defer it.Close() //nolint:errcheck + + for ; it.Valid(); it.Next() { + var event types.EventRecord + k.cdc.MustUnmarshal(it.Value(), &event) + events = append(events, &event) + } + return events +} + +func (k Keeper) verifyProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof types.Proof) error { + if receipt.Status != evmtypes.ReceiptStatusSuccessful { + return errorsmod.Wrapf(types.ErrInvalidTransaction, "cannot verify failed transactions") + } + + db := trie.NewDatabase(rawdb.NewMemoryDatabase()) + mpt := trie.NewEmpty(db) + _ = evmtypes.DeriveSha(evmtypes.Receipts{receipt}, mpt) + + var indexBuf []byte + indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(0)) + txValue := mpt.Get(indexBuf) + + header, exist := k.GetHeader(ctx, receipt.BlockNumber.Uint64()) + if !exist { + return errorsmod.Wrapf(types.ErrHeaderNotFound, "header %d not found", header.Number) + } + + val, err := trie.VerifyProof(common.Hash(header.ReceiptRoot), proof.Index, &proof.Path) + if err != nil { + return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") + } + + if !bytes.Equal(val, proof.Value) || !bytes.Equal(val, txValue) { + return errorsmod.Wrapf(types.ErrInvalidProof, "invalid receipt proof") + } + + return nil +} + +func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types.BNBCrossChainEvent, error) { + if len(receipt.Logs) == 0 { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "no event log found") + } + + params := k.GetParams(ctx) + contractAddr := common.HexToAddress(params.StakePlanHubAddress).Bytes() + + events := make([]types.BNBCrossChainEvent, 0, len(receipt.Logs)) + for _, log := range receipt.Logs { + if !bytes.Equal(contractAddr, log.Address.Bytes()) { + continue + } + + if len(log.Topics) != 5 { + return nil, errorsmod.Wrapf( + types.ErrInvalidEvent, + "event has wrong number of topics, expected 5, actual: %d", + len(log.Topics), + ) + } + + eventID := log.Topics[0] + event, err := types.StakePlanHubContractABI.EventByID(eventID) + if err != nil { + continue + } + + if event.Name != params.EventName { + continue + } + + eventArgs, err := types.StakePlanHubContractABI.Unpack(event.Name, log.Data) + if err != nil { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "failed to unpack %s event", event.Name) + } + + if len(eventArgs) != 3 { + return nil, errorsmod.Wrapf( + types.ErrInvalidEvent, + "event has wrong number of parameters, expected 2, actual: %d", + len(eventArgs), + ) + } + + eventIndex := new(big.Int).SetBytes(log.Topics[1].Bytes()) + record := types.EventRecord{ + BlockNumber: receipt.BlockNumber.Uint64(), + Index: eventIndex.Uint64(), + Contract: log.Address.Bytes(), + } + if k.hasEventRecord(ctx, record) { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "event index %d already exists", eventIndex.Uint64()) + } + k.setEventRecord(ctx, record) + + sender := common.BytesToAddress(log.Topics[2].Bytes()) + planID := new(big.Int).SetBytes(log.Topics[3].Bytes()) + btcContractAddress := common.BytesToAddress(log.Topics[4].Bytes()) + stakeAmount, ok := eventArgs[0].(*big.Int) + if !ok { + return nil, errorsmod.Wrap( + types.ErrInvalidEvent, + "event `stakeAmount` parameters is invalid, expected `*big.Int`", + ) + } + + stBTCAmount, ok := eventArgs[1].(*big.Int) + if !ok { + return nil, errorsmod.Wrap( + types.ErrInvalidEvent, + "event `stBTCAmount` parameters is invalid, expected `*big.Int`", + ) + } + + bnbEvent := types.BNBCrossChainEvent{ + EventIndex: eventIndex.Uint64(), + Sender: sender, + PlanID: planID.Uint64(), + BTCcontractAddress: btcContractAddress, + StakeAmount: stakeAmount, + StBTCAmount: stBTCAmount, + } + events = append(events, bnbEvent) + } + return events, nil +} + +func (k Keeper) hasEventRecord(ctx sdk.Context, record types.EventRecord) bool { + store := ctx.KVStore(k.storeKey) + key := record.Key() + return store.Has(key) +} + +func (k Keeper) setEventRecord(ctx sdk.Context, record types.EventRecord) { + store := ctx.KVStore(k.storeKey) + key := record.Key() + + bz := k.cdc.MustMarshal(&record) + store.Set(key[:], bz) +} diff --git a/x/bnblightclient/types/errors.go b/x/bnblightclient/types/errors.go index 0fff883c..edddb8c4 100644 --- a/x/bnblightclient/types/errors.go +++ b/x/bnblightclient/types/errors.go @@ -14,4 +14,8 @@ var ( ErrUnauthorized = errorsmod.Register(ModuleName, 4, "tx unauthorized") // ErrInvalidProof is returned when proof is not valid ErrInvalidProof = errorsmod.Register(ModuleName, 5, "invalid proof") + // ErrInvalidTransaction is returned when transaction is not valid + ErrInvalidTransaction = errorsmod.Register(ModuleName, 6, "invalid transaction") + // ErrInvalidEvent is returned when event is not valid + ErrInvalidEvent = errorsmod.Register(ModuleName, 7, "invalid event") ) diff --git a/x/bnblightclient/types/events.go b/x/bnblightclient/types/events.go new file mode 100644 index 00000000..4fef62a8 --- /dev/null +++ b/x/bnblightclient/types/events.go @@ -0,0 +1,26 @@ +package types + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" +) + +// StakePlanHubContractABI is the ABI for the StakePlanHub contract. TODO +var StakePlanHubContractABI abi.ABI + +// BNBCrossChainEvent is a struct that contains the sender, plan id, BTC contract address, stake amount, and stBTC amount. +type BNBCrossChainEvent struct { + EventIndex uint64 `json:"event_index"` + Sender common.Address `json:"sender"` + PlanID uint64 `json:"plan_id"` + BTCcontractAddress common.Address `json:"btc_contract_address"` + StakeAmount *big.Int `json:"stake_amount"` + StBTCAmount *big.Int `json:"st_btc_amount"` +} + +// Key returns the unique key of the EventRecord struct +func(e EventRecord) Key() []byte { + return KeyEventRecord(e.BlockNumber, e.Contract, e.Index) +} diff --git a/x/bnblightclient/types/genesis.pb.go b/x/bnblightclient/types/genesis.pb.go index 5fbc4e94..c19281eb 100644 --- a/x/bnblightclient/types/genesis.pb.go +++ b/x/bnblightclient/types/genesis.pb.go @@ -28,8 +28,8 @@ type GenesisState struct { Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` // headers defines the bnb light client headers Headers []*Header `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"` - // tx_hashes defines the transactions that the bnb chain has successfully processed - TxHashes []string `protobuf:"bytes,3,rep,name=tx_hashes,json=txHashes,proto3" json:"tx_hashes,omitempty"` + // records defines the bnb light client event records + Records []*EventRecord `protobuf:"bytes,3,rep,name=records,proto3" json:"records,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,15 +79,76 @@ func (m *GenesisState) GetHeaders() []*Header { return nil } -func (m *GenesisState) GetTxHashes() []string { +func (m *GenesisState) GetRecords() []*EventRecord { if m != nil { - return m.TxHashes + return m.Records } return nil } +type EventRecord struct { + BlockNumber uint64 `protobuf:"varint,1,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` + Contract []byte `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` + Index uint64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"` +} + +func (m *EventRecord) Reset() { *m = EventRecord{} } +func (m *EventRecord) String() string { return proto.CompactTextString(m) } +func (*EventRecord) ProtoMessage() {} +func (*EventRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_4f928fb205bb2cf6, []int{1} +} +func (m *EventRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventRecord.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 *EventRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventRecord.Merge(m, src) +} +func (m *EventRecord) XXX_Size() int { + return m.Size() +} +func (m *EventRecord) XXX_DiscardUnknown() { + xxx_messageInfo_EventRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_EventRecord proto.InternalMessageInfo + +func (m *EventRecord) GetBlockNumber() uint64 { + if m != nil { + return m.BlockNumber + } + return 0 +} + +func (m *EventRecord) GetContract() []byte { + if m != nil { + return m.Contract + } + return nil +} + +func (m *EventRecord) GetIndex() uint64 { + if m != nil { + return m.Index + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "lorenzo.bnblightclient.v1.GenesisState") + proto.RegisterType((*EventRecord)(nil), "lorenzo.bnblightclient.v1.EventRecord") } func init() { @@ -95,23 +156,27 @@ func init() { } var fileDescriptor_4f928fb205bb2cf6 = []byte{ - // 248 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcf, 0xc9, 0x2f, 0x4a, - 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, - 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, - 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x84, 0x2a, 0xd4, 0x43, 0x55, 0xa8, 0x57, 0x66, 0x28, 0xa5, 0x86, - 0xdb, 0x0c, 0xa8, 0x22, 0xb0, 0x11, 0xf8, 0xd4, 0x15, 0x24, 0x16, 0x25, 0xe6, 0x42, 0xad, 0x52, - 0x5a, 0xcc, 0xc8, 0xc5, 0xe3, 0x0e, 0xb1, 0x3c, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x92, 0x8b, - 0x0d, 0xa2, 0x40, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x51, 0x0f, 0xa7, 0x63, 0xf4, 0x02, - 0xc0, 0x0a, 0x83, 0xa0, 0x1a, 0x84, 0xac, 0xb9, 0xd8, 0x33, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, - 0x25, 0x98, 0x14, 0x98, 0x09, 0xe8, 0xf5, 0x00, 0xab, 0x0c, 0x82, 0xe9, 0x10, 0x92, 0xe6, 0xe2, - 0x2c, 0xa9, 0x88, 0xcf, 0x48, 0x2c, 0xce, 0x48, 0x2d, 0x96, 0x60, 0x56, 0x60, 0xd6, 0xe0, 0x0c, - 0xe2, 0x28, 0xa9, 0xf0, 0x00, 0xf3, 0x9d, 0x42, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, - 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, - 0x8e, 0x21, 0xca, 0x2a, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xdf, 0x07, - 0x62, 0x99, 0x6e, 0x00, 0xc8, 0x67, 0xc9, 0xf9, 0x39, 0xfa, 0xb0, 0x30, 0xa8, 0x40, 0x0f, 0x85, - 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0x10, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, - 0xab, 0x14, 0xb3, 0xbf, 0x98, 0x01, 0x00, 0x00, + // 315 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x31, 0x4f, 0x02, 0x31, + 0x14, 0xc7, 0x29, 0x28, 0x98, 0xc2, 0xd4, 0x38, 0x9c, 0x0c, 0x0d, 0x30, 0x20, 0x8b, 0xbd, 0xa0, + 0x93, 0xba, 0x18, 0x13, 0xa3, 0x83, 0x31, 0xa4, 0x3a, 0xb9, 0x98, 0x6b, 0x79, 0x81, 0x8b, 0x47, + 0x4b, 0x7a, 0xe5, 0x82, 0x7e, 0x0a, 0x3f, 0x16, 0x23, 0xa3, 0xa3, 0xb9, 0xfb, 0x22, 0xc6,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0x2f, 0x2f, 0x2e, 0x1f, 0x56, 0x29, 0x45, 0xeb, 0x94, 0xa2, 0x8f, + 0x94, 0xa2, 0xb7, 0x8c, 0x56, 0xd6, 0x19, 0xad, 0xbc, 0x67, 0xb4, 0xf2, 0x78, 0x36, 0x09, 0xed, + 0x74, 0x21, 0x98, 0xd4, 0x33, 0xff, 0x36, 0x3f, 0xfc, 0x68, 0xf4, 0xf5, 0xc5, 0x52, 0x47, 0x7e, + 0x19, 0xc6, 0xf2, 0x6f, 0x1c, 0xf6, 0x65, 0x0e, 0xb1, 0xa8, 0xbb, 0x2c, 0x4e, 0x3e, 0x03, 0x00, + 0x00, 0xff, 0xff, 0x48, 0x65, 0x4c, 0xef, 0x21, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -134,11 +199,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.TxHashes) > 0 { - for iNdEx := len(m.TxHashes) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.TxHashes[iNdEx]) - copy(dAtA[i:], m.TxHashes[iNdEx]) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.TxHashes[iNdEx]))) + if len(m.Records) > 0 { + for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Records[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x1a } @@ -172,6 +242,46 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EventRecord) 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 *EventRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Index != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x18 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x12 + } + if m.BlockNumber != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.BlockNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -199,15 +309,34 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.TxHashes) > 0 { - for _, s := range m.TxHashes { - l = len(s) + if len(m.Records) > 0 { + for _, e := range m.Records { + l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } } return n } +func (m *EventRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockNumber != 0 { + n += 1 + sovGenesis(uint64(m.BlockNumber)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Index != 0 { + n += 1 + sovGenesis(uint64(m.Index)) + } + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -315,9 +444,9 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TxHashes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -327,23 +456,25 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - m.TxHashes = append(m.TxHashes, string(dAtA[iNdEx:postIndex])) + m.Records = append(m.Records, &EventRecord{}) + if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -366,6 +497,128 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } +func (m *EventRecord) 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 ErrIntOverflowGenesis + } + 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: EventRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockNumber", wireType) + } + m.BlockNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = append(m.Contract[:0], dAtA[iNdEx:postIndex]...) + if m.Contract == nil { + m.Contract = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go index 32eba230..96775fa7 100644 --- a/x/bnblightclient/types/keys.go +++ b/x/bnblightclient/types/keys.go @@ -2,7 +2,6 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ) const ( @@ -25,8 +24,8 @@ var ( // KeyPrefixHeadHash defines the prefix to retrieve the head hash KeyPrefixHeadHash = []byte{0x04} - // KeyPrefixTxHash defines the prefix to retrieve the tx hash - KeyPrefixTxHash = []byte{0x05} + // KeyPrefixEventRecord defines the prefix to retrieve the cross chain event + KeyPrefixEventRecord = []byte{0x05} ) // KeyHeader returns the key for a header @@ -45,15 +44,18 @@ func KeyLatestedHeaderNumber() []byte { return KeyPrefixLatestedNumber } -// KeyTxHash returns the key for the tx hash -func KeyTxHash(blockNumber uint64, txHash common.Hash) []byte { - key := make([]byte, 0) - copy(key, KeyPrefixTxHash) +// KeyEventRecord returns the key for the cross chain event index +func KeyEventRecord(blockNumber uint64, contract []byte, idx uint64) []byte { + key := append([]byte{}, KeyPrefixEventRecord...) bumberBz := sdk.Uint64ToBigEndian(blockNumber) key = append(key, bumberBz...) + key = append(key, Delimiter...) - txHashBz := txHash.Bytes() - key = append(key, txHashBz...) + key = append(key, contract...) + key = append(key, Delimiter...) + + idxBz := sdk.Uint64ToBigEndian(idx) + key = append(key, idxBz...) return key } diff --git a/x/bnblightclient/types/params.go b/x/bnblightclient/types/params.go index 6989c3b9..4d2a3b54 100644 --- a/x/bnblightclient/types/params.go +++ b/x/bnblightclient/types/params.go @@ -12,10 +12,6 @@ import ( // It does not take any parameters. // It returns an error if the validation fails. func (p Params) Validate() error { - if p.ChainId == nil { - return fmt.Errorf("chain id cannot be nil") - } - if len(p.StakePlanHubAddress) == 0 { return fmt.Errorf("stake plan hub address cannot be empty") } diff --git a/x/bnblightclient/types/params.pb.go b/x/bnblightclient/types/params.pb.go index 50db2d31..b7962c58 100644 --- a/x/bnblightclient/types/params.pb.go +++ b/x/bnblightclient/types/params.pb.go @@ -4,7 +4,6 @@ package types import ( - cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -26,13 +25,16 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the module. type Params struct { - ChainId *cosmossdk_io_math.Uint `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3,customtype=cosmossdk.io/math.Uint" json:"chain_id,omitempty"` // the stake plan hub contract address - StakePlanHubAddress string `protobuf:"bytes,2,opt,name=stake_plan_hub_address,json=stakePlanHubAddress,proto3" json:"stake_plan_hub_address,omitempty"` + StakePlanHubAddress string `protobuf:"bytes,1,opt,name=stake_plan_hub_address,json=stakePlanHubAddress,proto3" json:"stake_plan_hub_address,omitempty"` + // event_index defines index of generated the event in the contract + EventIndices []string `protobuf:"bytes,2,rep,name=event_indices,json=eventIndices,proto3" json:"event_indices,omitempty"` + // event_name defines the event name + EventName string `protobuf:"bytes,3,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` // the maximum number of bnb block headers to retain - RetainedBlocks uint64 `protobuf:"varint,3,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` + RetainedBlocks uint64 `protobuf:"varint,4,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` // list of people who can upload bnb block header information - AllowList []string `protobuf:"bytes,4,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` + AllowList []string `protobuf:"bytes,5,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -75,6 +77,20 @@ func (m *Params) GetStakePlanHubAddress() string { return "" } +func (m *Params) GetEventIndices() []string { + if m != nil { + return m.EventIndices + } + return nil +} + +func (m *Params) GetEventName() string { + if m != nil { + return m.EventName + } + return "" +} + func (m *Params) GetRetainedBlocks() uint64 { if m != nil { return m.RetainedBlocks @@ -98,28 +114,27 @@ func init() { } var fileDescriptor_3608f71b6e08ae9c = []byte{ - // 322 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x3f, 0x4b, 0xc3, 0x40, - 0x18, 0xc6, 0x7b, 0xb6, 0x54, 0x7b, 0x88, 0x42, 0x94, 0x12, 0x0b, 0xa6, 0xc1, 0x41, 0xb3, 0x98, - 0xa3, 0x14, 0x97, 0x6e, 0x76, 0x52, 0xe8, 0x50, 0x82, 0x2e, 0x2e, 0xe1, 0x2e, 0x39, 0x92, 0xa3, - 0x97, 0x7b, 0x43, 0xee, 0x5a,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1, 0x14, 0xda, 0xb8, 0x0d, - 0xbf, 0x1e, 0xb4, 0xa2, 0x96, 0x4d, 0x46, 0x42, 0x9b, 0x41, 0xe3, 0xfb, 0xa5, 0x8b, 0x86, 0x37, - 0x6f, 0x0b, 0x0f, 0xcd, 0x17, 0x1e, 0xfa, 0x5a, 0x78, 0xe8, 0x79, 0xe9, 0xd5, 0xe6, 0x4b, 0xaf, - 0xf6, 0xbe, 0xf4, 0x6a, 0x77, 0x83, 0x4c, 0x98, 0x7c, 0xca, 0xc2, 0x04, 0x0a, 0x32, 0x5a, 0xab, - 0x39, 0x1f, 0xaf, 0x1e, 0x4f, 0x40, 0x92, 0x8d, 0xd3, 0x87, 0xff, 0x56, 0xcd, 0x63, 0xc9, 0x35, - 0x6b, 0x5a, 0x43, 0xfd, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xbe, 0x16, 0x9c, 0x7c, 0x01, - 0x00, 0x00, + // 315 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xcd, 0x4a, 0x33, 0x31, + 0x18, 0x85, 0x9b, 0xaf, 0xfd, 0x0a, 0x13, 0xfc, 0x81, 0x51, 0x64, 0x14, 0x8c, 0x45, 0x41, 0xbb, + 0x71, 0x42, 0xe9, 0xae, 0x3b, 0xbb, 0x52, 0x28, 0x52, 0x8a, 0x2b, 0x37, 0x21, 0x99, 0x79, 0x99, + 0x86, 0x66, 0x92, 0x61, 0x92, 0xd6, 0x9f, 0xab, 0xf0, 0x12, 0xbc, 0x1c, 0x77, 0x76, 0xe9, 0x52, + 0xda, 0x8d, 0x97, 0x21, 0x93, 0xb1, 0x0b, 0xdd, 0x85, 0xe7, 0x9c, 0x9c, 0x17, 0x1e, 0x7c, 0xae, + 0x4c, 0x09, 0xfa, 0xd9, 0x50, 0xa1, 0x85, 0x92, 0xd9, 0xd4, 0x25, 0x4a, 0x82, 0x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e9, 0x5c, 0xc4, 0x89, 0xc9, 0xe9, 0xa8, 0xf6, 0x74, 0x39, 0xae, 0x2c, 0x24, 0x46, 0xd1, + 0x8d, 0xe0, 0xc7, 0xbf, 0x8a, 0xdd, 0x53, 0x01, 0x56, 0xb4, 0xbd, 0xae, 0xfe, 0x77, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x9c, 0xb8, 0x0a, 0x29, 0x89, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -141,14 +156,18 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } - if that1.ChainId == nil { - if this.ChainId != nil { + if this.StakePlanHubAddress != that1.StakePlanHubAddress { + return false + } + if len(this.EventIndices) != len(that1.EventIndices) { + return false + } + for i := range this.EventIndices { + if this.EventIndices[i] != that1.EventIndices[i] { return false } - } else if !this.ChainId.Equal(*that1.ChainId) { - return false } - if this.StakePlanHubAddress != that1.StakePlanHubAddress { + if this.EventName != that1.EventName { return false } if this.RetainedBlocks != that1.RetainedBlocks { @@ -190,31 +209,35 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.AllowList[iNdEx]) i = encodeVarintParams(dAtA, i, uint64(len(m.AllowList[iNdEx]))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } if m.RetainedBlocks != 0 { i = encodeVarintParams(dAtA, i, uint64(m.RetainedBlocks)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 + } + if len(m.EventName) > 0 { + i -= len(m.EventName) + copy(dAtA[i:], m.EventName) + i = encodeVarintParams(dAtA, i, uint64(len(m.EventName))) + i-- + dAtA[i] = 0x1a + } + if len(m.EventIndices) > 0 { + for iNdEx := len(m.EventIndices) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.EventIndices[iNdEx]) + copy(dAtA[i:], m.EventIndices[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.EventIndices[iNdEx]))) + i-- + dAtA[i] = 0x12 + } } if len(m.StakePlanHubAddress) > 0 { i -= len(m.StakePlanHubAddress) copy(dAtA[i:], m.StakePlanHubAddress) i = encodeVarintParams(dAtA, i, uint64(len(m.StakePlanHubAddress))) i-- - dAtA[i] = 0x12 - } - if m.ChainId != nil { - { - size := m.ChainId.Size() - i -= size - if _, err := m.ChainId.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -237,11 +260,17 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.ChainId != nil { - l = m.ChainId.Size() + l = len(m.StakePlanHubAddress) + if l > 0 { n += 1 + l + sovParams(uint64(l)) } - l = len(m.StakePlanHubAddress) + if len(m.EventIndices) > 0 { + for _, s := range m.EventIndices { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + l = len(m.EventName) if l > 0 { n += 1 + l + sovParams(uint64(l)) } @@ -294,9 +323,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StakePlanHubAddress", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -306,30 +335,27 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthParams } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthParams } if postIndex > l { return io.ErrUnexpectedEOF } - var v cosmossdk_io_math.Uint - m.ChainId = &v - if err := m.ChainId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.StakePlanHubAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakePlanHubAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EventIndices", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -357,9 +383,41 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.StakePlanHubAddress = string(dAtA[iNdEx:postIndex]) + m.EventIndices = append(m.EventIndices, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EventName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EventName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RetainedBlocks", wireType) } @@ -378,7 +436,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AllowList", wireType) } diff --git a/x/bnblightclient/types/proof.go b/x/bnblightclient/types/proof.go index 84d3b30e..d026d042 100644 --- a/x/bnblightclient/types/proof.go +++ b/x/bnblightclient/types/proof.go @@ -124,7 +124,7 @@ func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*types.Receipt } var indexBuf []byte - indexBuf = rlp.AppendUint64(indexBuf[:0], uint64(txIndex)) + indexBuf = rlp.AppendUint64(indexBuf[:0], txIndex) valueTarget := mpt.Get(indexBuf) proof := NewProofPath() @@ -141,3 +141,4 @@ func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*types.Receipt return &res, nil } + From c5a927d9e677468f79563644f7c07a86be47744c Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Fri, 19 Jul 2024 17:01:26 +0800 Subject: [PATCH 08/19] support prune header --- x/bnblightclient/keeper/header.go | 1 + x/bnblightclient/keeper/prune.go | 54 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 x/bnblightclient/keeper/prune.go diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go index a71b25f5..c62e090b 100644 --- a/x/bnblightclient/keeper/header.go +++ b/x/bnblightclient/keeper/header.go @@ -30,6 +30,7 @@ func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { k.setHeader(ctx, header) } k.setLatestedHeaderNumber(ctx, headers[len(headers) - 1].Number) + k.prune(ctx) return nil } diff --git a/x/bnblightclient/keeper/prune.go b/x/bnblightclient/keeper/prune.go new file mode 100644 index 00000000..5d4f25a0 --- /dev/null +++ b/x/bnblightclient/keeper/prune.go @@ -0,0 +1,54 @@ +package keeper + +import ( + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func(k Keeper) prune(ctx sdk.Context) { + // get the latested header + latestedHeader, exist := k.GetLatestedHeader(ctx) + if !exist { + return + } + + params := k.GetParams(ctx) + + pruneEndNumber := latestedHeader.Number - params.RetainedBlocks + if pruneEndNumber <= 0 { + return + } + k.pruneHeaders(ctx, pruneEndNumber) +} + +func(k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStoreReversePrefixIterator(store, types.KeyPrefixHeader) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + iterKey := iterator.Key() + number := sdk.BigEndianToUint64(iterKey[1:]) + if number <= pruneEndNumber { + header,exist := k.GetHeader(ctx, number) + if !exist { + continue + } + + // delete header + store.Delete(iterKey) + // delete header hash + store.Delete(types.KeyHeaderHash(header.Hash)) + + // delete event record + prefix := append(types.KeyPrefixEventRecord, sdk.Uint64ToBigEndian(number)...) + iterator2 := sdk.KVStoreReversePrefixIterator(store, prefix) + defer iterator2.Close() + + for ; iterator2.Valid(); iterator2.Next() { + iterKey2 := iterator2.Key() + store.Delete(iterKey2) + } + } + } +} \ No newline at end of file From 604cd5b6f456d98e9dcf484a2697d24d198dc530 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Fri, 19 Jul 2024 17:13:34 +0800 Subject: [PATCH 09/19] refactor code --- x/bnblightclient/keeper/header.go | 20 ++++++++++++++++++-- x/bnblightclient/keeper/prune.go | 19 +++++++------------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go index c62e090b..e6a5c2ba 100644 --- a/x/bnblightclient/keeper/header.go +++ b/x/bnblightclient/keeper/header.go @@ -29,7 +29,7 @@ func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { for _, header := range headers { k.setHeader(ctx, header) } - k.setLatestedHeaderNumber(ctx, headers[len(headers) - 1].Number) + k.setLatestedNumber(ctx, headers[len(headers) - 1].Number) k.prune(ctx) return nil } @@ -75,6 +75,22 @@ func(k Keeper) GetLatestedHeader(ctx sdk.Context) (*types.Header, bool) { return k.GetHeader(ctx, number) } +// GetLatestedNumber retrieves the latested number from the store. +// +// Parameters: +// - ctx: the context object +// +// Returns: +// - uint64: the latested number +func(k Keeper) GetLatestedNumber(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyLatestedHeaderNumber()) + if bz == nil { + return 0 + } + return sdk.BigEndianToUint64(bz) +} + // GetHeader retrieves the header for a specific number from the store. // // Parameters: @@ -135,7 +151,7 @@ func(k Keeper) setHeader(ctx sdk.Context, header *types.Header) { store.Set(types.KeyHeaderHash(header.Hash), numberBz) } -func(k Keeper) setLatestedHeaderNumber(ctx sdk.Context, number uint64) { +func(k Keeper) setLatestedNumber(ctx sdk.Context, number uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(number) store.Set(types.KeyLatestedHeaderNumber(), bz) diff --git a/x/bnblightclient/keeper/prune.go b/x/bnblightclient/keeper/prune.go index 5d4f25a0..c3ebb77f 100644 --- a/x/bnblightclient/keeper/prune.go +++ b/x/bnblightclient/keeper/prune.go @@ -5,23 +5,18 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func(k Keeper) prune(ctx sdk.Context) { +func (k Keeper) prune(ctx sdk.Context) { // get the latested header - latestedHeader, exist := k.GetLatestedHeader(ctx) - if !exist { - return - } - + latestedNumber := k.GetLatestedNumber(ctx) params := k.GetParams(ctx) - - pruneEndNumber := latestedHeader.Number - params.RetainedBlocks + pruneEndNumber := int64(latestedNumber - params.RetainedBlocks) if pruneEndNumber <= 0 { return } - k.pruneHeaders(ctx, pruneEndNumber) + k.pruneHeaders(ctx, uint64(pruneEndNumber)) } -func(k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { +func (k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStoreReversePrefixIterator(store, types.KeyPrefixHeader) defer iterator.Close() @@ -30,7 +25,7 @@ func(k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { iterKey := iterator.Key() number := sdk.BigEndianToUint64(iterKey[1:]) if number <= pruneEndNumber { - header,exist := k.GetHeader(ctx, number) + header, exist := k.GetHeader(ctx, number) if !exist { continue } @@ -51,4 +46,4 @@ func(k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { } } } -} \ No newline at end of file +} From 58b4309544ecf3883aa42045b47daf0cec08919f Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Fri, 19 Jul 2024 18:38:33 +0800 Subject: [PATCH 10/19] implement msg interface --- proto/lorenzo/bnblightclient/v1/genesis.proto | 3 + proto/lorenzo/bnblightclient/v1/params.proto | 8 +- proto/lorenzo/bnblightclient/v1/query.proto | 16 +- x/bnblightclient/keeper/genesis.go | 42 ++++ x/bnblightclient/keeper/grpc_query.go | 10 +- x/bnblightclient/keeper/header.go | 41 +++- x/bnblightclient/keeper/msg_server.go | 2 +- x/bnblightclient/keeper/params.go | 8 +- x/bnblightclient/keeper/proof.go | 8 +- x/bnblightclient/keeper/prune.go | 2 +- x/bnblightclient/types/genesis.go | 11 + x/bnblightclient/types/genesis.pb.go | 7 +- x/bnblightclient/types/keys.go | 10 +- x/bnblightclient/types/msg.go | 55 +++++ x/bnblightclient/types/params.go | 5 + x/bnblightclient/types/params.pb.go | 121 +++-------- x/bnblightclient/types/query.pb.go | 192 +++++++++--------- x/bnblightclient/types/query.pb.gw.go | 28 +-- 18 files changed, 321 insertions(+), 248 deletions(-) create mode 100644 x/bnblightclient/keeper/genesis.go create mode 100644 x/bnblightclient/types/genesis.go create mode 100644 x/bnblightclient/types/msg.go diff --git a/proto/lorenzo/bnblightclient/v1/genesis.proto b/proto/lorenzo/bnblightclient/v1/genesis.proto index 8a0cbf3d..98652fd9 100644 --- a/proto/lorenzo/bnblightclient/v1/genesis.proto +++ b/proto/lorenzo/bnblightclient/v1/genesis.proto @@ -17,7 +17,10 @@ message GenesisState { } message EventRecord { + // block_number defines the block number uint64 block_number = 1; + // contract defines the contract bytes contract = 2; + // index defines the event index uint64 index = 3; } \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/params.proto b/proto/lorenzo/bnblightclient/v1/params.proto index e7f5f53b..803c6706 100644 --- a/proto/lorenzo/bnblightclient/v1/params.proto +++ b/proto/lorenzo/bnblightclient/v1/params.proto @@ -11,13 +11,11 @@ message Params { // the stake plan hub contract address string stake_plan_hub_address = 1; - // event_index defines index of generated the event in the contract - repeated string event_indices = 2; // event_name defines the event name - string event_name = 3; + string event_name = 2; // the maximum number of bnb block headers to retain - uint64 retained_blocks = 4; + uint64 retained_blocks = 3; // list of people who can upload bnb block header information - repeated string allow_list = 5; + repeated string allow_list = 4; } \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/query.proto b/proto/lorenzo/bnblightclient/v1/query.proto index a3de81e7..0fe48169 100644 --- a/proto/lorenzo/bnblightclient/v1/query.proto +++ b/proto/lorenzo/bnblightclient/v1/query.proto @@ -26,10 +26,10 @@ service Query { option (google.api.http).get = "/lorenzo/bnblightclient/v1/header/{hash}/hash"; } - // LatestedHeader returns the latested header in bnb chain - rpc LatestedHeader(QueryLatestedHeaderRequest) - returns (QueryLatestedHeaderResponse) { - option (google.api.http).get = "/lorenzo/bnblightclient/v1/latested_header"; + // LatestHeader returns the latest header in bnb chain + rpc LatestHeader(QueryLatestHeaderRequest) + returns (QueryLatestHeaderResponse) { + option (google.api.http).get = "/lorenzo/bnblightclient/v1/latest_header"; } } @@ -62,13 +62,13 @@ message QueryHeaderByHashResponse { lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = true ]; } -// QueryLatestedHeaderRequest is the request type for the Query/LatestedHeader +// QueryLatestHeaderRequest is the request type for the Query/LatestHeader // RPC method. -message QueryLatestedHeaderRequest {} +message QueryLatestHeaderRequest {} -// QueryLatestedHeaderResponse is the response type for the Query/LatestedHeader +// QueryLatestHeaderResponse is the response type for the Query/LatestHeader // RPC method. -message QueryLatestedHeaderResponse { +message QueryLatestHeaderResponse { // header holds the bnb light client header. lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/x/bnblightclient/keeper/genesis.go b/x/bnblightclient/keeper/genesis.go new file mode 100644 index 00000000..208f4172 --- /dev/null +++ b/x/bnblightclient/keeper/genesis.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "slices" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the capability module's state from a provided genesis +// state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { + if err := genState.Validate(); err != nil { + panic(err) + } + + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } + + slices.SortFunc(genState.Headers, func(a, b *types.Header) int { + return int(a.Number - b.Number) + }) + for _, header := range genState.Headers { + k.setHeader(ctx, header) + } + k.setLatestNumber(ctx, genState.Headers[len(genState.Headers) - 1].Number) + + for _, record := range genState.Records { + k.setEventRecord(ctx, record) + } +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return &types.GenesisState{ + Params: k.GetParams(ctx), + Headers: k.GetAllHeaders(ctx), + Records: k.GetAllEventRecord(ctx), + } +} \ No newline at end of file diff --git a/x/bnblightclient/keeper/grpc_query.go b/x/bnblightclient/keeper/grpc_query.go index df6dbf18..cb0f7a13 100644 --- a/x/bnblightclient/keeper/grpc_query.go +++ b/x/bnblightclient/keeper/grpc_query.go @@ -38,19 +38,19 @@ func (q Querier) HeaderByHash(goCtx context.Context, req *types.QueryHeaderByHas return &types.QueryHeaderByHashResponse{Header: header}, nil } -// LatestedHeader implements types.QueryServer. -func (q Querier) LatestedHeader(goCtx context.Context, req *types.QueryLatestedHeaderRequest) (*types.QueryLatestedHeaderResponse, error) { +// LatestHeader implements types.QueryServer. +func (q Querier) LatestHeader(goCtx context.Context, req *types.QueryLatestHeaderRequest) (*types.QueryLatestHeaderResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - header, found := q.k.GetLatestedHeader(ctx) + header, found := q.k.GetLatestHeader(ctx) if !found { return nil, errorsmod.Wrap(types.ErrHeaderNotFound, "latested header not found") } - return &types.QueryLatestedHeaderResponse{Header: *header}, nil + return &types.QueryLatestHeaderResponse{Header: *header}, nil } // Params implements types.QueryServer. func (q Querier) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) params := q.k.GetParams(ctx) - return &types.QueryParamsResponse{Params: params}, nil + return &types.QueryParamsResponse{Params: *params}, nil } diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go index e6a5c2ba..77ff731d 100644 --- a/x/bnblightclient/keeper/header.go +++ b/x/bnblightclient/keeper/header.go @@ -16,7 +16,7 @@ func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { }) vHeader := headers - latestedHeader, exist := k.GetLatestedHeader(ctx) + latestedHeader, exist := k.GetLatestHeader(ctx) if exist { vHeader = append([]*types.Header{latestedHeader}, headers...) } @@ -29,7 +29,7 @@ func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { for _, header := range headers { k.setHeader(ctx, header) } - k.setLatestedNumber(ctx, headers[len(headers) - 1].Number) + k.setLatestNumber(ctx, headers[len(headers) - 1].Number) k.prune(ctx) return nil } @@ -56,7 +56,7 @@ func(k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { } -// GetLatestedHeader retrieves the latested header from the store. +// GetLatestHeader retrieves the latested header from the store. // // Parameters: // - ctx: the context object @@ -64,9 +64,9 @@ func(k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { // Returns: // - types.Header: the latested header // - bool: true if the header was found, false otherwise -func(k Keeper) GetLatestedHeader(ctx sdk.Context) (*types.Header, bool) { +func(k Keeper) GetLatestHeader(ctx sdk.Context) (*types.Header, bool) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyLatestedHeaderNumber()) + bz := store.Get(types.KeyLatestHeaderNumber()) if bz == nil { return nil, false } @@ -75,16 +75,16 @@ func(k Keeper) GetLatestedHeader(ctx sdk.Context) (*types.Header, bool) { return k.GetHeader(ctx, number) } -// GetLatestedNumber retrieves the latested number from the store. +// GetLatestNumber retrieves the latested number from the store. // // Parameters: // - ctx: the context object // // Returns: // - uint64: the latested number -func(k Keeper) GetLatestedNumber(ctx sdk.Context) uint64 { +func(k Keeper) GetLatestNumber(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyLatestedHeaderNumber()) + bz := store.Get(types.KeyLatestHeaderNumber()) if bz == nil { return 0 } @@ -111,6 +111,27 @@ func(k Keeper) GetHeader(ctx sdk.Context, number uint64) (*types.Header, bool) { return &header, true } +// GetAllHeaders retrieves all headers from the store. +// +// Parameters: +// - ctx: the context object +// +// Returns: +// - headers: a slice of Header objects +func(k Keeper) GetAllHeaders(ctx sdk.Context) (headers []*types.Header) { + store := ctx.KVStore(k.storeKey) + + it := sdk.KVStorePrefixIterator(store, types.KeyPrefixHeader) + defer it.Close() //nolint:errcheck + + for ; it.Valid(); it.Next() { + var header types.Header + k.cdc.MustUnmarshal(it.Value(), &header) + headers = append(headers, &header) + } + return +} + // GetHeaderByHash retrieves a header from the store based on its hash. // // Parameters: @@ -151,8 +172,8 @@ func(k Keeper) setHeader(ctx sdk.Context, header *types.Header) { store.Set(types.KeyHeaderHash(header.Hash), numberBz) } -func(k Keeper) setLatestedNumber(ctx sdk.Context, number uint64) { +func(k Keeper) setLatestNumber(ctx sdk.Context, number uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(number) - store.Set(types.KeyLatestedHeaderNumber(), bz) + store.Set(types.KeyLatestHeaderNumber(), bz) } \ No newline at end of file diff --git a/x/bnblightclient/keeper/msg_server.go b/x/bnblightclient/keeper/msg_server.go index b96c9020..e73aaa6b 100644 --- a/x/bnblightclient/keeper/msg_server.go +++ b/x/bnblightclient/keeper/msg_server.go @@ -49,7 +49,7 @@ func (m msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.k.SetParams(ctx, req.Params); err != nil { + if err := m.k.SetParams(ctx, &req.Params); err != nil { return nil, err } return &types.MsgUpdateParamsResponse{}, nil diff --git a/x/bnblightclient/keeper/params.go b/x/bnblightclient/keeper/params.go index 65043ffd..96ba5777 100644 --- a/x/bnblightclient/keeper/params.go +++ b/x/bnblightclient/keeper/params.go @@ -11,12 +11,12 @@ import ( // ctx - Context object. // p - Params object to be set. // error - Returns an error if validation fails. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { +func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) error { if err := params.Validate(); err != nil { return err } store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(¶ms) + bz := k.cdc.MustMarshal(params) store.Set(types.ParamsKey, bz) return nil } @@ -26,12 +26,12 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { // ctx sdk.Context - Context // types.Params - Parameters // returns p types.Params - Parameters -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { +func (k Keeper) GetParams(ctx sdk.Context) (params *types.Params) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ParamsKey) if bz == nil { return params } - k.cdc.MustUnmarshal(bz, ¶ms) + k.cdc.MustUnmarshal(bz, params) return params } \ No newline at end of file diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 1322e3c4..24b676fc 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -135,7 +135,7 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types } eventIndex := new(big.Int).SetBytes(log.Topics[1].Bytes()) - record := types.EventRecord{ + record := &types.EventRecord{ BlockNumber: receipt.BlockNumber.Uint64(), Index: eventIndex.Uint64(), Contract: log.Address.Bytes(), @@ -177,16 +177,16 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types return events, nil } -func (k Keeper) hasEventRecord(ctx sdk.Context, record types.EventRecord) bool { +func (k Keeper) hasEventRecord(ctx sdk.Context, record *types.EventRecord) bool { store := ctx.KVStore(k.storeKey) key := record.Key() return store.Has(key) } -func (k Keeper) setEventRecord(ctx sdk.Context, record types.EventRecord) { +func (k Keeper) setEventRecord(ctx sdk.Context, record *types.EventRecord) { store := ctx.KVStore(k.storeKey) key := record.Key() - bz := k.cdc.MustMarshal(&record) + bz := k.cdc.MustMarshal(record) store.Set(key[:], bz) } diff --git a/x/bnblightclient/keeper/prune.go b/x/bnblightclient/keeper/prune.go index c3ebb77f..64e27fa5 100644 --- a/x/bnblightclient/keeper/prune.go +++ b/x/bnblightclient/keeper/prune.go @@ -7,7 +7,7 @@ import ( func (k Keeper) prune(ctx sdk.Context) { // get the latested header - latestedNumber := k.GetLatestedNumber(ctx) + latestedNumber := k.GetLatestNumber(ctx) params := k.GetParams(ctx) pruneEndNumber := int64(latestedNumber - params.RetainedBlocks) if pruneEndNumber <= 0 { diff --git a/x/bnblightclient/types/genesis.go b/x/bnblightclient/types/genesis.go new file mode 100644 index 00000000..2c6c59b4 --- /dev/null +++ b/x/bnblightclient/types/genesis.go @@ -0,0 +1,11 @@ +package types + +// Validate validates the GenesisState. +// +// It returns an error if the GenesisState parameters are invalid. +func (gs GenesisState) Validate() error { + if err := gs.Params.Validate(); err != nil { + return err + } + return VeryHeaders(gs.Headers) +} diff --git a/x/bnblightclient/types/genesis.pb.go b/x/bnblightclient/types/genesis.pb.go index c19281eb..f115c157 100644 --- a/x/bnblightclient/types/genesis.pb.go +++ b/x/bnblightclient/types/genesis.pb.go @@ -87,9 +87,12 @@ func (m *GenesisState) GetRecords() []*EventRecord { } type EventRecord struct { + // block_number defines the block number BlockNumber uint64 `protobuf:"varint,1,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` - Contract []byte `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` - Index uint64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"` + // contract defines the contract + Contract []byte `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` + // index defines the event index + Index uint64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"` } func (m *EventRecord) Reset() { *m = EventRecord{} } diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go index 96775fa7..3ffb95dc 100644 --- a/x/bnblightclient/types/keys.go +++ b/x/bnblightclient/types/keys.go @@ -19,8 +19,8 @@ var ( ParamsKey = []byte{0x01} // KeyPrefixHeader defines the prefix to retrieve all headers KeyPrefixHeader = []byte{0x02} - // KeyPrefixLatestedNumber defines the prefix to retrieve the latest header number - KeyPrefixLatestedNumber = []byte{0x03} + // KeyPrefixLatestNumber defines the prefix to retrieve the latest header number + KeyPrefixLatestNumber = []byte{0x03} // KeyPrefixHeadHash defines the prefix to retrieve the head hash KeyPrefixHeadHash = []byte{0x04} @@ -39,9 +39,9 @@ func KeyHeaderHash(hash []byte) []byte { return append(KeyPrefixHeadHash, hash...) } -// KeyLatestedHeaderNumber returns the key for the latest header number -func KeyLatestedHeaderNumber() []byte { - return KeyPrefixLatestedNumber +// KeyLatestHeaderNumber returns the key for the latest header number +func KeyLatestHeaderNumber() []byte { + return KeyPrefixLatestNumber } // KeyEventRecord returns the key for the cross chain event index diff --git a/x/bnblightclient/types/msg.go b/x/bnblightclient/types/msg.go new file mode 100644 index 00000000..8aeca06c --- /dev/null +++ b/x/bnblightclient/types/msg.go @@ -0,0 +1,55 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + _ sdk.Msg = (*MsgUpdateHeader)(nil) + _ sdk.Msg = (*MsgUploadHeaders)(nil) + _ sdk.Msg = (*MsgUpdateParams)(nil) +) + +// ValidateBasic implements sdk.Msg interface +func(m *MsgUpdateHeader) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return err + } + return VeryHeaders([]*Header{m.Header}) +} + +// GetSigners implements sdk.Msg interface +func(m *MsgUpdateHeader) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Signer)} +} + +// ValidateBasic implements sdk.Msg interface +func(m *MsgUploadHeaders) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return err + } + return VeryHeaders(m.Headers) +} + +// GetSigners implements sdk.Msg interface +func(m *MsgUploadHeaders) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Signer)} +} + +// ValidateBasic implements sdk.Msg interface +func(m *MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return err + } + return m.Params.Validate() +} + +// GetSigners implements sdk.Msg interface +func(m *MsgUpdateParams) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Authority)} +} + + + + + diff --git a/x/bnblightclient/types/params.go b/x/bnblightclient/types/params.go index 4d2a3b54..a273c1fb 100644 --- a/x/bnblightclient/types/params.go +++ b/x/bnblightclient/types/params.go @@ -19,6 +19,11 @@ func (p Params) Validate() error { if !common.IsHexAddress(p.StakePlanHubAddress) { return fmt.Errorf("invalid stake plan hub address: %s", p.StakePlanHubAddress) } + + if len(p.EventName) == 0 { + return fmt.Errorf("event name cannot be empty") + } + if err := ValidateAllowList(p.AllowList); err != nil { return err } diff --git a/x/bnblightclient/types/params.pb.go b/x/bnblightclient/types/params.pb.go index b7962c58..1852d42e 100644 --- a/x/bnblightclient/types/params.pb.go +++ b/x/bnblightclient/types/params.pb.go @@ -27,14 +27,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // the stake plan hub contract address StakePlanHubAddress string `protobuf:"bytes,1,opt,name=stake_plan_hub_address,json=stakePlanHubAddress,proto3" json:"stake_plan_hub_address,omitempty"` - // event_index defines index of generated the event in the contract - EventIndices []string `protobuf:"bytes,2,rep,name=event_indices,json=eventIndices,proto3" json:"event_indices,omitempty"` // event_name defines the event name - EventName string `protobuf:"bytes,3,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` + EventName string `protobuf:"bytes,2,opt,name=event_name,json=eventName,proto3" json:"event_name,omitempty"` // the maximum number of bnb block headers to retain - RetainedBlocks uint64 `protobuf:"varint,4,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` + RetainedBlocks uint64 `protobuf:"varint,3,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` // list of people who can upload bnb block header information - AllowList []string `protobuf:"bytes,5,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` + AllowList []string `protobuf:"bytes,4,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -77,13 +75,6 @@ func (m *Params) GetStakePlanHubAddress() string { return "" } -func (m *Params) GetEventIndices() []string { - if m != nil { - return m.EventIndices - } - return nil -} - func (m *Params) GetEventName() string { if m != nil { return m.EventName @@ -114,27 +105,26 @@ func init() { } var fileDescriptor_3608f71b6e08ae9c = []byte{ - // 315 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xcd, 0x4a, 0x33, 0x31, - 0x18, 0x85, 0x9b, 0xaf, 0xfd, 0x0a, 0x13, 0xfc, 0x81, 0x51, 0x64, 0x14, 0x8c, 0x45, 0x41, 0xbb, - 0x71, 0x42, 0xe9, 0xae, 0x3b, 0xbb, 0x52, 0x28, 0x52, 0x8a, 0x2b, 0x37, 0x21, 0x99, 0x79, 0x99, - 0x86, 0x66, 0x92, 0x61, 0x92, 0xd6, 0x9f, 0xab, 0xf0, 0x12, 0xbc, 0x1c, 0x77, 0x76, 0xe9, 0x52, - 0xda, 0x8d, 0x97, 0x21, 0x93, 0xb1, 0x0b, 0xdd, 0x85, 0xe7, 0x9c, 0x9c, 0x17, 0x1e, 0x7c, 0xae, - 0x4c, 0x09, 0xfa, 0xd9, 0x50, 0xa1, 0x85, 0x92, 0xd9, 0xd4, 0x25, 0x4a, 0x82, 0x76, 0x74, 0xd1, - 0xa3, 0x05, 0x2f, 0x79, 0x6e, 0xe3, 0xa2, 0x34, 0xce, 0x84, 0x87, 0x3f, 0xbd, 0xf8, 0x77, 0x2f, - 0x5e, 0xf4, 0x8e, 0xf6, 0x33, 0x93, 0x19, 0xdf, 0xa2, 0xd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77, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x9c, 0xb8, 0x0a, 0x29, 0x89, 0x01, 0x00, 0x00, + // 293 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x3f, 0x4e, 0xc3, 0x30, + 0x1c, 0x85, 0x6b, 0x5a, 0x55, 0xaa, 0x07, 0x90, 0x02, 0x42, 0x01, 0x09, 0x13, 0x31, 0x40, 0x17, + 0x62, 0x55, 0xdd, 0xba, 0xd1, 0x89, 0xa1, 0x42, 0x51, 0xc5, 0xc4, 0x62, 0xd9, 0x89, 0x95, 0x58, + 0x75, 0xec, 0x28, 0x76, 0xc2, 0x9f, 0x53, 0x70, 0x04, 0x66, 0x4e, 0xc2, 0xd8, 0x91, 0x11, 0x25, + 0x0b, 0xc7, 0x40, 0x71, 0xe8, 0x00, 0x9b, 0xf5, 0xde, 0xe7, 0x27, 0xfd, 0x3e, 0x78, 0x29, 0x75, + 0xc9, 0xd5, 0x8b, 0xc6, 0x4c, 0x31, 0x29, 0xd2, 0xcc, 0xc6, 0x52, 0x70, 0x65, 0x71, 0x3d, 0xc3, + 0x05, 0x2d, 0x69, 0x6e, 0xc2, 0xa2, 0xd4, 0x56, 0x7b, 0x27, 0xbf, 0x5c, 0xf8, 0x97, 0x0b, 0xeb, + 0xd9, 0xe9, 0x51, 0xaa, 0x53, 0xed, 0x28, 0xdc, 0xbd, 0xfa, 0x0f, 0x17, 0xef, 0x00, 0x8e, 0x23, + 0xb7, 0xe0, 0xcd, 0xe1, 0xb1, 0xb1, 0x74, 0xc3, 0x49, 0x21, 0xa9, 0x22, 0x59, 0xc5, 0x08, 0x4d, + 0x92, 0x92, 0x1b, 0xe3, 0x83, 0x00, 0x4c, 0x27, 0xeb, 0x43, 0xd7, 0x46, 0x92, 0xaa, 0xdb, 0x8a, + 0xdd, 0xf4, 0x95, 0x77, 0x06, 0x21, 0xaf, 0xb9, 0xb2, 0x44, 0xd1, 0x9c, 0xfb, 0x7b, 0x0e, 0x9c, + 0xb8, 0xe4, 0x8e, 0xe6, 0xdc, 0xbb, 0x82, 0x07, 0x25, 0xb7, 0x54, 0x28, 0x9e, 0x10, 0x26, 0x75, + 0xbc, 0x31, 0xfe, 0x30, 0x00, 0xd3, 0xd1, 0x7a, 0x7f, 0x17, 0x2f, 0x5d, 0xda, 0xed, 0x50, 0x29, + 0xf5, 0x23, 0x91, 0xc2, 0x58, 0x7f, 0x14, 0x0c, 0xbb, 0x1d, 0x97, 0xac, 0x84, 0xb1, 0x8b, 0xd1, + 0xf7, 0xdb, 0x39, 0x58, 0xde, 0x7f, 0x34, 0x08, 0x6c, 0x1b, 0x04, 0xbe, 0x1a, 0x04, 0x5e, 0x5b, + 0x34, 0xd8, 0xb6, 0x68, 0xf0, 0xd9, 0xa2, 0xc1, 0xc3, 0x22, 0x15, 0x36, 0xab, 0x58, 0x18, 0xeb, + 0x1c, 0xaf, 0x7a, 0x05, 0xd7, 0x51, 0x77, 0x60, 0xac, 0x25, 0xde, 0xb9, 0x7b, 0xfa, 0x6f, 0xcf, + 0x3e, 0x17, 0xdc, 0xb0, 0xb1, 0x33, 0x31, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xfc, 0x69, + 0xf6, 0x64, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -159,14 +149,6 @@ func (this *Params) Equal(that interface{}) bool { if this.StakePlanHubAddress != that1.StakePlanHubAddress { return false } - if len(this.EventIndices) != len(that1.EventIndices) { - return false - } - for i := range this.EventIndices { - if this.EventIndices[i] != that1.EventIndices[i] { - return false - } - } if this.EventName != that1.EventName { return false } @@ -209,29 +191,20 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.AllowList[iNdEx]) i = encodeVarintParams(dAtA, i, uint64(len(m.AllowList[iNdEx]))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } } if m.RetainedBlocks != 0 { i = encodeVarintParams(dAtA, i, uint64(m.RetainedBlocks)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x18 } if len(m.EventName) > 0 { i -= len(m.EventName) copy(dAtA[i:], m.EventName) i = encodeVarintParams(dAtA, i, uint64(len(m.EventName))) i-- - dAtA[i] = 0x1a - } - if len(m.EventIndices) > 0 { - for iNdEx := len(m.EventIndices) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.EventIndices[iNdEx]) - copy(dAtA[i:], m.EventIndices[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.EventIndices[iNdEx]))) - i-- - dAtA[i] = 0x12 - } + dAtA[i] = 0x12 } if len(m.StakePlanHubAddress) > 0 { i -= len(m.StakePlanHubAddress) @@ -264,12 +237,6 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - if len(m.EventIndices) > 0 { - for _, s := range m.EventIndices { - l = len(s) - n += 1 + l + sovParams(uint64(l)) - } - } l = len(m.EventName) if l > 0 { n += 1 + l + sovParams(uint64(l)) @@ -354,38 +321,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.StakePlanHubAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EventIndices", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EventIndices = append(m.EventIndices, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EventName", wireType) } @@ -417,7 +352,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.EventName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field RetainedBlocks", wireType) } @@ -436,7 +371,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AllowList", wireType) } diff --git a/x/bnblightclient/types/query.pb.go b/x/bnblightclient/types/query.pb.go index a2586554..b4d6cdb9 100644 --- a/x/bnblightclient/types/query.pb.go +++ b/x/bnblightclient/types/query.pb.go @@ -296,23 +296,23 @@ func (m *QueryHeaderByHashResponse) GetHeader() *Header { return nil } -// QueryLatestedHeaderRequest is the request type for the Query/LatestedHeader +// QueryLatestHeaderRequest is the request type for the Query/LatestHeader // RPC method. -type QueryLatestedHeaderRequest struct { +type QueryLatestHeaderRequest struct { } -func (m *QueryLatestedHeaderRequest) Reset() { *m = QueryLatestedHeaderRequest{} } -func (m *QueryLatestedHeaderRequest) String() string { return proto.CompactTextString(m) } -func (*QueryLatestedHeaderRequest) ProtoMessage() {} -func (*QueryLatestedHeaderRequest) Descriptor() ([]byte, []int) { +func (m *QueryLatestHeaderRequest) Reset() { *m = QueryLatestHeaderRequest{} } +func (m *QueryLatestHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryLatestHeaderRequest) ProtoMessage() {} +func (*QueryLatestHeaderRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f139d6422d3b3b56, []int{6} } -func (m *QueryLatestedHeaderRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryLatestHeaderRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryLatestedHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryLatestHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryLatestedHeaderRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryLatestHeaderRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -322,37 +322,37 @@ func (m *QueryLatestedHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryLatestedHeaderRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLatestedHeaderRequest.Merge(m, src) +func (m *QueryLatestHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestHeaderRequest.Merge(m, src) } -func (m *QueryLatestedHeaderRequest) XXX_Size() int { +func (m *QueryLatestHeaderRequest) XXX_Size() int { return m.Size() } -func (m *QueryLatestedHeaderRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLatestedHeaderRequest.DiscardUnknown(m) +func (m *QueryLatestHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestHeaderRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryLatestedHeaderRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryLatestHeaderRequest proto.InternalMessageInfo -// QueryLatestedHeaderResponse is the response type for the Query/LatestedHeader +// QueryLatestHeaderResponse is the response type for the Query/LatestHeader // RPC method. -type QueryLatestedHeaderResponse struct { +type QueryLatestHeaderResponse struct { // header holds the bnb light client header. Header Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` } -func (m *QueryLatestedHeaderResponse) Reset() { *m = QueryLatestedHeaderResponse{} } -func (m *QueryLatestedHeaderResponse) String() string { return proto.CompactTextString(m) } -func (*QueryLatestedHeaderResponse) ProtoMessage() {} -func (*QueryLatestedHeaderResponse) Descriptor() ([]byte, []int) { +func (m *QueryLatestHeaderResponse) Reset() { *m = QueryLatestHeaderResponse{} } +func (m *QueryLatestHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryLatestHeaderResponse) ProtoMessage() {} +func (*QueryLatestHeaderResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f139d6422d3b3b56, []int{7} } -func (m *QueryLatestedHeaderResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryLatestHeaderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryLatestedHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryLatestHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryLatestedHeaderResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryLatestHeaderResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -362,19 +362,19 @@ func (m *QueryLatestedHeaderResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryLatestedHeaderResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryLatestedHeaderResponse.Merge(m, src) +func (m *QueryLatestHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryLatestHeaderResponse.Merge(m, src) } -func (m *QueryLatestedHeaderResponse) XXX_Size() int { +func (m *QueryLatestHeaderResponse) XXX_Size() int { return m.Size() } -func (m *QueryLatestedHeaderResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryLatestedHeaderResponse.DiscardUnknown(m) +func (m *QueryLatestHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryLatestHeaderResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryLatestedHeaderResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryLatestHeaderResponse proto.InternalMessageInfo -func (m *QueryLatestedHeaderResponse) GetHeader() Header { +func (m *QueryLatestHeaderResponse) GetHeader() Header { if m != nil { return m.Header } @@ -388,8 +388,8 @@ func init() { proto.RegisterType((*QueryHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryHeaderResponse") proto.RegisterType((*QueryHeaderByHashRequest)(nil), "lorenzo.bnblightclient.v1.QueryHeaderByHashRequest") proto.RegisterType((*QueryHeaderByHashResponse)(nil), "lorenzo.bnblightclient.v1.QueryHeaderByHashResponse") - proto.RegisterType((*QueryLatestedHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryLatestedHeaderRequest") - proto.RegisterType((*QueryLatestedHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryLatestedHeaderResponse") + proto.RegisterType((*QueryLatestHeaderRequest)(nil), "lorenzo.bnblightclient.v1.QueryLatestHeaderRequest") + proto.RegisterType((*QueryLatestHeaderResponse)(nil), "lorenzo.bnblightclient.v1.QueryLatestHeaderResponse") } func init() { @@ -397,39 +397,39 @@ func init() { } var fileDescriptor_f139d6422d3b3b56 = []byte{ - // 503 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6a, 0xd4, 0x40, - 0x1c, 0xc6, 0x33, 0xb2, 0xcd, 0x61, 0x2c, 0x1e, 0xc6, 0x22, 0x6d, 0x2c, 0xd1, 0x8e, 0x28, 0x2a, - 0xdd, 0x19, 0xba, 0xb5, 0x1e, 0xbc, 0x08, 0x7b, 0xea, 0xa1, 0x87, 0x1a, 0xc4, 0x83, 0x88, 0x32, - 0xd9, 0x0e, 0x49, 0x20, 0x3b, 0x93, 0x66, 0x66, 0x8b, 0xab, 0xf4, 0xe2, 0x13, 0x88, 0x1e, 0x3d, - 0xfa, 0x02, 0x82, 0x2f, 0xd1, 0x63, 0xc1, 0x8b, 0x27, 0x91, 0x5d, 0x1f, 0x44, 0x32, 0x33, 0x5b, - 0x1b, 0xdd, 0x36, 0xbb, 0xd8, 0xcb, 0x92, 0x9d, 0xfc, 0xbf, 0xef, 0xfb, 0xe5, 0x9f, 0x8f, 0xc0, - 0xdb, 0xb9, 0x2c, 0xb9, 0x78, 0x23, 0x69, 0x2c, 0xe2, 0x3c, 0x4b, 0x52, 0xdd, 0xcb, 0x33, 0x2e, - 0x34, 0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 0x3f, 0x09, 0x78, 0xfd, 0x77, - 0x84, 0x1e, 0x16, 0x5c, 0xc5, 0xbe, 0xf9, 0x04, 0x6e, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x24, - 0xe1, 0xb4, 0xfe, 0xca, 0x05, 0x00, 0x00, + // 499 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6e, 0xd3, 0x30, + 0x1c, 0xc6, 0x63, 0xd4, 0xe5, 0x60, 0x7a, 0x32, 0x13, 0xda, 0x22, 0x14, 0x98, 0x11, 0x68, 0x4c, + 0xab, 0xcd, 0x3a, 0xb8, 0x70, 0x41, 0xea, 0x69, 0x87, 0x1d, 0x46, 0x84, 0x38, 0x20, 0x24, 0xe4, + 0x14, 0x2b, 0x89, 0x94, 0xda, 0x59, 0xec, 0x4e, 0x14, 0xb4, 0x0b, 0x4f, 0x80, 0xe0, 0xb8, 0x47, + 0xe0, 0xc2, 0x63, 0xec, 0x38, 0x89, 0x0b, 0x27, 0x84, 0x5a, 0x1e, 0x04, 0xc5, 0x76, 0x4b, 0x03, + 0x5d, 0x53, 0x04, 0x97, 0x2a, 0x75, 0xfe, 0xdf, 0xf7, 0xfd, 0xfa, 0xef, 0x27, 0xc3, 0x3b, 0xb9, + 0x2c, 0xb9, 0x78, 0x23, 0x69, 0x2c, 0xe2, 0x3c, 0x4b, 0x52, 0xdd, 0xcf, 0x33, 0x2e, 0x34, 0x3d, + 0xd9, 0xa3, 0xc7, 0x43, 0x5e, 0x8e, 0x48, 0x51, 0x4a, 0x2d, 0xd1, 0xa6, 0x1b, 0x23, 0xf5, 0x31, + 0x72, 0xb2, 0x17, 0xac, 0x27, 0x32, 0x91, 0x66, 0x8a, 0x56, 0x4f, 0x56, 0x10, 0xdc, 0x48, 0xa4, + 0x4c, 0x72, 0x4e, 0x59, 0x91, 0x51, 0x26, 0x84, 0xd4, 0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, + 0xdc, 0x46, 0x5b, 0xb4, 0xa9, 0xa0, 0xe8, 0x0c, 0x40, 0xdf, 0x72, 0x37, 0x43, 0xd5, 0xd6, 0xd6, + 0x0c, 0x55, 0xdf, 0x24, 0xee, 0x1a, 0xa8, 0x5d, 0xb4, 0xb3, 0x04, 0xca, 0xee, 0x8c, 0xbe, 0xb5, + 0xdd, 0x3c, 0x45, 0x9f, 0x01, 0x6c, 0xcf, 0x17, 0x02, 0xed, 0xaf, 0x16, 0x5a, 0xab, 0x5b, 0xf0, + 0xe0, 0xef, 0x44, 0x8e, 0xf7, 0xa1, 0xe1, 0xa5, 0xa8, 0xb3, 0x02, 0x6f, 0xd5, 0xe0, 0x53, 0x5a, + 0x7d, 0xa2, 0x4f, 0x00, 0xb6, 0xe7, 0x9b, 0xd4, 0x8c, 0xbc, 0xa0, 0x93, 0xcd, 0xc8, 0x8b, 0xca, + 0x8a, 0xef, 0x1b, 0xe4, 0x1d, 0xb4, 0xbd, 0x04, 0x39, 0x37, 0xc2, 0x97, 0x96, 0xbc, 0xf7, 0xf4, + 0x7c, 0x1c, 0x82, 0x8b, 0x71, 0x08, 0xbe, 0x8f, 0x43, 0xf0, 0x7e, 0x12, 0x7a, 0x17, 0x93, 0xd0, + 0xfb, 0x3a, 0x09, 0xbd, 0xe7, 0x8f, 0x92, 0x4c, 0xa7, 0xc3, 0x98, 0xf4, 0xe5, 0x80, 0x1e, 0x5a, + 0xb7, 0xce, 0x51, 0x75, 0x9b, 0xf5, 0x65, 0x3e, 0xb3, 0x7f, 0xfd, 0x7b, 0x80, 0x1e, 0x15, 0x5c, + 0xc5, 0xbe, 0xb9, 0xf6, 0xf6, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0xcd, 0x99, 0xa8, 0x80, 0xbe, + 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -450,8 +450,8 @@ type QueryClient interface { Header(ctx context.Context, in *QueryHeaderRequest, opts ...grpc.CallOption) (*QueryHeaderResponse, error) // HeaderByHash returns the header in bnb chain by hash HeaderByHash(ctx context.Context, in *QueryHeaderByHashRequest, opts ...grpc.CallOption) (*QueryHeaderByHashResponse, error) - // LatestedHeader returns the latested header in bnb chain - LatestedHeader(ctx context.Context, in *QueryLatestedHeaderRequest, opts ...grpc.CallOption) (*QueryLatestedHeaderResponse, error) + // LatestHeader returns the latest header in bnb chain + LatestHeader(ctx context.Context, in *QueryLatestHeaderRequest, opts ...grpc.CallOption) (*QueryLatestHeaderResponse, error) } type queryClient struct { @@ -489,9 +489,9 @@ func (c *queryClient) HeaderByHash(ctx context.Context, in *QueryHeaderByHashReq return out, nil } -func (c *queryClient) LatestedHeader(ctx context.Context, in *QueryLatestedHeaderRequest, opts ...grpc.CallOption) (*QueryLatestedHeaderResponse, error) { - out := new(QueryLatestedHeaderResponse) - err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/LatestedHeader", in, out, opts...) +func (c *queryClient) LatestHeader(ctx context.Context, in *QueryLatestHeaderRequest, opts ...grpc.CallOption) (*QueryLatestHeaderResponse, error) { + out := new(QueryLatestHeaderResponse) + err := c.cc.Invoke(ctx, "/lorenzo.bnblightclient.v1.Query/LatestHeader", in, out, opts...) if err != nil { return nil, err } @@ -506,8 +506,8 @@ type QueryServer interface { Header(context.Context, *QueryHeaderRequest) (*QueryHeaderResponse, error) // HeaderByHash returns the header in bnb chain by hash HeaderByHash(context.Context, *QueryHeaderByHashRequest) (*QueryHeaderByHashResponse, error) - // LatestedHeader returns the latested header in bnb chain - LatestedHeader(context.Context, *QueryLatestedHeaderRequest) (*QueryLatestedHeaderResponse, error) + // LatestHeader returns the latest header in bnb chain + LatestHeader(context.Context, *QueryLatestHeaderRequest) (*QueryLatestHeaderResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -523,8 +523,8 @@ func (*UnimplementedQueryServer) Header(ctx context.Context, req *QueryHeaderReq func (*UnimplementedQueryServer) HeaderByHash(ctx context.Context, req *QueryHeaderByHashRequest) (*QueryHeaderByHashResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method HeaderByHash not implemented") } -func (*UnimplementedQueryServer) LatestedHeader(ctx context.Context, req *QueryLatestedHeaderRequest) (*QueryLatestedHeaderResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method LatestedHeader not implemented") +func (*UnimplementedQueryServer) LatestHeader(ctx context.Context, req *QueryLatestHeaderRequest) (*QueryLatestHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method LatestHeader not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -585,20 +585,20 @@ func _Query_HeaderByHash_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } -func _Query_LatestedHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryLatestedHeaderRequest) +func _Query_LatestHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryLatestHeaderRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).LatestedHeader(ctx, in) + return srv.(QueryServer).LatestHeader(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/lorenzo.bnblightclient.v1.Query/LatestedHeader", + FullMethod: "/lorenzo.bnblightclient.v1.Query/LatestHeader", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).LatestedHeader(ctx, req.(*QueryLatestedHeaderRequest)) + return srv.(QueryServer).LatestHeader(ctx, req.(*QueryLatestHeaderRequest)) } return interceptor(ctx, in, info, handler) } @@ -620,8 +620,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_HeaderByHash_Handler, }, { - MethodName: "LatestedHeader", - Handler: _Query_LatestedHeader_Handler, + MethodName: "LatestHeader", + Handler: _Query_LatestHeader_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -812,7 +812,7 @@ func (m *QueryHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *QueryLatestedHeaderRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryLatestHeaderRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -822,12 +822,12 @@ func (m *QueryLatestedHeaderRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryLatestedHeaderRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryLatestHeaderRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryLatestedHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryLatestHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -835,7 +835,7 @@ func (m *QueryLatestedHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryLatestedHeaderResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryLatestHeaderResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -845,12 +845,12 @@ func (m *QueryLatestedHeaderResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryLatestedHeaderResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryLatestHeaderResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryLatestedHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryLatestHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -950,7 +950,7 @@ func (m *QueryHeaderByHashResponse) Size() (n int) { return n } -func (m *QueryLatestedHeaderRequest) Size() (n int) { +func (m *QueryLatestHeaderRequest) Size() (n int) { if m == nil { return 0 } @@ -959,7 +959,7 @@ func (m *QueryLatestedHeaderRequest) Size() (n int) { return n } -func (m *QueryLatestedHeaderResponse) Size() (n int) { +func (m *QueryLatestHeaderResponse) Size() (n int) { if m == nil { return 0 } @@ -1434,7 +1434,7 @@ func (m *QueryHeaderByHashResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryLatestedHeaderRequest) Unmarshal(dAtA []byte) error { +func (m *QueryLatestHeaderRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1457,10 +1457,10 @@ func (m *QueryLatestedHeaderRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryLatestedHeaderRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryLatestHeaderRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLatestedHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryLatestHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1484,7 +1484,7 @@ func (m *QueryLatestedHeaderRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryLatestedHeaderResponse) Unmarshal(dAtA []byte) error { +func (m *QueryLatestHeaderResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1507,10 +1507,10 @@ func (m *QueryLatestedHeaderResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryLatestedHeaderResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryLatestHeaderResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLatestedHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryLatestHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/bnblightclient/types/query.pb.gw.go b/x/bnblightclient/types/query.pb.gw.go index 6f69e6d3..6f0e1015 100644 --- a/x/bnblightclient/types/query.pb.gw.go +++ b/x/bnblightclient/types/query.pb.gw.go @@ -159,20 +159,20 @@ func local_request_Query_HeaderByHash_0(ctx context.Context, marshaler runtime.M } -func request_Query_LatestedHeader_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLatestedHeaderRequest +func request_Query_LatestHeader_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestHeaderRequest var metadata runtime.ServerMetadata - msg, err := client.LatestedHeader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.LatestHeader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_LatestedHeader_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryLatestedHeaderRequest +func local_request_Query_LatestHeader_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryLatestHeaderRequest var metadata runtime.ServerMetadata - msg, err := server.LatestedHeader(ctx, &protoReq) + msg, err := server.LatestHeader(ctx, &protoReq) return msg, metadata, err } @@ -252,7 +252,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_LatestedHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_LatestHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -263,7 +263,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_LatestedHeader_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_LatestHeader_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 { @@ -271,7 +271,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_LatestedHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_LatestHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -376,7 +376,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_LatestedHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_LatestHeader_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) @@ -385,14 +385,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_LatestedHeader_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_LatestHeader_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_LatestedHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_LatestHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -406,7 +406,7 @@ var ( pattern_Query_HeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 2, 4}, []string{"lorenzo", "bnblightclient", "v1", "header", "hash"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_LatestedHeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lorenzo", "bnblightclient", "v1", "latested_header"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_LatestHeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"lorenzo", "bnblightclient", "v1", "latest_header"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -416,5 +416,5 @@ var ( forward_Query_HeaderByHash_0 = runtime.ForwardResponseMessage - forward_Query_LatestedHeader_0 = runtime.ForwardResponseMessage + forward_Query_LatestHeader_0 = runtime.ForwardResponseMessage ) From c8ba4b37487037d05146132d9e7d248206f8dfd5 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Mon, 22 Jul 2024 11:19:48 +0800 Subject: [PATCH 11/19] implement commands --- proto/lorenzo/bnblightclient/v1/genesis.proto | 18 +- x/bnblightclient/client/cli/query.go | 135 +++++++++++++++ x/bnblightclient/client/cli/tx.go | 120 +++++++++++++ x/bnblightclient/keeper/genesis.go | 6 +- x/bnblightclient/keeper/grpc_query.go | 5 + x/bnblightclient/keeper/keeper.go | 9 + x/bnblightclient/keeper/proof.go | 40 ++--- x/bnblightclient/module.go | 161 ++++++++++++++++++ x/bnblightclient/types/codec.go | 20 +++ x/bnblightclient/types/events.go | 12 +- x/bnblightclient/types/genesis.go | 9 + x/bnblightclient/types/genesis.pb.go | 136 +++++++-------- 12 files changed, 563 insertions(+), 108 deletions(-) create mode 100644 x/bnblightclient/client/cli/query.go create mode 100644 x/bnblightclient/client/cli/tx.go create mode 100644 x/bnblightclient/module.go create mode 100644 x/bnblightclient/types/codec.go diff --git a/proto/lorenzo/bnblightclient/v1/genesis.proto b/proto/lorenzo/bnblightclient/v1/genesis.proto index 98652fd9..7e7534b6 100644 --- a/proto/lorenzo/bnblightclient/v1/genesis.proto +++ b/proto/lorenzo/bnblightclient/v1/genesis.proto @@ -8,19 +8,19 @@ option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" // GenesisState defines the bnb light client state message GenesisState { - // params defines the bnb light client parameters - lorenzo.bnblightclient.v1.Params params = 1; - // headers defines the bnb light client headers - repeated lorenzo.bnblightclient.v1.Header headers = 2; - // records defines the bnb light client event records - repeated EventRecord records = 3; + // params defines the bnb light client parameters + lorenzo.bnblightclient.v1.Params params = 1; + // headers defines the bnb light client headers + repeated lorenzo.bnblightclient.v1.Header headers = 2; + // events defines the bnb chain generated events + repeated EvmEvent events = 3; } -message EventRecord { +message EvmEvent { // block_number defines the block number uint64 block_number = 1; // contract defines the contract bytes contract = 2; - // index defines the event index - uint64 index = 3; + // index defines the unique identifier of the event + uint64 identifier = 3; } \ No newline at end of file diff --git a/x/bnblightclient/client/cli/query.go b/x/bnblightclient/client/cli/query.go new file mode 100644 index 00000000..e416a121 --- /dev/null +++ b/x/bnblightclient/client/cli/query.go @@ -0,0 +1,135 @@ +package cli + +import ( + "context" + "fmt" + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/ethereum/go-ethereum/common" + "github.com/spf13/cobra" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +// GetQueryCmd returns the cli query commands for bnblightclient module +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdQueryHeader()) + cmd.AddCommand(CmdQueryHeaderHash()) + cmd.AddCommand(CmdQueryLatestHeader()) + return cmd +} + +// CmdQueryParams returns a new Cobra command for showing the parameters of the bnblightclient module. +// +// No parameters. +// Returns *cobra.Command. +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "query the parameters of the fee module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// CmdQueryHeader returns a new Cobra command for querying the header of the bnblightclient module by number. +// +// It takes no parameters and returns a pointer to a Cobra command. +func CmdQueryHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "header", + Short: "query the header of the bnblightclient module by number", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + number, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("invalid number: %s, error: %s", args[0], err.Error()) + } + + res, err := queryClient.Header(context.Background(), &types.QueryHeaderRequest{Number: number}) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// CmdQueryHeaderHash queries the header of the bnblightclient module by hash. +// +// It takes exact 1 argument. +// Returns an error. +func CmdQueryHeaderHash() *cobra.Command { + cmd := &cobra.Command{ + Use: "header-hash", + Short: "query the header of the bnblightclient module by hash", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.HeaderByHash( + context.Background(), + &types.QueryHeaderByHashRequest{Hash: common.FromHex(args[0])}, + ) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// CmdQueryLatestHeader returns a new Cobra command for querying the latest header of the bnblightclient module. +// +// It takes exact 1 argument. +// Returns an error. +func CmdQueryLatestHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "latest-header", + Short: "query the latest header of the bnblightclient module", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.LatestHeader( + context.Background(), + &types.QueryLatestHeaderRequest{}, + ) + if err != nil { + return err + } + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/bnblightclient/client/cli/tx.go b/x/bnblightclient/client/cli/tx.go new file mode 100644 index 00000000..06ec0002 --- /dev/null +++ b/x/bnblightclient/client/cli/tx.go @@ -0,0 +1,120 @@ +package cli + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +// GetTxCmd returns the transaction commands for bnblightclient module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand(CmdTxUploadHeaders()) + cmd.AddCommand(CmdTxUpdateHeader()) + return cmd +} + +// CmdTxUploadHeaders creates a cobra.Command to upload BNB light client headers. +// +// It takes a single argument, which is the path to a JSON file containing the headers. +// The function reads the content of the file, unmarshals it into a slice of types.Header, +// and creates a MsgUploadHeaders message with the signer and the headers. +// +// The function returns an error if there is any issue reading the file or unmarshaling +// the content. +// +// The function also returns an error if there is any issue generating or broadcasting +// the transaction. +// +// The function returns a pointer to a cobra.Command. +func CmdTxUploadHeaders() *cobra.Command { + cmd := &cobra.Command{ + Use: "upload-headers [headers-file]", + Short: "upload bnb light client header", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + content,err := os.ReadFile(args[0]) + if err != nil { + return err + } + + var headers []*types.Header + if err := json.Unmarshal(content, &headers); err != nil { + return err + } + + msg := types.MsgUploadHeaders{ + Signer: clientCtx.GetFromAddress().String(), + Headers: headers, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// CmdTxUpdateHeader creates a cobra.Command to update the BNB light client header. +// +// It takes a single argument, which is the path to a JSON file containing the header. +// The function reads the content of the file, unmarshals it into a types.Header struct, +// and creates a MsgUpdateHeader message with the signer and the header. +// +// The function returns an error if there is any issue reading the file or unmarshaling +// the content. +// +// The function also returns an error if there is any issue generating or broadcasting +// the transaction. +// +// The function returns a pointer to a cobra.Command. +func CmdTxUpdateHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-header [header-file]", + Short: "update bnb light client header", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + content,err := os.ReadFile(args[0]) + if err != nil { + return err + } + + var header types.Header + if err := json.Unmarshal(content, &header); err != nil { + return err + } + + msg := types.MsgUpdateHeader{ + Signer: clientCtx.GetFromAddress().String(), + Header: &header, + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + return cmd +} \ No newline at end of file diff --git a/x/bnblightclient/keeper/genesis.go b/x/bnblightclient/keeper/genesis.go index 208f4172..44147e0b 100644 --- a/x/bnblightclient/keeper/genesis.go +++ b/x/bnblightclient/keeper/genesis.go @@ -27,8 +27,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { } k.setLatestNumber(ctx, genState.Headers[len(genState.Headers) - 1].Number) - for _, record := range genState.Records { - k.setEventRecord(ctx, record) + for _, record := range genState.Events { + k.setEvmEvent(ctx, record) } } @@ -37,6 +37,6 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return &types.GenesisState{ Params: k.GetParams(ctx), Headers: k.GetAllHeaders(ctx), - Records: k.GetAllEventRecord(ctx), + Events: k.GetAllEvmEvents(ctx), } } \ No newline at end of file diff --git a/x/bnblightclient/keeper/grpc_query.go b/x/bnblightclient/keeper/grpc_query.go index cb0f7a13..03670146 100644 --- a/x/bnblightclient/keeper/grpc_query.go +++ b/x/bnblightclient/keeper/grpc_query.go @@ -16,6 +16,11 @@ type Querier struct { k Keeper } +// NewQuerierImpl returns an implementation of the captains QueryServer interface. +func NewQuerierImpl(k Keeper) types.QueryServer { + return &Querier{k} +} + // Header implements types.QueryServer. func (q Querier) Header(goCtx context.Context, req *types.QueryHeaderRequest) (*types.QueryHeaderResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/bnblightclient/keeper/keeper.go b/x/bnblightclient/keeper/keeper.go index c33ef01b..98212c26 100644 --- a/x/bnblightclient/keeper/keeper.go +++ b/x/bnblightclient/keeper/keeper.go @@ -13,3 +13,12 @@ type Keeper struct { // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. authority string } + +// NewKeeper creates a new Keeper object +func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, authority string) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + authority: authority, + } +} diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 24b676fc..6ef95103 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -21,11 +21,7 @@ import ( // receipt - the EVM transaction receipt to verify // proof - the proof object containing the necessary data for verification // Returns an array of BNBCrossChainEvent and an error if the verification fails. -func (k Keeper) VerifyReceiptProof( - ctx sdk.Context, - receipt *evmtypes.Receipt, - proof types.Proof, -) ([]types.BNBCrossChainEvent, error) { +func (k Keeper) VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof types.Proof) ([]types.CrossChainEvent, error) { if err := k.verifyProof(ctx, receipt, proof); err != nil { return nil, err } @@ -41,18 +37,18 @@ func (k Keeper) VerifyReceiptProof( return events, nil } -// GetAllEventRecord retrieves all event records stored in the context. +// GetAllEvmEvents retrieves all event records stored in the context. // // ctx - The context object. -// []*types.EventRecord - A slice of event records. -func (k Keeper) GetAllEventRecord(ctx sdk.Context) (events []*types.EventRecord) { +// []*types.EvmEvent - A slice of event records. +func (k Keeper) GetAllEvmEvents(ctx sdk.Context) (events []*types.EvmEvent) { store := ctx.KVStore(k.storeKey) it := sdk.KVStorePrefixIterator(store, types.KeyPrefixEventRecord) defer it.Close() //nolint:errcheck for ; it.Valid(); it.Next() { - var event types.EventRecord + var event types.EvmEvent k.cdc.MustUnmarshal(it.Value(), &event) events = append(events, &event) } @@ -89,7 +85,7 @@ func (k Keeper) verifyProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof ty return nil } -func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types.BNBCrossChainEvent, error) { +func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types.CrossChainEvent, error) { if len(receipt.Logs) == 0 { return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "no event log found") } @@ -97,7 +93,7 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types params := k.GetParams(ctx) contractAddr := common.HexToAddress(params.StakePlanHubAddress).Bytes() - events := make([]types.BNBCrossChainEvent, 0, len(receipt.Logs)) + events := make([]types.CrossChainEvent, 0, len(receipt.Logs)) for _, log := range receipt.Logs { if !bytes.Equal(contractAddr, log.Address.Bytes()) { continue @@ -134,16 +130,16 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types ) } - eventIndex := new(big.Int).SetBytes(log.Topics[1].Bytes()) - record := &types.EventRecord{ + identifier := new(big.Int).SetBytes(log.Topics[1].Bytes()) + record := &types.EvmEvent{ BlockNumber: receipt.BlockNumber.Uint64(), - Index: eventIndex.Uint64(), - Contract: log.Address.Bytes(), + Identifier: identifier.Uint64(), + Contract: log.Address.Bytes(), } - if k.hasEventRecord(ctx, record) { - return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "event index %d already exists", eventIndex.Uint64()) + if k.hasEvmEvent(ctx, record) { + return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "event identifier %d already exists", identifier.Uint64()) } - k.setEventRecord(ctx, record) + k.setEvmEvent(ctx, record) sender := common.BytesToAddress(log.Topics[2].Bytes()) planID := new(big.Int).SetBytes(log.Topics[3].Bytes()) @@ -164,8 +160,8 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types ) } - bnbEvent := types.BNBCrossChainEvent{ - EventIndex: eventIndex.Uint64(), + bnbEvent := types.CrossChainEvent{ + Identifier: identifier.Uint64(), Sender: sender, PlanID: planID.Uint64(), BTCcontractAddress: btcContractAddress, @@ -177,13 +173,13 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types return events, nil } -func (k Keeper) hasEventRecord(ctx sdk.Context, record *types.EventRecord) bool { +func (k Keeper) hasEvmEvent(ctx sdk.Context, record *types.EvmEvent) bool { store := ctx.KVStore(k.storeKey) key := record.Key() return store.Has(key) } -func (k Keeper) setEventRecord(ctx sdk.Context, record *types.EventRecord) { +func (k Keeper) setEvmEvent(ctx sdk.Context, record *types.EvmEvent) { store := ctx.KVStore(k.storeKey) key := record.Key() diff --git a/x/bnblightclient/module.go b/x/bnblightclient/module.go new file mode 100644 index 00000000..b63307f7 --- /dev/null +++ b/x/bnblightclient/module.go @@ -0,0 +1,161 @@ +package bnblightclient + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/client/cli" + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/keeper" + "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the bnblightclient module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +// NewAppModuleBasic creates a new instance of the AppModuleBasic struct. +// +// Parameters: +// - cdc: The codec.BinaryCodec used for encoding and decoding. +// +// Returns: +// - An instance of the AppModuleBasic struct. +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the fee module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns the bnblightclient module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the bnblightclient module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck,gosec // generally we don't handle errors here +} + +// GetTxCmd returns the bnblightclient module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the bnblightclient module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the bnblightclient module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +// NewAppModule creates a new instance of the AppModule struct. +// +// Parameters: +// - cdc: The codec used for encoding and decoding. +// - keeper: The keeper for handling the module's state. +// +// Returns: +// - An instance of the AppModule struct. +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerierImpl(am.keeper)) +} + +// RegisterInvariants registers the bnblightclient module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the fe module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + am.keeper.InitGenesis(ctx, genState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the bnblightclient module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the bnblightclient module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the bnblightclient module. It +// returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return nil +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} \ No newline at end of file diff --git a/x/bnblightclient/types/codec.go b/x/bnblightclient/types/codec.go new file mode 100644 index 00000000..3a5a0f88 --- /dev/null +++ b/x/bnblightclient/types/codec.go @@ -0,0 +1,20 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterInterfaces registers implementations for sdk.Msg and MsgUpdateParams in the given InterfaceRegistry. +// +// Parameter: +// - registry: the InterfaceRegistry to register implementations to. +func RegisterInterfaces(registry types.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateParams{}, + &MsgUpdateHeader{}, + &MsgUploadHeaders{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} diff --git a/x/bnblightclient/types/events.go b/x/bnblightclient/types/events.go index 4fef62a8..81cf47b7 100644 --- a/x/bnblightclient/types/events.go +++ b/x/bnblightclient/types/events.go @@ -10,9 +10,9 @@ import ( // StakePlanHubContractABI is the ABI for the StakePlanHub contract. TODO var StakePlanHubContractABI abi.ABI -// BNBCrossChainEvent is a struct that contains the sender, plan id, BTC contract address, stake amount, and stBTC amount. -type BNBCrossChainEvent struct { - EventIndex uint64 `json:"event_index"` +// CrossChainEvent is a struct that contains the sender, plan id, BTC contract address, stake amount, and stBTC amount. +type CrossChainEvent struct { + Identifier uint64 `json:"event_index"` Sender common.Address `json:"sender"` PlanID uint64 `json:"plan_id"` BTCcontractAddress common.Address `json:"btc_contract_address"` @@ -20,7 +20,7 @@ type BNBCrossChainEvent struct { StBTCAmount *big.Int `json:"st_btc_amount"` } -// Key returns the unique key of the EventRecord struct -func(e EventRecord) Key() []byte { - return KeyEventRecord(e.BlockNumber, e.Contract, e.Index) +// Key returns the unique key of the EvmEvent struct +func(e EvmEvent) Key() []byte { + return KeyEventRecord(e.BlockNumber, e.Contract, e.Identifier) } diff --git a/x/bnblightclient/types/genesis.go b/x/bnblightclient/types/genesis.go index 2c6c59b4..a2daa305 100644 --- a/x/bnblightclient/types/genesis.go +++ b/x/bnblightclient/types/genesis.go @@ -9,3 +9,12 @@ func (gs GenesisState) Validate() error { } return VeryHeaders(gs.Headers) } + +// DefaultGenesisState returns the default genesis state +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Params: &Params{}, + Headers: []*Header{}, + Events: []*EvmEvent{}, + } +} diff --git a/x/bnblightclient/types/genesis.pb.go b/x/bnblightclient/types/genesis.pb.go index f115c157..67aefc54 100644 --- a/x/bnblightclient/types/genesis.pb.go +++ b/x/bnblightclient/types/genesis.pb.go @@ -28,8 +28,8 @@ type GenesisState struct { Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"` // headers defines the bnb light client headers Headers []*Header `protobuf:"bytes,2,rep,name=headers,proto3" json:"headers,omitempty"` - // records defines the bnb light client event records - Records []*EventRecord `protobuf:"bytes,3,rep,name=records,proto3" json:"records,omitempty"` + // events defines the bnb chain generated events + Events []*EvmEvent `protobuf:"bytes,3,rep,name=events,proto3" json:"events,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,34 +79,34 @@ func (m *GenesisState) GetHeaders() []*Header { return nil } -func (m *GenesisState) GetRecords() []*EventRecord { +func (m *GenesisState) GetEvents() []*EvmEvent { if m != nil { - return m.Records + return m.Events } return nil } -type EventRecord struct { +type EvmEvent struct { // block_number defines the block number BlockNumber uint64 `protobuf:"varint,1,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` // contract defines the contract Contract []byte `protobuf:"bytes,2,opt,name=contract,proto3" json:"contract,omitempty"` - // index defines the event index - Index uint64 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"` + // index defines the unique identifier of the event + Identifier uint64 `protobuf:"varint,3,opt,name=identifier,proto3" json:"identifier,omitempty"` } -func (m *EventRecord) Reset() { *m = EventRecord{} } -func (m *EventRecord) String() string { return proto.CompactTextString(m) } -func (*EventRecord) ProtoMessage() {} -func (*EventRecord) Descriptor() ([]byte, []int) { +func (m *EvmEvent) Reset() { *m = EvmEvent{} } +func (m *EvmEvent) String() string { return proto.CompactTextString(m) } +func (*EvmEvent) ProtoMessage() {} +func (*EvmEvent) Descriptor() ([]byte, []int) { return fileDescriptor_4f928fb205bb2cf6, []int{1} } -func (m *EventRecord) XXX_Unmarshal(b []byte) error { +func (m *EvmEvent) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EvmEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventRecord.Marshal(b, m, deterministic) + return xxx_messageInfo_EvmEvent.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -116,42 +116,42 @@ func (m *EventRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *EventRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventRecord.Merge(m, src) +func (m *EvmEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_EvmEvent.Merge(m, src) } -func (m *EventRecord) XXX_Size() int { +func (m *EvmEvent) XXX_Size() int { return m.Size() } -func (m *EventRecord) XXX_DiscardUnknown() { - xxx_messageInfo_EventRecord.DiscardUnknown(m) +func (m *EvmEvent) XXX_DiscardUnknown() { + xxx_messageInfo_EvmEvent.DiscardUnknown(m) } -var xxx_messageInfo_EventRecord proto.InternalMessageInfo +var xxx_messageInfo_EvmEvent proto.InternalMessageInfo -func (m *EventRecord) GetBlockNumber() uint64 { +func (m *EvmEvent) GetBlockNumber() uint64 { if m != nil { return m.BlockNumber } return 0 } -func (m *EventRecord) GetContract() []byte { +func (m *EvmEvent) GetContract() []byte { if m != nil { return m.Contract } return nil } -func (m *EventRecord) GetIndex() uint64 { +func (m *EvmEvent) GetIdentifier() uint64 { if m != nil { - return m.Index + return m.Identifier } return 0 } func init() { proto.RegisterType((*GenesisState)(nil), "lorenzo.bnblightclient.v1.GenesisState") - proto.RegisterType((*EventRecord)(nil), "lorenzo.bnblightclient.v1.EventRecord") + proto.RegisterType((*EvmEvent)(nil), "lorenzo.bnblightclient.v1.EvmEvent") } func init() { @@ -159,27 +159,27 @@ func init() { } var fileDescriptor_4f928fb205bb2cf6 = []byte{ - // 315 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x31, 0x4f, 0x02, 0x31, - 0x14, 0xc7, 0x29, 0x28, 0x98, 0xc2, 0xd4, 0x38, 0x9c, 0x0c, 0x0d, 0x30, 0x20, 0x8b, 0xbd, 0xa0, - 0x93, 0xba, 0x18, 0x13, 0xa3, 0x83, 0x31, 0xa4, 0x3a, 0xb9, 0x98, 0x6b, 0x79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 0x48, 0xeb, 0x55, 0x3b, 0x68, 0xd0, 0xe2, 0xdf, 0x35, 0xd9, 0xc7, 0xbb, 0xa1, - 0x1a, 0xc3, 0xd2, 0xab, 0x39, 0x2f, 0x2f, 0x2e, 0x1f, 0x56, 0x29, 0x45, 0xeb, 0x94, 0xa2, 0x8f, - 0x94, 0xa2, 0xb7, 0x8c, 0x56, 0xd6, 0x19, 0xad, 0xbc, 0x67, 0xb4, 0xf2, 0x78, 0x36, 0x09, 0xed, - 0x74, 0x21, 0x98, 0xd4, 0x33, 0xff, 0x36, 0x3f, 0xfc, 0x68, 0xf4, 0xf5, 0xc5, 0x52, 0x47, 0x7e, - 0x19, 0xc6, 0xf2, 0x6f, 0x1c, 0xf6, 0x65, 0x0e, 0xb1, 0xa8, 0xbb, 0x2c, 0x4e, 0x3e, 0x03, 0x00, - 0x00, 0xff, 0xff, 0x48, 0x65, 0x4c, 0xef, 0x21, 0x02, 0x00, 0x00, + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x31, 0x4f, 0xc2, 0x40, + 0x14, 0xc7, 0x39, 0x30, 0x48, 0x0e, 0xa6, 0x9b, 0x2a, 0xc3, 0x05, 0x30, 0x51, 0x16, 0xaf, 0x41, + 0x27, 0x65, 0x33, 0x21, 0x3a, 0x18, 0x43, 0xaa, 0x93, 0x8b, 0xe9, 0x1d, 0x4f, 0xb8, 0xd8, 0xde, + 0x91, 0xeb, 0xd1, 0xa8, 0x9f, 0xc2, 0xef, 0xe4, 0xe2, 0xc8, 0xe8, 0x68, 0xe8, 0x17, 0x31, 0x5c, + 0x5b, 0xa3, 0x26, 0xe0, 0xd8, 0x7f, 0x7e, 0xbf, 0xf7, 0x5e, 0xef, 0x8f, 0x0f, 0x23, 0x6d, 0x40, + 0xbd, 0x68, 0x9f, 0x2b, 0x1e, 0xc9, 0xe9, 0xcc, 0x8a, 0x48, 0x82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d2, 0xce, 0x16, 0x9c, 0x09, 0x1d, 0xfb, 0x57, 0xf9, 0xed, 0x47, 0xe3, 0xf5, 0x23, 0x0b, 0x1d, + 0xf9, 0x65, 0x1d, 0x4f, 0x7f, 0x0b, 0xb1, 0xcf, 0x73, 0x48, 0x78, 0xdd, 0xb5, 0x71, 0xf2, 0x15, + 0x00, 0x00, 0xff, 0xff, 0x7d, 0x9d, 0xd4, 0xd8, 0x23, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -202,10 +202,10 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Records) > 0 { - for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- { + if len(m.Events) > 0 { + for iNdEx := len(m.Events) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Records[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Events[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -245,7 +245,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *EventRecord) Marshal() (dAtA []byte, err error) { +func (m *EvmEvent) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -255,18 +255,18 @@ func (m *EventRecord) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventRecord) MarshalTo(dAtA []byte) (int, error) { +func (m *EvmEvent) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EvmEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Index != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.Index)) + if m.Identifier != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Identifier)) i-- dAtA[i] = 0x18 } @@ -312,8 +312,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.Records) > 0 { - for _, e := range m.Records { + if len(m.Events) > 0 { + for _, e := range m.Events { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -321,7 +321,7 @@ func (m *GenesisState) Size() (n int) { return n } -func (m *EventRecord) Size() (n int) { +func (m *EvmEvent) Size() (n int) { if m == nil { return 0 } @@ -334,8 +334,8 @@ func (m *EventRecord) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } - if m.Index != 0 { - n += 1 + sovGenesis(uint64(m.Index)) + if m.Identifier != 0 { + n += 1 + sovGenesis(uint64(m.Identifier)) } return n } @@ -447,7 +447,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Events", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -474,8 +474,8 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Records = append(m.Records, &EventRecord{}) - if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Events = append(m.Events, &EvmEvent{}) + if err := m.Events[len(m.Events)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -500,7 +500,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventRecord) Unmarshal(dAtA []byte) error { +func (m *EvmEvent) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -523,10 +523,10 @@ func (m *EventRecord) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventRecord: wiretype end group for non-group") + return fmt.Errorf("proto: EvmEvent: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventRecord: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EvmEvent: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -584,9 +584,9 @@ func (m *EventRecord) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) } - m.Index = 0 + m.Identifier = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -596,7 +596,7 @@ func (m *EventRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Index |= uint64(b&0x7F) << shift + m.Identifier |= uint64(b&0x7F) << shift if b < 0x80 { break } From bf10c7079488563427a48ac215d60cf8dc455ffe Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Mon, 22 Jul 2024 15:55:57 +0800 Subject: [PATCH 12/19] add abi file --- x/bnblightclient/keeper/proof.go | 36 +- x/bnblightclient/types/errors.go | 2 +- x/bnblightclient/types/events.go | 24 +- .../types/stake_plan_hub_abi.json | 798 ++++++++++++++++++ 4 files changed, 845 insertions(+), 15 deletions(-) create mode 100644 x/bnblightclient/types/stake_plan_hub_abi.json diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 6ef95103..0441397f 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -99,16 +99,16 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types continue } - if len(log.Topics) != 5 { + if len(log.Topics) != 4 { return nil, errorsmod.Wrapf( types.ErrInvalidEvent, - "event has wrong number of topics, expected 5, actual: %d", + "event has wrong number of topics, expected 4, actual: %d", len(log.Topics), ) } eventID := log.Topics[0] - event, err := types.StakePlanHubContractABI.EventByID(eventID) + event, err := types.ABIstakePlanHub().EventByID(eventID) if err != nil { continue } @@ -117,7 +117,14 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types continue } - eventArgs, err := types.StakePlanHubContractABI.Unpack(event.Name, log.Data) + // stakeIndex + identifier := new(big.Int).SetBytes(log.Topics[1].Bytes()) + // planId + planID := new(big.Int).SetBytes(log.Topics[2].Bytes()) + // sender + sender := common.BytesToAddress(log.Topics[3].Bytes()) + + eventArgs, err := types.ABIstakePlanHub().Unpack(event.Name, log.Data) if err != nil { return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "failed to unpack %s event", event.Name) } @@ -129,8 +136,7 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types len(eventArgs), ) } - - identifier := new(big.Int).SetBytes(log.Topics[1].Bytes()) + record := &types.EvmEvent{ BlockNumber: receipt.BlockNumber.Uint64(), Identifier: identifier.Uint64(), @@ -141,10 +147,17 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types } k.setEvmEvent(ctx, record) - sender := common.BytesToAddress(log.Topics[2].Bytes()) - planID := new(big.Int).SetBytes(log.Topics[3].Bytes()) - btcContractAddress := common.BytesToAddress(log.Topics[4].Bytes()) - stakeAmount, ok := eventArgs[0].(*big.Int) + // btcContractAddress + btcContractAddress, ok := eventArgs[0].(common.Address) + if !ok { + return nil, errorsmod.Wrap( + types.ErrInvalidEvent, + "event `btcContractAddress` parameters is invalid, expected `common.Address`", + ) + } + + // stakeAmount + stakeAmount, ok := eventArgs[1].(*big.Int) if !ok { return nil, errorsmod.Wrap( types.ErrInvalidEvent, @@ -152,7 +165,8 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types ) } - stBTCAmount, ok := eventArgs[1].(*big.Int) + // stBTCAmount + stBTCAmount, ok := eventArgs[2].(*big.Int) if !ok { return nil, errorsmod.Wrap( types.ErrInvalidEvent, diff --git a/x/bnblightclient/types/errors.go b/x/bnblightclient/types/errors.go index edddb8c4..a7ac1310 100644 --- a/x/bnblightclient/types/errors.go +++ b/x/bnblightclient/types/errors.go @@ -9,7 +9,7 @@ var ( ErrHeaderNotFound = errorsmod.Register(ModuleName, 2, "header not found") // ErrInvalidHeader is returned when header is not valid - ErrInvalidHeader = errorsmod.Register(ModuleName, 3, "header not found") + ErrInvalidHeader = errorsmod.Register(ModuleName, 3, "invalid header") // ErrUnauthorized is returned when tx is not authorized ErrUnauthorized = errorsmod.Register(ModuleName, 4, "tx unauthorized") // ErrInvalidProof is returned when proof is not valid diff --git a/x/bnblightclient/types/events.go b/x/bnblightclient/types/events.go index 81cf47b7..9a89788d 100644 --- a/x/bnblightclient/types/events.go +++ b/x/bnblightclient/types/events.go @@ -1,18 +1,36 @@ package types import ( + _ "embed" //nolint: golint + "encoding/json" + "math/big" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" ) -// StakePlanHubContractABI is the ABI for the StakePlanHub contract. TODO -var StakePlanHubContractABI abi.ABI +//go:embed stake_plan_hub_abi.json +var stakePlanHubContractABIJSON []byte //nolint: golint + +var stakePlanHubContractABI abi.ABI + +func init() { + // unmarshal the StakePlanHubContractABI + err := json.Unmarshal(stakePlanHubContractABIJSON, &stakePlanHubContractABI) + if err != nil { + panic(err) + } +} + +// ABIstakePlanHub is the compiled StakePlanHub contract abi +func ABIstakePlanHub() *abi.ABI { + return &stakePlanHubContractABI +} // CrossChainEvent is a struct that contains the sender, plan id, BTC contract address, stake amount, and stBTC amount. type CrossChainEvent struct { - Identifier uint64 `json:"event_index"` + Identifier uint64 `json:"identifier"` Sender common.Address `json:"sender"` PlanID uint64 `json:"plan_id"` BTCcontractAddress common.Address `json:"btc_contract_address"` diff --git a/x/bnblightclient/types/stake_plan_hub_abi.json b/x/bnblightclient/types/stake_plan_hub_abi.json new file mode 100644 index 00000000..0221f871 --- /dev/null +++ b/x/bnblightclient/types/stake_plan_hub_abi.json @@ -0,0 +1,798 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "ERC1167FailedCreateClone", + "type": "error" + }, + { + "inputs": [], + "name": "EnforcedPause", + "type": "error" + }, + { + "inputs": [], + "name": "ExpectedPause", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBTCContractAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInitialization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidPlanId", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTime", + "type": "error" + }, + { + "inputs": [], + "name": "NoPermission", + "type": "error" + }, + { + "inputs": [], + "name": "NotInitializing", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [], + "name": "StakePlanNotAvailable", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + } + ], + "name": "BTCContractAddressAdd", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + } + ], + "name": "BTCContractAddressRemove", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "derivedStakePlanAddr", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakePlanStartTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "periodTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "descUri", + "type": "string" + } + ], + "name": "CreateNewPlan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preGovernance", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "GovernanceSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "gov", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "stakePlanImpl", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "lorenzoAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "mintstBTCAuthorityAddress_", + "type": "address" + } + ], + "name": "Initialize", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "version", + "type": "uint64" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preLorenzoAdmin", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newLorenzoAdmin", + "type": "address" + } + ], + "name": "LorenzoAdminSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bool", + "name": "available", + "type": "bool" + } + ], + "name": "SetStakePlanAvailable", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preStBTCMintAuthorityAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newStBTCMintAuthorityAddress", + "type": "address" + } + ], + "name": "StBTCMintAuthoritySet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "stakeIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stBTCAmount", + "type": "uint256" + } + ], + "name": "StakeBTC2JoinStakePlan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "preStakePlanImpl", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newStakePlanImpl", + "type": "address" + } + ], + "name": "StakePlanImplSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "planId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "btcContractAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "name": "WithdrawBTC", + "type": "event" + }, + { + "inputs": [], + "name": "_governance", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_lorenzoAdmin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stBTCMintAuthorityAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stakeIndex", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "_stakePlanAvailableMap", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stakePlanCounter", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "_stakePlanImpl", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "_stakePlanMap", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "btcContractAddress_", + "type": "address[]" + } + ], + "name": "addSupportBtcContractAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "adminPauseBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "adminUnpauseBridge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "string", + "name": "descUri", + "type": "string" + }, + { + "internalType": "uint256", + "name": "agentId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stakePlanStartTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "periodTime", + "type": "uint256" + } + ], + "internalType": "struct DataTypes.CreateNewPlanData", + "name": "vars_", + "type": "tuple" + } + ], + "name": "createNewPlan", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getSupportBtcContractAddress", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "gov_", + "type": "address" + }, + { + "internalType": "address", + "name": "stakePlanImpl_", + "type": "address" + }, + { + "internalType": "address", + "name": "lorenzoAdmin_", + "type": "address" + }, + { + "internalType": "address", + "name": "stBTCMintAuthorityAddress_", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "btcContractAddress_", + "type": "address[]" + } + ], + "name": "removeSupportBtcContractAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGov_", + "type": "address" + } + ], + "name": "setGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newLorenzoAdmin_", + "type": "address" + } + ], + "name": "setLorenzoAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newStBTCMintAuthorityAddress_", + "type": "address" + } + ], + "name": "setStBTCMintAuthorityAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "planId_", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "available_", + "type": "bool" + } + ], + "name": "setStakePlanAvailable", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newStakePlanImpl_", + "type": "address" + } + ], + "name": "setStakePlanImpl", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "planId_", + "type": "uint256" + }, + { + "internalType": "address", + "name": "btcContractAddress_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stakeAmount", + "type": "uint256" + } + ], + "name": "stakeBTC2JoinStakePlan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "planId_", + "type": "uint256" + }, + { + "internalType": "address", + "name": "to_", + "type": "address" + } + ], + "name": "withdrawBTC", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ] \ No newline at end of file From ea21bf23f92ca57f6f9e40a434f7fe1854dbe5d7 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Wed, 24 Jul 2024 11:07:28 +0800 Subject: [PATCH 13/19] apply comments from github --- x/bnblightclient/keeper/header.go | 8 ++++---- x/bnblightclient/keeper/proof.go | 2 +- x/bnblightclient/keeper/prune.go | 2 +- x/bnblightclient/types/events.go | 2 +- x/bnblightclient/types/keys.go | 10 +++++----- x/btcstaking/types/msg.go | 23 +++++++++++++++++++++++ 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go index 77ff731d..551398db 100644 --- a/x/bnblightclient/keeper/header.go +++ b/x/bnblightclient/keeper/header.go @@ -56,13 +56,13 @@ func(k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { } -// GetLatestHeader retrieves the latested header from the store. +// GetLatestHeader retrieves the latest header from the store. // // Parameters: // - ctx: the context object // // Returns: -// - types.Header: the latested header +// - types.Header: the latest header // - bool: true if the header was found, false otherwise func(k Keeper) GetLatestHeader(ctx sdk.Context) (*types.Header, bool) { store := ctx.KVStore(k.storeKey) @@ -75,13 +75,13 @@ func(k Keeper) GetLatestHeader(ctx sdk.Context) (*types.Header, bool) { return k.GetHeader(ctx, number) } -// GetLatestNumber retrieves the latested number from the store. +// GetLatestNumber retrieves the latest number from the store. // // Parameters: // - ctx: the context object // // Returns: -// - uint64: the latested number +// - uint64: the latest number func(k Keeper) GetLatestNumber(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) bz := store.Get(types.KeyLatestHeaderNumber()) diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 0441397f..44b3095b 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -44,7 +44,7 @@ func (k Keeper) VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, p func (k Keeper) GetAllEvmEvents(ctx sdk.Context) (events []*types.EvmEvent) { store := ctx.KVStore(k.storeKey) - it := sdk.KVStorePrefixIterator(store, types.KeyPrefixEventRecord) + it := sdk.KVStorePrefixIterator(store, types.KeyPrefixEvmEvent) defer it.Close() //nolint:errcheck for ; it.Valid(); it.Next() { diff --git a/x/bnblightclient/keeper/prune.go b/x/bnblightclient/keeper/prune.go index 64e27fa5..9f054d66 100644 --- a/x/bnblightclient/keeper/prune.go +++ b/x/bnblightclient/keeper/prune.go @@ -36,7 +36,7 @@ func (k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { store.Delete(types.KeyHeaderHash(header.Hash)) // delete event record - prefix := append(types.KeyPrefixEventRecord, sdk.Uint64ToBigEndian(number)...) + prefix := append(types.KeyPrefixEvmEvent, sdk.Uint64ToBigEndian(number)...) iterator2 := sdk.KVStoreReversePrefixIterator(store, prefix) defer iterator2.Close() diff --git a/x/bnblightclient/types/events.go b/x/bnblightclient/types/events.go index 9a89788d..9015fb77 100644 --- a/x/bnblightclient/types/events.go +++ b/x/bnblightclient/types/events.go @@ -40,5 +40,5 @@ type CrossChainEvent struct { // Key returns the unique key of the EvmEvent struct func(e EvmEvent) Key() []byte { - return KeyEventRecord(e.BlockNumber, e.Contract, e.Identifier) + return KeyEvmEvent(e.BlockNumber, e.Contract, e.Identifier) } diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go index 3ffb95dc..2289a3ca 100644 --- a/x/bnblightclient/types/keys.go +++ b/x/bnblightclient/types/keys.go @@ -24,8 +24,8 @@ var ( // KeyPrefixHeadHash defines the prefix to retrieve the head hash KeyPrefixHeadHash = []byte{0x04} - // KeyPrefixEventRecord defines the prefix to retrieve the cross chain event - KeyPrefixEventRecord = []byte{0x05} + // KeyPrefixEvmEvent defines the prefix to retrieve the cross chain event + KeyPrefixEvmEvent = []byte{0x05} ) // KeyHeader returns the key for a header @@ -44,9 +44,9 @@ func KeyLatestHeaderNumber() []byte { return KeyPrefixLatestNumber } -// KeyEventRecord returns the key for the cross chain event index -func KeyEventRecord(blockNumber uint64, contract []byte, idx uint64) []byte { - key := append([]byte{}, KeyPrefixEventRecord...) +// KeyEvmEvent returns the key for the cross chain event index +func KeyEvmEvent(blockNumber uint64, contract []byte, idx uint64) []byte { + key := append([]byte{}, KeyPrefixEvmEvent...) bumberBz := sdk.Uint64ToBigEndian(blockNumber) key = append(key, bumberBz...) diff --git a/x/btcstaking/types/msg.go b/x/btcstaking/types/msg.go index f488bb4b..6b6d9751 100644 --- a/x/btcstaking/types/msg.go +++ b/x/btcstaking/types/msg.go @@ -13,6 +13,7 @@ import ( // ensure that these message types implement the sdk.Msg interface var ( _ sdk.Msg = &MsgCreateBTCStaking{} + _ sdk.Msg = &MsgCreateBTCStakingFromBNB{} _ sdk.Msg = &MsgBurnRequest{} _ sdk.Msg = &MsgRemoveReceiver{} _ sdk.Msg = &MsgAddReceiver{} @@ -33,6 +34,28 @@ func (m *MsgCreateBTCStaking) ValidateBasic() error { return nil } +// GetSigners implements types.Msg. +func (m *MsgCreateBTCStakingFromBNB) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Signer) + return []sdk.AccAddress{addr} +} + +// ValidateBasic implements types.Msg. +func (m *MsgCreateBTCStakingFromBNB) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { + return errorsmod.Wrap(err, "invalid signer address") + } + + if len(m.Proof) == 0 { + return fmt.Errorf("proof name cannot be empty") + } + + if len(m.Receipt) == 0 { + return fmt.Errorf("receipt name cannot be empty") + } + return nil +} + func (m *MsgAddReceiver) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(m.Authority) return []sdk.AccAddress{addr} From 43beb1abde542a71a548ec97599ae39bb6ef1604 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Wed, 24 Jul 2024 13:29:38 +0800 Subject: [PATCH 14/19] fix lint error --- x/bnblightclient/keeper/prune.go | 8 ++++++-- x/bnblightclient/types/events.go | 5 ++--- x/bnblightclient/types/header.go | 19 +++++++++---------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/x/bnblightclient/keeper/prune.go b/x/bnblightclient/keeper/prune.go index 9f054d66..b4fb9e85 100644 --- a/x/bnblightclient/keeper/prune.go +++ b/x/bnblightclient/keeper/prune.go @@ -19,7 +19,9 @@ func (k Keeper) prune(ctx sdk.Context) { func (k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStoreReversePrefixIterator(store, types.KeyPrefixHeader) - defer iterator.Close() + defer func() { + _ = iterator.Close() + }() for ; iterator.Valid(); iterator.Next() { iterKey := iterator.Key() @@ -38,7 +40,9 @@ func (k Keeper) pruneHeaders(ctx sdk.Context, pruneEndNumber uint64) { // delete event record prefix := append(types.KeyPrefixEvmEvent, sdk.Uint64ToBigEndian(number)...) iterator2 := sdk.KVStoreReversePrefixIterator(store, prefix) - defer iterator2.Close() + defer func() { + _ = iterator2.Close() + }() for ; iterator2.Valid(); iterator2.Next() { iterKey2 := iterator2.Key() diff --git a/x/bnblightclient/types/events.go b/x/bnblightclient/types/events.go index 9015fb77..44dd7713 100644 --- a/x/bnblightclient/types/events.go +++ b/x/bnblightclient/types/events.go @@ -3,7 +3,6 @@ package types import ( _ "embed" //nolint: golint "encoding/json" - "math/big" "github.com/ethereum/go-ethereum/accounts/abi" @@ -11,7 +10,7 @@ import ( ) //go:embed stake_plan_hub_abi.json -var stakePlanHubContractABIJSON []byte //nolint: golint +var stakePlanHubContractABIJSON []byte //nolint: golint var stakePlanHubContractABI abi.ABI @@ -39,6 +38,6 @@ type CrossChainEvent struct { } // Key returns the unique key of the EvmEvent struct -func(e EvmEvent) Key() []byte { +func (e EvmEvent) Key() []byte { return KeyEvmEvent(e.BlockNumber, e.Contract, e.Identifier) } diff --git a/x/bnblightclient/types/header.go b/x/bnblightclient/types/header.go index aafa5158..8689bebc 100644 --- a/x/bnblightclient/types/header.go +++ b/x/bnblightclient/types/header.go @@ -61,7 +61,6 @@ func (h *BNBHeader) Hash() common.Hash { return rlpHash(h) } - // ConvertToBNBHeader decodes the input data into a BNBHeader struct and validates it against the provided Header. // // It takes a pointer to a Header struct as input and returns a pointer to a BNBHeader struct and an error. @@ -74,25 +73,25 @@ func (h *BNBHeader) Hash() common.Hash { // If not, it returns an ErrInvalidHeader error with the message "receipt hash not equal". // If all checks pass, it returns the BNBHeader struct and a nil error. func ConvertToBNBHeader(header *Header) (*BNBHeader, error) { - bnbHeader,err := UnmarshalBNBHeader(header.RawHeader) + bnbHeader, err := UnmarshalBNBHeader(header.RawHeader) if err != nil { return nil, err } if bnbHeader.Number.Uint64() != header.Number { - return nil,errorsmod.Wrap(ErrInvalidHeader, "number not equal") + return nil, errorsmod.Wrap(ErrInvalidHeader, "number not equal") } if bnbHeader.Hash() != common.Hash(header.Hash) { - return nil,errorsmod.Wrap(ErrInvalidHeader, "hash not equal") + return nil, errorsmod.Wrap(ErrInvalidHeader, "hash not equal") } if bnbHeader.ParentHash != common.Hash(header.ParentHash) { - return nil,errorsmod.Wrap(ErrInvalidHeader, "parentHash not equal") + return nil, errorsmod.Wrap(ErrInvalidHeader, "parentHash not equal") } if bnbHeader.ReceiptHash != common.Hash(header.ReceiptRoot) { - return nil,errorsmod.Wrap(ErrInvalidHeader, "receipt hash not equal") + return nil, errorsmod.Wrap(ErrInvalidHeader, "receipt hash not equal") } return bnbHeader, nil } @@ -122,7 +121,7 @@ func VeryHeaders(headers []*Header) error { } if len(headers) == 1 { - _,err := ConvertToBNBHeader(headers[0]) + _, err := ConvertToBNBHeader(headers[0]) return err } @@ -149,10 +148,10 @@ func VeryHeaders(headers []*Header) error { } func rlpHash(x interface{}) (h common.Hash) { - sha := hasherPool.Get().(crypto.KeccakState) + sha, _ := hasherPool.Get().(crypto.KeccakState) defer hasherPool.Put(sha) sha.Reset() - rlp.Encode(sha, x) - sha.Read(h[:]) + _ = rlp.Encode(sha, x) + _, _ = sha.Read(h[:]) return h } From 83cdcbb2ffebecc28b60970429e6fea9353f5a59 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Wed, 24 Jul 2024 13:38:56 +0800 Subject: [PATCH 15/19] make format --- x/bnblightclient/client/cli/tx.go | 12 ++++++------ x/bnblightclient/keeper/genesis.go | 6 +++--- x/bnblightclient/keeper/header.go | 31 +++++++++++++++--------------- x/bnblightclient/keeper/params.go | 2 +- x/bnblightclient/keeper/proof.go | 4 ++-- x/bnblightclient/module.go | 2 +- x/bnblightclient/types/genesis.go | 4 ++-- x/bnblightclient/types/keys.go | 2 +- x/bnblightclient/types/msg.go | 19 +++++++----------- x/bnblightclient/types/params.go | 2 +- x/bnblightclient/types/proof.go | 1 - x/btcstaking/keeper/msg_server.go | 2 -- 12 files changed, 39 insertions(+), 48 deletions(-) diff --git a/x/bnblightclient/client/cli/tx.go b/x/bnblightclient/client/cli/tx.go index 06ec0002..211f0865 100644 --- a/x/bnblightclient/client/cli/tx.go +++ b/x/bnblightclient/client/cli/tx.go @@ -51,7 +51,7 @@ func CmdTxUploadHeaders() *cobra.Command { return err } - content,err := os.ReadFile(args[0]) + content, err := os.ReadFile(args[0]) if err != nil { return err } @@ -62,8 +62,8 @@ func CmdTxUploadHeaders() *cobra.Command { } msg := types.MsgUploadHeaders{ - Signer: clientCtx.GetFromAddress().String(), - Headers: headers, + Signer: clientCtx.GetFromAddress().String(), + Headers: headers, } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, @@ -97,7 +97,7 @@ func CmdTxUpdateHeader() *cobra.Command { return err } - content,err := os.ReadFile(args[0]) + content, err := os.ReadFile(args[0]) if err != nil { return err } @@ -109,7 +109,7 @@ func CmdTxUpdateHeader() *cobra.Command { msg := types.MsgUpdateHeader{ Signer: clientCtx.GetFromAddress().String(), - Header: &header, + Header: &header, } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, @@ -117,4 +117,4 @@ func CmdTxUpdateHeader() *cobra.Command { flags.AddTxFlagsToCmd(cmd) return cmd -} \ No newline at end of file +} diff --git a/x/bnblightclient/keeper/genesis.go b/x/bnblightclient/keeper/genesis.go index 44147e0b..6235bc49 100644 --- a/x/bnblightclient/keeper/genesis.go +++ b/x/bnblightclient/keeper/genesis.go @@ -25,7 +25,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { for _, header := range genState.Headers { k.setHeader(ctx, header) } - k.setLatestNumber(ctx, genState.Headers[len(genState.Headers) - 1].Number) + k.setLatestNumber(ctx, genState.Headers[len(genState.Headers)-1].Number) for _, record := range genState.Events { k.setEvmEvent(ctx, record) @@ -37,6 +37,6 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return &types.GenesisState{ Params: k.GetParams(ctx), Headers: k.GetAllHeaders(ctx), - Events: k.GetAllEvmEvents(ctx), + Events: k.GetAllEvmEvents(ctx), } -} \ No newline at end of file +} diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go index 551398db..a1001e9f 100644 --- a/x/bnblightclient/keeper/header.go +++ b/x/bnblightclient/keeper/header.go @@ -10,7 +10,7 @@ import ( ) // UploadHeaders adds a batch of headers to the bnb light client chain -func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { +func (k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { slices.SortFunc(headers, func(a, b *types.Header) int { return int(a.Number - b.Number) }) @@ -20,16 +20,16 @@ func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { if exist { vHeader = append([]*types.Header{latestedHeader}, headers...) } - + // verify headers - if err := types.VeryHeaders(vHeader); err != nil { - return err + if err := types.VeryHeaders(vHeader); err != nil { + return err } for _, header := range headers { k.setHeader(ctx, header) } - k.setLatestNumber(ctx, headers[len(headers) - 1].Number) + k.setLatestNumber(ctx, headers[len(headers)-1].Number) k.prune(ctx) return nil } @@ -42,7 +42,7 @@ func(k Keeper) UploadHeaders(ctx sdk.Context, headers []*types.Header) error { // // Returns: // - error: an error if the header update fails. -func(k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { +func (k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { if err := types.VeryHeaders([]*types.Header{header}); err != nil { return err } @@ -55,7 +55,6 @@ func(k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { return nil } - // GetLatestHeader retrieves the latest header from the store. // // Parameters: @@ -64,7 +63,7 @@ func(k Keeper) UpdateHeader(ctx sdk.Context, header *types.Header) error { // Returns: // - types.Header: the latest header // - bool: true if the header was found, false otherwise -func(k Keeper) GetLatestHeader(ctx sdk.Context) (*types.Header, bool) { +func (k Keeper) GetLatestHeader(ctx sdk.Context) (*types.Header, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.KeyLatestHeaderNumber()) if bz == nil { @@ -82,7 +81,7 @@ func(k Keeper) GetLatestHeader(ctx sdk.Context) (*types.Header, bool) { // // Returns: // - uint64: the latest number -func(k Keeper) GetLatestNumber(ctx sdk.Context) uint64 { +func (k Keeper) GetLatestNumber(ctx sdk.Context) uint64 { store := ctx.KVStore(k.storeKey) bz := store.Get(types.KeyLatestHeaderNumber()) if bz == nil { @@ -100,7 +99,7 @@ func(k Keeper) GetLatestNumber(ctx sdk.Context) uint64 { // Returns: // - types.Header: the header object // - bool: true if the header was found, false otherwise -func(k Keeper) GetHeader(ctx sdk.Context, number uint64) (*types.Header, bool) { +func (k Keeper) GetHeader(ctx sdk.Context, number uint64) (*types.Header, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.KeyHeader(number)) if bz == nil { @@ -118,7 +117,7 @@ func(k Keeper) GetHeader(ctx sdk.Context, number uint64) (*types.Header, bool) { // // Returns: // - headers: a slice of Header objects -func(k Keeper) GetAllHeaders(ctx sdk.Context) (headers []*types.Header) { +func (k Keeper) GetAllHeaders(ctx sdk.Context) (headers []*types.Header) { store := ctx.KVStore(k.storeKey) it := sdk.KVStorePrefixIterator(store, types.KeyPrefixHeader) @@ -141,7 +140,7 @@ func(k Keeper) GetAllHeaders(ctx sdk.Context) (headers []*types.Header) { // Returns: // - *types.Header: the header object, or nil if not found // - bool: true if the header was found, false otherwise -func(k Keeper) GetHeaderByHash(ctx sdk.Context, hash []byte) (*types.Header, bool) { +func (k Keeper) GetHeaderByHash(ctx sdk.Context, hash []byte) (*types.Header, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.KeyHeaderHash(hash)) if bz == nil { @@ -158,12 +157,12 @@ func(k Keeper) GetHeaderByHash(ctx sdk.Context, hash []byte) (*types.Header, boo // - ctx: the context object // - number: the number of the header to check // Return type: bool -func(k Keeper) HasHeader(ctx sdk.Context, number uint64) bool { +func (k Keeper) HasHeader(ctx sdk.Context, number uint64) bool { store := ctx.KVStore(k.storeKey) return store.Has(types.KeyHeader(number)) } -func(k Keeper) setHeader(ctx sdk.Context, header *types.Header) { +func (k Keeper) setHeader(ctx sdk.Context, header *types.Header) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(header) store.Set(types.KeyHeader(header.Number), bz) @@ -172,8 +171,8 @@ func(k Keeper) setHeader(ctx sdk.Context, header *types.Header) { store.Set(types.KeyHeaderHash(header.Hash), numberBz) } -func(k Keeper) setLatestNumber(ctx sdk.Context, number uint64) { +func (k Keeper) setLatestNumber(ctx sdk.Context, number uint64) { store := ctx.KVStore(k.storeKey) bz := sdk.Uint64ToBigEndian(number) store.Set(types.KeyLatestHeaderNumber(), bz) -} \ No newline at end of file +} diff --git a/x/bnblightclient/keeper/params.go b/x/bnblightclient/keeper/params.go index 96ba5777..c9077cdc 100644 --- a/x/bnblightclient/keeper/params.go +++ b/x/bnblightclient/keeper/params.go @@ -34,4 +34,4 @@ func (k Keeper) GetParams(ctx sdk.Context) (params *types.Params) { } k.cdc.MustUnmarshal(bz, params) return params -} \ No newline at end of file +} diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 44b3095b..5f7bf434 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -123,7 +123,7 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types planID := new(big.Int).SetBytes(log.Topics[2].Bytes()) // sender sender := common.BytesToAddress(log.Topics[3].Bytes()) - + eventArgs, err := types.ABIstakePlanHub().Unpack(event.Name, log.Data) if err != nil { return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "failed to unpack %s event", event.Name) @@ -136,7 +136,7 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types len(eventArgs), ) } - + record := &types.EvmEvent{ BlockNumber: receipt.BlockNumber.Uint64(), Identifier: identifier.Uint64(), diff --git a/x/bnblightclient/module.go b/x/bnblightclient/module.go index b63307f7..d89614ab 100644 --- a/x/bnblightclient/module.go +++ b/x/bnblightclient/module.go @@ -158,4 +158,4 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val func (am AppModule) IsOnePerModuleType() {} // IsAppModule implements the appmodule.AppModule interface. -func (am AppModule) IsAppModule() {} \ No newline at end of file +func (am AppModule) IsAppModule() {} diff --git a/x/bnblightclient/types/genesis.go b/x/bnblightclient/types/genesis.go index a2daa305..bb159378 100644 --- a/x/bnblightclient/types/genesis.go +++ b/x/bnblightclient/types/genesis.go @@ -13,8 +13,8 @@ func (gs GenesisState) Validate() error { // DefaultGenesisState returns the default genesis state func DefaultGenesisState() *GenesisState { return &GenesisState{ - Params: &Params{}, + Params: &Params{}, Headers: []*Header{}, - Events: []*EvmEvent{}, + Events: []*EvmEvent{}, } } diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go index 2289a3ca..30762ea7 100644 --- a/x/bnblightclient/types/keys.go +++ b/x/bnblightclient/types/keys.go @@ -46,7 +46,7 @@ func KeyLatestHeaderNumber() []byte { // KeyEvmEvent returns the key for the cross chain event index func KeyEvmEvent(blockNumber uint64, contract []byte, idx uint64) []byte { - key := append([]byte{}, KeyPrefixEvmEvent...) + key := append([]byte{}, KeyPrefixEvmEvent...) bumberBz := sdk.Uint64ToBigEndian(blockNumber) key = append(key, bumberBz...) diff --git a/x/bnblightclient/types/msg.go b/x/bnblightclient/types/msg.go index 8aeca06c..99dc2eb6 100644 --- a/x/bnblightclient/types/msg.go +++ b/x/bnblightclient/types/msg.go @@ -11,7 +11,7 @@ var ( ) // ValidateBasic implements sdk.Msg interface -func(m *MsgUpdateHeader) ValidateBasic() error { +func (m *MsgUpdateHeader) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { return err } @@ -19,25 +19,25 @@ func(m *MsgUpdateHeader) ValidateBasic() error { } // GetSigners implements sdk.Msg interface -func(m *MsgUpdateHeader) GetSigners() []sdk.AccAddress { +func (m *MsgUpdateHeader) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Signer)} } // ValidateBasic implements sdk.Msg interface -func(m *MsgUploadHeaders) ValidateBasic() error { - if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { +func (m *MsgUploadHeaders) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Signer); err != nil { return err } return VeryHeaders(m.Headers) } // GetSigners implements sdk.Msg interface -func(m *MsgUploadHeaders) GetSigners() []sdk.AccAddress { +func (m *MsgUploadHeaders) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Signer)} } // ValidateBasic implements sdk.Msg interface -func(m *MsgUpdateParams) ValidateBasic() error { +func (m *MsgUpdateParams) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { return err } @@ -45,11 +45,6 @@ func(m *MsgUpdateParams) ValidateBasic() error { } // GetSigners implements sdk.Msg interface -func(m *MsgUpdateParams) GetSigners() []sdk.AccAddress { +func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sdk.MustAccAddressFromBech32(m.Authority)} } - - - - - diff --git a/x/bnblightclient/types/params.go b/x/bnblightclient/types/params.go index a273c1fb..acdf8260 100644 --- a/x/bnblightclient/types/params.go +++ b/x/bnblightclient/types/params.go @@ -48,4 +48,4 @@ func ValidateAllowList(allowList []string) error { seenAddr[addr] = true } return nil -} \ No newline at end of file +} diff --git a/x/bnblightclient/types/proof.go b/x/bnblightclient/types/proof.go index d026d042..8bb5c3f2 100644 --- a/x/bnblightclient/types/proof.go +++ b/x/bnblightclient/types/proof.go @@ -141,4 +141,3 @@ func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*types.Receipt return &res, nil } - diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index 0ea40636..d97f039f 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -31,8 +31,6 @@ type msgServer struct { *Keeper } - - // NewMsgServerImpl returns an implementation of the MsgServer interface // for the provided Keeper. func NewMsgServerImpl(keeper *Keeper) types.MsgServer { From 8c9207765e7dd33a61d6ad820a40b51995e6533f Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 25 Jul 2024 15:45:59 +0800 Subject: [PATCH 16/19] merge from main branch --- go.mod | 2 +- go.sum | 32 +++++++++++++++++++++++++++ x/bnblightclient/client/cli/query.go | 2 +- x/bnblightclient/client/cli/tx.go | 2 +- x/bnblightclient/keeper/genesis.go | 2 +- x/bnblightclient/keeper/grpc_query.go | 2 +- x/bnblightclient/keeper/header.go | 2 +- x/bnblightclient/keeper/msg_server.go | 2 +- x/bnblightclient/keeper/params.go | 2 +- x/bnblightclient/keeper/proof.go | 2 +- x/bnblightclient/keeper/prune.go | 2 +- x/bnblightclient/module.go | 6 ++--- 12 files changed, 45 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index d0ccec0f..90dab20c 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require ( require ( cosmossdk.io/core v0.5.1 - github.com/armon/go-metrics v0.4.1 github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/btcsuite/btcd/btcutil v1.1.5 github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 @@ -60,6 +59,7 @@ require ( github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect + github.com/armon/go-metrics v0.4.1 // indirect github.com/aws/aws-sdk-go v1.44.203 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect diff --git a/go.sum b/go.sum index d6f989d5..7bae49ca 100644 --- a/go.sum +++ b/go.sum @@ -215,6 +215,7 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3 github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= +github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= @@ -225,7 +226,9 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go github.com/Lorenzo-Protocol/ethermint v0.22.0-lorenzo-4 h1:uMybTuWsBk+JuzNPDp+WdKyDM0U87TzEJgYR7sLzfMg= github.com/Lorenzo-Protocol/ethermint v0.22.0-lorenzo-4/go.mod h1:JEhGmVj5rZX5bTfOqh3nltE2N6+qMI4HVNV2vW6PpOQ= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -238,6 +241,7 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= +github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= @@ -321,6 +325,7 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= +github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.8.0 h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA= @@ -368,6 +373,7 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= +github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -392,6 +398,7 @@ github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSM github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -473,7 +480,9 @@ github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/ github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf h1:Yt+4K30SdjOkRoRRm3vYNQgR+/ZIy0RmeUDZo7Y8zeQ= github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= @@ -502,6 +511,7 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go. github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= +github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew= github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= @@ -514,9 +524,11 @@ github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlK github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= +github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= @@ -536,6 +548,7 @@ github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= +github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= @@ -573,6 +586,7 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= @@ -669,12 +683,14 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -991,6 +1007,7 @@ github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -1002,16 +1019,22 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= +github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= +github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= +github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= +github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1022,6 +1045,7 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -1042,6 +1066,7 @@ github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1137,6 +1162,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -1235,6 +1261,7 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y= +github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -1245,6 +1272,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1280,6 +1308,7 @@ go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znn go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1349,6 +1378,7 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1661,6 +1691,7 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1951,6 +1982,7 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/x/bnblightclient/client/cli/query.go b/x/bnblightclient/client/cli/query.go index e416a121..0a64ee78 100644 --- a/x/bnblightclient/client/cli/query.go +++ b/x/bnblightclient/client/cli/query.go @@ -10,7 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) // GetQueryCmd returns the cli query commands for bnblightclient module diff --git a/x/bnblightclient/client/cli/tx.go b/x/bnblightclient/client/cli/tx.go index 211f0865..00946a0f 100644 --- a/x/bnblightclient/client/cli/tx.go +++ b/x/bnblightclient/client/cli/tx.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) // GetTxCmd returns the transaction commands for bnblightclient module diff --git a/x/bnblightclient/keeper/genesis.go b/x/bnblightclient/keeper/genesis.go index 6235bc49..50c312fc 100644 --- a/x/bnblightclient/keeper/genesis.go +++ b/x/bnblightclient/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( "slices" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/bnblightclient/keeper/grpc_query.go b/x/bnblightclient/keeper/grpc_query.go index 03670146..deb79c29 100644 --- a/x/bnblightclient/keeper/grpc_query.go +++ b/x/bnblightclient/keeper/grpc_query.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) var _ types.QueryServer = Querier{} diff --git a/x/bnblightclient/keeper/header.go b/x/bnblightclient/keeper/header.go index a1001e9f..ea77cf30 100644 --- a/x/bnblightclient/keeper/header.go +++ b/x/bnblightclient/keeper/header.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) // UploadHeaders adds a batch of headers to the bnb light client chain diff --git a/x/bnblightclient/keeper/msg_server.go b/x/bnblightclient/keeper/msg_server.go index e73aaa6b..875c0bfb 100644 --- a/x/bnblightclient/keeper/msg_server.go +++ b/x/bnblightclient/keeper/msg_server.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) type msgServer struct { diff --git a/x/bnblightclient/keeper/params.go b/x/bnblightclient/keeper/params.go index c9077cdc..8b7e422b 100644 --- a/x/bnblightclient/keeper/params.go +++ b/x/bnblightclient/keeper/params.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) // SetParams sets the parameters for the given context. diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 5f7bf434..26bf01ff 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -12,7 +12,7 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) // VerifyReceiptProof verifies the receipt proof for a BNB cross-chain event. diff --git a/x/bnblightclient/keeper/prune.go b/x/bnblightclient/keeper/prune.go index b4fb9e85..ffd3023c 100644 --- a/x/bnblightclient/keeper/prune.go +++ b/x/bnblightclient/keeper/prune.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/bnblightclient/module.go b/x/bnblightclient/module.go index d89614ab..6aebaf3f 100644 --- a/x/bnblightclient/module.go +++ b/x/bnblightclient/module.go @@ -15,9 +15,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/client/cli" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/keeper" - "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/client/cli" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/keeper" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" ) var ( From acb1894c99b6c869e179d659b7e6d38d753ba9e9 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 25 Jul 2024 18:54:11 +0800 Subject: [PATCH 17/19] regenerate proto --- proto/lorenzo/bnblightclient/v1/client.proto | 2 +- proto/lorenzo/bnblightclient/v1/genesis.proto | 2 +- proto/lorenzo/bnblightclient/v1/params.proto | 5 +- proto/lorenzo/bnblightclient/v1/query.proto | 2 +- proto/lorenzo/bnblightclient/v1/tx.proto | 2 +- .../btcstaking/v1/staking_record.proto | 20 +- x/bnblightclient/types/client.pb.go | 12 +- x/bnblightclient/types/genesis.pb.go | 43 +- x/bnblightclient/types/params.pb.go | 80 +++- x/bnblightclient/types/query.pb.go | 64 +-- x/bnblightclient/types/tx.pb.go | 60 +-- x/btcstaking/types/staking_record.pb.go | 397 ++++++++++++++++-- x/btcstaking/types/tx.pb.go | 102 ++--- 13 files changed, 600 insertions(+), 191 deletions(-) diff --git a/proto/lorenzo/bnblightclient/v1/client.proto b/proto/lorenzo/bnblightclient/v1/client.proto index 7be17b2a..0ac6acf2 100644 --- a/proto/lorenzo/bnblightclient/v1/client.proto +++ b/proto/lorenzo/bnblightclient/v1/client.proto @@ -3,7 +3,7 @@ package lorenzo.bnblightclient.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; message Header { option (gogoproto.goproto_getters) = false; diff --git a/proto/lorenzo/bnblightclient/v1/genesis.proto b/proto/lorenzo/bnblightclient/v1/genesis.proto index 7e7534b6..5727ca57 100644 --- a/proto/lorenzo/bnblightclient/v1/genesis.proto +++ b/proto/lorenzo/bnblightclient/v1/genesis.proto @@ -4,7 +4,7 @@ package lorenzo.bnblightclient.v1; import "lorenzo/bnblightclient/v1/client.proto"; import "lorenzo/bnblightclient/v1/params.proto"; -option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; // GenesisState defines the bnb light client state message GenesisState { diff --git a/proto/lorenzo/bnblightclient/v1/params.proto b/proto/lorenzo/bnblightclient/v1/params.proto index 803c6706..3134b0b0 100644 --- a/proto/lorenzo/bnblightclient/v1/params.proto +++ b/proto/lorenzo/bnblightclient/v1/params.proto @@ -3,7 +3,7 @@ package lorenzo.bnblightclient.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; // Params defines the parameters for the module. message Params { @@ -17,5 +17,6 @@ message Params { uint64 retained_blocks = 3; // list of people who can upload bnb block header information repeated string allow_list = 4; - + // chain_id defines the bnb chain id + uint32 chain_id = 5; } \ No newline at end of file diff --git a/proto/lorenzo/bnblightclient/v1/query.proto b/proto/lorenzo/bnblightclient/v1/query.proto index 0fe48169..fcbe0049 100644 --- a/proto/lorenzo/bnblightclient/v1/query.proto +++ b/proto/lorenzo/bnblightclient/v1/query.proto @@ -6,7 +6,7 @@ import "google/api/annotations.proto"; import "lorenzo/bnblightclient/v1/client.proto"; import "lorenzo/bnblightclient/v1/params.proto"; -option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; // Query defines the gRPC querier service. service Query { diff --git a/proto/lorenzo/bnblightclient/v1/tx.proto b/proto/lorenzo/bnblightclient/v1/tx.proto index 91b8e5ca..b4af189c 100644 --- a/proto/lorenzo/bnblightclient/v1/tx.proto +++ b/proto/lorenzo/bnblightclient/v1/tx.proto @@ -7,7 +7,7 @@ import "cosmos/msg/v1/msg.proto"; import "lorenzo/bnblightclient/v1/client.proto"; import "lorenzo/bnblightclient/v1/params.proto"; -option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types"; +option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types"; // Msg defines the Msg service. service Msg { diff --git a/proto/lorenzo/btcstaking/v1/staking_record.proto b/proto/lorenzo/btcstaking/v1/staking_record.proto index c3f394a8..745f521b 100644 --- a/proto/lorenzo/btcstaking/v1/staking_record.proto +++ b/proto/lorenzo/btcstaking/v1/staking_record.proto @@ -1,10 +1,7 @@ syntax = "proto3"; package lorenzo.btcstaking.v1; -import "cosmos/msg/v1/msg.proto"; -import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -// import "cosmos/staking/v1beta1/staking.proto"; option go_package = "github.com/Lorenzo-Protocol/lorenzo/v2/x/btcstaking/types"; @@ -16,3 +13,20 @@ message BTCStakingRecord { string agent_btc_addr = 5; uint32 chain_id = 6; } + +// BTCBStakingRecord defines the message for btcb staking record +message BTCBStakingRecord { + // tx_hash defines the tx hash + bytes tx_hash = 1; + // event_idx defines the event index + uint64 event_idx = 2; + // receiver_addr defines the receiver address + string receiver_addr = 3; + // amount defines the stBTC amount + string amount = 4 [ + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false + ]; + // chain_id defines the chain id + uint32 chain_id = 5; +} diff --git a/x/bnblightclient/types/client.pb.go b/x/bnblightclient/types/client.pb.go index d0ee797c..dc33d492 100644 --- a/x/bnblightclient/types/client.pb.go +++ b/x/bnblightclient/types/client.pb.go @@ -78,7 +78,7 @@ func init() { } var fileDescriptor_30c005374b948758 = []byte{ - // 273 bytes of a gzipped FileDescriptorProto + // 276 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0xc9, 0x2f, 0x4a, 0xcd, 0xab, 0xca, 0xd7, 0x4f, 0xca, 0x4b, 0xca, 0xc9, 0x4c, 0xcf, 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x33, 0xd4, 0x87, 0xb0, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x24, @@ -91,12 +91,12 @@ var fileDescriptor_30c005374b948758 = []byte{ 0xa5, 0xb9, 0x49, 0xa9, 0x45, 0x12, 0x2c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x50, 0x9e, 0x90, 0x22, 0x17, 0x4f, 0x51, 0x6a, 0x72, 0x6a, 0x66, 0x41, 0x49, 0x7c, 0x51, 0x7e, 0x7e, 0x89, 0x04, 0x2b, 0x58, 0x0f, 0x37, 0x54, 0x2c, 0x28, 0x3f, 0xbf, 0xc4, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x53, - 0xc8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, - 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x59, 0xa5, 0x67, 0x96, 0x64, + 0xf8, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, + 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xd9, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xfb, 0x40, 0x7c, 0xad, 0x1b, 0x00, 0xf2, 0x53, 0x72, - 0x7e, 0x8e, 0x3e, 0x2c, 0xb8, 0x2a, 0xd0, 0x03, 0xac, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, - 0xec, 0x79, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x41, 0x31, 0x4a, 0x57, 0x01, 0x00, - 0x00, + 0x7e, 0x8e, 0x3e, 0x2c, 0xb8, 0xca, 0x8c, 0xf4, 0x2b, 0xd0, 0xc3, 0xac, 0xa4, 0xb2, 0x20, 0xb5, + 0x38, 0x89, 0x0d, 0xec, 0x7f, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x8e, 0x25, 0x7b, + 0x5a, 0x01, 0x00, 0x00, } func (m *Header) Marshal() (dAtA []byte, err error) { diff --git a/x/bnblightclient/types/genesis.pb.go b/x/bnblightclient/types/genesis.pb.go index 67aefc54..8af89ab4 100644 --- a/x/bnblightclient/types/genesis.pb.go +++ b/x/bnblightclient/types/genesis.pb.go @@ -159,27 +159,28 @@ func init() { } var fileDescriptor_4f928fb205bb2cf6 = []byte{ - // 316 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x31, 0x4f, 0xc2, 0x40, - 0x14, 0xc7, 0x39, 0x30, 0x48, 0x0e, 0xa6, 0x9b, 0x2a, 0xc3, 0x05, 0x30, 0x51, 0x16, 0xaf, 0x41, - 0x27, 0x65, 0x33, 0x21, 0x3a, 0x18, 0x43, 0xaa, 0x93, 0x8b, 0xe9, 0x1d, 0x4f, 0xb8, 0xd8, 0x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x76, 0x50, 0xbf, 0x15, 0x7c, 0x7f, 0x13, 0x8a, 0xb1, 0x9c, 0x80, 0xb2, - 0xf2, 0x41, 0x82, 0xf1, 0x6a, 0x4e, 0xfe, 0x91, 0x9c, 0xdf, 0xbe, 0xaf, 0x28, 0x5a, 0xae, 0x28, - 0xfa, 0x5c, 0x51, 0xf4, 0x9a, 0xd1, 0xca, 0x32, 0xa3, 0x95, 0x8f, 0x8c, 0x56, 0xee, 0xce, 0xa6, - 0xd2, 0xce, 0x16, 0x9c, 0x09, 0x1d, 0xfb, 0x57, 0xf9, 0xed, 0x47, 0xe3, 0xf5, 0x23, 0x0b, 0x1d, - 0xf9, 0x65, 0x1d, 0x4f, 0x7f, 0x0b, 0xb1, 0xcf, 0x73, 0x48, 0x78, 0xdd, 0xb5, 0x71, 0xf2, 0x15, - 0x00, 0x00, 0xff, 0xff, 0x7d, 0x9d, 0xd4, 0xd8, 0x23, 0x02, 0x00, 0x00, + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0x31, 0x4f, 0x32, 0x31, + 0x18, 0xc7, 0x29, 0xbc, 0xe1, 0x25, 0x85, 0xa9, 0xd3, 0xc9, 0xd0, 0x00, 0x26, 0xca, 0x62, 0x1b, + 0x70, 0x32, 0xc4, 0xc5, 0x84, 0xe8, 0x60, 0x0c, 0x39, 0x07, 0x13, 0x17, 0x73, 0x2d, 0x8f, 0xd0, + 0x78, 0xd7, 0x92, 0x5e, 0xb9, 0xa8, 0x9f, 0xc2, 0xef, 0xe4, 0xe2, 0xc8, 0xe8, 0x68, 0xe0, 0x8b, + 0x18, 0xca, 0x9d, 0x51, 0x13, 0x70, 0xbc, 0x7f, 0x7e, 0xbf, 0xe7, 0x79, 0xae, 0x7f, 0x7c, 0x18, + 0x1b, 0x0b, 0xfa, 0xd9, 0x70, 0xa1, 0x45, 0xac, 0x26, 0x53, 0x27, 0x63,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x89, 0x72, 0xd3, 0xb9, 0x60, 0xd2, 0x24, 0xfc, 0x72, 0x73, 0xfb, 0xd1, 0x68, 0xfd, + 0xc8, 0xd2, 0xc4, 0xbc, 0xa8, 0x23, 0xeb, 0xf3, 0xc7, 0xdf, 0x9d, 0xb8, 0xa7, 0x19, 0xa4, 0xa2, + 0xea, 0x0b, 0x39, 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x8b, 0x2e, 0xa6, 0x26, 0x02, 0x00, + 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/bnblightclient/types/params.pb.go b/x/bnblightclient/types/params.pb.go index 1852d42e..31cbcd39 100644 --- a/x/bnblightclient/types/params.pb.go +++ b/x/bnblightclient/types/params.pb.go @@ -33,6 +33,8 @@ type Params struct { RetainedBlocks uint64 `protobuf:"varint,3,opt,name=retained_blocks,json=retainedBlocks,proto3" json:"retained_blocks,omitempty"` // list of people who can upload bnb block header information AllowList []string `protobuf:"bytes,4,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` + // chain_id defines the bnb chain id + ChainId uint32 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -96,6 +98,13 @@ func (m *Params) GetAllowList() []string { return nil } +func (m *Params) GetChainId() uint32 { + if m != nil { + return m.ChainId + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "lorenzo.bnblightclient.v1.Params") } @@ -105,26 +114,27 @@ func init() { } var fileDescriptor_3608f71b6e08ae9c = []byte{ - // 293 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x3f, 0x4e, 0xc3, 0x30, - 0x1c, 0x85, 0x6b, 0x5a, 0x55, 0xaa, 0x07, 0x90, 0x02, 0x42, 0x01, 0x09, 0x13, 0x31, 0x40, 0x17, - 0x62, 0x55, 0xdd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, 0x97, 0xac, 0x84, 0xb1, 0x8b, 0xd1, - 0xf7, 0xdb, 0x39, 0x58, 0xde, 0x7f, 0x34, 0x08, 0x6c, 0x1b, 0x04, 0xbe, 0x1a, 0x04, 0x5e, 0x5b, - 0x34, 0xd8, 0xb6, 0x68, 0xf0, 0xd9, 0xa2, 0xc1, 0xc3, 0x22, 0x15, 0x36, 0xab, 0x58, 0x18, 0xeb, - 0x1c, 0xaf, 0x7a, 0x05, 0xd7, 0x51, 0x77, 0x60, 0xac, 0x25, 0xde, 0xb9, 0x7b, 0xfa, 0x6f, 0xcf, - 0x3e, 0x17, 0xdc, 0xb0, 0xb1, 0x33, 0x31, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xfc, 0x69, - 0xf6, 0x64, 0x01, 0x00, 0x00, + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x4f, 0x4b, 0xf3, 0x30, + 0x00, 0xc6, 0x97, 0x77, 0x7b, 0xa7, 0x0b, 0xa8, 0x50, 0x45, 0x3a, 0xc1, 0x58, 0x3c, 0xe8, 0x2e, + 0x36, 0xcc, 0xdd, 0x04, 0x0f, 0xee, 0xa4, 0x30, 0x64, 0xec, 0x22, 0x78, 0x09, 0x49, 0x1b, 0xda, + 0xb0, 0x34, 0x29, 0x4d, 0x56, 0xff, 0x7c, 0x0a, 0x3f, 0x82, 0x5f, 0x46, 0xf0, 0xb8, 0xa3, 0x47, + 0x59, 0x2f, 0x7e, 0x0c, 0x69, 0xea, 0x0e, 0x7a, 0x4b, 0x9e, 0xe7, 0x97, 0x07, 0xf2, 0x83, 0x27, + 0x52, 0x17, 0x5c, 0x3d, 0x6b, 0xcc, 0x14, 0x93, 0x22, 0x49, 0x6d, 0x24, 0x05, 0x57, 0x16, 0x97, + 0x43, 0x9c, 0xd3, 0x82, 0x66, 0x26, 0xcc, 0x0b, 0x6d, 0x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x12, + 0xaf, 0xb5, 0x96, 0xe7, 0xf8, 0xf1, 0xaf, 0x5b, 0xfb, 0x94, 0x73, 0xc3, 0xba, 0xce, 0xd3, 0xe8, + 0x3b, 0x00, 0x00, 0xff, 0xff, 0x46, 0xfe, 0x1a, 0x62, 0x82, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -163,6 +173,9 @@ func (this *Params) Equal(that interface{}) bool { return false } } + if this.ChainId != that1.ChainId { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -185,6 +198,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ChainId != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x28 + } if len(m.AllowList) > 0 { for iNdEx := len(m.AllowList) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.AllowList[iNdEx]) @@ -250,6 +268,9 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + if m.ChainId != 0 { + n += 1 + sovParams(uint64(m.ChainId)) + } return n } @@ -403,6 +424,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.AllowList = append(m.AllowList, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/bnblightclient/types/query.pb.go b/x/bnblightclient/types/query.pb.go index b4d6cdb9..70da899e 100644 --- a/x/bnblightclient/types/query.pb.go +++ b/x/bnblightclient/types/query.pb.go @@ -397,39 +397,39 @@ func init() { } var fileDescriptor_f139d6422d3b3b56 = []byte{ - // 499 bytes of a gzipped FileDescriptorProto + // 501 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x6e, 0xd3, 0x30, - 0x1c, 0xc6, 0x63, 0xd4, 0xe5, 0x60, 0x7a, 0x32, 0x13, 0xda, 0x22, 0x14, 0x98, 0x11, 0x68, 0x4c, - 0xab, 0xcd, 0x3a, 0xb8, 0x70, 0x41, 0xea, 0x69, 0x87, 0x1d, 0x46, 0x84, 0x38, 0x20, 0x24, 0xe4, - 0x14, 0x2b, 0x89, 0x94, 0xda, 0x59, 0xec, 0x4e, 0x14, 0xb4, 0x0b, 0x4f, 0x80, 0xe0, 0xb8, 0x47, - 0xe0, 0xc2, 0x63, 0xec, 0x38, 0x89, 0x0b, 0x27, 0x84, 0x5a, 0x1e, 0x04, 0xc5, 0x76, 0x4b, 0x03, - 0x5d, 0x53, 0x04, 0x97, 0x2a, 0x75, 0xfe, 0xdf, 0xf7, 0xfd, 0xfa, 0xef, 0x27, 0xc3, 0x3b, 0xb9, - 0x2c, 0xb9, 0x78, 0x23, 0x69, 0x2c, 0xe2, 0x3c, 0x4b, 0x52, 0xdd, 0xcf, 0x33, 0x2e, 0x34, 0x3d, - 0xd9, 0xa3, 0xc7, 0x43, 0x5e, 0x8e, 0x48, 0x51, 0x4a, 0x2d, 0xd1, 0xa6, 0x1b, 0x23, 0xf5, 0x31, - 0x72, 0xb2, 0x17, 0xac, 0x27, 0x32, 0x91, 0x66, 0x8a, 0x56, 0x4f, 0x56, 0x10, 0xdc, 0x48, 0xa4, - 0x4c, 0x72, 0x4e, 0x59, 0x91, 0x51, 0x26, 0x84, 0xd4, 0x4c, 0x67, 0x52, 0x28, 0xf7, 0xf6, 0xee, - 0xe5, 0xa9, 0xce, 0xb8, 0x71, 0xae, 0x60, 0x25, 0x1b, 0x38, 0x3f, 0xbc, 0x0e, 0xd1, 0x93, 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0xde, 0x43, 0xbb, 0x6b, 0x90, 0x33, 0x2d, 0x7c, 0x69, 0xc8, 0x7b, 0xcf, 0x2e, + 0x26, 0x3e, 0xb8, 0x9c, 0xf8, 0xe0, 0xfb, 0xc4, 0x07, 0xef, 0xa7, 0xbe, 0x73, 0x39, 0xf5, 0x9d, + 0xaf, 0x53, 0xdf, 0x79, 0xfe, 0x28, 0x4e, 0x55, 0x32, 0x8c, 0x70, 0x5f, 0x0c, 0xc8, 0xb1, 0x71, + 0xeb, 0x9c, 0x94, 0xb7, 0x59, 0x5f, 0x64, 0x73, 0xfb, 0x51, 0x97, 0xbc, 0xfe, 0x3d, 0x43, 0x8d, + 0x73, 0x26, 0x23, 0x57, 0xdf, 0x7c, 0x87, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x44, 0x8d, 0xaf, + 0x5e, 0xc1, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/bnblightclient/types/tx.pb.go b/x/bnblightclient/types/tx.pb.go index 87461d52..8b53396f 100644 --- a/x/bnblightclient/types/tx.pb.go +++ b/x/bnblightclient/types/tx.pb.go @@ -322,37 +322,37 @@ func init() { } var fileDescriptor_7077a7889346cb20 = []byte{ - // 471 bytes of a gzipped FileDescriptorProto + // 474 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x33, 0xad, 0x46, 0x3a, 0xf5, 0x1f, 0x43, 0xa1, 0xd9, 0x1c, 0xe2, 0x9a, 0x83, 0x94, - 0x95, 0x26, 0x76, 0x0b, 0x82, 0xeb, 0x41, 0xdc, 0x93, 0x07, 0x0b, 0x25, 0xea, 0xc5, 0x8b, 0xe4, - 0xcf, 0x30, 0x09, 0x24, 0x99, 0x30, 0x33, 0x2d, 0xad, 0x27, 0xf1, 0x2a, 0x88, 0x67, 0x3f, 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0x70, 0x2b, 0x43, 0xc5, 0x3d, 0xfe, 0xb3, 0x02, 0x57, 0xf7, 0x05, 0x45, 0x02, 0xde, 0x6a, + 0x76, 0xc4, 0xc3, 0x05, 0xa1, 0xed, 0xef, 0xb2, 0x76, 0xff, 0x43, 0x7c, 0xf1, 0x64, 0x06, 0xca, + 0xe0, 0xcd, 0xc6, 0x83, 0x8d, 0x96, 0x1d, 0x53, 0x6b, 0xad, 0x71, 0x77, 0x6d, 0x95, 0x58, 0xe7, + 0xe9, 0x4e, 0xea, 0x94, 0xa7, 0xb4, 0xdd, 0xf2, 0x9a, 0x4d, 0x61, 0x5d, 0xff, 0x78, 0x7e, 0x32, + 0x02, 0x93, 0xb7, 0xa7, 0x33, 0x1b, 0x9c, 0xcd, 0x6c, 0xf0, 0x7b, 0x66, 0x83, 0xaf, 0x73, 0xdb, + 0x38, 0x9b, 0xdb, 0xc6, 0xcf, 0xb9, 0x6d, 0xbc, 0x7b, 0x46, 0x63, 0x19, 0x1d, 0xfa, 0x4e, 0xc0, + 0x52, 0xfc, 0x4a, 0x1d, 0xbf, 0x7d, 0x50, 0x4c, 0x69, 0xc0, 0x12, 0x5c, 0xcd, 0xf3, 0x74, 0x8c, + 0x8f, 0xda, 0x43, 0x2d, 0x8f, 0x73, 0x22, 0xfc, 0x5e, 0x39, 0xd1, 0xbb, 0x7f, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x55, 0x15, 0xdb, 0x42, 0xac, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/btcstaking/types/staking_record.pb.go b/x/btcstaking/types/staking_record.pb.go index 3b8ef9b1..4af00278 100644 --- a/x/btcstaking/types/staking_record.pb.go +++ b/x/btcstaking/types/staking_record.pb.go @@ -4,9 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -109,8 +108,84 @@ func (m *BTCStakingRecord) GetChainId() uint32 { return 0 } +// BTCBStakingRecord defines the message for btcb staking record +type BTCBStakingRecord struct { + // tx_hash defines the tx hash + TxHash []byte `protobuf:"bytes,1,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` + // event_idx defines the event index + EventIdx uint64 `protobuf:"varint,2,opt,name=event_idx,json=eventIdx,proto3" json:"event_idx,omitempty"` + // receiver_addr defines the receiver address + ReceiverAddr string `protobuf:"bytes,3,opt,name=receiver_addr,json=receiverAddr,proto3" json:"receiver_addr,omitempty"` + // amount defines the stBTC amount + Amount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` + // chain_id defines the chain id + ChainId uint32 `protobuf:"varint,5,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *BTCBStakingRecord) Reset() { *m = BTCBStakingRecord{} } +func (m *BTCBStakingRecord) String() string { return proto.CompactTextString(m) } +func (*BTCBStakingRecord) ProtoMessage() {} +func (*BTCBStakingRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_8fe1ffedd1828bb5, []int{1} +} +func (m *BTCBStakingRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BTCBStakingRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BTCBStakingRecord.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 *BTCBStakingRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_BTCBStakingRecord.Merge(m, src) +} +func (m *BTCBStakingRecord) XXX_Size() int { + return m.Size() +} +func (m *BTCBStakingRecord) XXX_DiscardUnknown() { + xxx_messageInfo_BTCBStakingRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_BTCBStakingRecord proto.InternalMessageInfo + +func (m *BTCBStakingRecord) GetTxHash() []byte { + if m != nil { + return m.TxHash + } + return nil +} + +func (m *BTCBStakingRecord) GetEventIdx() uint64 { + if m != nil { + return m.EventIdx + } + return 0 +} + +func (m *BTCBStakingRecord) GetReceiverAddr() string { + if m != nil { + return m.ReceiverAddr + } + return "" +} + +func (m *BTCBStakingRecord) GetChainId() uint32 { + if m != nil { + return m.ChainId + } + return 0 +} + func init() { proto.RegisterType((*BTCStakingRecord)(nil), "lorenzo.btcstaking.v1.BTCStakingRecord") + proto.RegisterType((*BTCBStakingRecord)(nil), "lorenzo.btcstaking.v1.BTCBStakingRecord") } func init() { @@ -118,28 +193,32 @@ func init() { } var fileDescriptor_8fe1ffedd1828bb5 = []byte{ - // 330 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0x41, 0x4b, 0xc3, 0x30, - 0x14, 0xc7, 0x17, 0x9d, 0x9d, 0x0b, 0x9b, 0x48, 0x51, 0xd7, 0x0d, 0x2c, 0x45, 0x3d, 0x14, 0xc1, - 0x86, 0xe9, 0xc9, 0xa3, 0xf3, 0xa2, 0x20, 0x22, 0x9d, 0x27, 0x2f, 0x25, 0x4d, 0x42, 0x5b, 0x5c, - 0x9a, 0x91, 0x64, 0x65, 0xfa, 0x29, 0xfc, 0x58, 0x3b, 0xee, 0xe8, 0x51, 0xb6, 0x2f, 0x22, 0x4b, - 0x3a, 0xf4, 0xf6, 0xfe, 0xbf, 0xf7, 0x7f, 0xff, 0x90, 0xf7, 0xe0, 0xe5, 0x44, 0x48, 0x56, 0x7e, - 0x0a, 0x94, 0x6a, 0xa2, 0x34, 0x7e, 0x2f, 0xca, 0x0c, 0x55, 0x43, 0x54, 0x97, 0x89, 0x64, 0x44, - 0x48, 0x1a, 0x4d, 0xa5, 0xd0, 0xc2, 0x3d, 0xae, 0xbd, 0xd1, 0x9f, 0x37, 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1, 0xd1, 0x93, 0x5d, 0xe8, 0xd5, 0xcb, 0xe6, 0xfb, 0x44, 0x4c, 0xd0, 0xf6, 0x1a, 0xd5, 0x35, - 0x9a, 0xff, 0x3f, 0x89, 0xfe, 0x98, 0x32, 0x95, 0x3a, 0x66, 0x4d, 0x37, 0xbf, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x9f, 0x38, 0x65, 0x97, 0xb5, 0x01, 0x00, 0x00, + // 388 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0xce, 0xd2, 0x40, + 0x14, 0x85, 0x3b, 0x0a, 0x85, 0x4e, 0xc0, 0x68, 0x23, 0x5a, 0x35, 0x94, 0x06, 0x5d, 0x34, 0x26, + 0x76, 0x82, 0xc6, 0x85, 0x4b, 0xcb, 0x46, 0x12, 0x63, 0x4c, 0x61, 0xe5, 0xa6, 0x99, 0xce, 0x4c, + 0xda, 0x06, 0xda, 0x21, 0xd3, 0xa1, 0xa9, 0x3e, 0x85, 0x8f, 0xe4, 0x92, 0x25, 0x4b, 0xe3, 0x82, + 0x18, 0x78, 0x11, 0xc3, 0xb4, 0x20, 0x9a, 0x7f, 0xf1, 0xef, 0xee, 0x3d, 0x3d, 0xbd, 0x93, 0xef, + 0x9e, 0x0b, 0x5f, 0xae, 0xb8, 0x60, 0xf9, 0x37, 0x8e, 0x22, 0x49, 0x0a, 0x89, 0x97, 0x69, 0x1e, + 0xa3, 0x72, 0x82, 0x9a, 0x32, 0x14, 0x8c, 0x70, 0x41, 0xbd, 0xb5, 0xe0, 0x92, 0x9b, 0x83, 0xc6, + 0xeb, 0xfd, 0xf5, 0x7a, 0xe5, 0xe4, 0xe9, 0xc3, 0x98, 0xc7, 0x5c, 0x39, 0xd0, 0xa9, 0xaa, 0xcd, + 0xe3, 0x2d, 0x80, 0xf7, 0xfd, 0xc5, 0x74, 0x5e, 0xfb, 0x02, 0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, 0x06, 0xbf, 0x0f, 0x36, 0xf8, 0x7e, 0xb4, 0xb5, 0xdd, 0xd1, 0xd6, 0x7e, 0x1e, 0x6d, + 0xed, 0xcb, 0xbb, 0x38, 0x95, 0xc9, 0x26, 0xf2, 0x08, 0xcf, 0xd0, 0xc7, 0x3a, 0xdf, 0x57, 0x9f, + 0x4f, 0x09, 0x12, 0xbe, 0x42, 0xe7, 0xe3, 0x28, 0x5f, 0xa3, 0xea, 0xfa, 0x42, 0xe4, 0xd7, 0x35, + 0x2b, 0x22, 0x5d, 0x25, 0xfd, 0xe6, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x85, 0x94, 0x50, + 0x44, 0x02, 0x00, 0x00, } func (m *BTCStakingRecord) Marshal() (dAtA []byte, err error) { @@ -203,6 +282,63 @@ func (m *BTCStakingRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *BTCBStakingRecord) 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 *BTCBStakingRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BTCBStakingRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainId != 0 { + i = encodeVarintStakingRecord(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x28 + } + { + size := m.Amount.Size() + i -= size + if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintStakingRecord(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ReceiverAddr) > 0 { + i -= len(m.ReceiverAddr) + copy(dAtA[i:], m.ReceiverAddr) + i = encodeVarintStakingRecord(dAtA, i, uint64(len(m.ReceiverAddr))) + i-- + dAtA[i] = 0x1a + } + if m.EventIdx != 0 { + i = encodeVarintStakingRecord(dAtA, i, uint64(m.EventIdx)) + i-- + dAtA[i] = 0x10 + } + if len(m.TxHash) > 0 { + i -= len(m.TxHash) + copy(dAtA[i:], m.TxHash) + i = encodeVarintStakingRecord(dAtA, i, uint64(len(m.TxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintStakingRecord(dAtA []byte, offset int, v uint64) int { offset -= sovStakingRecord(v) base := offset @@ -245,6 +381,31 @@ func (m *BTCStakingRecord) Size() (n int) { return n } +func (m *BTCBStakingRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TxHash) + if l > 0 { + n += 1 + l + sovStakingRecord(uint64(l)) + } + if m.EventIdx != 0 { + n += 1 + sovStakingRecord(uint64(m.EventIdx)) + } + l = len(m.ReceiverAddr) + if l > 0 { + n += 1 + l + sovStakingRecord(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovStakingRecord(uint64(l)) + if m.ChainId != 0 { + n += 1 + sovStakingRecord(uint64(m.ChainId)) + } + return n +} + func sovStakingRecord(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -471,6 +632,194 @@ func (m *BTCStakingRecord) Unmarshal(dAtA []byte) error { } return nil } +func (m *BTCBStakingRecord) 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 ErrIntOverflowStakingRecord + } + 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: BTCBStakingRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BTCBStakingRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthStakingRecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthStakingRecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxHash = append(m.TxHash[:0], dAtA[iNdEx:postIndex]...) + if m.TxHash == nil { + m.TxHash = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EventIdx", wireType) + } + m.EventIdx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EventIdx |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReceiverAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + 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 ErrInvalidLengthStakingRecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReceiverAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + 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 ErrInvalidLengthStakingRecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipStakingRecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingRecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipStakingRecord(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/btcstaking/types/tx.pb.go b/x/btcstaking/types/tx.pb.go index 1f40cd1d..d4e57df3 100644 --- a/x/btcstaking/types/tx.pb.go +++ b/x/btcstaking/types/tx.pb.go @@ -714,55 +714,59 @@ func init() { func init() { proto.RegisterFile("lorenzo/btcstaking/v1/tx.proto", fileDescriptor_6be51bab5db52b8e) } var fileDescriptor_6be51bab5db52b8e = []byte{ - // 761 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0x41,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 0xa5, 0x4a, 0x2c, 0x78, 0xf8, 0xfe, 0xfe, 0x1e, 0x00, 0x00, 0xff, - 0xff, 0xd1, 0x9a, 0xb5, 0x53, 0x9f, 0x07, 0x00, 0x00, + // 822 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0x63, 0xda, 0x06, 0xf2, 0xb2, 0x64, 0x77, 0x87, 0xb2, 0x4d, 0xbd, 0xda, 0xa4, 0xb2, + 0xd8, 0xaa, 0xaa, 0x88, 0xbd, 0x0d, 0x12, 0xa8, 0x70, 0x40, 0x75, 0x44, 0xd5, 0x0a, 0x82, 0x2a, + 0x37, 0x15, 0x12, 0x97, 0xc8, 0xb1, 0xa7, 0x4e, 0xd4, 0xda, 0x13, 0x66, 0x26, 0x21, 0xe1, 0x02, + 0xea, 0x85, 0x03, 0x17, 0x4e, 0x5c, 0x80, 0x4f, 0xc0, 0xa5, 0x07, 0x3e, 0x44, 0x8f, 0x15, 0x27, + 0xd4, 0x43, 0x85, 0xda, 0x43, 0xbf, 0x06, 0xb2, 0x67, 0xe2, 0x38, 0x6d, 0xdc, 0x06, 0xf6, 0xd4, + 0xbe, 0x79, 0x6f, 0xde, 0xff, 0xf7, 0x5e, 0xdf, 0x9b, 0x1a, 0x4a, 0xc7, 0x84, 0xe2, 0xe0, 0x3b, + 0x62, 0xb4, 0xb8, 0xc3, 0xb8, 0x7d, 0xd4, 0x09, 0x3c, 0xa3, 0xbf, 0x61, 0xf0, 0x81, 0xde, 0xa5, + 0x84, 0x13, 0xf4, 0xae, 0xf4, 0xeb, 0x63, 0xbf, 0xde, 0xdf, 0x50, 0x97, 0x1c, 0xc2, 0x7c, 0xc2, + 0x0c, 0x9f, 0x45, 0xe1, 0x3e, 0xf3, 0x44, 0xbc, 0xba, 0x2c, 0x1c, 0xcd, 0xc8, 0x32, 0x84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 0x92, 0xab, 0xab, 0x0f, 0x85, 0xc9, 0xb4, 0x0e, 0xe4, 0x93, 0xab, 0x75, 0x4f, 0xf6, + 0x44, 0x98, 0x5a, 0x99, 0x29, 0x2c, 0x16, 0x39, 0x86, 0xc2, 0xad, 0x45, 0x58, 0x4b, 0x4f, 0x30, + 0x19, 0xa9, 0xbe, 0x9a, 0x35, 0x32, 0x56, 0x3b, 0x84, 0x47, 0x13, 0xf3, 0x7d, 0x4f, 0x2b, 0x92, + 0x71, 0xaa, 0x3e, 0x5b, 0xdc, 0x48, 0x47, 0x5d, 0xf8, 0xe1, 0xe6, 0x74, 0x5d, 0x31, 0xf7, 0xcf, + 0xae, 0x4a, 0xca, 0xf9, 0x55, 0x49, 0xf9, 0xe7, 0xaa, 0xa4, 0xfc, 0x7c, 0x5d, 0xca, 0x9c, 0x5f, + 0x97, 0x32, 0x7f, 0x5f, 0x97, 0x32, 0x5f, 0x6f, 0xce, 0xf8, 0xaf, 0x7b, 0x90, 0xfc, 0x72, 0x88, + 0x5e, 0xc8, 0x56, 0x36, 0xfa, 0x6c, 0xf8, 0xe0, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xd9, + 0x87, 0x66, 0xdd, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. From 5d363a6816fc296288beee743c584d5c1fd8b124 Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Thu, 25 Jul 2024 19:09:05 +0800 Subject: [PATCH 18/19] add chain-id --- x/bnblightclient/keeper/genesis.go | 2 +- x/bnblightclient/keeper/keeper.go | 6 ++++++ x/bnblightclient/keeper/proof.go | 17 +++++++++-------- x/bnblightclient/types/events.go | 10 ++++++---- x/bnblightclient/types/keys.go | 6 +++++- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/x/bnblightclient/keeper/genesis.go b/x/bnblightclient/keeper/genesis.go index 50c312fc..533c595a 100644 --- a/x/bnblightclient/keeper/genesis.go +++ b/x/bnblightclient/keeper/genesis.go @@ -28,7 +28,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { k.setLatestNumber(ctx, genState.Headers[len(genState.Headers)-1].Number) for _, record := range genState.Events { - k.setEvmEvent(ctx, record) + k.setEvmEvent(ctx, genState.Params.ChainId, record) } } diff --git a/x/bnblightclient/keeper/keeper.go b/x/bnblightclient/keeper/keeper.go index 98212c26..05fd98ff 100644 --- a/x/bnblightclient/keeper/keeper.go +++ b/x/bnblightclient/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) // Keeper is the keeper struct for the x/bnblightclient module @@ -22,3 +23,8 @@ func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, authority st authority: authority, } } + +// ChainID returns the chain id +func (k Keeper) ChainID(ctx sdk.Context) uint32 { + return k.GetParams(ctx).ChainId +} diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 26bf01ff..3c577730 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -142,10 +142,10 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types Identifier: identifier.Uint64(), Contract: log.Address.Bytes(), } - if k.hasEvmEvent(ctx, record) { + if k.hasEvmEvent(ctx, params.ChainId, record) { return nil, errorsmod.Wrapf(types.ErrInvalidEvent, "event identifier %d already exists", identifier.Uint64()) } - k.setEvmEvent(ctx, record) + k.setEvmEvent(ctx, params.ChainId, record) // btcContractAddress btcContractAddress, ok := eventArgs[0].(common.Address) @@ -175,27 +175,28 @@ func (k Keeper) parseEvents(ctx sdk.Context, receipt *evmtypes.Receipt) ([]types } bnbEvent := types.CrossChainEvent{ + TxHash: log.TxHash, Identifier: identifier.Uint64(), Sender: sender, PlanID: planID.Uint64(), BTCcontractAddress: btcContractAddress, - StakeAmount: stakeAmount, - StBTCAmount: stBTCAmount, + StakeAmount: *stakeAmount, + StBTCAmount: *stBTCAmount, } events = append(events, bnbEvent) } return events, nil } -func (k Keeper) hasEvmEvent(ctx sdk.Context, record *types.EvmEvent) bool { +func (k Keeper) hasEvmEvent(ctx sdk.Context, chainID uint32, record *types.EvmEvent) bool { store := ctx.KVStore(k.storeKey) - key := record.Key() + key := record.Key(chainID) return store.Has(key) } -func (k Keeper) setEvmEvent(ctx sdk.Context, record *types.EvmEvent) { +func (k Keeper) setEvmEvent(ctx sdk.Context, chainID uint32, record *types.EvmEvent) { store := ctx.KVStore(k.storeKey) - key := record.Key() + key := record.Key(chainID) bz := k.cdc.MustMarshal(record) store.Set(key[:], bz) diff --git a/x/bnblightclient/types/events.go b/x/bnblightclient/types/events.go index 44dd7713..267a0704 100644 --- a/x/bnblightclient/types/events.go +++ b/x/bnblightclient/types/events.go @@ -29,15 +29,17 @@ func ABIstakePlanHub() *abi.ABI { // CrossChainEvent is a struct that contains the sender, plan id, BTC contract address, stake amount, and stBTC amount. type CrossChainEvent struct { + // Note: TxHash is non-consensus data and untrustworthy + TxHash common.Hash `json:"tx_hash"` Identifier uint64 `json:"identifier"` Sender common.Address `json:"sender"` PlanID uint64 `json:"plan_id"` BTCcontractAddress common.Address `json:"btc_contract_address"` - StakeAmount *big.Int `json:"stake_amount"` - StBTCAmount *big.Int `json:"st_btc_amount"` + StakeAmount big.Int `json:"stake_amount"` + StBTCAmount big.Int `json:"st_btc_amount"` } // Key returns the unique key of the EvmEvent struct -func (e EvmEvent) Key() []byte { - return KeyEvmEvent(e.BlockNumber, e.Contract, e.Identifier) +func (e EvmEvent) Key(chainID uint32) []byte { + return KeyEvmEvent(chainID, e.BlockNumber, e.Contract, e.Identifier) } diff --git a/x/bnblightclient/types/keys.go b/x/bnblightclient/types/keys.go index 30762ea7..7dc37e46 100644 --- a/x/bnblightclient/types/keys.go +++ b/x/bnblightclient/types/keys.go @@ -45,9 +45,13 @@ func KeyLatestHeaderNumber() []byte { } // KeyEvmEvent returns the key for the cross chain event index -func KeyEvmEvent(blockNumber uint64, contract []byte, idx uint64) []byte { +func KeyEvmEvent(chainID uint32, blockNumber uint64, contract []byte, idx uint64) []byte { key := append([]byte{}, KeyPrefixEvmEvent...) + chainIDBz := sdk.Uint64ToBigEndian(uint64(chainID)) + key = append(key, chainIDBz...) + key = append(key, Delimiter...) + bumberBz := sdk.Uint64ToBigEndian(blockNumber) key = append(key, bumberBz...) key = append(key, Delimiter...) From 567c6fdf8fd4bc6d7b47715819fae6b2c1bc4c4b Mon Sep 17 00:00:00 2001 From: happycoder9345 Date: Wed, 31 Jul 2024 09:36:15 +0800 Subject: [PATCH 19/19] implement btcb staking --- x/bnblightclient/keeper/proof.go | 4 +- x/bnblightclient/types/proof.go | 39 +++++++++++++++++-- x/btcstaking/keeper/keeper.go | 1 + x/btcstaking/keeper/msg_server.go | 4 +- x/btcstaking/keeper/staking.go | 52 ++++++++++++++++++++++++++ x/btcstaking/types/expected_keepers.go | 9 ++++- 6 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 x/btcstaking/keeper/staking.go diff --git a/x/bnblightclient/keeper/proof.go b/x/bnblightclient/keeper/proof.go index 3c577730..b876be80 100644 --- a/x/bnblightclient/keeper/proof.go +++ b/x/bnblightclient/keeper/proof.go @@ -21,7 +21,7 @@ import ( // receipt - the EVM transaction receipt to verify // proof - the proof object containing the necessary data for verification // Returns an array of BNBCrossChainEvent and an error if the verification fails. -func (k Keeper) VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof types.Proof) ([]types.CrossChainEvent, error) { +func (k Keeper) VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof *types.Proof) ([]types.CrossChainEvent, error) { if err := k.verifyProof(ctx, receipt, proof); err != nil { return nil, err } @@ -55,7 +55,7 @@ func (k Keeper) GetAllEvmEvents(ctx sdk.Context) (events []*types.EvmEvent) { return events } -func (k Keeper) verifyProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof types.Proof) error { +func (k Keeper) verifyProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof *types.Proof) error { if receipt.Status != evmtypes.ReceiptStatusSuccessful { return errorsmod.Wrapf(types.ErrInvalidTransaction, "cannot verify failed transactions") } diff --git a/x/bnblightclient/types/proof.go b/x/bnblightclient/types/proof.go index 8bb5c3f2..2c2a5e9c 100644 --- a/x/bnblightclient/types/proof.go +++ b/x/bnblightclient/types/proof.go @@ -2,11 +2,12 @@ package types import ( "encoding/base64" + "encoding/json" "errors" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/core/types" + evmtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie" ) @@ -115,10 +116,10 @@ func (pm *ProofPath) valueIdx(key []byte) int { // Returns: // - *mptproof.MPTProof: a pointer to an MPTProof struct containing the index, value, and proof of the transaction. // - error: an error if the proof generation fails. -func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*types.Receipt) (*Proof, error) { +func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*evmtypes.Receipt) (*Proof, error) { db := trie.NewDatabase(rawdb.NewMemoryDatabase()) mpt := trie.NewEmpty(db) - receiptHash := types.DeriveSha(types.Receipts(receipts), mpt) + receiptHash := evmtypes.DeriveSha(evmtypes.Receipts(receipts), mpt) if receiptHash != root { return nil, errors.New("root hash mismatch") } @@ -141,3 +142,35 @@ func GenReceiptProof(txIndex uint64, root common.Hash, receipts []*types.Receipt return &res, nil } + +// UnmarshalProof unmarshals a byte slice into a Proof struct. +// +// Parameters: +// - data: a byte slice containing the JSON representation of a Proof struct. +// +// Returns: +// - *Proof: a pointer to a Proof struct if the unmarshalling is successful. +// - error: an error if the unmarshalling fails. +func UnmarshalProof(data []byte) (*Proof, error) { + var proof Proof + if err := json.Unmarshal(data, &proof); err != nil { + return nil, ErrInvalidProof + } + return &proof, nil +} + +// UnmarshalReceipt unmarshals the given data into an evmtypes.Receipt object. +// +// Parameters: +// - data: a byte slice containing the JSON-encoded receipt data. +// +// Returns: +// - *evmtypes.Receipt: a pointer to the unmarshaled receipt object. +// - error: an error if the unmarshaling process fails. +func UnmarshalReceipt(data []byte) (*evmtypes.Receipt, error) { + receipt := &evmtypes.Receipt{} + if err := receipt.UnmarshalJSON(data); err != nil { + return nil, err + } + return receipt, nil +} \ No newline at end of file diff --git a/x/btcstaking/keeper/keeper.go b/x/btcstaking/keeper/keeper.go index 85fa5d91..485dd615 100644 --- a/x/btcstaking/keeper/keeper.go +++ b/x/btcstaking/keeper/keeper.go @@ -20,6 +20,7 @@ type ( bankKeeper bankkeeper.Keeper btclcKeeper types.BTCLightClientKeeper + bnbLcKeeper types.BNBLightClientKeeper evmKeeper types.EvmKeeper diff --git a/x/btcstaking/keeper/msg_server.go b/x/btcstaking/keeper/msg_server.go index 44ef0f2a..f744966a 100644 --- a/x/btcstaking/keeper/msg_server.go +++ b/x/btcstaking/keeper/msg_server.go @@ -292,8 +292,8 @@ func (ms msgServer) Burn(goCtx context.Context, req *types.MsgBurnRequest) (*typ } // CreateBTCStakingFromBNB implements types.MsgServer. -func (ms msgServer) CreateBTCStakingFromBNB(context.Context, *types.MsgCreateBTCStakingFromBNB) (*types.MsgCreateBTCStakingFromBNBResponse, error) { - panic("unimplemented") +func (ms msgServer) CreateBTCStakingFromBNB(goctx context.Context, req *types.MsgCreateBTCStakingFromBNB) (*types.MsgCreateBTCStakingFromBNBResponse, error) { + return &types.MsgCreateBTCStakingFromBNBResponse{}, nil } func findReceiver(receivers []*types.Receiver, name string) (int, *types.Receiver) { diff --git a/x/btcstaking/keeper/staking.go b/x/btcstaking/keeper/staking.go new file mode 100644 index 00000000..29450232 --- /dev/null +++ b/x/btcstaking/keeper/staking.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + + bnblightclienttypes "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" + "github.com/Lorenzo-Protocol/lorenzo/v2/x/btcstaking/types" +) + +// DepositBTCB deposits BTCB to the staking module. +// +// ctx: the context of the current blockchain. +// depositor: the address of the depositor. +// receiptBz: the byte array representation of the receipt. +// proofBz: the byte array representation of the proof. +// error: returns an error if there was a problem with the deposit. +func (k Keeper) DepositBTCB(ctx sdk.Context, depositor sdk.AccAddress, receiptBz, proofBz []byte) error { + proof, err := bnblightclienttypes.UnmarshalProof(proofBz) + if err != nil { + return err + } + + receipt, err := bnblightclienttypes.UnmarshalReceipt(receiptBz) + if err != nil { + return err + } + + event,err := k.bnbLcKeeper.VerifyReceiptProof(ctx, receipt, proof) + if err != nil { + return err + } + + bridgeAddr := sdk.MustAccAddressFromBech32(k.GetParams(ctx).BridgeAddr) + totalStBTCAmt := new(big.Int) + for _, e := range event { + totalStBTCAmt = totalStBTCAmt.Add(totalStBTCAmt, &e.StBTCAmount) + } + + // mint stBTC to the bridgeAddr + totalStBTC := sdk.NewCoins(sdk.NewCoin(types.NativeTokenDenom, sdk.NewIntFromBigInt(totalStBTCAmt))) + if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, totalStBTC);err != nil { + return err + } + + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, bridgeAddr, totalStBTC) + if err != nil { + return err + } + return nil +} diff --git a/x/btcstaking/types/expected_keepers.go b/x/btcstaking/types/expected_keepers.go index a7b1d9b9..89b554fe 100644 --- a/x/btcstaking/types/expected_keepers.go +++ b/x/btcstaking/types/expected_keepers.go @@ -3,11 +3,13 @@ package types import ( big "math/big" + "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" + evmtypes "github.com/ethereum/go-ethereum/core/types" lrz "github.com/Lorenzo-Protocol/lorenzo/v2/types" + bnblightclienttypes "github.com/Lorenzo-Protocol/lorenzo/v2/x/bnblightclient/types" btclctypes "github.com/Lorenzo-Protocol/lorenzo/v2/x/btclightclient/types" - "github.com/btcsuite/btcd/chaincfg" ) type BTCLightClientKeeper interface { @@ -18,6 +20,11 @@ type BTCLightClientKeeper interface { GetFeeRate(ctx sdk.Context) uint64 } +// BNBLightClientKeeper is an expected keeper for the bnblightclient module +type BNBLightClientKeeper interface { + VerifyReceiptProof(ctx sdk.Context, receipt *evmtypes.Receipt, proof *bnblightclienttypes.Proof) ([]bnblightclienttypes.CrossChainEvent, error) +} + type EvmKeeper interface { ChainID() *big.Int }