Using different version of Node for Fabric peer to run chaincode #fabric-peer #fabric #fabric-questions


Harsh Sharma
 

Hello everyone,
I'm from the Blockchain Carbon Accounting Hyperledger Lab (https://github.com/hyperledger-labs/blockchain-carbon-accounting/). Our chaincode is written in TypeScript. We are trying to access an OrbitDB (https://github.com/orbitdb/orbit-db) database using the IPFS HTTP API through our chaincode. However, OrbitDB requires Node >=v16 in order to function. We were able to compile the TypeScript chaincode and then package it using the peer chaincode lifecycle method, and then subsequently install it on the peers as well. We are running our peers in development mode, so dev-peer containers are created to execute the chaincode.

However, since the peers run Node v12.16 (since some Fabric packages require this version of Node), they are unable to execute the chaincode, and throw errors on contract invocation. Is there a way to configure the version of Node to be installed on the peer? Or is there a workaround using which we can get our chaincode to run with the correct version of Node?

Thank you for your help.


Matthew White
 

Hello;

So for Fabric v2.4 - the node version used for the nodeenv container was updated to v16 (https://github.com/hyperledger/fabric-chaincode-node/blob/a53121f00afc309d3503f45ca6d728d0f8415677/docker/fabric-nodeenv/Dockerfile#L5)

If you use the very latest chaincode-node it will work with node 16, in fact, I've used earlier versions without issue.  The main problem encountered when moving up node levels was the code, but some of the testing tools didn't work with the later node versions.

On the subject of the chaincode calling out, general advice would be to not make a call out for two reasons.
- The time this could take, could hit the transaction timeout
- Depending on the endorsement policy multiple chaincode instances will need to make the same call. 3rd party dependencies can increase the risk of non-determinism.  

However, if you can take this into account, it's not prohibited at all. 

I will certainly look at the lab :-)

 

Thanks Matthew