-
Notifications
You must be signed in to change notification settings - Fork 285
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
feat(connector-polkadot): add connector pkg, openapi specs, test suite #2877
feat(connector-polkadot): add connector pkg, openapi specs, test suite #2877
Conversation
@AnmolBansalDEV can you squash merge commits into the logical ones? |
...ges/cactus-plugin-ledger-connector-polkadot/docs/architechture/run-transaction-endpoint.puml
Outdated
Show resolved
Hide resolved
...tus-plugin-ledger-connector-polkadot/src/main/typescript/plugin-ledger-connector-polkadot.ts
Outdated
Show resolved
Hide resolved
...tus-plugin-ledger-connector-polkadot/src/main/typescript/plugin-ledger-connector-polkadot.ts
Outdated
Show resolved
Hide resolved
Overall, great work done @AnmolBansalDEV 🌻 |
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.
Great work, thank you!
I've added some things to fix before merge.
packages/cactus-plugin-ledger-connector-polkadot/src/main/json/openapi.json
Outdated
Show resolved
Hide resolved
...tus-plugin-ledger-connector-polkadot/src/main/typescript/plugin-ledger-connector-polkadot.ts
Outdated
Show resolved
Hide resolved
...n-ledger-connector-polkadot/src/main/typescript/web-services/deploy-contract-ink-endpoint.ts
Outdated
Show resolved
Hide resolved
packages/cactus-plugin-ledger-connector-polkadot/src/main/json/openapi.json
Show resolved
Hide resolved
.../cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/api-surface.test.ts
Outdated
Show resolved
Hide resolved
11f5d2b
to
2b75d23
Compare
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.
- Exception throws and re-throws are done with the appropriate utilities which are either
createRuntimeErrorWithCause()
from the file atpackages/cactus-common/src/main/typescript/exception/create-runtime-error-with-cause.ts
or- The
http-errors
library's function collection accessed viacreateHttpError
. For HTTP REST API endpoint related error handling where your exceptions communicate with the web layer, have a look at the patterns established in this diff
https://github.com/hyperledger/cacti/pull/2869
In short, instead of this:Do this:// This is wrong - the HTTP response's status code will be // set to 500 but it should be 400 because it was user error // not a bug in the server's production code. throw new Error( `${fnTag} Cannot deploy contract without keychainId and the contractName` );
if (!keychainHasContract) { // This is better, because the HTTP response will // contain a status code of 400 instead of 500 const errorMessage = `${fnTag} Cannot create an instance of the contract instance because` + `the contractName in the request does not exist on the keychain`; throw new createHttpError[400](errorMessage); }
- Ensure that your are not swallowing valuable stack traces / exception messages by incorrectly serializing inner exceptions such as shown below (which is only one of many creative ways people accidentally come up with to destroy crash information). The below code will print
Something bad happened instead of something cool: [Object object]
try { await doSomethingCool(); } catch (ex: unknown) { const errorMessage = `Something bad happened instead of something cool: ${ex}`; throw new RuntimeError(errorMessage); }
- Ensure Linear git history by squashing your commits into a single one and then rebasing onto upstream/main (after having ran a
git fetch --all
) - Ensure that
yarn run custom-checks
is not failing with issues in the code that you are modifying/adding. - Ensure that the code you have written has test coverage in general and also, more specifically that negative cases are verified by your tests as well. An example for the latter through test cases that send in incorrect input intentionally and then verify that the exception thrown accurately explains what went wrong. An example of this principlan implemented in action can be seen at the test case here:
packages/cactus-cmd-api-server/src/test/typescript/integration/jwt-unprotected-endpoint-authz-ops-confirm.test.ts
. - Ensure that your yarn.lock file is up to date. If you haven't added/modified/removed any npm dependencies then this step is not necessary. Otherwise you can ensure an up to date yarn.lock file by running
yarn intsall
. It is important to NOT delete the lock file and then recreate it from scratch because this might trigger unintended auto-upgrades on all transitive dependencies that are set to auto-upgrade by the maintainers of the packages that we depend on. - Ensure that you are not using container images that you've self-published when it comes to testing infrastructure. If you've made changes to a container image (usually by altering a
Dockerfile
) then you can ask a maintainer to publish those changes to you to the official GitHub Container Registry repository of the project (e.g. ghcr.io/hyperledger/cacti-some-image-that-you-are-working-on) - Ensure that your commit message describes what is being changed and if there are multiple things then please try to break it down into multiple pull requests for easier review. Studies show that the larger the pull requests of a repository are on average, the worse code quality usually is.
a532989
to
0a57c36
Compare
Thank you @petermetz for your review, I've incorporated the changes and I request your re-review.
|
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.
@AnmolBansalDEV Please
- Update the yarn.lock file (I've just did a rebase locally and then
yarn install
made changes to the lock file so you need to do the same and then commit the lock file) - Rename
dockerfile
toDockerfile
just to match the conventions.
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.
@AnmolBansalDEV FYI: I left a few comments on one of the test cases but the same change requests also apply for all the other test cases as well
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
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.
@AnmolBansalDEV FYI: I left a few comments on one of the test cases but the same change requests also apply for all the other test cases as well
0a57c36
to
87ec994
Compare
@petermetz |
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 published the current branch's state as this canary release that you can use for the container:
@hyperledger/[email protected]
For my last round of change requests please see the comments above.
In general this is looking good and we should be good to go once these minor changes are also addressed.
...plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts
Outdated
Show resolved
Hide resolved
6410b7e
to
f7e7a2a
Compare
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.
@AnmolBansalDEV Well, one last push to fix the checks. Please rebase onto upstream main and fix the codegen action issues:
Run actions/[email protected]
Error: yarn codegen script produced version control side-effects: source files have been changed by it that are otherwise are under version control. This means (99% of the time) that you need to run the yarn codegen script locally and then include the changes it makes in your own commit when submitting your pull request.
Head branch was pushed to by a user without write access
e9241db
to
5ae638f
Compare
5ae638f
to
d110de9
Compare
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.
@AnmolBansalDEV I re-generated the yarn lock file and updated the commit message and the PR title. LGTM now
e4a2cc9
to
4e84be4
Compare
@AnmolBansalDEV Also fixed the linter errors and the spell checker issues. |
@petermetz thank you so much for fixing the issues! Is it now ready to be merged? |
I believe so, but let's see if all the required tests are passing or not. I
configured it so that if they do pass then it gets merged automatically.
If some fail we'll just fix them, no problem.
…On Mon, Feb 26, 2024, 9:41 PM Anmol Bansal ***@***.***> wrote:
@petermetz <https://github.com/petermetz> thank you so much for fixing
the issues! Is it now ready to be merged?
—
Reply to this email directly, view it on GitHub
<#2877 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMCQ76W5GQPEAGPY255KF3YVVWXXAVCNFSM6AAAAAA7HP73IOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRVHAZDOMZRGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
4e84be4
to
fb13476
Compare
@AnmolBansalDEV I also had to fix the I also updated the commit message to include the issue linking declarations. |
fb13476
to
f8be5c2
Compare
@petermetz the codegen test is still failing, I don't understand what's causing this. Can you please point me out how to fix this? I tried running |
Primary Changes --------------- 1. Created openapi specs for get-prometheus-exporter-metrics, get-transaction-info, get-raw-transaction, sign-raw-transaction, run-transaction, deploy-contract-ink, and invoke-contract endpoints 2. Created relevant types for the request as well as response for the above endpoints 3. Added generated code for these endpoints 4. Created connector class with functions to interact with the polkadot ledger 5. Created webservices to interact with the endpoint and the relevant class method 6. Created unit and integration testcases in jest to test base functionality of the connector Secondary Changes ----------------- 1. Added an ink! contract for running the testcases 2. Added the polkadot connector to ci workflow 3. Created substrate.md to docs-cactus 4. Added the polkadot connector to tsconfig.json Signed-off-by: Anmol Bansal <[email protected]> ======================================================================= feat(polkadot): creation of polkadot AIO image Primary Changes --------------- 1. Updated docker image to include multi-stage build 2. Added healthcheck to the image 3. Added Supervisord and removed unneccessary start script 4. Updated the Readme with relevant commands Signed-off-by: Anmol Bansal <[email protected]> ======================================================================= feat(polkadot): update substrate test tooling Primary Changes --------------- 1. Added correct healthcheck for ledger container 2. Update the Substrate test ledger testcases Signed-off-by: Anmol Bansal <[email protected]> ======================================================================= feat(polkadot): creation of readme and architecture reference diagrams Primary Changes --------------- 1. Added README.md for the connector 2. Added Architecture diagrams for the plugin Secondary Changes ----------------- 1. Added the docker image for the polkadot connector Fixes hyperledger/cacti#726 Fixes hyperledger/cacti#727 Fixes hyperledger/cacti#627 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: Anmol Bansal <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
f8be5c2
to
48308ed
Compare
@AnmolBansalDEV Oops, I forgot to delete a local ignore file. Should be good now, let's see. BTW: What are the hardware specs on the EC2 machine that you are using? I'd want to know especially the amount of RAM It has. |
All the requests seems to have been addressed, we are good to go!
@AnmolBansalDEV Congrats! Wohoo! |
oh okay, I think the EC2 instance have 16GB RAM |
@petermetz Thank you so much, it feels like achieving a major milestone! Also thanks to @outSH for valuable code reviews, and to @RafaelAPB and @CatarinaPedreira for foundational work! |
@AnmolBansalDEV it is a major milestone :D Congratulations for a great connector and thanks for your hard work! |
It's the updated PR for Polkadot support for Cacti that incorporates the efforts of @RafaelAPB @CatarinaPedreira along with my work during the Hyperledger Mentorship under the mentorship of @jagpreetsinghsasan @suvajit-sarkar @petermetz
COMMITS TO REVIEW
feat(polkadot): creation of polkadot AIO image
feat(polkadot): update substrate test tooling
feat(polkadot): creation of polkadot connector openapi specs, test case and connector class
feat(polkadot): creation of readme and architecture reference diagrams
Pull Request Requirements
upstream/main
branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.-s
flag when usinggit commit
command. You may refer to this link for more information.Character Limit
A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.