diff --git a/dependency-suppression.xml b/dependency-suppression.xml new file mode 100644 index 00000000..ead35887 --- /dev/null +++ b/dependency-suppression.xml @@ -0,0 +1,38 @@ + + + + + ^pkg:maven/org\.hyperledger\.fabric/fabric\-protos@.*$ + CVE-2022-31121 + + + + ^pkg:maven/org\.hyperledger\.fabric/fabric\-protos@.*$ + CVE-2022-36023 + + + + ^pkg:maven/io\.opentelemetry\.instrumentation/opentelemetry\-grpc\-1\.6@.*$ + CVE-2023-33953 + + + + ^pkg:maven/io\.opentelemetry\.instrumentation/opentelemetry\-grpc\-1\.6@.*$ + CVE-2023-32732 + + + + ^pkg:maven/org\.json/json@.*$ + CVE-2022-45688 + + diff --git a/examples/fabric-contract-example-as-service/build.gradle b/examples/fabric-contract-example-as-service/build.gradle index 52c3e933..f6c47455 100644 --- a/examples/fabric-contract-example-as-service/build.gradle +++ b/examples/fabric-contract-example-as-service/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version '2.0.3' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'java' } @@ -21,7 +21,7 @@ repositories { dependencies { compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.3.+' - compile group: 'org.json', name: 'json', version: '20180813' + compile 'org.json:json:20230618' testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' testImplementation 'org.assertj:assertj-core:3.11.1' testImplementation 'org.mockito:mockito-core:2.+' @@ -31,6 +31,7 @@ shadowJar { baseName = 'chaincode' version = null classifier = null + mergeServiceFiles() manifest { attributes 'Main-Class': 'org.example.Application' diff --git a/examples/fabric-contract-example-gradle-kotlin/build.gradle.kts b/examples/fabric-contract-example-gradle-kotlin/build.gradle.kts index 66795109..8d9aeab6 100644 --- a/examples/fabric-contract-example-gradle-kotlin/build.gradle.kts +++ b/examples/fabric-contract-example-gradle-kotlin/build.gradle.kts @@ -5,7 +5,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { - id("com.github.johnrengelman.shadow") version "5.2.0" + id("com.github.johnrengelman.shadow") version "7.1.2" id("org.jetbrains.kotlin.jvm") version "1.3.41" } @@ -20,7 +20,7 @@ java { dependencies { implementation("org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.0") - implementation("org.json:json:20180813") + implementation("org.json:json:20230618") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") testImplementation("org.junit.jupiter:junit-jupiter:5.4.2") @@ -44,6 +44,7 @@ tasks { baseName = "chaincode" version = null classifier = null + mergeServiceFiles() manifest { attributes(mapOf("Main-Class" to "org.hyperledger.fabric.contract.ContractRouter")) } diff --git a/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.jar b/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf0..afba1092 100644 Binary files a/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.jar and b/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.properties b/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.properties index 7c4388a9..4e86b927 100644 --- a/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/examples/fabric-contract-example-gradle-kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/fabric-contract-example-gradle-kotlin/gradlew b/examples/fabric-contract-example-gradle-kotlin/gradlew index 8e25e6c1..65dcd68d 100755 --- a/examples/fabric-contract-example-gradle-kotlin/gradlew +++ b/examples/fabric-contract-example-gradle-kotlin/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,84 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/fabric-contract-example-gradle-kotlin/gradlew.bat b/examples/fabric-contract-example-gradle-kotlin/gradlew.bat index 24467a14..6689b85b 100644 --- a/examples/fabric-contract-example-gradle-kotlin/gradlew.bat +++ b/examples/fabric-contract-example-gradle-kotlin/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +25,14 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,38 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/examples/fabric-contract-example-gradle/build.gradle b/examples/fabric-contract-example-gradle/build.gradle index 4b2f2553..d24a5581 100644 --- a/examples/fabric-contract-example-gradle/build.gradle +++ b/examples/fabric-contract-example-gradle/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version '2.0.3' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'java' } @@ -21,7 +21,7 @@ repositories { dependencies { compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.5.0' - compile group: 'org.json', name: 'json', version: '20180813' + compile 'org.json:json:20230618' testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' testImplementation 'org.assertj:assertj-core:3.11.1' testImplementation 'org.mockito:mockito-core:2.+' @@ -31,6 +31,7 @@ shadowJar { baseName = 'chaincode' version = null classifier = null + mergeServiceFiles() manifest { attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter' diff --git a/examples/ledger-api/build.gradle b/examples/ledger-api/build.gradle index d609f2a4..41aa7cc8 100644 --- a/examples/ledger-api/build.gradle +++ b/examples/ledger-api/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version '2.0.3' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'java' } @@ -21,7 +21,7 @@ repositories { dependencies { compile group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '1.4.5' - compile group: 'org.json', name: 'json', version: '20180813' + compile 'org.json:json:20230618' testImplementation 'org.junit.jupiter:junit-jupiter:5.4.2' testImplementation 'org.assertj:assertj-core:3.11.1' testImplementation 'org.mockito:mockito-core:2.+' @@ -31,6 +31,7 @@ shadowJar { baseName = 'chaincode' version = null classifier = null + mergeServiceFiles() manifest { attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter' diff --git a/fabric-chaincode-integration-test/build.gradle b/fabric-chaincode-integration-test/build.gradle index 9d47ffb1..41c58429 100644 --- a/fabric-chaincode-integration-test/build.gradle +++ b/fabric-chaincode-integration-test/build.gradle @@ -1,7 +1,7 @@ dependencies { implementation project(':fabric-chaincode-docker') implementation project(':fabric-chaincode-shim') - implementation group: 'org.json', name: 'json', version: '20180813' + implementation 'org.json:json:20230618' } diff --git a/fabric-chaincode-integration-test/src/contracts/bare-gradle/build.gradle b/fabric-chaincode-integration-test/src/contracts/bare-gradle/build.gradle index 51376299..d1a04496 100644 --- a/fabric-chaincode-integration-test/src/contracts/bare-gradle/build.gradle +++ b/fabric-chaincode-integration-test/src/contracts/bare-gradle/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'com.github.johnrengelman.shadow' version '5.2.0' id 'java' } @@ -18,18 +18,15 @@ repositories { } dependencies { - implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.5.1' - implementation group: 'org.hyperledger.fabric', name:'fabric-protos', version:'0.1.3' - testImplementation group: 'junit', name: 'junit', version: '4.12' - implementation group: 'commons-logging', name: 'commons-logging', version: '1.2' - implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' - implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0' + implementation'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1' + implementation 'org.hyperledger.fabric:fabric-protos:0.2.+' } shadowJar { baseName = 'chaincode' version = null classifier = null + mergeServiceFiles() manifest { attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter' diff --git a/fabric-chaincode-integration-test/src/contracts/bare-gradle/src/main/java/org/hyperledger/fabric/example/BareGradle.java b/fabric-chaincode-integration-test/src/contracts/bare-gradle/src/main/java/org/hyperledger/fabric/example/BareGradle.java index 20e80ae7..538e0c2b 100644 --- a/fabric-chaincode-integration-test/src/contracts/bare-gradle/src/main/java/org/hyperledger/fabric/example/BareGradle.java +++ b/fabric-chaincode-integration-test/src/contracts/bare-gradle/src/main/java/org/hyperledger/fabric/example/BareGradle.java @@ -5,14 +5,12 @@ import org.hyperledger.fabric.contract.Context; import org.hyperledger.fabric.contract.ContractInterface; -import org.hyperledger.fabric.contract.annotation.*; -import org.hyperledger.fabric.metrics.Metrics; -import org.hyperledger.fabric.metrics.MetricsProvider; -import org.hyperledger.fabric.shim.ledger.*; -import org.hyperledger.fabric.shim.*; - -import java.util.*; -import static java.nio.charset.StandardCharsets.UTF_8; +import org.hyperledger.fabric.contract.annotation.Contact; +import org.hyperledger.fabric.contract.annotation.Contract; +import org.hyperledger.fabric.contract.annotation.Default; +import org.hyperledger.fabric.contract.annotation.Info; +import org.hyperledger.fabric.contract.annotation.License; +import org.hyperledger.fabric.contract.annotation.Transaction; @Contract(name = "BareGradle", info = @Info(title = "BareGradle contract", diff --git a/fabric-chaincode-integration-test/src/contracts/bare-maven/pom.xml b/fabric-chaincode-integration-test/src/contracts/bare-maven/pom.xml index 5b215836..51e9df37 100644 --- a/fabric-chaincode-integration-test/src/contracts/bare-maven/pom.xml +++ b/fabric-chaincode-integration-test/src/contracts/bare-maven/pom.xml @@ -14,14 +14,6 @@ 2.5.1 - - 1.2.0 - 1.7.5 - - - 5.3.0-RC1 - 1.3.0-RC1 - @@ -49,75 +41,13 @@ compile - - org.hyperledger.fabric - fabric-protos - 0.1.3 - compile - - - - - - - - org.slf4j - slf4j-api - ${slf4j.version} - compile - - - ch.qos.logback - logback-classic - ${logback.version} - runtime - - - - - org.junit.jupiter - junit-jupiter-api - ${junit.jupiter.version} - compile - - - org.junit.jupiter - junit-jupiter-params - ${junit.jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.jupiter.version} - test - - - - org.mockito - mockito-core - 2.10.0 - - - - - org.json - json - 20180813 - - src - - - maven-surefire-plugin - 2.22.0 - maven-compiler-plugin - 3.1 + 3.11.0 ${java.version} ${java.version} @@ -126,7 +56,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.5.0 package @@ -136,6 +66,7 @@ chaincode + org.hyperledger.fabric.contract.ContractRouter @@ -158,5 +89,4 @@ - diff --git a/fabric-chaincode-integration-test/src/contracts/bare-maven/src/main/java/org/hyperledger/fabric/example/BareMaven.java b/fabric-chaincode-integration-test/src/contracts/bare-maven/src/main/java/org/hyperledger/fabric/example/BareMaven.java index 6ed910ed..8539bd6a 100644 --- a/fabric-chaincode-integration-test/src/contracts/bare-maven/src/main/java/org/hyperledger/fabric/example/BareMaven.java +++ b/fabric-chaincode-integration-test/src/contracts/bare-maven/src/main/java/org/hyperledger/fabric/example/BareMaven.java @@ -5,14 +5,12 @@ import org.hyperledger.fabric.contract.Context; import org.hyperledger.fabric.contract.ContractInterface; -import org.hyperledger.fabric.contract.annotation.*; -import org.hyperledger.fabric.metrics.Metrics; -import org.hyperledger.fabric.metrics.MetricsProvider; -import org.hyperledger.fabric.shim.ledger.*; -import org.hyperledger.fabric.shim.*; - -import java.util.*; -import static java.nio.charset.StandardCharsets.UTF_8; +import org.hyperledger.fabric.contract.annotation.Contact; +import org.hyperledger.fabric.contract.annotation.Contract; +import org.hyperledger.fabric.contract.annotation.Default; +import org.hyperledger.fabric.contract.annotation.Info; +import org.hyperledger.fabric.contract.annotation.License; +import org.hyperledger.fabric.contract.annotation.Transaction; @Contract(name = "BareMaven", info = @Info(title = "BareGradle contract", diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/build.gradle b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/build.gradle index 681668a3..8762d6bd 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/build.gradle +++ b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'java' } @@ -18,14 +18,15 @@ repositories { } dependencies { - implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.5.1' - testImplementation group: 'junit', name: 'junit', version: '4.12' + implementation'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1' + implementation 'org.hyperledger.fabric:fabric-protos:0.2.+' } shadowJar { baseName = 'chaincode' version = null classifier = null + mergeServiceFiles() manifest { attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter' diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.jar b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf0..e708b1c0 100644 Binary files a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.jar and b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.jar differ diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.properties b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.properties index f371643e..98debb84 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.properties +++ b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew index 8e25e6c1..4f906e0c 100755 --- a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew +++ b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -125,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew.bat b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew.bat index 24467a14..ac1b06f9 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew.bat +++ b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/src/main/java/org/hyperledger/fabric/example/AllLedgerAPI.java b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/src/main/java/org/hyperledger/fabric/example/AllLedgerAPI.java index 309bb09a..c0ea6944 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/src/main/java/org/hyperledger/fabric/example/AllLedgerAPI.java +++ b/fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/src/main/java/org/hyperledger/fabric/example/AllLedgerAPI.java @@ -3,17 +3,15 @@ */ package org.hyperledger.fabric.example; - - import org.hyperledger.fabric.contract.Context; import org.hyperledger.fabric.contract.ContractInterface; -import org.hyperledger.fabric.contract.annotation.*; - - -import org.hyperledger.fabric.ledger.*; - -import java.util.*; -import static java.nio.charset.StandardCharsets.UTF_8; +import org.hyperledger.fabric.contract.annotation.Contact; +import org.hyperledger.fabric.contract.annotation.Contract; +import org.hyperledger.fabric.contract.annotation.Default; +import org.hyperledger.fabric.contract.annotation.Info; +import org.hyperledger.fabric.contract.annotation.License; +import org.hyperledger.fabric.contract.annotation.Transaction; +import org.hyperledger.fabric.ledger.Ledger; @Contract(name = "AllLedgerAPI", info = @Info(title = "AllLedgerAPI contract", diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/build.gradle b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/build.gradle index 51376299..fa796caf 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/build.gradle +++ b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'com.github.johnrengelman.shadow' version '7.1.2' id 'java' } @@ -18,18 +18,17 @@ repositories { } dependencies { - implementation group: 'org.hyperledger.fabric-chaincode-java', name: 'fabric-chaincode-shim', version: '2.5.1' - implementation group: 'org.hyperledger.fabric', name:'fabric-protos', version:'0.1.3' - testImplementation group: 'junit', name: 'junit', version: '4.12' - implementation group: 'commons-logging', name: 'commons-logging', version: '1.2' - implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6' - implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.4.0' + implementation'org.hyperledger.fabric-chaincode-java:fabric-chaincode-shim:2.5.1' + implementation 'org.hyperledger.fabric:fabric-protos:0.2.+' + implementation 'commons-logging:commons-logging:1.2' + implementation 'com.google.code.gson:gson:2.10.1' } shadowJar { baseName = 'chaincode' version = null classifier = null + mergeServiceFiles() manifest { attributes 'Main-Class': 'org.hyperledger.fabric.contract.ContractRouter' diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.jar b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf0..e708b1c0 100644 Binary files a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.jar and b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.jar differ diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.properties b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.properties index f371643e..98debb84 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.properties +++ b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew index 8e25e6c1..4f906e0c 100755 --- a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew +++ b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -125,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew.bat b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew.bat index 24467a14..ac1b06f9 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew.bat +++ b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/gradlew.bat @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/AllAPI.java b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/AllAPI.java index 630c584f..5c58ba14 100644 --- a/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/AllAPI.java +++ b/fabric-chaincode-integration-test/src/contracts/fabric-shim-api/src/main/java/org/hyperledger/fabric/example/AllAPI.java @@ -5,12 +5,16 @@ import org.hyperledger.fabric.contract.Context; import org.hyperledger.fabric.contract.ContractInterface; -import org.hyperledger.fabric.contract.annotation.*; +import org.hyperledger.fabric.contract.annotation.Contact; +import org.hyperledger.fabric.contract.annotation.Contract; +import org.hyperledger.fabric.contract.annotation.Default; +import org.hyperledger.fabric.contract.annotation.Info; +import org.hyperledger.fabric.contract.annotation.License; +import org.hyperledger.fabric.contract.annotation.Transaction; import org.hyperledger.fabric.metrics.Metrics; import org.hyperledger.fabric.metrics.MetricsProvider; import org.hyperledger.fabric.shim.ledger.*; import org.hyperledger.fabric.shim.*; -import java.util.*; import static java.nio.charset.StandardCharsets.UTF_8; @Contract(name = "AllAPI", diff --git a/fabric-chaincode-integration-test/src/contracts/wrapper-maven/pom.xml b/fabric-chaincode-integration-test/src/contracts/wrapper-maven/pom.xml index c3df85b9..069665ac 100644 --- a/fabric-chaincode-integration-test/src/contracts/wrapper-maven/pom.xml +++ b/fabric-chaincode-integration-test/src/contracts/wrapper-maven/pom.xml @@ -14,14 +14,6 @@ 2.5.1 - - 1.2.0 - 1.7.5 - - - 5.3.0-RC1 - 1.3.0-RC1 - @@ -49,75 +41,13 @@ compile - - org.hyperledger.fabric - fabric-protos - 0.1.3 - compile - - - - - - - - org.slf4j - slf4j-api - ${slf4j.version} - compile - - - ch.qos.logback - logback-classic - ${logback.version} - runtime - - - - - org.junit.jupiter - junit-jupiter-api - ${junit.jupiter.version} - compile - - - org.junit.jupiter - junit-jupiter-params - ${junit.jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.jupiter.version} - test - - - - org.mockito - mockito-core - 2.10.0 - - - - - org.json - json - 20180813 - - src - - - maven-surefire-plugin - 2.22.0 - maven-compiler-plugin - 3.1 + 3.11.0 ${java.version} ${java.version} @@ -126,7 +56,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.5.0 package @@ -136,6 +66,7 @@ chaincode + org.hyperledger.fabric.contract.ContractRouter @@ -158,5 +89,4 @@ - diff --git a/fabric-chaincode-integration-test/src/contracts/wrapper-maven/src/main/java/org/hyperledger/fabric/example/WrapperMaven.java b/fabric-chaincode-integration-test/src/contracts/wrapper-maven/src/main/java/org/hyperledger/fabric/example/WrapperMaven.java index b92be287..436751ba 100644 --- a/fabric-chaincode-integration-test/src/contracts/wrapper-maven/src/main/java/org/hyperledger/fabric/example/WrapperMaven.java +++ b/fabric-chaincode-integration-test/src/contracts/wrapper-maven/src/main/java/org/hyperledger/fabric/example/WrapperMaven.java @@ -5,14 +5,12 @@ import org.hyperledger.fabric.contract.Context; import org.hyperledger.fabric.contract.ContractInterface; -import org.hyperledger.fabric.contract.annotation.*; -import org.hyperledger.fabric.metrics.Metrics; -import org.hyperledger.fabric.metrics.MetricsProvider; -import org.hyperledger.fabric.shim.ledger.*; -import org.hyperledger.fabric.shim.*; - -import java.util.*; -import static java.nio.charset.StandardCharsets.UTF_8; +import org.hyperledger.fabric.contract.annotation.Contact; +import org.hyperledger.fabric.contract.annotation.Contract; +import org.hyperledger.fabric.contract.annotation.Default; +import org.hyperledger.fabric.contract.annotation.Info; +import org.hyperledger.fabric.contract.annotation.License; +import org.hyperledger.fabric.contract.annotation.Transaction; @Contract(name = "WrapperMaven", info = @Info(title = "BareGradle contract", diff --git a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/util/InvokeHelper.java b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/util/InvokeHelper.java index b8ee128e..971cb252 100644 --- a/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/util/InvokeHelper.java +++ b/fabric-chaincode-integration-test/src/test/java/org/hyperleder/fabric/shim/integration/util/InvokeHelper.java @@ -1,11 +1,12 @@ package org.hyperleder.fabric.shim.integration.util; -import java.util.Map; -import java.util.stream.Collectors; - import org.hyperleder.fabric.shim.integration.util.Command.Result; import org.hyperleder.fabric.shim.integration.util.Peer.PeerBuilder; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + public class InvokeHelper { private String ccname; @@ -33,6 +34,8 @@ public String invoke(String org, String... args){ .trim(); if (!text.contains("result: status:200")){ + Command logsCommand = new Command(Arrays.asList("docker", "logs", "microfab"), orgEnv); + logsCommand.run(); throw new RuntimeException(text); } diff --git a/fabric-chaincode-shim/build.gradle b/fabric-chaincode-shim/build.gradle index 02daa4e5..86ee2bcd 100644 --- a/fabric-chaincode-shim/build.gradle +++ b/fabric-chaincode-shim/build.gradle @@ -8,7 +8,7 @@ mavenCentral() } dependencies { - classpath 'org.owasp:dependency-check-gradle:8.2.1' + classpath 'org.owasp:dependency-check-gradle:8.4.0' } } @@ -22,7 +22,7 @@ plugins { apply plugin: 'org.owasp.dependencycheck' checkstyle { - toolVersion '8.29' + toolVersion '10.12.2' configFile file("../ci/checkstyle/checkstyle.xml") configProperties = [root_dir: file("..") ] } @@ -34,6 +34,11 @@ checkstyleTest { source ='src/test/java' } +dependencyCheck { + suppressionFile='dependency-suppression.xml' + scanConfigurations = ['runtimeClasspath'] +} + check.dependsOn dependencyCheckAnalyze tasks.withType(org.gradle.api.tasks.testing.Test) { @@ -41,30 +46,32 @@ tasks.withType(org.gradle.api.tasks.testing.Test) { } dependencies { - implementation group: 'org.hyperledger.fabric', name:'fabric-protos', version:'0.2.0' - implementation 'org.bouncycastle:bcpkix-jdk18on:1.75' - implementation 'org.bouncycastle:bcprov-jdk18on:1.75' - implementation 'io.github.classgraph:classgraph:4.8.161' - implementation group: 'com.github.everit-org.json-schema', name: 'org.everit.json.schema', version: '1.14.2' + implementation 'org.hyperledger.fabric:fabric-protos:0.2.1' + implementation 'org.bouncycastle:bcpkix-jdk18on:1.76' + implementation 'org.bouncycastle:bcprov-jdk18on:1.76' + implementation 'io.github.classgraph:classgraph:4.8.162' + implementation 'com.github.everit-org.json-schema:org.everit.json.schema:1.14.2' implementation 'org.json:json:20230618' - implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.19.6' + implementation 'com.google.protobuf:protobuf-java-util:3.22.5' // Required if using Java 11+ as no longer bundled in the core libraries - testImplementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' - implementation 'io.grpc:grpc-netty-shaded:1.45.4' - implementation 'io.grpc:grpc-protobuf:1.45.4' - implementation 'io.grpc:grpc-stub:1.45.4' - - implementation platform("io.opentelemetry:opentelemetry-bom:1.6.0") - - implementation "io.opentelemetry:opentelemetry-api" - implementation "io.opentelemetry:opentelemetry-proto:1.6.0-alpha" - implementation "io.opentelemetry:opentelemetry-sdk" - implementation "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:1.6.0-alpha" - implementation "io.opentelemetry:opentelemetry-sdk-trace" + testImplementation 'javax.xml.bind:jaxb-api:2.3.1' + + implementation platform('io.grpc:grpc-bom:1.57.2') + implementation 'io.grpc:grpc-netty-shaded' + implementation 'io.grpc:grpc-protobuf' + implementation 'io.grpc:grpc-stub' + + implementation platform("io.opentelemetry:opentelemetry-bom:1.29.0") + + implementation 'io.opentelemetry:opentelemetry-api' + implementation 'io.opentelemetry.proto:opentelemetry-proto:1.0.0-alpha' + implementation 'io.opentelemetry:opentelemetry-sdk' + implementation 'io.opentelemetry:opentelemetry-sdk-extension-autoconfigure' + implementation 'io.opentelemetry:opentelemetry-sdk-trace' implementation 'io.opentelemetry:opentelemetry-exporter-otlp' - implementation 'io.opentelemetry:opentelemetry-extension-trace-propagators:1.6.0' - implementation "io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:1.5.3-alpha" + implementation 'io.opentelemetry:opentelemetry-extension-trace-propagators' + implementation 'io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:1.29.0-alpha' } dependencyCheck { diff --git a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Serializer.java b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Serializer.java index ba0ebb23..10ff45d6 100644 --- a/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Serializer.java +++ b/fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/annotation/Serializer.java @@ -15,7 +15,7 @@ * Class level annotation that defines the serializer that should be used to * convert objects to and from the wire format. * - * This should annotate a class that implements the Serializer interface + *

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 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* )