Skip to content

Commit

Permalink
FAB-5625 Java SDK v1.1 commencement
Browse files Browse the repository at this point in the history
PS 3 Addressed Jim's review.
PS 4 Fixed  change in fabric error message.

Change-Id: I4d905b533d5888fb52245c6a3b1fe65b0c766d4d
Signed-off-by: rickr <[email protected]>
  • Loading branch information
cr22rc committed Aug 15, 2017
1 parent 11bd160 commit 8eca761
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 57 deletions.
58 changes: 22 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Java SDK for Hyperledger Fabric 1.0
# Java SDK for Hyperledger Fabric 1.1
Welcome to Java SDK for Hyperledger project. The SDK helps facilitate Java applications to manage the lifecycle of
Hyperledger channels and user chaincode. The SDK also provides a means to execute
user chaincode, query blocks
Expand All @@ -24,7 +24,6 @@ SDK's `Enrollment` interface.
* TCerts are not supported: JIRA FAB-1401
* HSM not supported. JIRA FAB-3137
* Single Crypto strength 256 JIRA FAB-2564
* Network configuration updates not supported JIRA FAB-3103



Expand All @@ -34,44 +33,44 @@ SDK's `Enrollment` interface.
`*************************************************`
## *v1.0.1*

This is git tagged v1.0.1 release of the SDK where there is no
### Git v1.0.1

There is a git tagged v1.0.1 release of the SDK where there is no
need to build the Hyperledger Fabric and Hyperledger Fabric CA described below.
The provided docker-compose.yaml for the integration tests should pull v1.0.1 tagged images from Docker hub.

Later versions of the SDK are NOT guaranteed to work with v1.0.1 tagged images of Hyperledger Fabric and Hyperledger Fabric CA.

The v1.0.1 version of the Hyperledger Fabric Java SDK is published to Maven so you can directly use in your application's pom.xml.

[Maven Repository Hyperledger Fabric Java SDK](https://mvnrepository.com/artifact/org.hyperledger.fabric-sdk-java/fabric-sdk-java)

_Make sure you're using docker images at the level of the Fabric that matches the level of the SDK you're using in your application._

<p &nbsp; />
<p &nbsp; />
### Using the SDK in your application

`*************************************************`
Add below code in your `pom.xml` to download fabric-sdk-java-1.0.1

```xml

## Valid builds of Fabric and Fabric-ca
<dependencies>
<dependency>
<groupId>org.hyperledger.fabric-sdk-java</groupId>
<artifactId>fabric-sdk-java</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
```

Hyperledger Fabric v1.1 is currently under active development and the very latest Hyperledger Fabric builds may not work with this sdk.
You should use the following commit levels of the Hyperledger projects:
<p &nbsp; />
<p &nbsp; />

<!--
[comment]: <> (****************************************************************************************************)
[comment]: <> (******* src/test/fabric_test_commitlevel.sh tells Jenkins to use the latest commit levels ******)
-->
`*************************************************`

| Project | Commit level | Date |
|:---------------|:------------------------------------------:|---------------------------:|
| fabric | 3a4b1f2bce86daa86c025a9244a90106a58bb54b | Jul 22 18:18:25 2017 +0000 |
| fabric-ca | bc2b642f4a9ef2dcb393bf7da512ce43e1ec1a68 | Jul 23 03:38:20 2017 -0400 |

You can clone these projects by going to the [Hyperledger repository](https://gerrit.hyperledger.org/r/#/admin/projects/).
## Latest builds of Fabric and Fabric-ca v1.1.0

As SDK development continues, this file will be updated with compatible Hyperledger Fabric and Fabric-ca commit levels.
Hyperledger Fabric v1.1.0 is currently under active development.

Once you have cloned `fabric` and `fabric-ca`, use the `git reset --hard commitlevel` to set your repositories to the correct commit.
You can clone these projects by going to the [Hyperledger repository](https://gerrit.hyperledger.org/r/#/admin/projects/).

## Working with the Fabric Vagrant environment
Vagrant is NOT required if your OS has Docker support and all the requirements needed to build directly in your
Expand Down Expand Up @@ -137,21 +136,8 @@ Alternatively, <code> mvn dependency:analyze-report </code> will produce a repor
## Using the SDK
The SDK's test cases uses chaincode in the SDK's source tree: `/src/test/fixture`

The SDK's JAR is in `target/fabric-sdk-java-1.0.0-SNAPSHOT.jar` and you will need the additional dependencies listed above.
When the SDK is published to `Maven` you will be able to simply include it in your application's `pom.xml`.

Add below code in your `pom.xml` to download fabric-sdk-java-1.0
The SDK's JAR is in `target/fabric-sdk-java-1.1.0-SNAPSHOT.jar` and you will need the additional dependencies listed above.

```xml

<dependencies>
<dependency>
<groupId>org.hyperledger.fabric-sdk-java</groupId>
<artifactId>fabric-sdk-java</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
```

### Compiling
To build this project, the following dependencies must be met
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>org.hyperledger.fabric-sdk-java</groupId>
<artifactId>fabric-sdk-java</artifactId>
<packaging>jar</packaging>
<version>${fabric.sdk.java.version}</version>
<version>${fabric.sdk.java.version}-SNAPSHOT</version>
<name>fabric-java-sdk</name>
<description>Java SDK for Hyperledger fabric project</description>
<url>https://www.hyperledger.org/community/projects</url>
Expand All @@ -28,7 +28,7 @@
<tag>fabric-sdk-java-1.0</tag>
</scm>
<properties>
<fabric.sdk.java.version>1.0.1</fabric.sdk.java.version>
<fabric.sdk.java.version>1.1.0</fabric.sdk.java.version>
<grpc.version>1.5.0</grpc.version><!-- CURRENT_GRPC_VERSION -->
<bouncycastle.version>1.57</bouncycastle.version>
<httpclient.version>4.5.3</httpclient.version>
Expand Down
28 changes: 14 additions & 14 deletions src/main/proto/common/configtx.proto
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright IBM Corp. 2017 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
*/

syntax = "proto3";
Expand All @@ -24,6 +14,13 @@ option java_package = "org.hyperledger.fabric.protos.common";

package common;

// ConfigType is an enumeration of possible types for the config. The type field in the config is
// an int32 for extensibility, but this enum type should generally be used to populate it
enum ConfigType {
CHANNEL = 0; // The original and default configuration type, defines parameters for the operation of a channel
RESOURCE = 1; // Defines a set of resource names, and their mapping to policies which restrict access to those resources
}

// ConfigEnvelope is designed to contain _all_ configuration for a chain with no dependency
// on previous configuration transactions.
//
Expand Down Expand Up @@ -64,7 +61,8 @@ message ConfigPolicySchema {}
// Config represents the config for a particular channel
message Config {
uint64 sequence = 1;
ConfigGroup channel_group = 2;
ConfigGroup channel_group = 2; // channel_group is a bad name for this, it should be changed to root when API breakage is allowed
int32 type = 3;
}

message ConfigUpdateEnvelope {
Expand All @@ -82,9 +80,11 @@ message ConfigUpdateEnvelope {
// 4. Each policy is checked against the signatures from the ConfigUpdateEnvelope, any failing to verify are rejected
// 5. The write_set is applied to the Config and the ConfigGroupSchema verifies that the updates were legal
message ConfigUpdate {
string channel_id = 1; // Which channel this config update is for
ConfigGroup read_set = 2; // ReadSet explicitly lists the portion of the config which was read, this should be sparse with only Version set
string channel_id = 1; // Which channel this config update is for
ConfigGroup read_set = 2; // ReadSet explicitly lists the portion of the config which was read, this should be sparse with only Version set
ConfigGroup write_set = 3; // WriteSet lists the portion of the config which was written, this should included updated Versions
int32 type = 4; // The type of config this update is intended for (usually a value from ConfigType enum) , must match the type in the Config message
map<string, bytes> isolated_data = 5; // Data which is not to be reflected in the resulting Config, but is still needed for some other purpose. For instance, rscc_seed_data
}

// ConfigGroup is the hierarchical data structure for holding config
Expand Down
22 changes: 22 additions & 0 deletions src/main/proto/ledger/rwset/kvrwset/kv_rwset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ option java_package = "org.hyperledger.fabric.protos.ledger.rwset.kvrwset";
package kvrwset;

// KVRWSet encapsulates the read-write set for a chaincode that operates upon a KV or Document data model
// This structure is used for both the public data and the private data
message KVRWSet {
repeated KVRead reads = 1;
repeated RangeQueryInfo range_queries_info = 2;
repeated KVWrite writes = 3;
}

// HashedRWSet encapsulates hashed representation of a private read-write set for KV or Document data model
message HashedRWSet {
repeated KVReadHash hashed_reads = 1;
repeated KVWriteHash hashed_writes = 2;
}

// KVRead captures a read operation performed during transaction simulation
// A 'nil' version indicates a non-existing key read by the transaction
message KVRead {
Expand All @@ -42,6 +49,21 @@ message KVWrite {
bytes value = 3;
}

// KVReadHash is similar to the KVRead in spirit. However, it captures the hash of the key instead of the key itself
// version is kept as is for now. However, if the version also needs to be privacy-protected, it would need to be the
// hash of the version and hence of 'bytes' type
message KVReadHash {
bytes key_hash = 1;
Version version = 2;
}

// KVWriteHash is similar to the KVWrite in spiritcaptures a write (update/delete) operation performed during transaction simulation
message KVWriteHash {
bytes key_hash = 1;
bool is_delete = 2;
bytes value_hash = 3;
}

// Version encapsulates the version of a Key
// A version of a committed key is maintained as the height of the transaction that committed the key.
// The height is represenetd as a tuple <blockNum, txNum> where the txNum is the height of the transaction
Expand Down
26 changes: 26 additions & 0 deletions src/main/proto/ledger/rwset/rwset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,30 @@ message TxReadWriteSet {
message NsReadWriteSet {
string namespace = 1;
bytes rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)
repeated CollectionHashedReadWriteSet collection_hashed_rwset = 3;
}

// CollectionHashedReadWriteSet encapsulate the hashed representation for the private read-write set for a collection
message CollectionHashedReadWriteSet {
string collection_name = 1;
bytes hashed_rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.HashedRWSet for KV and Document data models)
bytes pvt_rwset_hash = 3; // Hash of entire private read-write set for a specific collection. This helps in authenticating the private read-write set efficiently
}

// TxPvtReadWriteSet encapsulate the private read-write set for a transaction
message TxPvtReadWriteSet {
TxReadWriteSet.DataModel data_model = 1;
repeated NsPvtReadWriteSet ns_pvt_rwset = 2;
}

// NsPvtReadWriteSet encapsulates the private read-write set for a chaincode
message NsPvtReadWriteSet {
string namespace = 1;
repeated CollectionPvtReadWriteSet collection_pvt_rwset = 2;
}

// CollectionPvtReadWriteSet encapsulates the private read-write set for a collection
message CollectionPvtReadWriteSet {
string collection_name = 1;
bytes rwset = 2; // Data model specific serialized proto message (e.g., kvrwset.KVRWSet for KV and Document data models)
}
3 changes: 3 additions & 0 deletions src/main/proto/orderer/ab.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ option java_package = "org.hyperledger.fabric.protos.orderer";
package orderer;

message BroadcastResponse {
// Status code, which may be used to programatically respond to success/failure
common.Status status = 1;
// Info string which may contain additional information about the status returned
string info = 2;
}

message SeekNewest { }
Expand Down
1 change: 1 addition & 0 deletions src/main/proto/peer/chaincode.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ message ChaincodeID {
// the []byte-based current ChaincodeInput structure.
message ChaincodeInput {
repeated bytes args = 1;
map<string, bytes> decorations = 2;
}

// Carries the chaincode specification. This is the actual metadata required for
Expand Down
1 change: 1 addition & 0 deletions src/main/proto/peer/proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ message ChaincodeProposalPayload {

// Input contains the arguments for this invocation. If this invocation
// deploys a new chaincode, ESCC/VSCC are part of this field.
// This is usually a marshaled ChaincodeInvocationSpec
bytes input = 1;

// TransientMap contains data (e.g. cryptographic material) that might be used
Expand Down
8 changes: 4 additions & 4 deletions src/test/fixture/sdkintegration/.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ORG_HYPERLEDGER_FABRIC_SDKTEST_INTEGRATIONTESTS_TLS=false
ORG_HYPERLEDGER_FABRIC_SDKTEST_INTEGRATIONTESTS_CA_TLS=
#
#Image tags:
IMAGE_TAG_FABRIC=:x86_64-1.0.1
IMAGE_TAG_FABRIC_CA=:x86_64-1.0.1
#IMAGE_TAG_FABRIC=
#IMAGE_TAG_FABRIC_CA=
#IMAGE_TAG_FABRIC=:x86_64-1.0.1
#IMAGE_TAG_FABRIC_CA=:x86_64-1.0.1
IMAGE_TAG_FABRIC=
IMAGE_TAG_FABRIC_CA=
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void testEnrollNoKeyPair() throws Exception {
public void testRevokeNotAuthorized() throws Exception {

thrown.expect(RevocationException.class);
thrown.expectMessage("does not have attribute 'hf.Revoker'");
thrown.expectMessage("Error while revoking the user");

// See if a normal user can revoke the admin...
SampleUser user = getEnrolledUser(TEST_ADMIN_ORG);
Expand Down

0 comments on commit 8eca761

Please sign in to comment.