diff --git a/src/dlt/gateway/README.md b/src/dlt/gateway/README.md index 401e178642ca36d08abb80d8438b1169acd117c5..0ea41cd2f12d57d5ebc4d9865256781612c6e2c2 100644 --- a/src/dlt/gateway/README.md +++ b/src/dlt/gateway/README.md @@ -1,16 +1,8 @@ -# ADRENALINE DLT App - -<figure> - <img src="./resources/System.png" - alt="DLT Gateway for chaincode interaction" - width="960" - height="480"> - <figcaption>DLT_APP for chaincode tests.</figcaption> -</figure> +# DLT Gateway ## Description -The DLT app consists of a **fabricConnect.ts** TypeScript file, which contains the logic for identification management (certificates required for the MSP), connection management to the blockchain, and finally, it exposes a contract object with all the required information for interacting with the chaincode. The **fabricConnect.ts** is coded following the Fabric Gateway API recommendations from Hyperledger Fabric 2.4+. The compiled **fabricConnect.ts** logic is imported into a **dltGateway.js** file, which contains the gRPC logic for interaction with the TFS controller. Testing code for various performance tests is included inside the [/dltApp/tests](./dltApp/tests/) folder. +The DLT Gateway consists of a **fabricConnect.ts** TypeScript file, which contains the logic for identification management (certificates required for the MSP), connection management to the blockchain, and finally, it exposes a contract object with all the required information for interacting with the chaincode. The **fabricConnect.ts** is coded following the Fabric Gateway API recommendations from Hyperledger Fabric 2.4+. The compiled **fabricConnect.ts** logic is imported into a **dltGateway.js** file, which contains the gRPC logic for interaction with the TFS controller. Testing code for various performance tests is included inside the [/tests](./tests/) folder. The chaincode is written in Go, providing a reference for the operations that are recorded in the blockchain. This chaincode must already be deployed in a working Hyperledger Fabric blockchain. @@ -20,38 +12,3 @@ The chaincode is written in Go, providing a reference for the operations that ar * Docker * K8s -## Building the App - -Install the dependencies and compile the source code. - -```bash -npm install -``` - -## Packing the App - -The [automation](./automation/) folder contains the Dockerfiles and Kubernetes configuration files alongside deployment scripts. - -### Build a Docker Image - -Using the Dockerfile, create a Docker image of the Gateway. - -```bash -docker build -t your-username/dltgateway:v1.0.0 . -``` - -If necessary, upload the Docker image to a Docker repository for convenience. (You can work with the local image if deploying the Kubernetes service on the same machine.) - -```bash -docker push your-username/dltgateway:v1.0.0 -``` - -### Run the Deployment Script - -Make the necessary changes to the environment variables inside the **configmap.yaml** according to the specific Fabric deployment. Also, update the path in the **persistent-volume.yaml** with the correct information. - -```bash -./deploy_dlt_gateway.sh -``` - -Once the Kubernetes service is deployed, TFS can perform gRPC requests to as usual. \ No newline at end of file diff --git a/src/dlt/gateway/dltApp/package-lock.json b/src/dlt/gateway/dltApp/package-lock.json index 9ab326263a5eabde3f76af865997a25e6f43f4d9..6fb245621a1e38f84d6806aae2f94fc83394b05a 100644 --- a/src/dlt/gateway/dltApp/package-lock.json +++ b/src/dlt/gateway/dltApp/package-lock.json @@ -1,11 +1,11 @@ { - "name": "adrenalineDLT_APP", + "name": "dlt_gateway", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "adrenalineDLT_APP", + "name": "dlt_gateway", "version": "1.0.0", "license": "Apache-2.0", "dependencies": { diff --git a/src/dlt/gateway/dltApp/package.json b/src/dlt/gateway/dltApp/package.json index 58ec22dea3d15f3d2870656f05058ed603dbd37a..5eabc2dff8cc819fa1db189a0b3dec0c37f7d245 100644 --- a/src/dlt/gateway/dltApp/package.json +++ b/src/dlt/gateway/dltApp/package.json @@ -1,7 +1,7 @@ { - "name": "adrenalineDLT_APP", + "name": "dlt_gateway", "version": "1.0.0", - "description": "A DLT application that record and manages topology data as JSON implemented in typeScript using fabric-gateway", + "description": "A DLT application that record and manages network related data as JSON, implemented in typeScript using HLF fabric-gateway", "main": "dist/index.js", "typings": "dist/index.d.ts", "engines": { @@ -13,7 +13,7 @@ "lint": "eslint . --ext .ts", "prepare": "npm run build", "pretest": "npm run lint", - "start": "node dist/adrenalineDLT_app.js" + "start": "node dist/dlt_gateway.js" }, "engineStrict": true, "author": "CTTC-Javier", diff --git a/src/dlt/gateway/dltApp/tsconfig.json b/src/dlt/gateway/dltApp/tsconfig.json index c81e4d5f92e51a166b91db2fe92d664ffb087cf0..34eddef69221adeca4861399d574047a8c9ae6f1 100644 --- a/src/dlt/gateway/dltApp/tsconfig.json +++ b/src/dlt/gateway/dltApp/tsconfig.json @@ -9,8 +9,7 @@ "noImplicitAny": true }, "include": [ - "./src/**/*" -, "src.old/grpcClient.js", "src.old/grpcServer.js", "tests/testEvents.js", "tests/testGateway.js" ], + "./src/**/*" ], "exclude": [ "./src/**/*.spec.ts" ] diff --git a/src/dlt/gateway/dltApp/tests/perfTest.js b/src/dlt/gateway/tests/perfTest.js similarity index 95% rename from src/dlt/gateway/dltApp/tests/perfTest.js rename to src/dlt/gateway/tests/perfTest.js index 6549d4e7b48eef68d079e1f7067b26d4cc1533f5..fd60bd9c4bba04a7c2a048d26389dd66381b5749 100644 --- a/src/dlt/gateway/dltApp/tests/perfTest.js +++ b/src/dlt/gateway/tests/perfTest.js @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -const { connectToNetwork } = require('../dist/fabricConnect'); +const { connectToNetwork } = require('../dltApp/dist/fabricConnect'); const fsp = require('fs').promises; const fs = require('fs'); const util = require('util'); const utf8Decoder = new TextDecoder(); const topoDirectory = '../samples/'; -//const topologies = ['topo1.json', 'topo2.json', 'topo3.json', 'topo4.json']; -const topologies = ['topo4.json']; +const topologies = ['topo1.json', 'topo2.json', 'topo3.json', 'topo4.json']; +//const topologies = ['topo4.json']; const iterations = 1000; diff --git a/src/dlt/gateway/dltApp/tests/rateTest.js b/src/dlt/gateway/tests/rateTest.js similarity index 97% rename from src/dlt/gateway/dltApp/tests/rateTest.js rename to src/dlt/gateway/tests/rateTest.js index ca3f540d3c3bd2c6ad0f665217bfc4c62f0c1305..f7c40884293220c0ab235322d74aee61074a281c 100644 --- a/src/dlt/gateway/dltApp/tests/rateTest.js +++ b/src/dlt/gateway/tests/rateTest.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -const { connectToNetwork } = require('../dist/fabricConnect'); +const { connectToNetwork } = require('../dltApp/dist/fabricConnect'); const fs = require('fs'); const util = require('util'); const appendFile = util.promisify(fs.appendFile); diff --git a/src/dlt/gateway/dltApp/tests/simpleTest.js b/src/dlt/gateway/tests/simpleTest.js similarity index 97% rename from src/dlt/gateway/dltApp/tests/simpleTest.js rename to src/dlt/gateway/tests/simpleTest.js index d84b5dba1eb4209f543bd48675f1cfe896debd84..72da03dec16b91c7b6acc21e339f2844d74153be 100644 --- a/src/dlt/gateway/dltApp/tests/simpleTest.js +++ b/src/dlt/gateway/tests/simpleTest.js @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -const { connectToNetwork } = require('../dist/fabricConnect'); +const { connectToNetwork } = require('../dltApp/dist/fabricConnect'); const fs = require('fs'); const util = require('util'); const appendFile = util.promisify(fs.appendFile); diff --git a/src/dlt/gateway/dltApp/tests/testEvents.js b/src/dlt/gateway/tests/testEvents.js similarity index 92% rename from src/dlt/gateway/dltApp/tests/testEvents.js rename to src/dlt/gateway/tests/testEvents.js index d788f04e14519053f09e8ab4dd55e69a9a61a298..8d209723eaf7999de3b5829308099f0c0ffd78f4 100644 --- a/src/dlt/gateway/dltApp/tests/testEvents.js +++ b/src/dlt/gateway/tests/testEvents.js @@ -17,7 +17,7 @@ const grpc = require('@grpc/grpc-js'); const protoLoader = require('@grpc/proto-loader'); const path = require('path'); -const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_gateway.proto'); +const PROTO_PATH = path.resolve(__dirname, '../../../../proto/dlt_gateway.proto'); const packageDefinition = protoLoader.loadSync(PROTO_PATH, { keepCase: true, longs: String, @@ -28,7 +28,7 @@ const packageDefinition = protoLoader.loadSync(PROTO_PATH, { const dltProto = grpc.loadPackageDefinition(packageDefinition).dlt; const client = new dltProto.DltGatewayService( - '10.1.1.96:32001', + '10.1.1.96:32001', //Replace with TFS server IP_ADDRESS grpc.credentials.createInsecure() ); diff --git a/src/dlt/gateway/dltApp/tests/testGateway.js b/src/dlt/gateway/tests/testGateway.js similarity index 96% rename from src/dlt/gateway/dltApp/tests/testGateway.js rename to src/dlt/gateway/tests/testGateway.js index 0998375673a75bee39a110ac4d470f2c5a3330a4..dde6b3efc8427c5a1d3f9e35a8938a8d1aac21ee 100644 --- a/src/dlt/gateway/dltApp/tests/testGateway.js +++ b/src/dlt/gateway/tests/testGateway.js @@ -20,7 +20,7 @@ const fs = require('fs').promises; const { v4: uuidv4 } = require('uuid'); // Import the UUID library -const PROTO_PATH = path.resolve(__dirname, '../proto/dlt_gateway.proto'); +const PROTO_PATH = path.resolve(__dirname, '../../../../proto/dlt_gateway.proto'); const packageDefinition = protoLoader.loadSync(PROTO_PATH, { keepCase: true, longs: String, @@ -40,7 +40,7 @@ const domainUuid = `domain-${uuidv4()}`; // Generate a pretty domain UUID async function getTopoData(filename) { try { - const data = await fs.readFile(`../../samples/${filename}`, 'utf8'); + const data = await fs.readFile(`../samples/${filename}`, 'utf8'); return data; } catch (error) { console.error('Failed to read file:', filename, error);