Skip to content

Commit

Permalink
[quorum] Supplychain app updates
Browse files Browse the repository at this point in the history
Signed-off-by: sownak.roy <[email protected]>
  • Loading branch information
sownak committed Jan 26, 2024
1 parent a14a98f commit 1524c8a
Show file tree
Hide file tree
Showing 42 changed files with 39,508 additions and 32,286 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/test_smartcontract.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,8 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install npm
npm version
npm install -g ganache-cli
npm install -g truffle
npm install -g truffle-export-abi
- name: Start local node and test smartcontracts
- name: Test smartcontracts using hardhat
run: |
nohup ganache-cli --allowUnlimitedContractSize --gasLimit=68219752232 &
sleep 2
cd examples/supplychain-app/quorum/smartContracts
truffle test --config ./truffle-config.js
npm install
npm test

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
include_role:
name: helm_component
vars:
type: "expressapi"
type: "expressapi-corda"
name: "{{ node.name }}"
charts_dir: "{{ organization_data.gitops.chart_source }}"
expressapi_image: "bevel-supplychain-corda:{{ express_image_tag[network.version] }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
type: "expressapi-fabric"
name: "{{ organization_data.name | lower }}"
charts_dir: "{{ organization_data.gitops.chart_source }}"
expressapi_image: "{{ network.docker.url | lower }}/bevel-supplychain-fabric:express-app-latest"
url: "http://{{ organization_data.name | lower }}-restserver.{{ component_ns }}"
peer_name: "{{ peer_data.name }}"
peer_expressapi_port: "{{ peer_data.expressapi.port }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
type: "expressapi-quorum"
name: "{{ peer_data.name }}"
charts_dir: "{{ organization_data.gitops.chart_source }}"
expressapi_image: "bevel-supplychain-quorum:express-app-latest"
geth_address: "{{ peer_data.geth_url }}"
peer_expressapi_port: "{{ peer_data.expressapi.port }}"
peer_expressapi_targetport: "{{ peer_data.expressapi.targetPort }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
name: "../../../platforms/shared/configuration/roles/check/helm_component"
vars:
component_type: "Pod"
namespace: "{{ organization_data.name | lower }}-quo"
namespace: "{{ component_ns }}"
component_name: "{{ peer.name }}"
kubernetes: "{{ organization_data.k8s }}"
label_selectors:
Expand All @@ -22,12 +22,43 @@
npm:
path: "{{ playbook_dir }}/../../../{{ smart_contract.deployjs_path }}"

# delete build directory directory
- name: delete build directory
file:
path: "{{ playbook_dir }}/../../../{{ smart_contract.deployjs_path }}/build"
state: absent

# create build directory directory
- name: create build directory
file:
path: "{{ playbook_dir }}/../../../{{ smart_contract.deployjs_path }}/build"
state: directory

- name: Get partyinfo from tessera url
uri:
url: "https://{{ peer.name }}.{{ organization_data.external_url_suffix }}/partyinfo"
method: GET
validate_certs: no
status_code: 200
register: response
when:
- smart_contract.public_tx is not defined or smart_contract.public_tx == false
- smart_contract.private_for | length > 0

- name: Set local_private_for to empty
set_fact:
local_private_for: ''

- name: Extract tm_key based on filter
set_fact:
local_private_for: |-
{% for i in smart_contract.private_for %}
{{ response.json | json_query('keys[?contains(url, `' + i + '`)].key') | first }}{%if not loop.last %},{% endif %}
{% endfor %}
when:
- smart_contract.public_tx is not defined or smart_contract.public_tx == false
- smart_contract.private_for | length > 0

############################################################################################
# Run deploy.js to to install smart contract
- name: Run deploy.js for "{{ organization_data.name | lower }}"
Expand All @@ -39,7 +70,7 @@
contract_path: "{{ smart_contract.contract_path }}"
entrypoint: "{{ smart_contract.entrypoint}}"
contract: "{{ smart_contract.name}}"
privateFor: "{{ smart_contract.private_for | default('0', true) }}"
privateFor: "{{ local_private_for }}"
environment:
ITERATIONS: "{{ smart_contract.iterations }}"
register: address
Expand Down Expand Up @@ -67,4 +98,3 @@
file:
path: "{{ playbook_dir }}/../../../{{ smart_contract.deployjs_path }}/node_modules"
state: absent

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
replicaCount: 1
expressapp:
serviceType: ClusterIP
image: {{ expressapi_image }}
image: ghcr.io/hyperledger/bevel-supplychain-fabric:express-app-latest
pullPolicy: Always
pullSecrets: regcred
nodePorts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ spec:
replicaCount: 1
vault:
address: {{ organization_data.vault.url }}
secretprefix: {{ organization_data.vault.secret_path | default('secretsv2') }}/data/{{ component_ns }}/smartContracts
secretprefix: {{ organization_data.vault.secret_path | default('secretsv2') }}/data/{{ organization_data.name | lower }}/smartContracts
serviceaccountname: vault-auth
keyname: General
role: vault-role
authpath: quorum{{ name }}
authpath: {{ network.env.type }}{{ name }}
images:
alpineutils: {{ network.docker.url }}/alpine-utils:1.0
expressapp:
serviceType: ClusterIP
image: {{ network.docker.url }}/{{ expressapi_image }}
pullPolicy: Always
image: ghcr.io/hyperledger/bevel-supplychain-quorum:1.0.0
pullPolicy: IfNotPresent
pullSecrets: regcred
nodePorts:
port: {{ peer_expressapi_port }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ spec:
nodePorts:
port: {{ peer_frontend_port }}
targetPort: {{ peer_frontend_targetport }}
image: {{ network.docker.url }}/bevel-supplychain-frontend:latest
pullPolicy: Always
image: {{ network.docker.url }}/bevel-supplychain-frontend:1.0.0
pullPolicy: IfNotPresent
pullSecrets: regcred
env:
webserver: https://{{ peer_name }}api.{{ organization_data.external_url_suffix }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

helm_templates:
restserver: restserver.tpl
expressapi: expressapi.tpl
expressapi-corda: expressapi-corda.tpl
expressapi-fabric: expressapi-fabric.tpl
webserver: webserver.tpl
webserver-ent: webserver-cordaent.tpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ network:
# Network level configuration specifies the attributes required for each organization
# to join an existing network.
type: quorum
version: 21.4.2 #this is the version of Quorum docker image that will be deployed. older version 2.1.1 is not compatible with supplychain contracts
version: 23.4.0 #this is the version of Quorum docker image that will be deployed. older version 2.1.1 is not compatible with supplychain contracts

frontend: enabled #Flag for frontend to enabled for nodes/peers

Expand Down Expand Up @@ -39,7 +39,7 @@ network:

# Following are the configurations for the common Quorum network
config:
consensus: "raft" # Options are "raft" and "ibft"
consensus: "ibft" # Options are "raft" and "ibft"
## Certificate subject for the root CA of the network.
# This is for development usage only where we create self-signed certificates and the truststores are generated automatically.
# Production systems should generate proper certificates and configure truststores accordingly.
Expand All @@ -48,7 +48,7 @@ network:
# This is the version of "tessera" or "constellation" docker image that will be deployed
# Supported versions #
# constellation: 0.3.2 (For all versions of quorum)
tm_version: "21.7.3"
tm_version: "23.4.0"
tm_tls: "strict" # Options are "strict" and "off"
tm_trust: "tofu" # Options are: "ca-or-tofu", "ca", "tofu"
## Transaction Manager nodes public addresses should be provided.
Expand Down Expand Up @@ -111,7 +111,7 @@ network:
- peer:
name: carrier
subject: "O=Carrier,OU=Carrier,L=51.50/-0.13/London,C=GB" # This is the node subject. L=lat/long is mandatory for supplychain sample app
type: validator # value can be validator or member, only applicable if consensus = 'ibft'
type: member # value can be validator or member, only applicable if consensus = 'ibft'
geth_passphrase: 12345 # Passphrase to be used to generate geth account
p2p:
port: 21000
Expand Down Expand Up @@ -181,7 +181,7 @@ network:
- peer:
name: manufacturer
subject: "O=Manufacturer,OU=Manufacturer,L=47.38/8.54/Zurich,C=CH" # This is the node identity. L=lat/long is mandatory for supplychain sample app
type: validator # value can be validator or member, only applicable if consensus = 'ibft'
type: member # value can be validator or member, only applicable if consensus = 'ibft'
geth_passphrase: 12345 # Passphrase to be used to generate geth account
p2p:
port: 21000
Expand Down Expand Up @@ -211,7 +211,11 @@ network:
contract_path: "./contracts" # Path of the smart contract folder under deployjs_path
iterations: 200 # Number of Iteration of execution to which the gas and the code is optimised
entrypoint: "General.sol" # Main entrypoint solidity file of the contract
private_for: "FxaY4uzuyaFoQrEdrC6glrIwmEUcQQFh+XEB7N1QcDo=,CXtt5UNdZkJyA2CYWBhjmTSmyhMqjWGq4CBMKijhYFQ=" # Sample Public keys for the privateFor, leave empty if not needed
public_tx: true # Set to true enable public transactions.
private_for: # List of peer names for private transactions, only if public_tx=false
- "store"
- "carrier"
- "warehouse"

- organization:
name: store
Expand Down Expand Up @@ -256,7 +260,7 @@ network:
- peer:
name: store
subject: "O=Store,OU=Store,L=40.73/-74/New York,C=US" # This is the node identity. L=lat/long is mandatory for supplychain sample app
type: validator # value can be validator or member, only applicable if consensus = 'ibft'
type: member # value can be validator or member, only applicable if consensus = 'ibft'
geth_passphrase: 12345 # Passphrase to be used to generate geth account
p2p:
port: 21000
Expand Down Expand Up @@ -323,7 +327,7 @@ network:
- peer:
name: warehouse
subject: "O=Warehouse,OU=Warehouse,L=42.36/-71.06/Boston,C=US" # This is the node identity. L=lat/long is mandatory for supplychain sample app
type: validator # value can be validator or member, only applicable if consensus = 'ibft'
type: member # value can be validator or member, only applicable if consensus = 'ibft'
geth_passphrase: 12345 # Passphrase to be used to generate geth account
p2p:
port: 21000
Expand Down
4 changes: 2 additions & 2 deletions examples/supplychain-app/quorum/express_nodeJS/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:10-alpine
FROM node:16-alpine

#copy app
COPY . ./app

#Set working directory and copy package files over for
WORKDIR /app

RUN apk update || : && apk add python make build-base
RUN apk update || : && apk add python3 make build-base

#install dependencies
RUN npm install
Expand Down
21 changes: 7 additions & 14 deletions examples/supplychain-app/quorum/express_nodeJS/PartyAEnv.list
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
#This is a sample env file for running the docker image

#Provide Quorum P2P address. This is not used in current implementation
QUORUM_SERVER="P2P"

#Provide Quorum Geth RPC address which is accessible from the docker container/ kubernetes cluster.
GANACHE_SERVER=http://manufacturer.test.quorum.blockchaincloudpoc.com:15021

GANACHE_SERVER=http://manufacturerrpc.test.quorum.blockchaincloudpoc.com
#Provide the Geth account address for the RPC server above. This will be different for different parties
NODE_IDENTITY=0xccdd8aa32944992b7489718e213c9547f1640980

NODE_IDENTITY=0x6e0be57124cbc3d65d88fcc76cd3a41d9e0fcda7
#Provide the contract address of the General smartcontract. This is generated after the contract is deployed. This will be same for all parties
PRODUCT_CONTRACT_ADDRESS=0xCd2fb4A02280E3746B9EB8c53Aa493EAC6229Bf5

PRODUCT_CONTRACT_ADDRESS=0x26B8BC44f7a1DCE9A3b642354281431bA55E683D
#Provide the party name/organization
NODE_ORGANIZATION=Manufacturer

#Provide the party organization unit
NODE_ORGANIZATIONUNIT=manufacturer

NODE_ORGANIZATION_UNIT=manufacturer
#Provide the party address like certificate subject. This is mandatory if the supplychain-frontend is going to be used.
NODE_SUBJECT=O=Manufacturer,OU=Manufacturer,L=47.38/8.54/Zurich,C=CH
NODE_SUBJECT="O=Manufacturer,OU=Manufacturer,L=47.38/8.54/Zurich,C=CH"
#Provide the consensus protocol
PROTOCOL=ibft
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ router.get("/:trackingID?", function(req, res) {
container.custodian = newContainer.custodian;
container.custodian = container.custodian + "," + newContainer.lastScannedAt;
container.trackingID = newContainer.trackingID;
let timestampAsNumber = Number(newContainer.timestamp);
if(protocol==="raft")
container.timestamp = (new Date(newContainer.timestamp/1000000)).getTime();
container.timestamp = (new Date(timestampAsNumber/1000000)).getTime();
else
container.timestamp = (new Date(newContainer.timestamp*1000)).getTime();
container.timestamp = (new Date(timestampAsNumber*1000)).getTime();
container.containerID = newContainer.containerID;
container.linearId = {};
container.linearId.externalId = null;
Expand Down Expand Up @@ -83,10 +84,11 @@ router.get("/:trackingID?", function(req, res) {
container.custodian = container.custodian + "," + toPush.lastScannedAt;
container.lastScannedAt = toPush.lastScannedAt;
container.trackingID = toPush.trackingID;
let timestampAsNumber = Number(toPush.timestamp);
if(protocol==="raft")
container.timestamp = (new Date(toPush.timestamp/1000000)).getTime();
container.timestamp = (new Date(timestampAsNumber/1000000)).getTime();
else
container.timestamp = (new Date(toPush.timestamp*1000)).getTime();
container.timestamp = (new Date(timestampAsNumber*1000)).getTime();
container.containerID = toPush.containerID;
container.linearId = {};
container.linearId.externalId = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ router.get('/:trackingID/history', function (req, res) {
var history = {};
history.party = toPush.custodian;
history.party = history.party+","+toPush.lastScannedAt;
let timestampAsNumber = Number(toPush.timestamp);
if(protocol==="raft")
history.time = (new Date(toPush.timestamp/1000000)).getTime();
history.time = (new Date(timestampAsNumber/1000000)).getTime();
else
history.time = (new Date(toPush.timestamp * 1000)).getTime();
history.time = (new Date(timestampAsNumber * 1000)).getTime();
history.location = toPush.lastScannedAt;
allTransaction.push(history);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ router.get('/containerless', function (req, res) {
product.recalled = toPush.recalled;
product.custodian = toPush.custodian;
product.custodian = product.custodian + "," + toPush.lastScannedAt;
let timestampAsNumber = Number(toPush.timestamp);
if(protocol==="raft")
product.time = (new Date(toPush.timestamp/1000000)).getTime();
product.time = (new Date(timestampAsNumber/1000000)).getTime();
else
product.time = (new Date(toPush.timestamp * 1000)).getTime();
product.time = (new Date(timestampAsNumber * 1000)).getTime();
product.lastScannedAt = toPush.lastScannedAt;
product.containerID = toPush.containerID;
product.misc = {};
Expand Down Expand Up @@ -83,10 +84,11 @@ router.get('/:trackingID?', function (req, res) {
product.custodian = newProduct.custodian;
product.custodian = product.custodian + "," + newProduct.lastScannedAt;
product.trackingID = newProduct.trackingID;
let timestampAsNumber = Number(newProduct.timestamp);
if(protocol==="raft")
product.timestamp = (new Date(newProduct.timestamp/1000000)).getTime();
product.timestamp = (new Date(timestampAsNumber/1000000)).getTime();
else
product.timestamp = (new Date(newProduct.timestamp * 1000)).getTime();
product.timestamp = (new Date(timestampAsNumber * 1000)).getTime();
product.containerID = newProduct.containerID;
product.linearId = {
"externalId": null,
Expand Down Expand Up @@ -126,14 +128,14 @@ router.get('/:trackingID?', function (req, res) {
product.misc[key] = json[key];
}


product.custodian = toPush.custodian;
product.custodian = product.custodian + "," + toPush.lastScannedAt;
product.trackingID = toPush.trackingID;
let timestampAsNumber = Number(toPush.timestamp);
if(protocol==="raft")
product.timestamp = (new Date(toPush.timestamp/1000000)).getTime();
product.timestamp = (new Date(timestampAsNumber/1000000)).getTime();
else
product.timestamp = (new Date(toPush.timestamp * 1000)).getTime();
product.timestamp = (new Date(timestampAsNumber * 1000)).getTime();
product.containerID = toPush.containerID;
product.linearId = {
"externalId": null,
Expand Down
Loading

0 comments on commit 1524c8a

Please sign in to comment.