New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(cc-tx-visualization): capture transactional data with RxJS #3100 #3208
base: satp-dev
Are you sure you want to change the base?
Conversation
Please rebase with the latest version of satp-dev |
0cf79a6
to
4bd50b7
Compare
fabricTxObservable: Observable<RunTxReqWithTxId>; | ||
} | ||
|
||
export class CcTxVisualization implements ICactusPlugin, IPluginWebService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brunoffmateus I'm looking at the CcTxVisualization
class' source code but cannot see any mention of RxJS in the imports nor the class implementation. Could you please let me know where to look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an import { Observable } from "rxjs";
in line 56.
Then besuTxObservable
and fabricTxObservable
are used in the constructor (lines 104/105) and in the methods watchRunTransactionV1Exchange
(line 254) and watchRunTxReqWithTxId
(line 269).
@brunoffmateus please don't forget to add me as a maintainer for this package (see https://github.com/brunoffmateus/blockchain-integration-framework/blob/satp-3100-cctx/CODEOWNERS). Please also rename the plugin to cactus-plugin-ccmodel-hepheastus |
Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cc-tx-viz): add methods to fabric connector Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> fix(prometheus): metrics.ts leaks to global registry hyperledger#1202 1. Specified a `register` property of the gauges as an empty array so that it does not pollute the global namespace. This is how this is supposed to be done as per the docs of prom-client. 2. Once the change from 1) took place, the issue became that the metrics gathering code was still trying to hit up the global scope for the metrics, e.g. calling the get metrics methods directly on the promClient object instead of the registry that we create for each prmoetheus exporter object separately. So a little additional refactor ensued to fix this as well by making sure that we grab a reference of the registry object at construction time and then re-use that wherever needed instead of going through the global promClient object. 3. Added missing .startMetricsCollection calls in the plugin constructors to ensure that the prometheus exporter object gets initialized properly (this is where the registry gets created as well so without this there are crashes happening when one tries to access the metrics through the registry) Why though? The problem was that the metrics.ts file that we have for all the plugin's metrics constructs a new Metric (Gauge) object at import time which then defaults to registering the metric in the global registry of prom-client by default. The latter was causing crashes when separate versions of the same metrics.ts file are imported in a scenario were the API server imports plugins from a different directory (this issue is coming from the branch where I'm working on plugin sandboxing via the live-plugin-manager). Fixes hyperledger#1202 Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com> feat(cc-tx-viz): added test for multiple prometheus metrics on fabric Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> feat(cc-tx-viz): add metric model Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> feat(cc-tx-viz): added croschainEventLog models Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> feat(fabric): added endpoint for list of transaction receipts Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> feat(test-tooling): add RabbitMQ test server feat(cc-tx-viz): add RabbitMQ support; update model feat(cc-tx-viz): add preliminary support to Fabric and Besu build(deps): upgrade axios to latest to fix CVE Details CVE-2021-3749 high severity Vulnerable versions: <= 0.21.1 Patched version: 0.21.2 axios is vulnerable to Inefficient Regular Expression Complexity Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com> feat(cc-tx-viz): add methods to fabric connector Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> feat(cc-tx-viz): add metric model Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> xfix(cc-tx-viz): error implementation of IsVisualizable feat(cc-tx-viz): add methods to fabric and besu; update models Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> feat(cc-tx-viz): update cross chain events log for fabric transactions Signed-off-by: Iulia Mihaiu <maramih.2007@yahoo.com> feat(cctxviz): fix fabric prometheus feat(cctxviz): fix besu prometheus feat(cctxviz): fix fabric test feat(cctxviz): update tx receipt feat(cctxviz): add test script Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add test receipts feat(cctxviz): refactor CrossChainEventLog Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): refactor tests feat(cc-tx-viz): update model, add tests chore(cc-tx-viz): update dependencies Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cc-tx-viz): persist logs Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cc-tx-viz): update test Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cc-tx-viz): update strinfify to csv Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> chore(cc-tx-viz): add csv folder Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> chore(cc-tx-viz): move csv folder Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cc-tx-viz): add test feat(cctxviz): add csv file, process mining script Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): proof of concept v1 Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> chore(cctxviz): update csv Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> docs(cctxviz): update readme Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update tests Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add carbon footprint Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update tests Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update model Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(fabric-connector): update default queue Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): fabric test Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add parameters to fabric calls Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): support besu Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update metrics Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxvi): update fabric and besu tests Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): besu and fabric Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): support call transactions on fabric Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add aggregation basis Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): aggregate cctx Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> chore: update yarn and remove package.lock Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): containerize draft Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add revenue Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update model playbook Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add dummy use case playbook Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): update persist test and dummy uc Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add timer Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): workload test Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add more timers Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): add timer to map on connectors Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update testing framework Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): vis plot wip Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): evaluate baseline Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update plots Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): add test files Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> feat(cctxviz): update testing framework Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): time-efficient polling receipts Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> chore(cctxviz): add test chaincode Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): update test Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): use case v1 Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): update test framework Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> build(cc-tx-visualization): added missing fabric-contract-api This will fix one compilation error. Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com> chore(deps): updated yarn.lock after rebase onto upstream/main Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com> build(cc-tx-visualization): deleted redundant test fixtures Also added the test-tooling package as a dev dependency which should fix a few of the compiler errors we were getting on account of missing dependencies. Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com> fix: resolved build errors for cctxviz branch - test-tooling package changed that needs to be reverted before commmit to main branch - added import statement for test data generationt xfix(cc-tx-viz): error implementation of IsVisualizable chore: update yarn and remove package.lock Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): testing framework Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): test framework Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): update framework Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): add graphs Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): add test Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> fix(cctxviz): fix bug Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> test(cctxviz): add process conformance Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>
The plugin now utilizes RxJS instead of RabbitMQ in transaction monitoring. ReplaySubjects store and emit observed transactional data to subscribers. fix(cc-tx-visualization): rebase latest version Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt> squash! - migrate a test case to Fabric v2.5.6 LTS AIO This is just a snippet of a change from the pair programming call with Bruno, it can be safely squashed, no worries. Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com> Signed-off-by: Bruno Mateus <brumat315@gmail.com>
4bd50b7
to
a2e32f7
Compare
@brunoffmateus Looks much better. Please rename the plugin too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, but there are a few concerns that need to be addressed:
- Code does not compile
- Tests need to be refactored to use Jest
- Test connectors transaction polling via Observables (instead of using mocks).
@@ -33,6 +33,8 @@ | |||
"cccs", | |||
"ccep", | |||
"ccid", | |||
"cctx", | |||
"cctxviz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will remove this as we will rename the plugin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad, missed 3. good job
@@ -1,5 +1,6 @@ | |||
* @petermetz @takeutak @izuru0 @jagpreetsinghsasan @vramakrishna @sandeepnRES @outSH | |||
|
|||
packages/cactus-plugin-cc-tx-visualization @RafaelAPB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename plugin
@@ -121,5 +121,9 @@ module.exports = { | |||
`./examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts`, | |||
`./examples/cactus-example-supply-chain-backend/src/test/typescript/integration/supply-chain-backend-api-calls.test.ts`, | |||
`./examples/cactus-example-supply-chain-backend/src/test/typescript/integration/supply-chain-cli-via-npm-script.test.ts`, | |||
`./packages/cactus-plugin-cc-tx-visualization/src/test/typescript/integration/cctxviz-generate-use-case-dummy-baseline-events.test.ts`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please re-implement the tests to use Jest, and remove this
@@ -130,6 +130,9 @@ | |||
{ | |||
"path": "./packages/cactus-test-verifier-client/tsconfig.json" | |||
}, | |||
{ | |||
"path": "./packages/cactus-plugin-cc-tx-visualization/tsconfig.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget rename
return 30; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try to obtain this dynamically for EVM chains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if fabric or besu, return default
public async saveModel( | ||
modelType: CrossChainModelType, | ||
model: string, | ||
): Promise<void> { | ||
this.crossChainModel.saveModel(modelType, model); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also have methods to:
- read a serialized CrossChainModelType
- read the output from pm4py
- convert pm4py into CrossChainModelType, and vice versa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend you to create a new directory, something like pm4py-adapter
, where you put the code that handles interactions between this plugin and pm4py
1;txID2;2024-04-15T18:11:42.598Z;FABRIC_2;FabricContractInvocationType.SEND;LockAsset;"[""asset1""]";A;0;0.00018;39;0 | ||
1;txID3;2024-04-15T18:11:42.599Z;FABRIC_2;FabricContractInvocationType.SEND;CreateAsset;"[""1"",""100""]";A;0;0.00018;60;0 | ||
1;txID4;2024-04-15T18:11:42.600Z;FABRIC_2;FabricContractInvocationType.SEND;TransferAsset;"[""asset1"",""targetAccount""]";A;0;0.00018;61;0 | ||
1;txID5;2024-04-15T18:11:42.601Z;FABRIC_2;FabricContractInvocationType.SEND;TransferAsset;"[""asset1"",""targetAccount2""]";A;0;0.00018;61;0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have these tests all start with example-dummy
. don't forget to change the file name on the csv creation logic in the tests
@@ -0,0 +1,102 @@ | |||
[ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see CSV comment
@@ -0,0 +1,241 @@ | |||
import test, { Test } from "tape-promise/tape"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor to use Jest; refactor to use new functionality
import { | ||
FabricContractInvocationType, | ||
RunTxReqWithTxId, | ||
} from "@hyperledger/cactus-plugin-ledger-connector-fabric"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is a connector being initialized? we need to test with real connectors, not mocks. Is the observable functionality enabled in the respective connector?
The plugin now utilizes RxJS instead of RabbitMQ in transaction monitoring.
ReplaySubjects store and emit observed transactional data to subscribers.