Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support staking btc by bnb chain #71

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
id: git_diff
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Lorenzo-Protocol/lorenzo

go 1.20
go 1.21

require (
cosmossdk.io/errors v1.0.1
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions proto/lorenzo/bnblightclient/v1/client.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";
package lorenzo.bnblightclient.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/Lorenzo-Protocol/lorenzo/x/bnblightclient/types";

message Header {
option (gogoproto.goproto_getters) = false;

// 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;
}
26 changes: 26 additions & 0 deletions proto/lorenzo/bnblightclient/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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;
// events defines the bnb chain generated events
repeated EvmEvent events = 3;
}

message EvmEvent {
// block_number defines the block number
uint64 block_number = 1;
// contract defines the contract
bytes contract = 2;
// index defines the unique identifier of the event
uint64 identifier = 3;
}
21 changes: 21 additions & 0 deletions proto/lorenzo/bnblightclient/v1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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;

// the stake plan hub contract address
string stake_plan_hub_address = 1;
// event_name defines the event name
string event_name = 2;
// the maximum number of bnb block headers to retain
uint64 retained_blocks = 3;
// list of people who can upload bnb block header information
repeated string allow_list = 4;

}
74 changes: 74 additions & 0 deletions proto/lorenzo/bnblightclient/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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}";
}

// 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";
}

// LatestHeader returns the latest header in bnb chain
rpc LatestHeader(QueryLatestHeaderRequest)
returns (QueryLatestHeaderResponse) {
option (google.api.http).get = "/lorenzo/bnblightclient/v1/latest_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 ];
}

// 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 ];
}

// QueryLatestHeaderRequest is the request type for the Query/LatestHeader
// RPC method.
message QueryLatestHeaderRequest {}

// QueryLatestHeaderResponse is the response type for the Query/LatestHeader
// RPC method.
message QueryLatestHeaderResponse {
// header holds the bnb light client header.
lorenzo.bnblightclient.v1.Header header = 1 [ (gogoproto.nullable) = false ];
}
65 changes: 65 additions & 0 deletions proto/lorenzo/bnblightclient/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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 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
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 {}

// MsgUpdateHeader defines the message for updating bnb light client header.
message MsgUpdateHeader {
option (cosmos.msg.v1.signer) = "signer";

lorenzo.bnblightclient.v1.Header header = 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";

// 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 {}
13 changes: 13 additions & 0 deletions proto/lorenzo/btcstaking/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -58,6 +61,16 @@ message MsgCreateBTCStaking {

message MsgCreateBTCStakingResponse {}

message MsgCreateBTCStakingFromBNB {
option (cosmos.msg.v1.signer) = "signer";

string signer = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
bytes receipt = 2;
bytes proof = 3;
}

message MsgCreateBTCStakingFromBNBResponse {}

message MsgBurnRequest {
option (cosmos.msg.v1.signer) = "signer";
string signer = 1;
Expand Down
Loading
Loading