Skip to content

Commit

Permalink
Data Module Proof of Concept Init (#124)
Browse files Browse the repository at this point in the history
* Add basic proto files

* Protogen

* Revert go.mod

* Fix go.mod

* Fix lint

* Add version

* Update Makefile

* Switch to third_party proto folder

* Ignore .idea

* update docs
  • Loading branch information
aaronc authored Nov 4, 2020
1 parent 2e69f71 commit 5d94cc4
Show file tree
Hide file tree
Showing 25 changed files with 3,986 additions and 136 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/proto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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:
paths:
- "**.proto"
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@master
- name: lint
run: make proto-lint-docker
breakage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: check-breakage
run: make proto-check-breaking-docker
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,7 @@ tags
# vscode
.vscode

# goland
.idea

build/
5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

35 changes: 0 additions & 35 deletions .idea/compiler.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/encodings.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/regen-ledger.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/sqldialects.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

58 changes: 3 additions & 55 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -295,87 +295,35 @@ devdoc-update:
### Protobuf ###
###############################################################################

proto-all: proto-tools proto-gen proto-lint proto-check-breaking proto-swagger-gen proto-format
proto-all: proto-gen proto-lint proto-check-breaking proto-format
.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-format

proto-gen:
@./scripts/protocgen.sh

proto-format:
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;

# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
proto-gen-any:
@./scripts/protocgen-any.sh

proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh

proto-lint:
@buf check lint --error-format=json

proto-check-breaking:
@buf check breaking --against-input '.git#branch=master'
@buf check breaking --against '.git#branch=master'

proto-lint-docker:
@$(DOCKER_BUF) check lint --error-format=json
.PHONY: proto-lint

proto-check-breaking-docker:
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master
.PHONY: proto-check-breaking-ci

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/3359e0bf2f8414d9687f9eecda67b899d64a9cd1/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.2

TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
TM_ABCI_TYPES = third_party/proto/tendermint/abci
TM_TYPES = third_party/proto/tendermint/types
TM_VERSION = third_party/proto/tendermint/version
TM_LIBS = third_party/proto/tendermint/libs/bits

GOGO_PROTO_TYPES = third_party/proto/gogoproto
COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
CONFIO_TYPES = third_party/proto/confio

proto-update-deps:
@mkdir -p $(GOGO_PROTO_TYPES)
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto

@mkdir -p $(COSMOS_PROTO_TYPES)
@curl -sSL $(COSMOS_PROTO_URL)/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto

## Importing of tendermint protobuf definitions currently requires the
## use of `sed` in order to build properly with cosmos-sdk's proto file layout
## (which is the standard Buf.build FILE_LAYOUT)
## Issue link: https://github.com/tendermint/tendermint/issues/5021
@mkdir -p $(TM_ABCI_TYPES)
@curl -sSL $(TM_URL)/abci/types.proto > $(TM_ABCI_TYPES)/types.proto

@mkdir -p $(TM_VERSION)
@curl -sSL $(TM_URL)/version/types.proto > $(TM_VERSION)/types.proto

@mkdir -p $(TM_TYPES)
@curl -sSL $(TM_URL)/types/types.proto > $(TM_TYPES)/types.proto
@curl -sSL $(TM_URL)/types/evidence.proto > $(TM_TYPES)/evidence.proto
@curl -sSL $(TM_URL)/types/params.proto > $(TM_TYPES)/params.proto
@curl -sSL $(TM_URL)/types/validator.proto > $(TM_TYPES)/validator.proto

@mkdir -p $(TM_CRYPTO_TYPES)
@curl -sSL $(TM_URL)/crypto/proof.proto > $(TM_CRYPTO_TYPES)/proof.proto
@curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto

@mkdir -p $(TM_LIBS)
@curl -sSL $(TM_URL)/libs/bits/types.proto > $(TM_LIBS)/types.proto

@mkdir -p $(CONFIO_TYPES)
@curl -sSL $(CONFIO_URL)/proofs.proto > $(CONFIO_TYPES)/proofs.proto
## insert go package option into proofs.proto file
## Issue link: https://github.com/confio/ics23/issues/32
@sed -i '4ioption go_package = "github.com/confio/ics23/go";' $(CONFIO_TYPES)/proofs.proto

.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-deps

###############################################################################
### Localnet ###
Expand Down
20 changes: 20 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: v1beta1
build:
roots:
- proto
- third_party/proto
lint:
use:
- DEFAULT
- COMMENTS
except:
- SERVICE_SUFFIX
ignore:
- cosmos
- gogoproto
breaking:
use:
- FILE
ignore:
- cosmos
- gogoproto
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.14
require (
github.com/cosmos/cosmos-sdk v0.40.0-rc1
github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25
github.com/gogo/protobuf v1.3.1
github.com/gorilla/mux v1.8.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.3.1
Expand Down
32 changes: 32 additions & 0 deletions proto/regen/data/v1alpha1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

package regen.data.v1alpha1;

option go_package = "github.com/regen-network/regen-ledger/x/data";

// EventAnchorData is an event emitted when data is anchored on-chain.
message EventAnchorData {

// cid is a Content Identifier for the data corresponding to the IPFS CID
// specification: https://github.com/multiformats/cid.
bytes cid = 1;
}

// EventAnchorData is an event emitted when data is signed on-chain.
message EventSignData {

// cid is a Content Identifier for the data corresponding to the IPFS CID
// specification: https://github.com/multiformats/cid.
bytes cid = 1;

// signers are the addresses of the accounts which have signed the data.
repeated string signers = 2;
}

// EventAnchorData is an event emitted when data is stored on-chain.
message EventStoreData {

// cid is a Content Identifier for the data corresponding to the IPFS CID
// specification: https://github.com/multiformats/cid.
bytes cid = 1;
}
10 changes: 10 additions & 0 deletions proto/regen/data/v1alpha1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
syntax = "proto3";

package regen.data.v1alpha1;

option go_package = "github.com/regen-network/regen-ledger/x/data";

// TODO
message GenesisState {

}
12 changes: 12 additions & 0 deletions proto/regen/data/v1alpha1/misc.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

package regen.data.v1alpha1;

option go_package = "github.com/regen-network/regen-ledger/x/data";

// Signers is an internal type for storing a list of signers in state.
message Signers {

// signers are the addresses of the accounts which have signed the data.
repeated string signers = 1;
}
35 changes: 35 additions & 0 deletions proto/regen/data/v1alpha1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";

package regen.data.v1alpha1;

import "google/protobuf/timestamp.proto";

option go_package = "github.com/regen-network/regen-ledger/x/data";

// Query is the regen.data.v1alpha1 Query service
service Query {

// Data queries data based on its CID.
rpc Data(QueryDataRequest) returns (QueryDataResponse);
}

// QueryDataRequest is the Query/Data request type.
message QueryDataRequest {

// cid is a Content Identifier for the data corresponding to the IPFS CID
// specification: https://github.com/multiformats/cid.
bytes cid = 1;
}

// QueryDataRequest is the Query/Data response type.
message QueryDataResponse {

// timestamp is the timestamp of the block at which the data was anchored.
google.protobuf.Timestamp timestamp = 1;

// signers are the addresses of the accounts which have signed the data.
repeated string signers = 2;

// content is the content of the data, if it was stored on-chain.
bytes content = 3;
}
Loading

0 comments on commit 5d94cc4

Please sign in to comment.