Skip to content
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

Add monitoring and send sync/async functionality #1966

Closed
wants to merge 3 commits into from

Conversation

StepniowskiP
Copy link

Add monitoring and sending async/sync requests to ledger via SocketIO.

stepniowskip and others added 2 commits April 11, 2022 12:45
Add monitoring and sending async/sync requests to ledger via SocketIO.

Closes: hyperledger-cacti#1941
Signed-off-by: stepniowskip <[email protected]>
Copy link
Contributor

@izuru0 izuru0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP The two tests below are being skipped by the CI right now, did you run these manually on your machine and did they pass?

  • packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-iroha-transfer-example.test.ts
  • packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts

args: any,
method?: Record<string, unknown>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Seems like a breaking change. Could you please refactor it to be backwards compatible with 1.0.0?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I have refactored method parameter to one before my changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Is it just me or the parameters are still out of order (e.g. not backwards compatible)?
This is the diff I'm looking at:

image

args: any,
method?: Record<string, unknown>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Seems like a breaking change. Could you please refactor it to be backwards compatible with 1.0.0?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I have refactored method parameter to one before my changes

return Transaction.CLASS_NAME;
}

constructor(logLevel?: LogLevelDesc) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Please use an interface to define an object that contains the options, that way adding new arguments can be done within that object instead of having to pile up new options as the Nth constructor parameter and struggle with ordering, etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import commands from "iroha-helpers-ts/lib/commands/index";
import queries from "iroha-helpers-ts/lib/queries";

export class Transaction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Could this be called IrohaTransactionWrapper instead? The Iroha prefix will help with distinguishing it in the logs from every other ledger's transaction logs and the Wrapper will hint at the fact that it's not the class/type that ships with the Iroha libraries that we use.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, renamed to IrohaTransactionWrapper

public async sendSyncRequest(syncRequestData: any): Promise<void> {
this.log.debug(`Inside ##sendSyncRequest()`);

syncRequestData["syncRequest"] = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Could this input mutation be avoided by having the boolean flag as a separate parameter of the sendAsyncRequest method?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added flag parameter async to sendRequest function

clearInterval(this.monitoringInterval);
}

public async sendAsyncRequest(asyncRequestData: any): Promise<any> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP If it supports both sync and async would it make sense to not call it sendAsyncRequest but maybe sendRequest ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, renamed and refactored

const block = await this.sendAsyncRequest(syncRequestData);
this.log.debug(block);
this.socket.emit("response", block.transactionReceipt);
} catch (err: any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Can you use unknown instead of any?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

socket: SocketIoSocket;
}

export class SocketSessionEndpoint {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Any chance that you could make the name of the class and the constructor arg interface type consistent?
SocketSessionEndpoint is a bit too generic in my opinion because literally every endpoint that uses SocketIO could be accurately be described by the same name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, renamed to iroha-socketio-endpoint

@@ -206,6 +206,9 @@
"type": "boolean",
"nullable": false,
"description": "Can only be set to false for an insecure grpc connection."
},
"monitorMode": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP mode implies to me an enum not a boolean, could you add a description to the spec here that explains what this does and what are the possible values (true and false) change in the behavior?
If it is a boolean then maybe call it monitorModeEnabled and if it has more possible values other than true/false then make it an enum so that later on those other possible values can be added as needed without having to break backwards compatibility.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added description to this parameter

@petermetz petermetz removed the request for review from jonathan-m-hamilton April 19, 2022 18:29
@petermetz petermetz added enhancement New feature or request Iroha Bugs/features related to the Iroha ledger connector plugin labels Apr 19, 2022
StepniowskiP pushed a commit to StepniowskiP/cactus that referenced this pull request Apr 29, 2022
fixes for iroha pr hyperledger-cacti#1966

Signed-off-by: stepniowskip <[email protected]>
StepniowskiP pushed a commit to StepniowskiP/cactus that referenced this pull request May 9, 2022
fixes for iroha pr hyperledger-cacti#1966

Signed-off-by: stepniowskip <[email protected]>
fixes for iroha pr hyperledger-cacti#1966

Signed-off-by: stepniowskip <[email protected]>
@StepniowskiP StepniowskiP requested a review from petermetz May 17, 2022 09:08
args: any,
method?: Record<string, unknown>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StepniowskiP Is it just me or the parameters are still out of order (e.g. not backwards compatible)?
This is the diff I'm looking at:

image

@outSH
Copy link
Contributor

outSH commented May 26, 2022

Is it just me or the parameters are still out of order (e.g. not backwards compatible)?
This is the diff I'm looking at:

@petermetz Author of this PR no longer works for us, I'll take over this task. I've opened separate PR here - #2048 where I've fixed the ordering issue you mentioned. Please continue your review there, and close this PR since it'll not be handled anymore.

@petermetz petermetz closed this Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Iroha Bugs/features related to the Iroha ledger connector plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants