Skip to content

Commit

Permalink
FAB-1084 Move MemberServices out of HFC
Browse files Browse the repository at this point in the history
To support the new member service aka COP,
MemberService.js has been moved to it's own
directory, hfc-cop, so that it can be published
as a separate npmjs package.  This also
required the remaining HFC code to be moved
to a new directory, hfc.  The build tasks
were modified to run against both directories.
The readthedocs files remain in the root
fabric-node-sdk directory.  FAB-1084

Patch set 1: Move hfc src to hfc directory and
add hfc-cop directory.
Patch set 2: Readme update in root.
Patch set 3: Remove MemberServices and references
in hfc and headless-tests. Pare down package.json
in root which is needed to npm install test
dependencies.
Patch set 4: Update commit message.
Patch set 5: Move FabricCOPImpl to hfc-cop.
Patch set 6: Change root package.json to point to
hfc and hfc-cop directories and remove relative
path to hfc from hfc-cop FabricCOPImpl requires.
Patch set 7: the following changes were made
- use 'hfc' and 'hfc-cop' modules instead of relative
paths so that each package's dependencies can be
properly found by npm
- added gulp watch for hfc-cop's dependencies in the
hfc folder
- added gulp watch to update installed hfc and hfc-cop
modules from source code changes during development
- set required node and npm versions to earlier
- updated how User object is obtained in tests with
test/unit/unit.js -> getSubmitter()
- updated README with the new developer workflow

Change-Id: I16c85d2e3b73dca883b56e106e35bf4fceb97a8b
Signed-off-by: cdaughtr <[email protected]>
Signed-off-by: Jim Zhang <[email protected]>
  • Loading branch information
jimthematrix committed Nov 30, 2016
1 parent 68d7280 commit 1f08e84
Show file tree
Hide file tree
Showing 64 changed files with 376 additions and 898 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
coverage
docs/gen
node_modules/*
hfc/node_modules/*
hfc-cop/node_modules/*
hfc-cop/lib/api.js
hfc-cop/lib/utils.js
hfc-cop/lib/Config.js
hfc-cop/lib/Remote.js
hfc-cop/lib/hash.js
hfc-cop/lib/impl/*
test/fixtures/src/github.com/example_cc/Dockerfile
test/fixtures/src/github.com/marbles_cc/Dockerfile
npm-shrinkwrap.json
npm-debug.log
tmp
.project
.DS_Store
hfc/.DS_Store
hfc-cop/.DS_Store
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,38 @@
[![Build Status](https://jenkins.hyperledger.org/buildStatus/icon?job=fabric-sdk-node-merge-x86_64)](https://jenkins.hyperledger.org/view/fabric-sdk-node/job/fabric-sdk-node-merge-x86_64/)
[![Documentation Status](https://readthedocs.org/projects/fabric-sdk-node/badge/?version=master)](http://fabric-sdk-node.readthedocs.io/en/master/?badge=master)

The Hyperledger Fabric Client SDK (HFC) provides a powerful and easy to use API to interact with a Hyperledger Fabric blockchain.
The Hyperledger Fabric Client SDK (HFC) makes it easy to use APIs to interact with a Hyperledger Fabric blockchain.

As an application developer, to learn about how to install and use the Node.js SDK, please visit the [fabric documentation](http://hyperledger-fabric.readthedocs.io/en/latest/Setup/NodeSDK-setup).

The following section targets a current or future contributor to this project itself. It describes the main object hierarchy, plus HFC's pluggability and extensibility design.
The following section targets a current or future contributor to this project itself.

### Build and Test
To build and test, the following pre-requisites must be installed first:
* node runtime version 4.3 or later (which also installs the npm tool)
* node runtime version 4.5 or later (which also installs the npm tool)
* npm tool version 2.15.9 or later
* gulp command
* docker (not required if you only want to run the headless tests with `npm test`, see below)

Clone the project and launch the following commands in the project root folder to install the dependencies and perform various tasks:
* `npm install` to install all dependencies
Clone the project and launch the following commands to install the dependencies and perform various tasks.

This project publishes two separate npm packages:
* `hfc` - main client for the Hyperledger Fabric. Applications can use this package to deploy chaincodes, submit transactions and make queries against a Hyperledger Fabric-based blockchain network.
* `hfc-cop` - client for the optional component in Hyperledger Fabric, [COP](https://github.com/hyperledger/fabric-cop). The COP component allows applications to enroll Peers and application users to establish trusted identities on the blockchain network. It also provides support for pseudonymous transaction submissions with Transaction Certificates. If the target blockchain network is configured with standard Certificate Authorities for trust anchors, then the application does not need to use this package.

In the project root folder:
* `npm install` to install dependencies
* `gulp cop` to copy common dependent modules from the `hfc` folder to the `hfc-cop` folder
* `gulp watch` to set up watch that updates hfc-cop's shared dependencies from hfc/lib and updates installed hfc and hfc-cop modules in node_modules
* `gulp doc` to generate API docs
* `npm test` to run the headless tests that do not require any additional set up

The following tests require setting up a local blockchain network as the target. Because v1.0 is still in active development, you still need the vagrant environment to build the necessary Docker images needed to run the network. Follow the steps below to set it up.
* `cd fabric/devenv`
* Open the file `Vagrantfile` and insert the following statement below the existing `config.vm.network` statements:
* ` config.vm.network :forwarded_port, guest: 7056, host: 7056 # gRPC services port for peer vp1`
* ` config.vm.network :forwarded_port, guest: 8888, host: 8888 # http port for COP server`
* ` config.vm.network :forwarded_port, guest: 7056, host: 7056 # Openchain gRPC services`
* ` config.vm.network :forwarded_port, guest: 7058, host: 7058 # GRPCCient gRPC services`
* ` config.vm.network :forwarded_port, guest: 8888, host: 8888 # COP services`

* run `vagrant up` to launch the vagrant VM
* Once inside vagrant, `cd $GOPATH/src/github.com/hyperledger/fabric`
Expand Down
23 changes: 23 additions & 0 deletions build/tasks/cop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

var gulp = require('gulp');
var debug = require('gulp-debug');

const DEPS = [
'hfc/lib/api.js',
'hfc/lib/hash.js',
'hfc/lib/utils.js',
'hfc/lib/Config.js',
'hfc/lib/Remote.js',
'hfc/lib/impl/CryptoSuite_ECDSA_AES.js',
'hfc/lib/impl/ecdsa/*',
'hfc/lib/impl/FileKeyValueStore.js'
];

gulp.task('cop', function() {
return gulp.src(DEPS, { base: 'hfc/' })
.pipe(debug())
.pipe(gulp.dest('hfc-cop/'));
});

module.exports.DEPS = DEPS;
21 changes: 10 additions & 11 deletions build/tasks/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ var jsdoc = require('gulp-jsdoc3');
gulp.task('doc', function () {
gulp.src([
'README.md',
'index.js',
'./lib/api.js',
'./lib/impl/FileKeyValueStore.js',
'./lib/impl/CryptoSuite_ECDSA_AES.js',
'./lib/impl/ecdsa/key.js',
'./lib/impl/MemberServices.js',
'./lib/impl/FabricCOPImpl.js',
'./lib/Chain.js',
'./lib/Member.js',
'./lib/Peer.js',
'./lib/X509Certificate.js'
'hfc/index.js',
'hfc/lib/api.js',
'hfc/lib/impl/FileKeyValueStore.js',
'hfc/lib/impl/CryptoSuite_ECDSA_AES.js',
'hfc/lib/impl/ecdsa/key.js',
'hfc/lib/impl/FabricCOPImpl.js',
'hfc/lib/Chain.js',
'hfc/lib/Member.js',
'hfc/lib/Peer.js',
'hfc/lib/X509Certificate.js'
], {read: false})
.pipe(jsdoc())
.pipe(gulp.dest('./docs/gen'));
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var gulp = require('gulp');
var eslint = require('gulp-eslint');

gulp.task('lint', function () {
return gulp.src(['**/*.js', '!node_modules/**', '!docs/**', '!coverage/**', '!tmp/**'])
return gulp.src(['**/*.js', 'hfc/**/*.js', '!node_modules/**', '!docs/**', '!coverage/**', '!tmp/**', 'hfc-cop/lib/*.js'])
.pipe(eslint(
{
env: ['es6', 'node'],
Expand Down
20 changes: 14 additions & 6 deletions build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var tapColorize = require('tap-colorize');
var istanbul = require('gulp-istanbul');

gulp.task('pre-test', function() {
return gulp.src(['lib/**/*.js'])
return gulp.src(['hfc/lib/**/*.js','hfc-cop/lib/**/*.js'])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
Expand All @@ -17,11 +17,19 @@ gulp.task('test', ['pre-test'], function() {
// enrollment scenarios (good and bad calls). then the rest of the
// tests will re-used the same key value store that has saved the
// user certificates so they can interact with the network
return gulp.src(['test/unit/ca-tests.js', 'test/unit/endorser-tests.js', 'test/unit/orderer-tests.js', 'test/unit/orderer-member-tests.js', 'test/unit/end-to-end.js', 'test/unit/headless-tests.js'])
.pipe(tape({
reporter: tapColorize()
}))
.pipe(istanbul.writeReports());
return gulp.src([
// 'test/unit/ca-tests.js',
'test/unit/chain-fabriccop-tests.js',
'test/unit/endorser-tests.js',
'test/unit/orderer-tests.js',
'test/unit/orderer-member-tests.js',
'test/unit/end-to-end.js',
'test/unit/headless-tests.js'
])
.pipe(tape({
reporter: tapColorize()
}))
.pipe(istanbul.writeReports());
});

gulp.task('test-headless', ['pre-test'], function() {
Expand Down
17 changes: 17 additions & 0 deletions build/tasks/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var gulp = require('gulp'),
watch = require('gulp-watch'),
debug = require('gulp-debug'),
cop = require('./cop.js');

gulp.task('watch', function () {
watch(cop.DEPS, { ignoreInitial: false, base: 'hfc/' })
.pipe(debug())
.pipe(gulp.dest('hfc-cop/'));

watch([
'hfc/lib/**/*',
'hfc-cop/lib/**/*'
], { ignoreInitial: false, base: './' })
.pipe(debug())
.pipe(gulp.dest('node_modules'));
});
3 changes: 3 additions & 0 deletions hfc-cop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Hyperledger Fabric Client SDK for Node.js, Membership Services (aka `COP`)

See hyperledger\fabric-sdk-node root README.md for more information.
8 changes: 8 additions & 0 deletions hfc-cop/config/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"request-timeout" : 3000,
"tcert-batch-size" : 10,
"crypto-asymmetric-key-algo": "ECDSA",
"crypto-hash-algo": "SHA3",
"crypto-keysize": 384,
"crypto-suite": "./impl/CryptoSuite_ECDSA_AES.js",
}
4 changes: 2 additions & 2 deletions lib/impl/FabricCOPImpl.js → hfc-cop/lib/FabricCOPImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

'use strict';

var api = require('../api.js');
var utils = require('../utils');
var api = require('./api.js');
var utils = require('./utils.js');
var util = require('util');
var jsrsa = require('jsrsasign');
var asn1 = jsrsa.asn1;
Expand Down
35 changes: 35 additions & 0 deletions hfc-cop/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "hfc-cop",
"version": "0.0.1",
"main": "./lib/FabricCOPImpl.js",
"repository": {
"type": "gerrit",
"url": "http://gerrit.hyperledger.org/r/fabric-sdk-node"
},
"engines": {
"node": ">=4.5.0",
"npm": ">=2.15.9"
},
"engine-strict": true,
"engineStrict": true,
"dependencies": {
"asn1": "https://github.com/mcavage/node-asn1",
"elliptic": "^6.2.3",
"fs-extra": ">=0.30.0 <0.31.0",
"grpc": "^1.0.0",
"js-sha3": "^0.5.1",
"jsrsasign": "^6.2.2",
"jssha": "^2.1.0",
"nconf": "^0.8.4",
"sjcl": "1.0.3",
"sjcl-codec": "0.1.1",
"tar-fs": "^1.13.0",
"url": "^0.11.0",
"util": "^0.10.3"
},
"license": "Apache-2.0",
"licenses": [{
"type": "Apache-2.0",
"url": "https://github.com/hyperledger/fabric/blob/master/LICENSE"
}]
}
3 changes: 3 additions & 0 deletions hfc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Hyperledger Fabric Client SDK for Node.js

See hyperledger\fabric-sdk-node root README.md for more information.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1f08e84

Please sign in to comment.