Skip to content

Commit 5520053

Browse files
author
Simon Stone
committed
[FAB-16669] Update gRPC and Protocol Buffers code
Update gRPC to 1.23.0 and Protocol Buffers to 3.9.1, along with the Gradle plugins. Update the protocol buffers generation to pull the Fabric protos from their new home, and remove the tokens protos at the same time. Signed-off-by: Simon Stone <[email protected]> Change-Id: I09b237139bcc41174aaa122741b226df84b4a1cd
1 parent abff28f commit 5520053

File tree

32 files changed

+9908
-14141
lines changed

32 files changed

+9908
-14141
lines changed

fabric-chaincode-integration-test/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
dependencies {
2-
compile project(':fabric-chaincode-docker')
3-
compile project(':fabric-chaincode-example-sacc-jars')
42
testCompile 'org.testcontainers:testcontainers:1.10.3'
53
testCompile 'org.hyperledger.fabric-sdk-java:fabric-sdk-java:1.4.4'
64
}
@@ -14,5 +12,6 @@ task getLatestDockerImages{
1412
}
1513
}
1614
compileJava.dependsOn project(':fabric-chaincode-docker').buildImage
15+
compileJava.dependsOn project(':fabric-chaincode-example-sacc-jars').jar
1716
test.dependsOn project.getLatestDockerImages
1817

fabric-chaincode-protos/build.gradle

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,50 @@ repositories {
1919
// Fabric branch to download proto files from
2020
def fabricBranch = 'master'
2121
// Fabric Github repository link
22-
def fabricRepo = 'https://raw.githubusercontent.com/hyperledger/fabric'
22+
def fabricRepo = 'https://raw.githubusercontent.com/hyperledger/fabric-protos'
2323
def protosDir = 'src/main/protos'
2424
// List of files to download
25-
def protoFiles = ['protos/common/common.proto' : "$protosDir/common/common.proto",
26-
'protos/ledger/queryresult/kv_query_result.proto': "$protosDir/ledger/queryresult/kv_query_result.proto",
27-
'protos/peer/chaincode.proto' : "$protosDir/peer/chaincode.proto",
28-
'protos/peer/chaincode_event.proto' : "$protosDir/peer/chaincode_event.proto",
29-
'protos/peer/chaincode_shim.proto' : "$protosDir/peer/chaincode_shim.proto",
30-
'protos/peer/proposal.proto' : "$protosDir/peer/proposal.proto",
31-
'protos/peer/proposal_response.proto' : "$protosDir/peer/proposal_response.proto",
32-
'protos/msp/identities.proto' : "$protosDir/msp/identities.proto",
33-
'protos/peer/transaction.proto' : "$protosDir/peer/transaction.proto",
34-
'protos/msp/msp_principal.proto' : "$protosDir/msp/msp_principal.proto",
35-
'protos/common/policies.proto' : "$protosDir/common/policies.proto",
36-
'protos/token/operations.proto' : "$protosDir/token/operations.proto",
37-
'protos/token/transaction.proto' : "$protosDir/token/transaction.proto"]
25+
def protoFiles = ['common/common.proto' : "$protosDir/common/common.proto",
26+
'ledger/queryresult/kv_query_result.proto': "$protosDir/ledger/queryresult/kv_query_result.proto",
27+
'peer/chaincode.proto' : "$protosDir/peer/chaincode.proto",
28+
'peer/chaincode_event.proto' : "$protosDir/peer/chaincode_event.proto",
29+
'peer/chaincode_shim.proto' : "$protosDir/peer/chaincode_shim.proto",
30+
'peer/proposal.proto' : "$protosDir/peer/proposal.proto",
31+
'peer/proposal_response.proto' : "$protosDir/peer/proposal_response.proto",
32+
'msp/identities.proto' : "$protosDir/msp/identities.proto",
33+
'peer/transaction.proto' : "$protosDir/peer/transaction.proto",
34+
'msp/msp_principal.proto' : "$protosDir/msp/msp_principal.proto",
35+
'common/policies.proto' : "$protosDir/common/policies.proto"]
3836

3937
buildscript {
4038
repositories {
4139
maven { url "https://plugins.gradle.org/m2/" }
4240
}
4341
dependencies {
44-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
42+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
4543
classpath 'de.undercouch:gradle-download-task:3.4.2'
4644
}
4745
}
4846

4947
dependencies {
50-
compile 'com.google.protobuf:protobuf-java:3.7.1'
51-
compile 'com.google.protobuf:protobuf-java-util:3.5.1'
52-
compile 'io.grpc:grpc-netty-shaded:1.9.0'
53-
compile 'io.grpc:grpc-protobuf:1.9.0'
54-
compile 'io.grpc:grpc-stub:1.9.0'
48+
compile 'com.google.protobuf:protobuf-java:3.9.1'
49+
compile 'com.google.protobuf:protobuf-java-util:3.9.1'
50+
compile 'io.grpc:grpc-netty-shaded:1.23.0'
51+
compile 'io.grpc:grpc-protobuf:1.23.0'
52+
compile 'io.grpc:grpc-stub:1.23.0'
5553
// Required if using Java 11+ as no longer bundled in the core libraries
5654
compile 'javax.annotation:javax.annotation-api:1.3.2'
5755
}
5856

5957
protobuf {
6058
protoc {
6159
// download the protobuf compiler
62-
artifact = 'com.google.protobuf:protoc:3.0.0'
60+
artifact = 'com.google.protobuf:protoc:3.9.1'
6361
}
6462
plugins {
6563
// define grpc plugin for the protobuf compiler
6664
grpc {
67-
artifact = 'io.grpc:protoc-gen-grpc-java:1.9.0'
65+
artifact = 'io.grpc:protoc-gen-grpc-java:1.23.0'
6866
}
6967
}
7068
generateProtoTasks {
Lines changed: 283 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,283 @@
1+
package org.hyperledger.fabric.protos.peer;
2+
3+
import static io.grpc.MethodDescriptor.generateFullMethodName;
4+
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
5+
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6+
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
7+
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
8+
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
9+
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
10+
import static io.grpc.stub.ClientCalls.futureUnaryCall;
11+
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
12+
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
13+
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
14+
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
15+
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
16+
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
17+
18+
/**
19+
* <pre>
20+
* Chaincode as a server - peer establishes a connection to the chaincode as a client
21+
* Currently only supports a stream connection.
22+
* </pre>
23+
*/
24+
@javax.annotation.Generated(
25+
value = "by gRPC proto compiler (version 1.23.0)",
26+
comments = "Source: peer/chaincode_shim.proto")
27+
public final class ChaincodeGrpc {
28+
29+
private ChaincodeGrpc() {}
30+
31+
public static final String SERVICE_NAME = "protos.Chaincode";
32+
33+
// Static method descriptors that strictly reflect the proto.
34+
private static volatile io.grpc.MethodDescriptor<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage,
35+
org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage> getConnectMethod;
36+
37+
@io.grpc.stub.annotations.RpcMethod(
38+
fullMethodName = SERVICE_NAME + '/' + "Connect",
39+
requestType = org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage.class,
40+
responseType = org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage.class,
41+
methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
42+
public static io.grpc.MethodDescriptor<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage,
43+
org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage> getConnectMethod() {
44+
io.grpc.MethodDescriptor<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage, org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage> getConnectMethod;
45+
if ((getConnectMethod = ChaincodeGrpc.getConnectMethod) == null) {
46+
synchronized (ChaincodeGrpc.class) {
47+
if ((getConnectMethod = ChaincodeGrpc.getConnectMethod) == null) {
48+
ChaincodeGrpc.getConnectMethod = getConnectMethod =
49+
io.grpc.MethodDescriptor.<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage, org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage>newBuilder()
50+
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
51+
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "Connect"))
52+
.setSampledToLocalTracing(true)
53+
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
54+
org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage.getDefaultInstance()))
55+
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
56+
org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage.getDefaultInstance()))
57+
.setSchemaDescriptor(new ChaincodeMethodDescriptorSupplier("Connect"))
58+
.build();
59+
}
60+
}
61+
}
62+
return getConnectMethod;
63+
}
64+
65+
/**
66+
* Creates a new async stub that supports all call types for the service
67+
*/
68+
public static ChaincodeStub newStub(io.grpc.Channel channel) {
69+
return new ChaincodeStub(channel);
70+
}
71+
72+
/**
73+
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
74+
*/
75+
public static ChaincodeBlockingStub newBlockingStub(
76+
io.grpc.Channel channel) {
77+
return new ChaincodeBlockingStub(channel);
78+
}
79+
80+
/**
81+
* Creates a new ListenableFuture-style stub that supports unary calls on the service
82+
*/
83+
public static ChaincodeFutureStub newFutureStub(
84+
io.grpc.Channel channel) {
85+
return new ChaincodeFutureStub(channel);
86+
}
87+
88+
/**
89+
* <pre>
90+
* Chaincode as a server - peer establishes a connection to the chaincode as a client
91+
* Currently only supports a stream connection.
92+
* </pre>
93+
*/
94+
public static abstract class ChaincodeImplBase implements io.grpc.BindableService {
95+
96+
/**
97+
*/
98+
public io.grpc.stub.StreamObserver<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage> connect(
99+
io.grpc.stub.StreamObserver<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage> responseObserver) {
100+
return asyncUnimplementedStreamingCall(getConnectMethod(), responseObserver);
101+
}
102+
103+
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
104+
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
105+
.addMethod(
106+
getConnectMethod(),
107+
asyncBidiStreamingCall(
108+
new MethodHandlers<
109+
org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage,
110+
org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage>(
111+
this, METHODID_CONNECT)))
112+
.build();
113+
}
114+
}
115+
116+
/**
117+
* <pre>
118+
* Chaincode as a server - peer establishes a connection to the chaincode as a client
119+
* Currently only supports a stream connection.
120+
* </pre>
121+
*/
122+
public static final class ChaincodeStub extends io.grpc.stub.AbstractStub<ChaincodeStub> {
123+
private ChaincodeStub(io.grpc.Channel channel) {
124+
super(channel);
125+
}
126+
127+
private ChaincodeStub(io.grpc.Channel channel,
128+
io.grpc.CallOptions callOptions) {
129+
super(channel, callOptions);
130+
}
131+
132+
@java.lang.Override
133+
protected ChaincodeStub build(io.grpc.Channel channel,
134+
io.grpc.CallOptions callOptions) {
135+
return new ChaincodeStub(channel, callOptions);
136+
}
137+
138+
/**
139+
*/
140+
public io.grpc.stub.StreamObserver<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage> connect(
141+
io.grpc.stub.StreamObserver<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage> responseObserver) {
142+
return asyncBidiStreamingCall(
143+
getChannel().newCall(getConnectMethod(), getCallOptions()), responseObserver);
144+
}
145+
}
146+
147+
/**
148+
* <pre>
149+
* Chaincode as a server - peer establishes a connection to the chaincode as a client
150+
* Currently only supports a stream connection.
151+
* </pre>
152+
*/
153+
public static final class ChaincodeBlockingStub extends io.grpc.stub.AbstractStub<ChaincodeBlockingStub> {
154+
private ChaincodeBlockingStub(io.grpc.Channel channel) {
155+
super(channel);
156+
}
157+
158+
private ChaincodeBlockingStub(io.grpc.Channel channel,
159+
io.grpc.CallOptions callOptions) {
160+
super(channel, callOptions);
161+
}
162+
163+
@java.lang.Override
164+
protected ChaincodeBlockingStub build(io.grpc.Channel channel,
165+
io.grpc.CallOptions callOptions) {
166+
return new ChaincodeBlockingStub(channel, callOptions);
167+
}
168+
}
169+
170+
/**
171+
* <pre>
172+
* Chaincode as a server - peer establishes a connection to the chaincode as a client
173+
* Currently only supports a stream connection.
174+
* </pre>
175+
*/
176+
public static final class ChaincodeFutureStub extends io.grpc.stub.AbstractStub<ChaincodeFutureStub> {
177+
private ChaincodeFutureStub(io.grpc.Channel channel) {
178+
super(channel);
179+
}
180+
181+
private ChaincodeFutureStub(io.grpc.Channel channel,
182+
io.grpc.CallOptions callOptions) {
183+
super(channel, callOptions);
184+
}
185+
186+
@java.lang.Override
187+
protected ChaincodeFutureStub build(io.grpc.Channel channel,
188+
io.grpc.CallOptions callOptions) {
189+
return new ChaincodeFutureStub(channel, callOptions);
190+
}
191+
}
192+
193+
private static final int METHODID_CONNECT = 0;
194+
195+
private static final class MethodHandlers<Req, Resp> implements
196+
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
197+
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
198+
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
199+
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
200+
private final ChaincodeImplBase serviceImpl;
201+
private final int methodId;
202+
203+
MethodHandlers(ChaincodeImplBase serviceImpl, int methodId) {
204+
this.serviceImpl = serviceImpl;
205+
this.methodId = methodId;
206+
}
207+
208+
@java.lang.Override
209+
@java.lang.SuppressWarnings("unchecked")
210+
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
211+
switch (methodId) {
212+
default:
213+
throw new AssertionError();
214+
}
215+
}
216+
217+
@java.lang.Override
218+
@java.lang.SuppressWarnings("unchecked")
219+
public io.grpc.stub.StreamObserver<Req> invoke(
220+
io.grpc.stub.StreamObserver<Resp> responseObserver) {
221+
switch (methodId) {
222+
case METHODID_CONNECT:
223+
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.connect(
224+
(io.grpc.stub.StreamObserver<org.hyperledger.fabric.protos.peer.ChaincodeShim.ChaincodeMessage>) responseObserver);
225+
default:
226+
throw new AssertionError();
227+
}
228+
}
229+
}
230+
231+
private static abstract class ChaincodeBaseDescriptorSupplier
232+
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
233+
ChaincodeBaseDescriptorSupplier() {}
234+
235+
@java.lang.Override
236+
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
237+
return org.hyperledger.fabric.protos.peer.ChaincodeShim.getDescriptor();
238+
}
239+
240+
@java.lang.Override
241+
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
242+
return getFileDescriptor().findServiceByName("Chaincode");
243+
}
244+
}
245+
246+
private static final class ChaincodeFileDescriptorSupplier
247+
extends ChaincodeBaseDescriptorSupplier {
248+
ChaincodeFileDescriptorSupplier() {}
249+
}
250+
251+
private static final class ChaincodeMethodDescriptorSupplier
252+
extends ChaincodeBaseDescriptorSupplier
253+
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
254+
private final String methodName;
255+
256+
ChaincodeMethodDescriptorSupplier(String methodName) {
257+
this.methodName = methodName;
258+
}
259+
260+
@java.lang.Override
261+
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
262+
return getServiceDescriptor().findMethodByName(methodName);
263+
}
264+
}
265+
266+
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
267+
268+
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
269+
io.grpc.ServiceDescriptor result = serviceDescriptor;
270+
if (result == null) {
271+
synchronized (ChaincodeGrpc.class) {
272+
result = serviceDescriptor;
273+
if (result == null) {
274+
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
275+
.setSchemaDescriptor(new ChaincodeFileDescriptorSupplier())
276+
.addMethod(getConnectMethod())
277+
.build();
278+
}
279+
}
280+
}
281+
return result;
282+
}
283+
}

0 commit comments

Comments
 (0)