Skip to content

Commit

Permalink
proto: add buf.yaml, fix linting (#300)
Browse files Browse the repository at this point in the history
* add buf.yaml and make it work

* remove confio

* switch from master to main

* Update module/proto/peggy/v1/msgs.proto

Co-authored-by: Federico Kunze <[email protected]>
  • Loading branch information
tac0turtle and fedekunze committed Mar 23, 2021
1 parent 28cd2c5 commit ab480f4
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 83 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Protobuf
# Protobuf runs buf (https://buf.build/) lint and check-breakage
# This workflow is only run when a .proto file has been changed
on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@master
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.proto
- name: lint
run: cd module && make proto-lint
if: env.GIT_DIFF

breakage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.proto
- name: check-breakage
run: cd module && make proto-check-breaking
if: env.GIT_DIFF
8 changes: 5 additions & 3 deletions module/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PACKAGES=$(shell go list ./... | grep -v '/simulation')
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
Expand Down Expand Up @@ -71,10 +73,10 @@ proto-gen:
./contrib/local/protocgen.sh

proto-lint:
buf check lint --error-format=json
@$(DOCKER_BUF) check lint --error-format=json

proto-check-breaking:
buf check breaking --against-input '.git#branch=master'
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=main

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc3/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
Expand Down Expand Up @@ -178,4 +180,4 @@ buf-stamp:
touch $@

tools-clean:
rm -f proto-tools-stamp buf-stamp
rm -f proto-tools-stamp buf-stamp
39 changes: 39 additions & 0 deletions module/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: v1beta1

build:
roots:
- proto
- third_party/proto
excludes:
- third_party/proto/google/protobuf
lint:
use:
- DEFAULT
- COMMENTS
- FILE_LOWER_SNAKE_CASE
except:
- UNARY_RPC
- COMMENT_FIELD
- COMMENT_ENUM
- COMMENT_ENUM_VALUE
- COMMENT_RPC
- COMMENT_MESSAGE
- SERVICE_SUFFIX
- PACKAGE_VERSION_SUFFIX
- RPC_REQUEST_STANDARD_NAME
- RPC_RESPONSE_STANDARD_NAME
ignore:
- tendermint
- gogoproto
- cosmos_proto
- google
breaking:
use:
- FILE
except:
- FIELD_NO_DELETE
ignore:
- tendermint
- gogoproto
- cosmos_proto
- google
22 changes: 11 additions & 11 deletions module/proto/peggy/v1/attestation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ option go_package = "github.com/althea-net/peggy/module/x/peggy/types";
enum ClaimType {
option (gogoproto.goproto_enum_prefix) = false;

CLAIM_TYPE_UNKNOWN = 0 [(gogoproto.enumvalue_customname) = "CLAIM_TYPE_UNKNOWN" ];
CLAIM_TYPE_DEPOSIT = 1 [(gogoproto.enumvalue_customname) = "CLAIM_TYPE_DEPOSIT" ];
CLAIM_TYPE_WITHDRAW = 2 [(gogoproto.enumvalue_customname) = "CLAIM_TYPE_WITHDRAW"];
CLAIM_TYPE_ERC20_DEPLOYED = 3 [(gogoproto.enumvalue_customname) = "CLAIM_TYPE_ERC20_DEPLOYED"];
CLAIM_TYPE_LOGIC_CALL_EXECUTED = 4 [(gogoproto.enumvalue_customname) = "CLAIM_TYPE_LOGIC_CALL_EXECUTED"];
CLAIM_TYPE_UNSPECIFIED = 0;
CLAIM_TYPE_DEPOSIT = 1;
CLAIM_TYPE_WITHDRAW = 2;
CLAIM_TYPE_ERC20_DEPLOYED = 3;
CLAIM_TYPE_LOGIC_CALL_EXECUTED = 4;
}

// Attestation is an aggregate of `claims` that eventually becomes `observed` by
Expand All @@ -36,10 +36,10 @@ enum ClaimType {
// but there is no reason to store those exact details becuause the next message sender
// will kindly provide you with them.
message Attestation {
bool observed = 1;
repeated string votes = 2;
uint64 height = 3;
google.protobuf.Any claim = 4;
bool observed = 1;
repeated string votes = 2;
uint64 height = 3;
google.protobuf.Any claim = 4;
}

// ERC20Token unique identifier for an Ethereum ERC20 token.
Expand All @@ -50,7 +50,7 @@ message Attestation {
message ERC20Token {
string contract = 1;
string amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}
4 changes: 2 additions & 2 deletions module/proto/peggy/v1/ethereum_signer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum SignType {
option (gogoproto.goproto_enum_prefix) = false;
option (gogoproto.goproto_enum_stringer) = false;

SIGN_TYPE_UNKNOWN = 0;
SIGN_TYPE_UNSPECIFIED = 0;
SIGN_TYPE_ORCHESTRATOR_SIGNED_MULTI_SIG_UPDATE = 1;
SIGN_TYPE_ORCHESTRATOR_SIGNED_WITHDRAW_BATCH = 2;
SIGN_TYPE_ORCHESTRATOR_SIGNED_WITHDRAW_BATCH = 2;
}
34 changes: 16 additions & 18 deletions module/proto/peggy/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,39 +70,37 @@ option go_package = "github.com/althea-net/peggy/module/x/peggy/types";
// refer to not submitting a particular message, the third for submitting a different claim
// for the same Ethereum event
message Params {
option (gogoproto.stringer) = false;
option (gogoproto.stringer) = false;

string peggy_id = 1;
string contract_source_hash = 2;
string bridge_ethereum_address = 4;
uint64 bridge_chain_id = 5;
uint64 signed_valsets_window = 6;
uint64 signed_batches_window = 7;
uint64 signed_claims_window = 8;
uint64 target_batch_timeout = 10;
uint64 average_block_time = 11;
uint64 average_ethereum_block_time = 12;
bytes slash_fraction_valset = 13 [
string peggy_id = 1;
string contract_source_hash = 2;
string bridge_ethereum_address = 4;
uint64 bridge_chain_id = 5;
uint64 signed_valsets_window = 6;
uint64 signed_batches_window = 7;
uint64 signed_claims_window = 8;
uint64 target_batch_timeout = 10;
uint64 average_block_time = 11;
uint64 average_ethereum_block_time = 12;
bytes slash_fraction_valset = 13 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bytes slash_fraction_batch = 14 [
bytes slash_fraction_batch = 14 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bytes slash_fraction_claim = 15 [
bytes slash_fraction_claim = 15 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bytes slash_fraction_conflicting_claim = 16 [
bytes slash_fraction_conflicting_claim = 16 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 unbond_slashing_valsets_window = 17;

uint64 unbond_slashing_valsets_window = 17;
}


// GenesisState struct
message GenesisState {
Params params = 1;
Expand Down
3 changes: 2 additions & 1 deletion module/proto/peggy/v1/msgs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
option go_package = "github.com/althea-net/peggy/module/x/peggy/types";

// Msg defines the state transitions possible within gravity
service Msg {
rpc ValsetConfirm(MsgValsetConfirm) returns (MsgValsetConfirmResponse) {
option (google.api.http).post = "/peggy/v1/valset_confirm";
Expand Down Expand Up @@ -38,7 +39,7 @@ service Msg {
rpc SetOrchestratorAddress(MsgSetOrchestratorAddress) returns (MsgSetOrchestratorAddressResponse) {
option (google.api.http).post = "/peggy/v1/set_orchestrator_address";
}
rpc CancelSendToEth(MsgCancelSendToEth) returns(MsgCancelSendToEthResponse) {
rpc CancelSendToEth(MsgCancelSendToEth) returns (MsgCancelSendToEthResponse) {
option (google.api.http).post = "/peggy/v1/cancel_send_to_eth";
}
}
Expand Down
12 changes: 7 additions & 5 deletions module/proto/peggy/v1/pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/althea-net/peggy/module/x/peggy/types";

// IDSet represents a set of IDs
message IDSet { repeated uint64 ids = 1; }
message IDSet {
repeated uint64 ids = 1;
}

message BatchFees {
string token = 1;
string topOneHundred = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
}
message BatchFees {
string token = 1;
string top_one_hundred = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
}
Loading

0 comments on commit ab480f4

Please sign in to comment.