You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Node 24 is the latest LTS release and is used as the runtime in the
fabric-nodeenv Docker image to provide access to the latest features and
performance improvements.
Node 20 is now the minimum supported version since Node 18 is no longer
supported.
Signed-off-by: Mark S. Lewis <[email protected]>
Copy file name to clipboardExpand all lines: COMPATIBILITY.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,8 @@ This table shows the summary of the compatibility of the Node chaincode packages
12
12
| v2.2 | 12 | 12 | amd64 |
13
13
| v2.5.0 - v2.5.4 | 18 | 18 | amd64, arm64 |
14
14
| v2.5.5 - v2.5.7 | 18 | 20 | amd64, arm64 |
15
-
| v2.5.8+ | 18 | 22 | amd64, arm64 |
15
+
| v2.5.8 | 18 | 22 | amd64, arm64 |
16
+
| v2.5.9+ | 20 | 24 | amd64, arm64 |
16
17
17
18
The Node runtime provided by the chaincode Docker image determines the maximum Node version (and features) that smart contract code can exploit when using the default Node chaincode container.
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+19-24Lines changed: 19 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,52 +22,47 @@ The following [Rush categories](https://rushjs.io/pages/maintainer/add_to_repo/)
22
22
23
23
### Pre-requisites
24
24
25
-
* node v18 => recommend to use [nvm](https://github.com/nvm-sh/nvm)
26
-
* rush => `npm install -g @microsoft/rush`
25
+
- node 20+ => recommend to use [nvm](https://github.com/nvm-sh/nvm)
26
+
- rush => `npm install -g @microsoft/rush`
27
27
28
28
> As an alternative to installing rush on your system, you can also have node install it for executing single commands similar to what is done in CI, for example from the `libraries/fabric-shim` directory you could add or update a dependency by running `node ../../common/scripts/install-run-rush.js add --package @grpc/grpc-js@latest`
29
29
30
30
> Note that npm v6 has some bugs that mean adding new dependencies etc are not properly picked up. Longer term we should consider moving to yarn or pnpm. However in practice this isn't a serious problem and has been possible to be worked around by issuing `rm ./common/config/rush/npm-shrinkwrap.json` and then `rush update`
31
31
32
-
The fv and e2e tests require a set of docker images of Fabric Peers, Orderers and CAs. To ensure you have the correct images ensure these have been dowloaded and tagged. `rush edge-docker` will do this for you.
33
-
34
-
They also need to have the `nodeenv` image present - this is build as part of the `rush rebuild` so please ensure this has been run first. It is advisable to clean up the docker containers and images between test runs to avoid any odd behaviour. Commands to help do this are below.
32
+
They also need to have the `nodeenv` image present - this is build as part of the `rush rebuild` so please ensure this has been run first. It is advisable to clean up the docker containers and images between test runs to avoid any odd behaviour. Commands to help do this are below.
35
33
36
34
## Using the repo
37
35
38
-
* Clone the repo, and ensure you are using node v18, and have rush installed
39
-
*`rush update` is needed to ensure everything is correctly linked and updated.
40
-
- For example, after updating dependencies in `libraries/fabric-shim/package.json` run `rush update` which will delegate to `pnpm` to update the appropriate project files.
41
-
- Note - you could also use `rush add` to have rush manage the `package.json` updates.
42
-
*`rush edge-docker` will pull down and tag the very latest docker images for the peers, orderes etc to test against
36
+
- Clone the repo, and ensure you are using node v18, and have rush installed
37
+
-`rush update` is needed to ensure everything is correctly linked and updated.
38
+
- For example, after updating dependencies in `libraries/fabric-shim/package.json` run `rush update` which will delegate to `pnpm` to update the appropriate project files.
39
+
- Note - you could also use `rush add` to have rush manage the `package.json` updates.
43
40
44
41
At this point the repo is fully ready for use and running tests, etc. A full sequence of build-test that is equivalent to the CI pipeline is
45
42
46
-
*`rush rebuild` will run the linting, and unit tests across the codebase, as well as building the docker images, and jsdoc API docs
47
-
*`rush start-verdaccio` & `rush stop-verdaccio` will start/stop verdaccio (used for local hosting of NPM modules)
48
-
*`rush start-fabric` & `rush stop-fabric` will start/stop the test fabric ready for running FV tests
49
-
*`rush test:fv` will run the fv tests, ensure that both the fabric and verdaccio have already been started
50
-
*`rush test:e2e` to run e2e tests across the repos
43
+
-`rush rebuild` will run the linting, and unit tests across the codebase, as well as building the docker images, and jsdoc API docs
44
+
-`rush start-verdaccio` & `rush stop-verdaccio` will start/stop verdaccio (used for local hosting of NPM modules)
45
+
-`rush start-fabric` & `rush stop-fabric` will start/stop the test fabric ready for running FV tests
46
+
-`rush test:fv` will run the fv tests, ensure that both the fabric and verdaccio have already been started
47
+
-`rush test:e2e` to run e2e tests across the repos
51
48
52
49
For more specific purposes during development the following are useful:
If you want to get a set of `.tar.gz` files of the node modules to use for local testing this command will put them into the `tarballs` directory
53
+
-`rush rebuild --to fvtests` to run the unit tests for the core modules, but not the docker or jsdoc
54
+
-`rush rebuild --to fabric-contract-api` to build, lint and run just the `fabric-contract-api`
55
+
-`rush logs` will show the location of all the log files
59
56
60
57
To clean up docker
61
58
62
-
*`docker kill $(docker ps -q) && docker rm $(docker ps -aq)` will remove the running containers
63
-
*`docker rmi $(docker images 'dev-*' -q) --force` will remove the images for the chaincode containers
59
+
-`docker kill $(docker ps -q) && docker rm $(docker ps -aq)` will remove the running containers
60
+
-`docker rmi $(docker images 'dev-*' -q) --force` will remove the images for the chaincode containers
64
61
65
62
## Mechanics of Contributing
66
63
67
64
The codebase is maintained in [github](https://github.com/hyperledger/fabric-chaincode-node), with a CI pipeline run with [Github Actions](https://github.com/hyperledger/fabric-chaincode-node/actions). Issues are handled in [Github Issues](https://github.com/hyperledger/fabric-chaincode-node/issues).
68
65
69
-
70
-
71
66
## Code of Conduct Guidelines <aname="conduct"></a>
72
67
73
68
See our [Code of Conduct Guidelines](https://github.com/hyperledger/fabric-chaincode-node/blob/main/CODE_OF_CONDUCT.md).
Copy file name to clipboardExpand all lines: TUTORIAL.md
+17-19Lines changed: 17 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ The dependencies of `fabric-contract-api` and `fabric-shim` will be required.
15
15
"name": "chaincode",
16
16
"description": "My first exciting chaincode implemented in node.js",
17
17
"engines": {
18
-
"node": ">=18"
18
+
"node": ">=20"
19
19
},
20
20
"scripts": {
21
21
"test": "mocha....."
@@ -33,6 +33,7 @@ The dependencies of `fabric-contract-api` and `fabric-shim` will be required.
33
33
}
34
34
35
35
```
36
+
36
37
Remember to add in any additional business logic, and testing libraries needed
37
38
38
39
Adding `fabric-shim` as a dependency, gives a command `fabric-chaincode-node` that is the script to run for `npm start`.
@@ -45,7 +46,6 @@ Adding `fabric-shim` as a dependency, gives a command `fabric-chaincode-node` th
45
46
},
46
47
```
47
48
48
-
49
49
### 2: How is chaincode deployed?
50
50
51
51
Chaincode is deployed by the peer in response to issuing a number of (usually CLI) commands. For node.js chaincode the location of the chaincode npm project is required (the directory that the package.json is in). This does not need to be an installed project, but has to have all the code, and the package.json.
@@ -54,7 +54,7 @@ A docker image is built for this chaincode, the package.json and code copied in.
54
54
55
55
After the install there is a 'bootstrap' process that starts the chaincode up (more details later). The constructors of the exported Contracts will be run at this point; these constructors are for setting the name and optional setup of the 'error/monitoring functions', (again more later). This instance of the contract will existing whilst this chaincode docker image is up.
56
56
57
-
When chaincode is instantiated or updated, the `init()` function in the chaincode is called. As with the `invoke()` call from the client, a fn name and parameters can be passed. Remember therefore to have specific functions to call on `init()` and `update()` in order to do any data initialisation or migration that might be needed. These two functions have been abstracted away to focus on specific function implementations.
57
+
When chaincode is instantiated or updated, the `init()` function in the chaincode is called. As with the `invoke()` call from the client, a fn name and parameters can be passed. Remember therefore to have specific functions to call on `init()` and `update()` in order to do any data initialisation or migration that might be needed. These two functions have been abstracted away to focus on specific function implementations.
58
58
59
59
It is strongly recommended to use the npm shrinkwrap mechanism so the versions of the modules that are used are fixed.
In Fabric, there is a *stub* api that provides chaincode with functionality.
207
+
In Fabric, there is a _stub_ api that provides chaincode with functionality.
210
208
No functionality has been removed, but a new approach to providing abstractions on this to facilitate programming.
211
209
212
-
*user additions*: additional properties can be added to the object to support for example common handling of the data serialization.
210
+
_user additions_: additional properties can be added to the object to support for example common handling of the data serialization.
213
211
214
212
The context object contains
215
213
216
-
-`ctx.stub`the same stub instance as in earlier versions for compatibility
214
+
-`ctx.stub` the same stub instance as in earlier versions for compatibility
217
215
-`ctx.identity` and instance of the Client Identity object
218
216
219
217
You are at liberty to create a subclass of the Context to provide additional functions, or per-transaction context storage. For example
@@ -249,29 +247,29 @@ class ScenarioContext extends Context {
249
247
250
248
Definitions as per https://www.ietf.org/rfc/rfc2119.txt
251
249
252
-
- All the functions that are present in the prototype of a class that extends *Contract* will be invokable
253
-
- The exports from the node module *MUST* include *contracts* that is an array of constructors (1 or more)
254
-
- Each class *MAY* call in it's constructor pass a name. This is prefixed to each of the function names by an _ (underscore)
255
-
- Each class *MAY* define functions that are executed before and functions that are executed after the invoked function.
250
+
- All the functions that are present in the prototype of a class that extends _Contract_ will be invokable
251
+
- The exports from the node module _MUST_ include _contracts_ that is an array of constructors (1 or more)
252
+
- Each class _MAY_ call in it's constructor pass a name. This is prefixed to each of the function names by an \_ (underscore)
253
+
- Each class _MAY_ define functions that are executed before and functions that are executed after the invoked function.
256
254
- These are part of the same fabric transaction
257
255
- They are scoped per name
258
-
- Each class *MAY* define a function that would be executed if a matching function name does not exist; otherwise a 'no function exists' error will be thrown
256
+
- Each class _MAY_ define a function that would be executed if a matching function name does not exist; otherwise a 'no function exists' error will be thrown
259
257
- If too many parameters are passed, they will be discarded
260
258
- If too few parameters are passed, the remainder will be set to undefined
261
-
- as per node.js language standard
259
+
- as per node.js language standard
262
260
- Having duplicate function names in a single class is an error
263
261
- Any function that is dynamically added will not be registered as an invokable function
264
-
- There is no specific function that is invoked per Fabric's *init* chaincode spi. The instantiate flow can pass function name and parameters; therefore consider
265
-
a dedicated function that will be called for new chaincode deployments, and for upgrade deployments.
262
+
- There is no specific function that is invoked per Fabric's _init_ chaincode spi. The instantiate flow can pass function name and parameters; therefore consider
263
+
a dedicated function that will be called for new chaincode deployments, and for upgrade deployments.
266
264
267
265
## Restrictions on programming in side a Contract function
268
266
269
267
Hyperledger Fabric's consensus algorithm permits the ability to use general purpose languages; rather than a more restrictive language. But the following restrictions apply
270
268
271
269
- Functions should not create random variables, or use any function whose return values are functions of the current time or location of execution
272
-
- i.e. the function will be executed in another context (i.e. peer process). This could potentially be in a different time zone in a different locale.
270
+
- i.e. the function will be executed in another context (i.e. peer process). This could potentially be in a different time zone in a different locale.
273
271
- Functions should be aware that they may read state, and write state. But they are producing a set of changes that will be applied to the state. The implication is that updates to the state
0 commit comments