This should annotate a class that implements the Serializer interface
*/
@Retention(RUNTIME)
@Target({ElementType.TYPE, ElementType.TYPE_USE})
@@ -25,7 +25,14 @@
*
*/
enum TARGET {
- TRANSACTION, ALL
+ /**
+ * Target transaction functions.
+ */
+ TRANSACTION,
+ /**
+ * Target all elements.
+ */
+ ALL
}
/**
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Transaction.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Transaction.java
index 5bdf8c95..c9180ca4 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Transaction.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Transaction.java
@@ -29,20 +29,27 @@
public @interface Transaction {
/**
- * SUBMIT or EVALUATE semantics.
+ * The intended invocation style for a transaction function.
*/
enum TYPE {
- SUBMIT, EVALUATE
+ /**
+ * Transaction is used to submit updates to the ledger.
+ */
+ SUBMIT,
+ /**
+ * Transaction is evaluated to query information from the ledger.
+ */
+ EVALUATE
}
/**
* Submit semantics.
*
- * TRUE indicates that this function is intended to be called with the 'submit'
- * semantics
+ *
TRUE indicates that this function is intended to be called with the 'submit'
+ * semantics
*
- * FALSE indicates that this is intended to be called with the evaluate
- * semantics
+ *
FALSE indicates that this is intended to be called with the evaluate
+ * semantics
*
* @return boolean, default is true
* @deprecated Please use intent
@@ -52,11 +59,12 @@ enum TYPE {
/**
* What are submit semantics for this transaction.
- *
- * SUBMIT - indicates that this function is intended to be called with the
- * 'submit' semantics EVALUATE - indicates that this is intended to be called
- * with the 'evaluate' semantics
- *
+ *
+ *
SUBMIT
indicates that this function is intended to be called with the
+ * 'submit' semantics
+ *
EVALUATE
indicates that this is intended to be called
+ * with the 'evaluate' semantics
+ *
* @return submit semantics
*/
TYPE intent() default Transaction.TYPE.SUBMIT;
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/TxFunction.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/TxFunction.java
index b2df4203..860e2278 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/TxFunction.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/routing/TxFunction.java
@@ -15,13 +15,32 @@
public interface TxFunction {
interface Routing {
-
+ /**
+ * Method to route calls to the transaction function.
+ * @return a method.
+ */
Method getMethod();
+ /**
+ * The associated contract class.
+ * @return a contract class.
+ */
Class extends ContractInterface> getContractClass();
+ /**
+ * The associated contract instance.
+ * @return a contract.
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ * @throws InvocationTargetException
+ * @throws NoSuchMethodException
+ */
ContractInterface getContractInstance() throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException;
+ /**
+ * Name of the serializer used for the transaction function.
+ * @return a serializer name.
+ */
String getSerializerName();
}
@@ -31,7 +50,7 @@ interface Routing {
boolean isUnknownTx();
/**
- * @param unknown
+ * @param unknown true if the transaction is to be called when the request fn is unknown; otherwise false.
*/
void setUnknownTx(boolean unknown);
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/ledger/impl/package-info.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/ledger/impl/package-info.java
new file mode 100644
index 00000000..96b288ea
--- /dev/null
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/ledger/impl/package-info.java
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2023 IBM All Rights Reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.fabric.ledger.impl;
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/Chaincode.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/Chaincode.java
index 8209c666..046595df 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/Chaincode.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/Chaincode.java
@@ -39,23 +39,38 @@ public interface Chaincode {
* and{@link #invoke(ChaincodeStub)}
*/
class Response {
-
private final int statusCode;
private final String message;
private final byte[] payload;
+ /**
+ * Constructor.
+ * @param status a status object.
+ * @param message a response message.
+ * @param payload a response payload.
+ */
public Response(final Status status, final String message, final byte[] payload) {
this.statusCode = status.getCode();
this.message = message;
this.payload = payload;
}
+ /**
+ * Constructor.
+ * @param statusCode a status code.
+ * @param message a response message.
+ * @param payload a response payload.
+ */
public Response(final int statusCode, final String message, final byte[] payload) {
this.statusCode = statusCode;
this.message = message;
this.payload = payload;
}
+ /**
+ * Get the response status.
+ * @return status.
+ */
public Status getStatus() {
if (Status.hasStatusForCode(statusCode)) {
return Status.forCode(statusCode);
@@ -64,18 +79,34 @@ public Status getStatus() {
}
}
+ /**
+ * Get the response status code.
+ * @return status code.
+ */
public int getStatusCode() {
return statusCode;
}
+ /**
+ * Get the response message.
+ * @return a message.
+ */
public String getMessage() {
return message;
}
+ /**
+ * Get the response payload.
+ * @return payload bytes.
+ */
public byte[] getPayload() {
return payload;
}
+ /**
+ * Get the response payload as a UTF-8 string.
+ * @return a string.
+ */
public String getStringPayload() {
return (payload == null) ? null : new String(payload, UTF_8);
}
@@ -84,7 +115,18 @@ public String getStringPayload() {
* {@link Response} status enum.
*/
public enum Status {
- SUCCESS(200), ERROR_THRESHOLD(400), INTERNAL_SERVER_ERROR(500);
+ /**
+ * Successful response status.
+ */
+ SUCCESS(200),
+ /**
+ * Minimum threshold for as error status code.
+ */
+ ERROR_THRESHOLD(400),
+ /**
+ * Server-side error status.
+ */
+ INTERNAL_SERVER_ERROR(500);
private static final Map CODETOSTATUS = new HashMap<>();
private final int code;
@@ -93,10 +135,19 @@ public enum Status {
this.code = code;
}
+ /**
+ * Get the status code associated with this status object.
+ * @return a status code.
+ */
public int getCode() {
return code;
}
+ /**
+ * Get a status object for a given status code.
+ * @param code a status code.
+ * @return a status object.
+ */
public static Status forCode(final int code) {
final Status result = CODETOSTATUS.get(code);
if (result == null) {
@@ -105,6 +156,11 @@ public static Status forCode(final int code) {
return result;
}
+ /**
+ * Whether a status exists for a given status code.
+ * @param code a status code.
+ * @return True if a status for the code exists; otherwise false.
+ */
public static boolean hasStatusForCode(final int code) {
return CODETOSTATUS.containsKey(code);
}
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ChaincodeServerProperties.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ChaincodeServerProperties.java
index 6e9f0192..27c84257 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ChaincodeServerProperties.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ChaincodeServerProperties.java
@@ -8,14 +8,13 @@
import java.net.SocketAddress;
public final class ChaincodeServerProperties {
-
private SocketAddress serverAddress;
- private int maxInboundMetadataSize = 100 * 1024 * 1024;
- private int maxInboundMessageSize = 100 * 1024 * 1024;
- private int maxConnectionAgeSeconds = 5;
- private int keepAliveTimeoutSeconds = 20;
- private int permitKeepAliveTimeMinutes = 1;
- private int keepAliveTimeMinutes = 1;
+ private int maxInboundMetadataSize = 100 * 1024 * 1024; // checkstyle:ignore-line:MagicNumber
+ private int maxInboundMessageSize = 100 * 1024 * 1024; // checkstyle:ignore-line:MagicNumber
+ private int maxConnectionAgeSeconds = 5; // checkstyle:ignore-line:MagicNumber
+ private int keepAliveTimeoutSeconds = 20; // checkstyle:ignore-line:MagicNumber
+ private int permitKeepAliveTimeMinutes = 1; // checkstyle:ignore-line:MagicNumber
+ private int keepAliveTimeMinutes = 1; // checkstyle:ignore-line:MagicNumber
private boolean permitKeepAliveWithoutCalls = true;
private String keyPassword;
private String keyCertChainFile;
@@ -23,9 +22,24 @@ public final class ChaincodeServerProperties {
private String trustCertCollectionFile;
private boolean tlsEnabled = false;
+ /**
+ * Constructor using default configuration.
+ */
public ChaincodeServerProperties() {
}
+ /**
+ * Constructor.
+ * @param portChaincodeServer ignored.
+ * @param maxInboundMetadataSize the maximum metadata size allowed to be received by the server.
+ * @param maxInboundMessageSize the maximum message size allowed to be received by the server.
+ * @param maxConnectionAgeSeconds the maximum connection age in seconds.
+ * @param keepAliveTimeoutSeconds timeout for a keep-alive ping request in seconds.
+ * @param permitKeepAliveTimeMinutes the most aggressive keep-alive time clients are permitted to configure in minutes.
+ * @param keepAliveTimeMinutes delay before server sends a keep-alive in minutes.
+ * @param permitKeepAliveWithoutCalls whether clients are allowed to send keep-alive HTTP/2 PINGs even if there are no outstanding RPCs on the connection.
+ */
+ // checkstyle:ignore-next-line:ParameterNumber
public ChaincodeServerProperties(
final int portChaincodeServer, final int maxInboundMetadataSize, final int maxInboundMessageSize,
final int maxConnectionAgeSeconds, final int keepAliveTimeoutSeconds, final int permitKeepAliveTimeMinutes,
@@ -41,114 +55,226 @@ public ChaincodeServerProperties(
this.permitKeepAliveWithoutCalls = permitKeepAliveWithoutCalls;
}
+ /**
+ * The maximum size of metadata allowed to be received.
+ * @return The maximum metadata size allowed.
+ */
public int getMaxInboundMetadataSize() {
return maxInboundMetadataSize;
}
+ /**
+ * Sets the maximum metadata size allowed to be received by the server.
+ * @param maxInboundMetadataSize The new maximum size allowed for incoming metadata.
+ */
public void setMaxInboundMetadataSize(final int maxInboundMetadataSize) {
this.maxInboundMetadataSize = maxInboundMetadataSize;
}
+ /**
+ * The maximum message size allowed to be received by the server.
+ * @return the maximum message size allowed.
+ */
public int getMaxInboundMessageSize() {
return maxInboundMessageSize;
}
+ /**
+ * Sets the maximum message size allowed to be received by the server.
+ * @param maxInboundMessageSize The new maximum size allowed for incoming messages.
+ */
public void setMaxInboundMessageSize(final int maxInboundMessageSize) {
this.maxInboundMessageSize = maxInboundMessageSize;
}
+ /**
+ * The maximum connection age.
+ * @return The maximum connection age in seconds.
+ */
public int getMaxConnectionAgeSeconds() {
return maxConnectionAgeSeconds;
}
+ /**
+ * Specify a maximum connection age.
+ * @param maxConnectionAgeSeconds The maximum connection age in seconds.
+ */
public void setMaxConnectionAgeSeconds(final int maxConnectionAgeSeconds) {
this.maxConnectionAgeSeconds = maxConnectionAgeSeconds;
}
+ /**
+ * The timeout for a keep-alive ping requests.
+ * @return timeout in seconds.
+ */
public int getKeepAliveTimeoutSeconds() {
return keepAliveTimeoutSeconds;
}
+ /**
+ * Set the timeout for keep-alive ping requests.
+ * @param keepAliveTimeoutSeconds timeout in seconds.
+ */
public void setKeepAliveTimeoutSeconds(final int keepAliveTimeoutSeconds) {
this.keepAliveTimeoutSeconds = keepAliveTimeoutSeconds;
}
+ /**
+ * The most aggressive keep-alive time clients are permitted to configure.
+ * @return time in minutes.
+ */
public int getPermitKeepAliveTimeMinutes() {
return permitKeepAliveTimeMinutes;
}
+ /**
+ * Specify the most aggressive keep-alive time clients are permitted to configure.
+ * @param permitKeepAliveTimeMinutes time in minutes.
+ */
public void setPermitKeepAliveTimeMinutes(final int permitKeepAliveTimeMinutes) {
this.permitKeepAliveTimeMinutes = permitKeepAliveTimeMinutes;
}
+ /**
+ * The delay before the server sends a keep-alive.
+ * @return delay in minutes.
+ */
public int getKeepAliveTimeMinutes() {
return keepAliveTimeMinutes;
}
+ /**
+ * Set the delay before the server sends a keep-alive.
+ * @param keepAliveTimeMinutes delay in minutes.
+ */
public void setKeepAliveTimeMinutes(final int keepAliveTimeMinutes) {
this.keepAliveTimeMinutes = keepAliveTimeMinutes;
}
+ /**
+ * Whether clients are allowed to send keep-alive HTTP/2 PINGs even if there are no outstanding RPCs on the connection.
+ * @return true if clients are allowed to send keep-alive requests without calls; otherwise false.
+ */
public boolean getPermitKeepAliveWithoutCalls() {
return permitKeepAliveWithoutCalls;
}
+ /**
+ * Get the server socket address.
+ * @return a socket address.
+ */
public SocketAddress getServerAddress() {
return serverAddress;
}
+ /**
+ * Set the server socket address.
+ * @param address a socket address.
+ */
public void setServerAddress(final SocketAddress address) {
this.serverAddress = address;
}
+ /**
+ * Whether clients are allowed to send keep-alive HTTP/2 PINGs even if there are no outstanding RPCs on the connection.
+ * @return true if clients are allowed to send keep-alive requests without calls; otherwise false.
+ */
public boolean isPermitKeepAliveWithoutCalls() {
return permitKeepAliveWithoutCalls;
}
+ /**
+ * Specify whether clients are allowed to send keep-alive HTTP/2 PINGs even if there are no outstanding RPCs on the connection.
+ * @param permitKeepAliveWithoutCalls Whether to allow clients to send keep-alive requests without calls.
+ */
public void setPermitKeepAliveWithoutCalls(final boolean permitKeepAliveWithoutCalls) {
this.permitKeepAliveWithoutCalls = permitKeepAliveWithoutCalls;
}
+ /**
+ * Password used to access the server key.
+ * @return a password.
+ */
public String getKeyPassword() {
return keyPassword;
}
+ /**
+ * Set the password used to access the server key.
+ * @param keyPassword a password.
+ */
public void setKeyPassword(final String keyPassword) {
this.keyPassword = keyPassword;
}
+ /**
+ * Server keychain file name.
+ * @return a file name.
+ */
public String getKeyCertChainFile() {
return keyCertChainFile;
}
+ /**
+ * Set the server keychain file name.
+ * @param keyCertChainFile a file name.
+ */
public void setKeyCertChainFile(final String keyCertChainFile) {
this.keyCertChainFile = keyCertChainFile;
}
+ /**
+ * Server key file name.
+ * @return a file name.
+ */
public String getKeyFile() {
return keyFile;
}
+ /**
+ * Set the server key file name.
+ * @param keyFile a file name.
+ */
public void setKeyFile(final String keyFile) {
this.keyFile = keyFile;
}
+ /**
+ * Server trust certificate collection file name.
+ * @return a file name.
+ */
public String getTrustCertCollectionFile() {
return trustCertCollectionFile;
}
+ /**
+ * Set the server trust certificate collection file name.
+ * @param trustCertCollectionFile a file name.
+ */
public void setTrustCertCollectionFile(final String trustCertCollectionFile) {
this.trustCertCollectionFile = trustCertCollectionFile;
}
+ /**
+ * Whether TLS is enabled for the server.
+ * @return true if TLS is enabled; otherwise false.
+ */
public boolean isTlsEnabled() {
return tlsEnabled;
}
+ /**
+ * Set whether TLS is enabled for the server.
+ * @param tlsEnabled true to enable TLS; otherwise false.
+ */
public void setTlsEnabled(final boolean tlsEnabled) {
this.tlsEnabled = tlsEnabled;
}
+ /**
+ * Check that all the server property values are valid.
+ * @throws IllegalArgumentException if any properties are not valid.
+ */
public void validate() {
if (this.getServerAddress() == null) {
throw new IllegalArgumentException("chaincodeServerProperties.getServerAddress() must be set");
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ext/sbe/impl/package-info.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ext/sbe/impl/package-info.java
new file mode 100644
index 00000000..f4f3bb51
--- /dev/null
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ext/sbe/impl/package-info.java
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2023 IBM All Rights Reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.fabric.shim.ext.sbe.impl;
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProvider.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProvider.java
index 5610985b..dd15f05e 100644
--- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProvider.java
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProvider.java
@@ -11,12 +11,14 @@
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Context;
-import io.opentelemetry.instrumentation.grpc.v1_6.GrpcTracing;
-import io.opentelemetry.sdk.autoconfigure.OpenTelemetrySdkAutoConfiguration;
+import io.opentelemetry.instrumentation.grpc.v1_6.GrpcTelemetry;
+import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.hyperledger.fabric.traces.TracesProvider;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
public final class OpenTelemetryTracesProvider implements TracesProvider {
@@ -26,17 +28,31 @@ public final class OpenTelemetryTracesProvider implements TracesProvider {
private static final String CORE_CHAINCODE_ID_NAME = "CORE_CHAINCODE_ID_NAME";
private Tracer tracer;
- private GrpcTracing grpcTracer;
+ private GrpcTelemetry grpcTracer;
@Override
public void initialize(final Properties props) {
String serviceName = props.getProperty(CORE_CHAINCODE_ID_NAME, "unknown");
props.setProperty(ResourceAttributes.SERVICE_NAME.getKey(), serviceName);
- OpenTelemetry openTelemetry = OpenTelemetrySdkAutoConfiguration.initialize(false,
- new OpenTelemetryProperties(System.getenv(), System.getProperties(), props));
+ OpenTelemetry openTelemetry = AutoConfiguredOpenTelemetrySdk.builder()
+ .addPropertiesSupplier(() -> getOpenTelemetryProperties(props))
+ .build()
+ .getOpenTelemetrySdk();
+
tracer = openTelemetry.getTracerProvider().get("org.hyperledger.traces");
- grpcTracer = GrpcTracing.newBuilder(openTelemetry).build();
+ grpcTracer = GrpcTelemetry.create(openTelemetry);
+ }
+
+ private Map getOpenTelemetryProperties(final Properties props) {
+ Map results = new HashMap<>(System.getenv());
+
+ Properties systemProps = System.getProperties();
+ systemProps.stringPropertyNames().forEach(key -> results.put(key, systemProps.getProperty(key)));
+
+ props.stringPropertyNames().forEach(key -> results.put(key, props.getProperty(key)));
+
+ return results;
}
@Override
diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/package-info.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/package-info.java
new file mode 100644
index 00000000..b8aef10b
--- /dev/null
+++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/traces/impl/package-info.java
@@ -0,0 +1,6 @@
+/*
+ * Copyright 2023 IBM All Rights Reserved.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.hyperledger.fabric.traces.impl;
diff --git a/fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProviderTest.java b/fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProviderTest.java
index 3b900b36..7b03a3f2 100644
--- a/fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProviderTest.java
+++ b/fabric-chaincode-shim/src/test/java/org/hyperledger/fabric/traces/impl/OpenTelemetryTracesProviderTest.java
@@ -40,7 +40,7 @@
public final class OpenTelemetryTracesProviderTest {
- private class ContextGetterChaincode extends ChaincodeBase {
+ private final class ContextGetterChaincode extends ChaincodeBase {
@Override
public Response init(final ChaincodeStub stub) {
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e708b1c0..7454180f 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 05679dc3..98debb84 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 4f906e0c..744e882e 100755
--- a/gradlew
+++ b/gradlew
@@ -72,7 +72,7 @@ case "`uname`" in
Darwin* )
darwin=true
;;
- MINGW* )
+ MSYS* | MINGW* )
msys=true
;;
NONSTOP* )