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

refactor(cmd-socketio-server): remove code duplication #2047

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

outSH
Copy link
Contributor

@outSH outSH commented May 26, 2022

  • Moved verifyValidatorJwt to cactus-common to keep encrypt/decrypt logic
    of socketio-based validators in one, common location.
  • Move config-reading and signMessageJwt helper functions from validators to cmd-socketio-server
    to remove code duplication.
    Refactor validators to use these common instead of own implementation.
  • Remove ValidatorAuthentication.ts that is not used anymore
    (not part of public interface, it was copied by validators during before couple commits ago).
  • Create jwt-message-authentication.test.ts from old, similar one in cactus-api-client.
  • Updated readme with instructions of how to start asset-trade and electricity-trade samples
    without docker-compose (to be used during development).
    Added helper script for patching the config.

Signed-off-by: Michal Bajer michal.bajer@fujitsu.com


This PR is for the last commit only - refactor(cmd-socketio-server): remove code duplication. Please ignore previous one (dependencies) which will be removed before the merge.

Depends on #2033
Depends on #2129

@gitguardian
Copy link

gitguardian bot commented May 26, 2022

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@jagpreetsinghsasan
Copy link
Contributor

Thanks @outSH for your contribution.
It will take a while for me to review this, hope this ain't blocking anything super urgently.

@outSH
Copy link
Contributor Author

outSH commented May 27, 2022

Thanks @outSH for your contribution. It will take a while for me to review this, hope this ain't blocking anything super urgently.

@jagpreetsinghsasan Sure, there are bunch of depndencies awaiting to be merged first, no hurry ;) Just remember to look only at the last commit.

@outSH
Copy link
Contributor Author

outSH commented May 27, 2022

Note to myself: Fix sample apps dockerfiles to use only npm packages

outSH added a commit to outSH/cactus that referenced this pull request May 31, 2022
- Add functional test of all functions from go-ethereum-socketio validator.
- Refactor go-ethereum validator to allow importing as a module, to simplify the functional test.
- Fix sendRawTransaction to work with Verifier protocol.
  It couldn't be reached by any client library until now, so I consider this as "private" interface.
- Add common web3 client object in openethereum test ledger helper class.
- Add few new functions to ethereum test ledger helper class:
  newEthPersonalAccount, transferAssetFromCoinbase, deployContract.

Depends on hyperledger-cacti#2051
Depends on hyperledger-cacti#2047

Closes: hyperledger-cacti#2052

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
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

@takeutak
Copy link
Contributor

@petermetz @jagpreetsinghsasan (cc: @izuru0)
Could you review this PR?

Copy link
Contributor

@jagpreetsinghsasan jagpreetsinghsasan left a comment

Choose a reason for hiding this comment

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

This looks all good to me.

outSH added a commit to outSH/cactus that referenced this pull request Jul 1, 2022
- Add functional test of all functions from sawtooth-socketio validator.
- Refactor sawtooth validator to allow importing as a module, to simplify the functional test.
- Add stopMonitor to terminate tests easily.
- Allow multiple clients to monitor for blocks.
- Fix parsing of URL from config so that it doesn't depend on trailing slash anymore.

Closes: hyperledger-cacti#2107

Depends on: hyperledger-cacti#2109
Depends on: hyperledger-cacti#2110
Depends on: hyperledger-cacti#2047

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
@outSH outSH force-pushed the refactor_validator_config_pr branch 2 times, most recently from e14caa0 to 4fb5d7b Compare July 22, 2022 12:34
@outSH
Copy link
Contributor Author

outSH commented Jul 22, 2022

@petermetz Can you also publish cmd-sockio package from this branch to npm after #2129 is merged? It is needed by the connectors in this PR.

// Note to myself: Test the dockerized sample apps manually after cmd-socketio package is published

@outSH outSH requested a review from petermetz July 22, 2022 12:57
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.

@outSH LGTM, thank you!

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.

@outSH Please resolve the conflict and then pass it back for review!

@outSH outSH force-pushed the refactor_validator_config_pr branch from 4fb5d7b to 343f6ff Compare November 16, 2022 13:41
@outSH
Copy link
Contributor Author

outSH commented Nov 16, 2022

@petermetz I've rebased to the current main branch status, went through example apps startup (both docker and dockerless scenarios), fixed all errors and connector dockerfiles. Additionally, I've removed the dependency on Indy-SDK for main cactus build since it was tricky to install and sometimes their repo was not available. Updated the ci.sh and readme files.

For better understanding of changes I've done since review, you can check this commit: outSH@de5dfef
(it was squashed in this PR).

// EDIT Will fix the tests soon

@outSH outSH force-pushed the refactor_validator_config_pr branch from 343f6ff to 74d336e Compare November 16, 2022 13:50
@outSH outSH requested review from petermetz and removed request for sandeepnRES and takeutak November 16, 2022 13:50
@outSH outSH force-pushed the refactor_validator_config_pr branch from 74d336e to 3ff0636 Compare November 17, 2022 12:41
@outSH
Copy link
Contributor Author

outSH commented Nov 17, 2022

@petermetz OK, the tests are fixed, please merge when possible.

Changes since your last review: outSH@083d91b

@petermetz
Copy link
Contributor

@petermetz Can you also publish cmd-sockio package from this branch to npm after #2129 is merged? It is needed by the connectors in this PR.

// Note to myself: Test the dockerized sample apps manually after cmd-socketio package is published

@outSH Yes, sorry for not responding earlier, we now have the packages published to npm for v1.1.0 and v1.1.1 and v1.1.2 as well so you can use them with the new package names!

@petermetz
Copy link
Contributor

@petermetz OK, the tests are fixed, please merge when possible.

Changes since your last review: outSH@083d91b

@outSH Thank you that commit link and the squash+rebase helped a lot with the re-review! LGTM

Additionally, I've removed the dependency on Indy-SDK for main cactus build since it was tricky to install and sometimes their repo was not available. Updated the ci.sh and readme files.

Extra thanks for this because it was causing problems for people in ways that I could not reliably reproduce so it's much better that it is not an optional part of the build. Thank you!

- Move config-reading and signMessageJwt helper functions from validators to cmd-socketio-server
  to remove code duplication. Refactor validators to use these common instead of own implementation.
- Remove ValidatorAuthentication.ts that is not used anymore
  (not part of public interface, it was copied by validators during before couple commits ago).
- Updated readme with instructions of how to start asset-trade and electricity-trade samples
  without docker-compose (to be used during development).
  Added helper script for patching the config.
- Remove dependency on Indy SDK for the main build
  (it's needed only for running dockerless discounted-cartrade sample now)
- Update legacy-socketio-connector Dockerfiles to work after updates.

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
@outSH outSH force-pushed the refactor_validator_config_pr branch from dc48415 to c2d9e4c Compare November 18, 2022 08:44
@izuru0 izuru0 merged commit 673f122 into hyperledger-cacti:main Nov 18, 2022
outSH added a commit to outSH/cactus that referenced this pull request Nov 21, 2022
- Add functional test of all functions from sawtooth-socketio validator.
- Refactor sawtooth validator to allow importing as a module, to simplify the functional test.
- Add stopMonitor to terminate tests easily.
- Allow multiple clients to monitor for blocks.
- Fix parsing of URL from config so that it doesn't depend on trailing slash anymore.

Closes: hyperledger-cacti#2107

Depends on: hyperledger-cacti#2109
Depends on: hyperledger-cacti#2110
Depends on: hyperledger-cacti#2047

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
outSH added a commit to outSH/cactus that referenced this pull request Nov 21, 2022
- Add functional test of all functions from go-ethereum-socketio validator.
- Refactor go-ethereum validator to allow importing as a module, to simplify the functional test.
- Fix sendRawTransaction to work with Verifier protocol.
  It couldn't be reached by any client library until now, so I consider this as "private" interface.
- Add common web3 client object in openethereum test ledger helper class.
- Add few new functions to ethereum test ledger helper class:
  newEthPersonalAccount, transferAssetFromCoinbase, deployContract.

Depends on hyperledger-cacti#2051
Depends on hyperledger-cacti#2047

Closes: hyperledger-cacti#2052

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
outSH added a commit to outSH/cactus that referenced this pull request Nov 22, 2022
- Add functional test of all functions from go-ethereum-socketio validator.
- Refactor go-ethereum validator to allow importing as a module, to simplify the functional test.
- Fix sendRawTransaction to work with Verifier protocol.
  It couldn't be reached by any client library until now, so I consider this as "private" interface.
- Add common web3 client object in openethereum test ledger helper class.
- Add few new functions to ethereum test ledger helper class:
  newEthPersonalAccount, transferAssetFromCoinbase, deployContract.

Depends on hyperledger-cacti#2051
Depends on hyperledger-cacti#2047

Closes: hyperledger-cacti#2052

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
petermetz pushed a commit to outSH/cactus that referenced this pull request Nov 22, 2022
- Add functional test of all functions from go-ethereum-socketio validator.
- Refactor go-ethereum validator to allow importing as a module, to simplify the functional test.
- Fix sendRawTransaction to work with Verifier protocol.
  It couldn't be reached by any client library until now, so I consider this as "private" interface.
- Add common web3 client object in openethereum test ledger helper class.
- Add few new functions to ethereum test ledger helper class:
  newEthPersonalAccount, transferAssetFromCoinbase, deployContract.

Depends on hyperledger-cacti#2051
Depends on hyperledger-cacti#2047

Closes: hyperledger-cacti#2052

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
petermetz pushed a commit to outSH/cactus that referenced this pull request Nov 22, 2022
- Add functional test of all functions from sawtooth-socketio validator.
- Refactor sawtooth validator to allow importing as a module, to simplify the functional test.
- Add stopMonitor to terminate tests easily.
- Allow multiple clients to monitor for blocks.
- Fix parsing of URL from config so that it doesn't depend on trailing slash anymore.

Closes: hyperledger-cacti#2107

Depends on: hyperledger-cacti#2109
Depends on: hyperledger-cacti#2110
Depends on: hyperledger-cacti#2047

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
petermetz pushed a commit that referenced this pull request Nov 22, 2022
- Add functional test of all functions from go-ethereum-socketio validator.
- Refactor go-ethereum validator to allow importing as a module, to simplify the functional test.
- Fix sendRawTransaction to work with Verifier protocol.
  It couldn't be reached by any client library until now, so I consider this as "private" interface.
- Add common web3 client object in openethereum test ledger helper class.
- Add few new functions to ethereum test ledger helper class:
  newEthPersonalAccount, transferAssetFromCoinbase, deployContract.

Depends on #2051
Depends on #2047

Closes: #2052

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
petermetz pushed a commit to outSH/cactus that referenced this pull request Nov 22, 2022
- Add functional test of all functions from sawtooth-socketio validator.
- Refactor sawtooth validator to allow importing as a module, to simplify the functional test.
- Add stopMonitor to terminate tests easily.
- Allow multiple clients to monitor for blocks.
- Fix parsing of URL from config so that it doesn't depend on trailing slash anymore.

Closes: hyperledger-cacti#2107

Depends on: hyperledger-cacti#2109
Depends on: hyperledger-cacti#2110
Depends on: hyperledger-cacti#2047

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
petermetz pushed a commit to outSH/cactus that referenced this pull request Nov 23, 2022
- Add functional test of all functions from sawtooth-socketio validator.
- Refactor sawtooth validator to allow importing as a module, to simplify the functional test.
- Add stopMonitor to terminate tests easily.
- Allow multiple clients to monitor for blocks.
- Fix parsing of URL from config so that it doesn't depend on trailing slash anymore.

Closes: hyperledger-cacti#2107

Depends on: hyperledger-cacti#2109
Depends on: hyperledger-cacti#2110
Depends on: hyperledger-cacti#2047

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
petermetz pushed a commit that referenced this pull request Nov 24, 2022
- Add functional test of all functions from sawtooth-socketio validator.
- Refactor sawtooth validator to allow importing as a module, to simplify the functional test.
- Add stopMonitor to terminate tests easily.
- Allow multiple clients to monitor for blocks.
- Fix parsing of URL from config so that it doesn't depend on trailing slash anymore.

Closes: #2107

Depends on: #2109
Depends on: #2110
Depends on: #2047

Signed-off-by: Michal Bajer <michal.bajer@fujitsu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants