Skip to content

Commit 851c071

Browse files
committed
feat(core-api): add weaver protocol buffer definitions #1523
Adding the .proto definitions from here as discussed earlier with @VRamakrishna To-do: I skipped the fabric driver proto due to an error on account of the Fabric peer definitions not being present (unresolved import error). Fixes #1523 Signed-off-by: Peter Somogyvari <[email protected]>
1 parent 21fc5ba commit 851c071

31 files changed

+3566
-1
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"karma-webpack": "5.0.0",
120120
"lerna": "4.0.0",
121121
"lint-staged": "11.1.2",
122+
"make-dir-cli": "3.0.0",
122123
"node-polyfill-webpack-plugin": "1.1.4",
123124
"npm-run-all": "4.1.5",
124125
"npm-watch": "0.11.0",

packages/cactus-core-api/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"scripts": {
1515
"generate-sdk": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
1616
"codegen:openapi": "npm run generate-sdk",
17+
"preproto:protoc-gen-ts": "make-dir ./src/main/typescript/generated/proto/protoc-gen-ts/weaver/common/protos/",
18+
"proto:protoc-gen-ts": "yarn run grpc_tools_node_protoc --plugin=protoc-gen-ts=../../node_modules/.bin/protoc-gen-ts --ts_out=grpc_js:./src/main/typescript/generated/proto/protoc-gen-ts/weaver/common/protos/ --proto_path ./src/main/proto/weaver/common/protos/ ./src/main/proto/weaver/common/protos/common/*.proto ./src/main/proto/weaver/common/protos/corda/*.proto ./src/main/proto/weaver/common/protos/driver/*.proto ./src/main/proto/weaver/common/protos/networks/*.proto ./src/main/proto/weaver/common/protos/relay/*.proto",
19+
"codegen:proto": "run-s proto:protoc-gen-ts",
1720
"codegen": "run-p 'codegen:*'",
1821
"watch": "npm-watch",
1922
"webpack": "npm-run-all webpack:dev",
@@ -69,7 +72,10 @@
6972
},
7073
"homepage": "https://github.com/hyperledger/cactus#readme",
7174
"devDependencies": {
75+
"@grpc/grpc-js": "1.3.6",
76+
"@grpc/proto-loader": "0.6.4",
7277
"@types/express": "4.17.13",
78+
"make-dir-cli": "3.0.0",
7379
"socket.io": "4.1.3",
7480
"typescript-optional": "2.0.1"
7581
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!--
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: CC-BY-4.0
5+
-->
6+
## protos
7+
8+
This repository contains the grpc service and protocol buffer definitions for the relay, drivers and other interop modules. protos
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
syntax = "proto3";
2+
3+
package common.access_control;
4+
5+
option java_package = "com.weaver.protos.common.access_control";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
7+
8+
// AccessControlPolicy specifies a set of data that can be accessed by some
9+
// SecurityGroup
10+
message AccessControlPolicy {
11+
string securityDomain = 1;
12+
repeated Rule rules = 2;
13+
}
14+
15+
// Rule represents a single data access rule for the AccessControlPolicy
16+
message Rule {
17+
string principal = 1;
18+
string principalType = 2;
19+
string resource = 3;
20+
bool read = 4;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
syntax = "proto3";
2+
3+
package common.ack;
4+
5+
option java_package = "com.weaver.protos.common.ack";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
7+
8+
// This message respresents "ACKs" sent between relay-relay,
9+
// relay-driver and relay-network
10+
message Ack {
11+
enum STATUS {
12+
OK = 0;
13+
ERROR = 1;
14+
};
15+
STATUS status = 2;
16+
string request_id = 3;
17+
// an error can have an associated string
18+
// this is the best way to represent this in protobuf
19+
string message = 4;
20+
}
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
syntax = "proto3";
2+
3+
package common.asset_locks;
4+
5+
option java_package = "com.weaver.protos.common.asset_locks";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
7+
8+
enum LockMechanism {
9+
HTLC = 0;
10+
}
11+
12+
message AssetLock {
13+
LockMechanism lockMechanism = 1;
14+
bytes lockInfo = 2;
15+
}
16+
17+
message AssetClaim {
18+
LockMechanism lockMechanism = 1;
19+
bytes claimInfo = 2;
20+
}
21+
22+
message AssetLockHTLC {
23+
bytes hashBase64 = 1;
24+
uint64 expiryTimeSecs = 2;
25+
enum TimeSpec {
26+
EPOCH = 0;
27+
DURATION = 1;
28+
}
29+
TimeSpec timeSpec = 3;
30+
}
31+
32+
message AssetClaimHTLC {
33+
bytes hashPreimageBase64 = 1;
34+
}
35+
36+
message AssetExchangeAgreement {
37+
string type = 1;
38+
string id = 2;
39+
string locker = 3;
40+
string recipient = 4;
41+
}
42+
43+
message FungibleAssetExchangeAgreement {
44+
string type = 1;
45+
uint64 numUnits = 2;
46+
string locker = 3;
47+
string recipient = 4;
48+
}
49+
50+
message AssetContractHTLC {
51+
string contractId = 1;
52+
AssetExchangeAgreement agreement = 2;
53+
AssetLockHTLC lock = 3;
54+
AssetClaimHTLC claim = 4;
55+
}
56+
57+
message FungibleAssetContractHTLC {
58+
string contractId = 1;
59+
FungibleAssetExchangeAgreement agreement = 2;
60+
AssetLockHTLC lock = 3;
61+
AssetClaimHTLC claim = 4;
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
syntax = "proto3";
2+
3+
package common.interop_payload;
4+
5+
option java_package = "com.weaver.protos.common.interop_payload";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
7+
8+
message InteropPayload {
9+
bytes payload = 1;
10+
string address = 2;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
syntax = "proto3";
2+
3+
package common.membership;
4+
5+
option java_package = "com.weaver.protos.common.membership";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
7+
8+
// Membership captures the members of an external entity such as a thing,
9+
// person, organization or groups of entities such as networks
10+
message Membership {
11+
string securityDomain = 1;
12+
map<string, Member> members = 2;
13+
}
14+
15+
// Member of a security group is represented by a set of public keys,
16+
// certificates or certificate authorities
17+
message Member {
18+
string value = 1;
19+
string type = 2;
20+
repeated string chain = 3;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
syntax = "proto3";
2+
3+
package common.proofs;
4+
option java_package = "com.weaver.protos.common.proofs";
5+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
6+
7+
message Proof {
8+
string signature = 1;
9+
string certificate = 2;
10+
}
11+
12+
message Proofs { repeated Proof proofs = 1; }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
syntax = "proto3";
2+
3+
package common.query;
4+
option java_package = "com.weaver.protos.common.query";
5+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
6+
7+
// the payload to define the data that is being requested
8+
message Query {
9+
repeated string policy = 1;
10+
string address = 2;
11+
string requesting_relay = 3;
12+
string requesting_network = 4;
13+
string certificate = 5;
14+
string requestor_signature = 6;
15+
string nonce = 7;
16+
string request_id = 8;
17+
string requesting_org = 9;
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
syntax = "proto3";
2+
3+
package common.state;
4+
option java_package = "com.weaver.protos.common.state";
5+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
6+
7+
// Metadata for a View
8+
message Meta {
9+
enum Protocol {
10+
BITCOIN = 0;
11+
ETHEREUM = 1;
12+
FABRIC = 3;
13+
CORDA = 4;
14+
}
15+
// Underlying distributed ledger protocol.
16+
Protocol protocol = 1;
17+
// What notion of time?
18+
// If the observer and network are synchronizing on a global clock
19+
// there won't be a need to distinguish between static and dynamic views.
20+
string timestamp = 2;
21+
// Notorization, SPV, ZKP, etc. Possibly enum
22+
string proof_type = 3;
23+
// The data field's serialization format (e.g. JSON, XML, Protobuf)
24+
string serialization_format = 4;
25+
}
26+
27+
message View {
28+
Meta meta = 1;
29+
// Represents the data playload of this view.
30+
// The representation of Fabric, Corda etc will be captured elsewhere.
31+
// For some protocols, like Bitcoin, the structure of an SPV proof is well known.
32+
bytes data = 2;
33+
}
34+
35+
// View represents the response from a remote network
36+
message ViewPayload {
37+
string request_id = 1;
38+
oneof state {
39+
View view = 2;
40+
string error = 3;
41+
};
42+
}
43+
44+
// the payload that is used for the communication between the requesting relay
45+
// and its network
46+
message RequestState {
47+
enum STATUS {
48+
// pending ACK from remote relay
49+
PENDING_ACK = 0;
50+
// Received ACK, waiting for data to be sent from remote relay
51+
PENDING = 1;
52+
ERROR = 2;
53+
COMPLETED = 3;
54+
};
55+
string request_id = 1;
56+
STATUS status = 2;
57+
oneof state {
58+
View view = 3;
59+
string error = 4;
60+
};
61+
}
62+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
syntax = "proto3";
2+
3+
package common.verification_policy;
4+
5+
option java_package = "com.weaver.protos.common.verification_policy";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/common";
7+
8+
// VerificationPolicy stores the rules around which parties from a foreign
9+
// network need to provide proof of a view in order for it to be deemed valid by
10+
// the Fabric network
11+
message VerificationPolicy {
12+
string securityDomain = 1;
13+
repeated Identifier identifiers = 2;
14+
}
15+
16+
// The Policy captures the list of parties that are required to provide proofs
17+
// of a view in order for the Fabric network to accept the view as valid.
18+
message Policy {
19+
string type = 1;
20+
repeated string criteria = 2;
21+
}
22+
23+
// List of identifiers for the VerificationPolicy
24+
message Identifier {
25+
// pattern defines the view/views that this rule applies to
26+
// A rule may contain a "*" at the end of the pattern
27+
string pattern = 1;
28+
Policy policy = 2;
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
package corda;
4+
5+
option java_package = "com.weaver.protos.corda";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/corda";
7+
8+
message ViewData {
9+
message Notarization {
10+
string signature = 1;
11+
string certificate = 2;
12+
string id = 3;
13+
}
14+
repeated Notarization notarizations = 1;
15+
// Bytes of InteropPayload
16+
bytes payload = 2;
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
syntax = "proto3";
2+
3+
package driver.driver;
4+
5+
import "common/ack.proto";
6+
import "common/query.proto";
7+
8+
option java_package = "com.weaver.protos.driver.driver";
9+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/driver";
10+
11+
service DriverCommunication {
12+
// the remote relay sends a RequestDriverState request to its driver with a
13+
// query defining the data it wants to receive
14+
rpc RequestDriverState(common.query.Query) returns (common.ack.Ack) {}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
syntax = "proto3";
2+
3+
package fabric.view_data;
4+
5+
option java_package = "com.weaver.protos.fabric.view_data";
6+
option go_package = "github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go/fabric";
7+
8+
import "peer/proposal_response.proto";
9+
10+
message FabricView {
11+
// `Response` from the peers
12+
// https://github.com/hyperledger/fabric-protos-go/blob/main/peer/proposal_response.pb.go#L113
13+
// We only need the `Payload` field though.
14+
protos.Response response = 1;
15+
// `ProposalResponsePayload` is the output produced by each peer and signed as a serialized blob
16+
// https://github.com/hyperledger/fabric-protos-go/blob/main/peer/proposal_response.pb.go#L176
17+
// `ProposalResponsePayload` contains an `Extension` field which is of type `ChaincodeAction`
18+
// https://github.com/hyperledger/fabric-protos-go/blob/main/peer/proposal.pb.go#L280
19+
// We only need the `ProposalHash`, `ChaincodeId` and `Response` fields.
20+
protos.ProposalResponsePayload proposal_response_payload = 3;
21+
// Each `Endorsement` is an identity coupled with a signature
22+
// https://github.com/hyperledger/fabric-protos-go/blob/main/peer/proposal_response.pb.go#L242
23+
repeated protos.Endorsement endorsements = 4;
24+
}

0 commit comments

Comments
 (0)