PharmaLedger-IMI / fgt-workspace

UC3 Finished Goods Traceability
MIT License
5 stars 3 forks source link

Connect system to blockchain node #30

Closed TiagoV-PDMFC closed 2 years ago

TiagoV-PDMFC commented 3 years ago

Deploy blockchain environment and connect fgt to it to simulate 'real-world' behaviour.

connects to issue #28

TiagoV-PDMFC commented 3 years ago

as of commit 4a5fd32223ee7b07637b2df56e56c3d2478eb67a the build and environment deployment happes successfully

joaoluis-pdm commented 2 years ago

image image image

joaoluis-pdm commented 2 years ago
[10h17](https://opendsu.slack.com/archives/G01DZPK1212/p1645697827305079)
[João Luís (PDM)](https://app.slack.com/team/U01DMGU0W5T) Today I have this error in ethAdaptor 62c61b45c9ff44900d31d79d1efc803e024c3589 and psk-release a34b39909b21db33b8219a1e2a88226bdba135d9 - ReporterError: length octect is too long at: (shallow)finished get anchors : 2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BvYQW3X48Wj6FGtKXpoV8PrfQe2HVgxVT5oGG5krPy43zkSu7FdNVWVDr3tJ9QcrUCKeHSTrZ7ANfZJYsiyqXbHogt9FonaB7PNPeiX76TCL24qapmGvBB9RC5PDH []
response getAnchorVersions 200 2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BvYQW3X48Wj6FGtKXpoV8PrfQe2HVgxVT5oGG5krPy43zkSu7FdNVWVDr3tJ9QcrUCKeHSTrZ7ANfZJYsiyqXbHogt9FonaB7PNPeiX76TCL24qapmGvBB9RC5PDH []
body received :  {
  hash: {
    newHashLinkSSI: 'HxMN6F7bEr3M14JMPPgGVkXwUyAf6zQtFMYFhT4AVxmNmdQJEbRbEj9pZBwb3uUip5HHYeMSgYW9UwRiqyKpzWmPydegEJCj69irmRkor1goGxkTTAfaFtPQLQEF43ZUVbV3pYEHttZXKDaEZNNWkudsNymqVUhjAUvPxRoSJsDAFCrtujyUCJfy7f9hup51PtuzZSgzFdAD8R3LuLJD2rgQGrirDjLaq2LXRgBpvwh',
    lastHashLinkSSI: null
  },
  digitalProof: {
    signature: 'B4RnxF5i3fCw9QkrKLhWAY2iRQwmnGbBcGnbXWDVhUs8YNRcanRMG163KNF8FGEUY2e3yhpL6fViH5AV8ZwB4qx9Z',
    publicKey: 'PZodA79Fn12o38w5DafpYWj7KzPGBycafLUfj32vXWnuo2m9ULNrLd3LbkJU3YR45Gft1KKdrq5iTTHaNG6c6faL'
  },
  zkp: ''
}
Decoded from 2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BvYQW3X48Wj6FGtKXpoV8PrfQe2HVgxVT5oGG5krPy43zkSu7FdNVWVDr3tJ9QcrUCKeHSTrZ7ANfZJYsiyqXbHogt9FonaB7PNPeiX76TCL24qapmGvBB9RC5PDH  into KEYSSI :  [
  'ssi',
  'sza',
  'traceability',
  '',
  'PZodA79Fn12o38w5DafpYWj7KzPGBycafLUfj32vXWnuo2m9ULNrLd3LbkJU3YR45Gft1KKdrq5iTTHaNG6c6faL',
  'v0'
]
public key RAW :  PZodA79Fn12o38w5DafpYWj7KzPGBycafLUfj32vXWnuo2m9ULNrLd3LbkJU3YR45Gft1KKdrq5iTTHaNG6c6faL
prefixed pub key :  0x0468a9aab314bec48a1c2f8646d0105eb117e148b7dbf719568c78e72f888996e32ca02301a2d95c4a77c87fb17ed46c0de406bbfb5a23ef65cf9e3f5a6774763d
signature :  B4RnxF5i3fCw9QkrKLhWAY2iRQwmnGbBcGnbXWDVhUs8YNRcanRMG163KNF8FGEUY2e3yhpL6fViH5AV8ZwB4qx9Z
------------------------------------------------------
2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BvYQW3X48Wj6FGtKXpoV8PrfQe2HVgxVT5oGG5krPy43zkSu7FdNVWVDr3tJ9QcrUCKeHSTrZ7ANfZJYsiyqXbHogt9FonaB7PNPeiX76TCL24qapmGvBB9RC5PDH
ReporterError: length octect is too long at: (shallow)
    at DecoderBuffer.error (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:32788:11)
    at derDecodeLen (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:35613:16)
    at DERNode.decodeTag [as _decodeTag] (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:35389:13)
    at DERNode.decode [as _decode] (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:32447:23)
    at DERNode.decode [as _decode] (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:32389:47)
    at ECPrivateKey.decode (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:35359:20)
    at Entity.decode (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:31970:32)
    at Object.decodeDERIntoASN1ETH (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:36192:31)
    at PskCrypto.decodeDerToASN1ETH (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:31806:70)
    at Object.convertDerSignatureToASN1 (/ePI-workspace/privatesky/psknode/bundles/openDSU.js:16279:33)
    at Object.convertDerSignatureToASN1 (/ePI-workspace/ethadapter/EthAdapter/utils/opendsuutils.js:20:26)
    at getSignatureForSmartContract (/ePI-workspace/ethadapter/EthAdapter/controllers/addAnchor.js:114:38)
    at /ePI-workspace/ethadapter/EthAdapter/controllers/addAnchor.js:59:31
    at Layer.handle [as handle_request] (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/layer.js:95:5)
    at next (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/layer.js:95:5)
    at /ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:281:22
    at param (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:360:14)
    at param (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:371:14)
    at Function.process_params (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:416:3)
    at next (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:275:10)
    at IncomingMessage.<anonymous> (/ePI-workspace/ethadapter/EthAdapter/webserver.js:25:9)
    at IncomingMessage.emit (events.js:314:20)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  path: ''
}
------------------------------------------------------
finished get anchors : 2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BvYQW3X48Wj6FGtKXpoV8PrfQe2HVgxVT5oGG5krPy43zkSu7FdNVWVDr3tJ9QcrUCKeHSTrZ7ANfZJYsiyqXbHogt9FonaB7PNPeiX76TCL24qapmGvBB9RC5PDH [] (editado)
[11h40](https://opendsu.slack.com/archives/G01DZPK1212/p1645702806395969)
[Tiago](https://app.slack.com/team/U01DQJ39VDH) can it be a conflict since we're using the opendsu version os last week on fgt?
[12h16](https://opendsu.slack.com/archives/G01DZPK1212/p1645704979254559)
[João Luís (PDM)](https://app.slack.com/team/U01DMGU0W5T) Same error using FGT on psk-release a34b39909b21db33b8219a1e2a88226bdba135d9 and quorum-docker:latest, wich pulls ethAdapter:latest (and the latest smart contract).
joaoluis-pdm commented 2 years ago

image

joaoluis-pdm commented 2 years ago
[João Luís (PDM)](https://app.slack.com/team/U01DMGU0W5T)  [há 4 horas](https://opendsu.slack.com/archives/G01DZPK1212/p1647528120674039?thread_ts=1647452936.964729&cid=G01DZPK1212)
Just to update that we managed a working combination with:psk-release      6f5ad4c50f6eea9589a5eaeaf056767c4a43d2b8     Thu Feb 17 11:50:54 2022 +0200
ethadapter       a63308f5ffe1182311dc10b6e49473727b8acc99      Mon Mar 14 15:45:02 2022 +0200
epi-workspace adac48270eef5629ab2134ea3fc50be2da5e9f02      Wed Mar 16 17:05:55 2022 +0200So please consider the above questions overcome (by trial and error :-)

Spoke too soon! :decepcionado:

I am getting in ethAdapter the error:TypeError: anchorFactory.methods.getAnchorVersions is not a function
    at getVersions (/ePI-workspace/ethadapter/EthAdapter/anchoring/getVersionsAnchorSmartContract.js:3:27)
    at /ePI-workspace/ethadapter/EthAdapter/controllers/getVersions.js:6:63
    at Layer.handle [as handle_request] (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/layer.js:95:5)
    at next (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/layer.js:95:5)
    at /ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:281:22
    at param (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:360:14)
    at param (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:371:14)
    at Function.process_params (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:416:3)
    at next (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:275:10)
    at IncomingMessage.<anonymous> (/ePI-workspace/ethadapter/EthAdapter/webserver.js:25:9)
    at IncomingMessage.emit (events.js:314:20)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)Any ideas ? Go forward/backwards with versions ? (editado) 

Even if I replace (in the ethadapter) the implementation of

ethadapter/EthAdapter/anchoring/getVersionsAnchorSmartContract.js

with the existing

ethadapter/EthAdapter/anchoring/getAllVersionsSmartContract.jsit passes that error.But later will fail on

[João Luís (PDM)](https://app.slack.com/team/U01DMGU0W5T)  [há 3 minutos](https://opendsu.slack.com/archives/G01DZPK1212/p1647543855510719?thread_ts=1647452936.964729&cid=G01DZPK1212)
/addAnchor/2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BkoDW1gpEY1kvTCYzPFacnzBmj9kBtz8zaQ4NPFUkZNDGmGcNHKgAdNfzVw1y45W8vxDhmEPopZ9kDCwkCtcPdtP7MAnNtFb4rmnYoyinULMzX8KaUAn3YgdBewBm {
  hash: {
    newHashLinkSSI: '4qnrBhooj78L2psbyjJ44LqFA4DA5wVRmv8oEbHF4yd9XAmrYKFVeSnPjCNVb7F6seKGR6BtapYTsTVLx2yMJevnu6PtohEau2694UgRNeeWbYJzbzZhvpiC37Eh2ziWQLeKfSSwdTJSKh1PTCnqK8cRLV12tRMyTdbVH7AnQ2zi5fqdQj2GuUy8YpgP6HVjyTBwkuP7brpLmb5pwZL7EF1vfyrXus5Q7VVUgkFUQo',
    lastHashLinkSSI: null
  },
  digitalProof: {
    signature: '30Egm52sBEtQTggn6JyG2wLDdF8PeXaN2iJTIWyz1itSJjbVsMjYeyp2zLZ0symMZ0UUxPGvBUid4MbcG2V6wBw=',
    publicKey: 'BD6qfaLJ+5IP7OfGWvWVOCprLYG/YNb7F88Z4J8gIepFm95CILlc7OMLN4sKZwjQfcE4ViMjwzCOQ8pSdMQHVVs='
  },
  zkp: ''
}
body received :  {
  hash: {
    newHashLinkSSI: '4qnrBhooj78L2psbyjJ44LqFA4DA5wVRmv8oEbHF4yd9XAmrYKFVeSnPjCNVb7F6seKGR6BtapYTsTVLx2yMJevnu6PtohEau2694UgRNeeWbYJzbzZhvpiC37Eh2ziWQLeKfSSwdTJSKh1PTCnqK8cRLV12tRMyTdbVH7AnQ2zi5fqdQj2GuUy8YpgP6HVjyTBwkuP7brpLmb5pwZL7EF1vfyrXus5Q7VVUgkFUQo',
    lastHashLinkSSI: null
  },
  digitalProof: {
    signature: '30Egm52sBEtQTggn6JyG2wLDdF8PeXaN2iJTIWyz1itSJjbVsMjYeyp2zLZ0symMZ0UUxPGvBUid4MbcG2V6wBw=',
    publicKey: 'BD6qfaLJ+5IP7OfGWvWVOCprLYG/YNb7F88Z4J8gIepFm95CILlc7OMLN4sKZwjQfcE4ViMjwzCOQ8pSdMQHVVs='
  },
  zkp: ''
}
Decoded from 2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BkoDW1gpEY1kvTCYzPFacnzBmj9kBtz8zaQ4NPFUkZNDGmGcNHKgAdNfzVw1y45W8vxDhmEPopZ9kDCwkCtcPdtP7MAnNtFb4rmnYoyinULMzX8KaUAn3YgdBewBm  into KEYSSI :  [
  'ssi',
  'sza',
  'traceability',
  '',
  'BD6qfaLJ+5IP7OfGWvWVOCprLYG/YNb7F88Z4J8gIepFm95CILlc7OMLN4sKZwjQfcE4ViMjwzCOQ8pSdMQHVVs=',
  'v0'
]
------------------------------------------------------
2eg3XSYLuY9m6WqTiuqrGAy3mMB9s3BkoDW1gpEY1kvTCYzPFacnzBmj9kBtz8zaQ4NPFUkZNDGmGcNHKgAdNfzVw1y45W8vxDhmEPopZ9kDCwkCtcPdtP7MAnNtFb4rmnYoyinULMzX8KaUAn3YgdBewBm
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Function.from (buffer.js:330:9)
    at /ePI-workspace/ethadapter/EthAdapter/controllers/addAnchor.js:35:43
    at Layer.handle [as handle_request] (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/layer.js:95:5)
    at next (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/layer.js:95:5)
    at /ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:281:22
    at param (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:360:14)
    at param (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:371:14)
    at Function.process_params (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:416:3)
    at next (/ePI-workspace/ethadapter/EthAdapter/node_modules/express/lib/router/index.js:275:10)
    at IncomingMessage.<anonymous> (/ePI-workspace/ethadapter/EthAdapter/webserver.js:26:9)
    at IncomingMessage.emit (events.js:314:20)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}
------------------------------------------------------    

ethAdapter+psk-release seems just to unstable to do anything with it.

joaoluis-pdm commented 2 years ago

After updating psk-release, seems to work with cda1a9e498cc4fba10006d5f4c08c0554e8f4762

joaoluis-pdm commented 2 years ago

Spoke too soon. Failed wsCreateStuff

Sleep 2000ms
http PUT {"path":"/traceability/shipment/update/MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758","method":"PUT","headers":{"content-type":"application/json","content-length":82},"hostname":"api-mah-msd.localhost","port":"8080"} {"status":"delivered","extraInfo":"Delivered in good condition by a test script!"}
res {
  shipmentId: 'MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758',
  orderId: 'WHS000001-2022-03-18T12:11:26.231Z',
  requesterId: 'WHS000001',
  senderId: 'MAH136366355',
  status: {
    status: 'delivered',
    log: [
      'MAH136366355 1647605496725 set status to created',
      'MAH136366355 1647605542271 updated status from created to pickup',
      'MAH136366355 1647605548503 updated status from pickup to transit',
      'MAH136366355 1647605554867 updated status from transit to delivered'
    ],
    extraInfo: { pickup: [Array], transit: [Array], delivered: [Array] }
  },
  shipmentLines: [
    {
      gtin: '00366582505358',
      batch: 'R034995',
      quantity: 100,
      senderId: 'MAH136366355',
      requesterId: 'WHS000001',
      status: [Object],
      createdOn: 1647605486249
    },
    {
      gtin: '00191778005295',
      batch: 'U002114',
      quantity: 100,
      senderId: 'MAH136366355',
      requesterId: 'WHS000001',
      status: [Object],
      createdOn: 1647605486249
    }
  ]
}
Sleep 2000ms
http PUT {"path":"/traceability/shipment/update/MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758","method":"PUT","headers":{"content-type":"application/json","content-length":80},"hostname":"api-whs1.localhost","port":"8080"} {"status":"received","extraInfo":"Received in good condition by a test script!"}
res {
  status: 400,
  error: 'Bad Request',
  message: 'Missing record in table simpleShipments and key MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758(Path </mydb/simpleShipments/records/MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758> not found.)'
}
/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:505
        throw Error("shipment/update "+shipmentId+" reply has no shipmentId: "+JSON.stringify(resUReceived));
              ^

Error: shipment/update MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758 reply has no shipmentId: {"status":400,"error":"Bad Request","message":"Missing record in table simpleShipments and key MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758(Path </mydb/simpleShipments/records/MAH136366355-WHS000001-WHS000001-2022-03-18T12:11:26.231Z-16476054862483241758> not found.)"}
    at shipmentCreateAndDeliver (/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:505:15)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async shipmentsCreateTest (/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:552:5)
    at async shipmentsCreate (/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:620:9)
    at async /export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:799:5

mahAndWhs1Log.zip

joaoluis-pdm commented 2 years ago

Analyzing with @TiagoV-PDMFC and @pccosta-pdm it seems that the problem above is just a very hight delay (>60 seconds) between a shipment is updated on the MAH and propagated to the WHS.

joaoluis-pdm commented 2 years ago

Problem with slow requests on haproxy:

Sleep 10000ms
https POST {"path":"/traceability/shipment/create","method":"POST","headers":{"content-type":"application/json","content-length":210},"hostname":"api-mah-msd-fgt-dev.pharmaledger.pdmfc.com","port":"443"} {"orderId":"WHS000001-2022-03-18T15:50:29.373Z","requesterId":"WHS000001","shipmentLines":[{"gtin":"00366582505358","batch":"R034995","quantity":100},{"gtin":"00191778005295","batch":"U002114","quantity":100}]}
res <html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>
Mar 18 15:51:19 haproxy haproxy[858791]: 95.136.94.6:48978 [18/Mar/2022:15:50:29
.425] localhost~ fgt-dev-pl/fgt-dev-pl 0/0/1/-1/50003 504 203 - - sH-- 3/3/0/0/0
 0/0 "POST /traceability/shipment/create HTTP/1.1"
joaoluis-pdm commented 2 years ago

haproxy server timeout raised to 5min

backend fgt-dev-pl
        option forwardfor
        timeout server 5m
        server fgt-dev-pl fgt-dev-pl:8080
joaoluis-pdm commented 2 years ago

Timings comparison (for the same test run of wsCreateStuff):

timingsEth.log

timingsLocal.log

A total of 1228 transactions on ETH (including building of the solution at v0.8.4)

The "timingsEth.log" is from fgt-dev-pl with geth on HDD and "timingsLocal.log" is from a laptop with geth on SSD, so the hardware is not directly comparable.

geth block creation (mining) every 1 second.

But you get +/- between 10 and 20 times slower without ETH.

The slowest transaction seems to be /shipment/create (2 shipment lines, takes +/- 53 seconds).

The wait time needed to so something between participants also needs to be much higher. 3 seconds wait time on laptop, 60 seconds on fgt-dev-pl with ETH.

joaoluis-pdm commented 2 years ago

Actual steps to install ETH on fgt-dev-pl:

# 1st - start blockchain
cd ~/
git clone https://github.com/PharmaLedger-IMI/blockchain-node-workspace
cd blockchain-node-workspace
npm install
npm run deploy-blockchain

On another terminal, after the ethadapter starts up:

#2 - remove all running dockers and volume data, and then startup dockers with fgt-workspace (domain traceability) pointing to the ethAdapter at http://172.16.16.16:3000
cd fgt-workspace/docker/api
docker-compose down -v --rmi local
./bootCompose eth-dev

... and then wait for everyting to be operational.

# from a laptop, create a few test data
cd fgt-workspace/bin/environment
node wsCreateStuff.js --env=dev

Screenshot 2 days uptime. image

Screenshot 5 days uptime. image

joaoluis-pdm commented 2 years ago

blockchain-node-workspace was upgraded to v0.4.0

ethadapter image needs to be re-generated, sot it must be deleted.

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ npm run down-blockchain
Removing node4-qbn ... done
Removing network qbn-net
ERROR: error while removing network: network qbn-net id d365805159d015731870c804348af4e2b2fc1b4e1b3d86a53fc62f39c3403e72 has active endpoints

# qbn-net cannot be removed because fgt-workspace is using it

# volumes are kept

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ docker images
REPOSITORY                       TAG            IMAGE ID       CREATED         SIZE
api_mah-msd                      latest         22ed2afff93c   4 days ago      2.26GB
api_mah-roche                    latest         22ed2afff93c   4 days ago      2.26GB
api_pha-1                        latest         22ed2afff93c   4 days ago      2.26GB
api_whs-1                        latest         22ed2afff93c   4 days ago      2.26GB
api_whs-takeda                   latest         22ed2afff93c   4 days ago      2.26GB
api_whs-2                        latest         22ed2afff93c   4 days ago      2.26GB
api_mah-bayer                    latest         22ed2afff93c   4 days ago      2.26GB
api_mah-gsk                      latest         22ed2afff93c   4 days ago      2.26GB
api_mah-novo-nordisk             latest         22ed2afff93c   4 days ago      2.26GB
api_mah-pfizer                   latest         22ed2afff93c   4 days ago      2.26GB
api_mah-takeda                   latest         22ed2afff93c   4 days ago      2.26GB
api_pha-2                        latest         22ed2afff93c   4 days ago      2.26GB
api_fgt-workspace                latest         c5ead592202c   4 days ago      2.26GB
ethadapter                       latest         394d990f37c7   5 days ago      1.42GB
nginx                            latest         f2f70adc5d89   5 days ago      142MB
mongo                            latest         cb2388d1f0a5   2 weeks ago     698MB
vegardit/traefik-logrotate       latest         4f9a2b6c24d0   2 weeks ago     66.2MB
traefik                          v2.6           eddc86c9f0a0   5 weeks ago     102MB
debian                           bullseye       04fbdaf87a6a   8 weeks ago     124MB
quorumengineering/quorum         21.7.1         8f2316bf5c56   7 months ago    85.3MB
node                             14.16-buster   3e08f95a9c7f   10 months ago   911MB
web3labs/epirus-free-api         latest         c413a5a5c027   15 months ago   353MB
web3labs/epirus-free-ingestion   latest         965d284e497e   15 months ago   351MB
web3labs/epirus-free-web         latest         d5521e0c1abc   16 months ago   378MB

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ docker rmi ethadapter

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ df -k /
Filesystem                        1K-blocks     Used Available Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv  60759916 28319716  29640048  49% /
pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ rm -rf *
pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ git checkout .
Updated 107 paths from the index
pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ git pull
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 28 (delta 24), reused 19 (delta 15), pack-reused 0
Unpacking objects: 100% (28/28), 3.43 KiB | 351.00 KiB/s, done.
From https://github.com/PharmaLedger-IMI/blockchain-node-workspace
   7719cc2..f23ab0c  master     -> origin/master
 * [new tag]         v0.4.0     -> v0.4.0
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ git checkout v0.4.0
Previous HEAD position was cda1a9e #1 - try epi-workspace 2022-03-02
HEAD is now at f23ab0c #3 - v0.4.0 wait 5 seconds after starting quorum

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ npm i

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ docker volume ls
DRIVER    VOLUME NAME
local     9bfa88b511013dce201d9eb92d234231e7e7be3e48a0819281faba594e182e83
local     042dd8cb3f4c9afa4070cdaabad0eb4fdb99be368d2a7435f8780d8cf5de439a
local     api_mah-bayer_vol
local     api_mah-gsk_vol
local     api_mah-msd_vol
local     api_mah-novo-nordisk_vol
local     api_mah-pfizer_vol
local     api_mah-roche_vol
local     api_mah-takeda_vol
local     api_pha1_vol
local     api_pha2_vol
local     api_traceability_vol
local     api_whs1_vol
local     api_whs2_vol
local     api_whs-takeda_vol
local     quorum_vol1
local     quorum_vol2
local     quorum_vol3
local     quorum_vol4

pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ npm run deploy-blockchain
pharmaledger@fgt-dev-pl:~/blockchain-node-workspace$ npm run deploy-blockchain

> blockchain-node-workspace@0.4.0 deploy-blockchain /home/pharmaledger/blockchain-node-workspace
> node ./node_modules/octopus/scripts/setEnv --file=../../../env.json "node ./node_modules/octopus/scripts/run deploy-blockchain"

Running in STABLE (FREEZED) mode
Preparing to set on process.env the following info: {
  PSK_TMP_WORKING_DIR: 'tmp',
  PSK_CONFIG_LOCATION: '../apihub-root/external-volume/config',
  DEV: false
}
Environment updated accordingly to env file passed as argument.
Preparing to execute cmd node ./node_modules/octopus/scripts/run deploy-blockchain
Looking for configuration file at path /home/pharmaledger/blockchain-node-workspace/octopus-freeze.json
Action buildWebCardinalComponents was registered.
[Octopus] Start checking deploy-blockchain...
[Octopus] Found 4 deploy-blockchain...
[Octopus] Running tasks for: [0] start goQuorum as in quorum/deploy-quorum.sh
Running command: cd quorum && docker-compose up -d
Creating node1-qbn ... done
Creating node4-qbn ... done
Creating node2-qbn ... done
Creating node3-qbn ... done
Running command: node -e "setTimeout(()=>{},5000)"
[Octopus] Running tasks for: [1] Start blockchain explorer as in blockchain-explorer/deploy-explorer.sh
Running command: cd blockchain-explorer && docker-compose -f docker-compose.yml -f docker-compose-quorum.yml up -d
Creating blockchain-explorer_mongodb_1 ... done
Creating blockchain-explorer_api_1       ... done
Creating blockchain-explorer_ingestion_1 ... done
Creating blockchain-explorer_web_1       ... done
Creating blockchain-explorer_nginx_1     ... done
[Octopus] Running tasks for: [2] Create Org Account and deploy smart contract
Running command: node bin/createOrgAcc.js
Running command: node bin/deployAnchoringSC.js
/home/pharmaledger/blockchain-node-workspace/node_modules/solc/soljson.js:138
    process["on"]("unhandledRejection", function (reason) { throw reason; });
                                                            ^

Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/home/pharmaledger/blockchain-node-workspace/node_modules/web3-core-helpers/lib/errors.js:43:16)
    at XMLHttpRequest.request.onreadystatechange (/home/pharmaledger/blockchain-node-workspace/node_modules/web3-providers-http/lib/index.js:95:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/pharmaledger/blockchain-node-workspace/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/pharmaledger/blockchain-node-workspace/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpRequestError (/home/pharmaledger/blockchain-node-workspace/node_modules/xhr2-cookies/dist/xml-http-request.js:349:14)
    at ClientRequest.<anonymous> (/home/pharmaledger/blockchain-node-workspace/node_modules/xhr2-cookies/dist/xml-http-request.js:252:61)
    at ClientRequest.emit (events.js:400:28)
    at Socket.socketOnEnd (_http_client.js:499:9)
    at Socket.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

/home/pharmaledger/blockchain-node-workspace/node_modules/octopus/scripts/run.js:22
    throw err;
    ^
Action execute finished: exit code 1
(Use `node --trace-uncaught ...` to show where the exception was thrown)

I did not took note of previous account and smart contract address, so I have to re-create everything :-(

... re-created both blockchain-node-workspace and fgt-workspace/docker/api

I should have backed up /home/pharmaledger/blockchain-node-workspace/ethadapter/EthAdapter/docker-compose.yml and preserve data:

    environment:
      - RPC_ADDRESS=http://node1-qbn:8545
      - SMARTCONTRACTADDRESS=...
      - 'SMARTCONTRACTABI=...
      - 'ORGACCOUNT=...'

Alternative, preserve for the next time

pharmaledger@fgt-dev-pl:~/fgt-workspace/docker/api$ cp -p ~/blockchain-node-workspace/stages/OrgAcc/orgAcc.json ~/blockchain-node-workspace/stages/SmartContracts/AnchoringSCInfo.json ~/blockchain-node-workspace/stages/SmartContracts/AnchoringSCCompiled.json ~/blockchain-keybackup/
joaoluis-pdm commented 2 years ago

For memory leak purposes, the memory usage after re-creating the blockchain-node-workspace and all fgt dockers (without running wsCreateStuff):

image

Then created stuff:

jpsl@PDM-00781:/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment$ node --unhandled-rejections=strict wsCreateStuff.js --env=dev 2>&1 | tee -a xLogDevFull20220323.log

Several errors of kind

Sleep 2000ms
https PUT {"path":"/traceability/shipment/update/MAH136366355-WHS000001-WHS000001-2022-03-23T16:20:51.407Z-16480524514777834538","method":"PUT","headers":{"content-type":"application/json","content-length":80},"hostname":"api-whs1-fgt-dev.pharmaledger.pdmfc.com","port":"443"} {"status":"received","extraInfo":"Received in good condition by a test script!"}
res 109ms {
  status: 400,
  error: 'Bad Request',
  message: 'Missing record in table simpleShipments and key MAH136366355-WHS000001-WHS000001-2022-03-23T16:20:51.407Z-16480524514777834538(Path </mydb/simpleShipments/records/MAH136366355-WHS000001-WHS000001-2022-03-23T16:20:51.407Z-16480524514777834538> not found.)'
}

Need a sleep of 65secs

node --unhandled-rejections=strict wsCreateStuff.js --env=dev --sleep=60000 2>&1 | tee -a xLogDevFull20220323.log

top screenshot after wsCreateStuff image

joaoluis-pdm commented 2 years ago

Done for https://github.com/PharmaLedger-IMI/blockchain-node-workspace/releases/tag/v0.4.2

The BC v0.4.2 is unstable, but let that solve itslef in its own issue https://github.com/PharmaLedger-IMI/blockchain-node-workspace/issues/5

joaoluis-pdm commented 2 years ago

Also connect the system to hlf. https://github.com/PharmaLedger-IMI/blockchain-hf-workspace

As hlf is using a distinct IP address 172.16.0.9, a distinct traceability.json domain patch is required.

joaoluis-pdm commented 2 years ago

As the change https://github.com/PharmaLedger-IMI/blockchain-hf-workspace/commit/6eeda211722cfaf711009209726443c3a221bda5 allows the hlf-adapter to run at the same private IP address 172.16.16.16:3000 there is no need to change fgt.

joaoluis-pdm commented 2 years ago

Branch refs30_dockerSeqStartup was created to test the startup of all the docker containers in sequence.

This was done to attempt workaround of https://github.com/PharmaLedger-IMI/blockchain-hf-workspace/issues/3

joaoluis-pdm commented 2 years ago

Branch refs30_dockerSeqStartup was created to test the startup of all the docker containers in sequence.

This was done to attempt workaround of https://github.com/PharmaLedger-IMI/blockchain-hf-workspace/issues/3

joaoluis-pdm commented 2 years ago

qbn-net has been renamed to dsu-bc-net in https://github.com/PharmaLedger-IMI/blockchain-node-workspace/ (since v0.4.5) and in https://github.com/PharmaLedger-IMI/blockchain-hlf-workspace

Rename qbn-net to dsu-bc-net

joaoluis-pdm commented 2 years ago

HyperLedger experiments where suspended on 2022-08-19 due to https://github.com/PharmaLedger-IMI/blockchain-hlf-workspace/issues/6

fgt-dev is now running with simulated blockchain.

joaoluis-pdm commented 2 years ago

https://github.com/PharmaLedger-IMI/blockchain-hlf-workspace/issues/6 closed. fgt-dev back to hlf blockchain.

joaoluis-pdm commented 2 years ago

Quoted from: https://github.com/PharmaLedger-IMI/blockchain-node-workspace/issues/5#issuecomment-1245393626

On OpenDSU acceleration meeting 2022-09-13, it was presented that this problem seems due to some sort of GoQuorum limitation/protection. 2 kinds of workaround will be provided: 1 - OBA (Optimistic Blockchain Anchoring) 2 - throttling at the eth-adapter (client will have do deal with errors and retry...)