Skip to content

Commit

Permalink
Merge pull request #103 from heatherlp/portFromMaster
Browse files Browse the repository at this point in the history
FABCN-391: Cherry pick relevant changes from master to release-2.0
  • Loading branch information
mbwhite authored Mar 30, 2020
2 parents 2e8e698 + 0014244 commit ff0962f
Show file tree
Hide file tree
Showing 26 changed files with 310 additions and 256 deletions.
51 changes: 51 additions & 0 deletions COMPATIBILITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Support and Compatibility for fabric-chaincode-node

Github is used for code base management, issues should reported in the [FABCN](https://jira.hyperledger.org/projects/FABCN/issues/) component in JIRA.


## Summary of Compatibility

This table shows the summary of the compatibility of the Node modules at versions 1.4 and 2.0, together with the Nodejs runtime they require and the Fabric Peer versions they can communicate with.

| | Peer Connectivity v1.4 | NodeJS | Peer Connectivity v2.0 |
| --------------------- | ---------------------- | ------ | ---------------------- |
| Node modules **v1.4** | Yes | 8 | Yes |
| Node modules **v2.0** | Yes | 10 | Yes |

By default a Fabric Peer v1.4 will create a Nodejs v8 , and a Fabric Peer v2.0 will create a Nodejs v12 runtime. Whilst is the default, the docker image used to host the chaincode and contracts can be altered. Set the environment variable `CORE_CHAINCODE_NODE_RUNTIME` on the peer to the name of the docker image. For example `CORE_CHAINCODE_NODE_RUNTIME=example/customNodeRuntime:latest`

The Node modules will connect to the peer whilst running; this is referred to as 'Fabric Peer Connectivity' in the table. For example, whilst the Fabric Peer v1.4 will create a Nodejs 8 runtime, if a Nodejs 12 runtime was configured, the Node modules at v2.0.0 still function when connecting to the Fabric Peer v1.4.

## Compatibility

The key elements are : 

- the version of the Fabric Contract Node modules used
- the version of the Nodejs runtime used to run the code
- When starting a chaincode container to run a Smart Contract the version of the runtime that is used is determined by these factors:

Fabric v1.4.2, and Fabric v2.0.0 will, by default, start up docker image to host the chaincode and contracts. The version of the docker image used is defined by the version of Fabric in use.

With Fabric v2.0.0, the chaincode container can be configured to be started by other means, and not the Peer. In this case, the environment used is not in the control of Fabric.

Node modules that are produced are `fabric-contract-api`, `fabric-shim`, `fabric-shim-crypto` & `fabric-shim-api`

### Supported Runtimes

v1.4.x and v2.0.0 Node modules are supported running in Nodejs 12.13 with the x86_64 architecture. Later Nodejs 12 versions are supported but are not tested.

v1.4.x Node modules are supported running Nodejs 8.16.1 with the  x86_64 architecture. Later Nodejs 8 versions are supported but are not tested.

Architecture Support: all docker images, runtimes, tools are tested under x86_64 ONLY

### Default Peer Runtime selection

When using Fabric 2.0.0, the default docker image that is used to run the Node chaincode is node:12.13.0-alpine 

*Note:* With the default docker image used by Fabric 2.0.0 the packaged code will be installed with npm. If a `package-lock.json` or a `npm-shrinkwrap.json` file is present, `npm ci --only=production` will be used. Otherwise `npm install --production` will be used. 

When using Fabric 1.4.4, the docker image that is used to run the Node chaincode is node v8.16.1. It is installed with npm install --production

### Supported Runtime communication with the Peer

Subject to a suitable runtime environment, the 1.4.4 Node modules and 2.0.0 Node modules can used to communicate with a Fabric 2.0.0 or 1.4.4 Peer - with the level of functionality that is implied by the Fabric version in use. 
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ As an application developer, to learn about how to implement **"Smart Contracts"
- docker images
- [fabric-nodeenv](https://hub.docker.com/r/hyperledger/fabric-nodeenv)

## Compatibility

For details on what Nodejs runtime and versions of Hyperledger Fabric can be used please see the [compatibility document](COMPATIBILITY.md).

---

## License <a name="license"></a>
Expand Down
6 changes: 3 additions & 3 deletions apis/fabric-contract-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fabric-contract-api",
"version": "2.0.1",
"tag": "latest",
"version": "2.1.0-unstable",
"tag": "unstable",
"description": "A node.js implementation of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other",
"main": "index.js",
"repository": {
Expand Down Expand Up @@ -46,7 +46,7 @@
"lines": 100
},
"dependencies": {
"fabric-shim-api": "2.0.1",
"fabric-shim-api": "2.1.0-unstable",
"class-transformer": "^0.2.2",
"fast-safe-stringify": "~2.0.7",
"get-params": "^0.1.2",
Expand Down
4 changes: 2 additions & 2 deletions apis/fabric-shim-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fabric-shim-api",
"version": "2.0.1",
"tag": "latest",
"version": "2.1.0-unstable",
"tag": "unstable",
"description": "A node.js API of Hyperledger Fabric chaincode shim, to allow endorsing peers and user-provided chaincodes to communicate with each other",
"main": "index.js",
"repository": {
Expand Down
28 changes: 15 additions & 13 deletions ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,16 @@ stages:
codeCoverageTool: 'cobertura'
summaryFileLocation: '**/cobertura-coverage.xml'
artifactName: 'Unit Test Coverage'
# CopyFiles can follow symlinks hence be careful with node_modules
- task: CopyFiles@2
condition: or(succeeded(), failed()) # publish either way
inputs:
contents: |
**/*.build*.log
!**/node_modules/**
targetFolder: $(Build.ArtifactStagingDirectory)/logs
- script: |
mkdir -p $(Build.ArtifactStagingDirectory)/logs
find . \( -type d -name 'node_modules' \) -prune -o -name '*.build*.log' -exec cp {} $(Build.ArtifactStagingDirectory)/logs \;
displayName: 'Copy build logs'
- task: PublishBuildArtifacts@1
condition: or(succeeded(), failed()) # publish either way
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)/logs
artifactName: 'Build logs'
displayName: 'Publish build logs'

# Copy the built artifacts to the staging directory, tgz, and the docker image
- script: |
Expand Down Expand Up @@ -161,11 +158,16 @@ stages:
**/*.build*.log
!**/node_modules/**
targetFolder: $(Build.ArtifactStagingDirectory)/testlogs
- script: |
mkdir -p $(Build.ArtifactStagingDirectory)/testlogs
find . \( -type d -name 'node_modules' \) -prune -o -name '*.build*.log' -exec cp {} $(Build.ArtifactStagingDirectory)/testlogs \;
displayName: 'Copy test logs'
- task: PublishBuildArtifacts@1
condition: or(succeeded(), failed()) # publish either way
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)/testlogs
artifactName: 'Test logs'
displayName: 'Publish test logs'
- task: PublishBuildArtifacts@1
condition: or(succeeded(), failed()) # publish either way
inputs:
Expand Down Expand Up @@ -278,7 +280,7 @@ stages:
workingFile: '$(Agent.TempDirectory)/.npmrc'
customEndpoint: 'fabric-chainode-node-npm'
- script: |
find $(Pipeline.Workspace)/node-tgz/ -maxdepth 1 -type f -name 'fabric-*.tgz' -exec npm publish {} --tag latest \;
find $(Pipeline.Workspace)/node-tgz/ -maxdepth 1 -type f -name 'fabric-*.tgz' -exec npm publish {} --tag unstable \;
displayName: 'npm publish'
- job: jsdoc_publish
steps:
Expand All @@ -303,11 +305,11 @@ stages:
docker login ${DOCKER_REGISTRY_URL} --username=${DOCKER_REGISTRY_USERNAME} --password=${DOCKER_REGISTRY_PASSWORD}
echo "Logged in to docker registry"
# tag nodeenv image to PACKAGE_VERSION
docker tag hyperledger/fabric-nodeenv hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)
docker tag hyperledger/fabric-nodeenv fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable
# push nodeenv to repository
docker push hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)" --target "hyperledger/fabric-nodeenv:$(BuildData.PACKAGE_VERSION)"
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)" --target "hyperledger/fabric-nodeenv:2.0"
docker push hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable" --target "hyperledger/fabric-nodeenv:$(BuildData.PACKAGE_VERSION)-unstable"
./manifest-tool push from-args --platforms linux/amd64 --template "hyperledger/fabric-nodeenv:amd64-$(BuildData.PACKAGE_VERSION)-unstable" --target "hyperledger/fabric-nodeenv:2.0-unstable"
env:
DOCKER_REGISTRY_USERNAME: $(DockerHub-Username)
DOCKER_REGISTRY_PASSWORD: $(DockerHub-Password)
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[You probably want to look here](https://hyperledger.github.io/fabric-chaincode-node/)
4 changes: 2 additions & 2 deletions docs/_jsdoc/tutorials/using-chaincodeinterface.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cd mycc
// create a new node project
npm init
// install fabric-shim at master branch
npm install 2.0.1
npm install 2.1.0-unstable
// or using the released version
npm install fabric-shim
touch mychaincode.js
Expand Down Expand Up @@ -68,7 +68,7 @@ Finally, update the "start" script in package.json to "node mychaincode.js":
"engineStrict": true,
"license": "Apache-2.0",
"dependencies": {
"fabric-shim": "2.0.1"
"fabric-shim": "2.1.0-unstable"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/_jsdoc/tutorials/using-iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function getAllResults(iterator) {
const res = await iterator.next();
if (res.value) {
// if not a getHistoryForKey iterator then key is contained in res.value.key
allResults.push(res.value.value.toString('utf8'););
allResults.push(res.value.value.toString('utf8'));
}

// check to see if we have reached then end
Expand Down
4 changes: 2 additions & 2 deletions libraries/fabric-shim-crypto/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fabric-shim-crypto",
"version": "2.0.1",
"tag": "latest",
"version": "2.1.0-unstable",
"tag": "unstable",
"description": "A node.js implementation of encryption library for Hyperledger Fabric chaincode shim",
"main": "index.js",
"repository": {
Expand Down
Loading

0 comments on commit ff0962f

Please sign in to comment.