From c2c0c828042c0bd81e9ff68ffe18be6f2623d26c Mon Sep 17 00:00:00 2001 From: Nicolo' Padovani <69471887+nicopado@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:57:07 +0200 Subject: [PATCH 1/2] feat: Implement openapi client code generator | NPG-6475 (#580) # Description Implement openapi client generator to automatically generate cat-data-service client code ## Type of change - [X] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [X] This change requires a documentation update ## How Has This Been Tested? - [X] Navigate to the test folder and run `earthly +generate-client` ## Checklist - [X] My code follows the style guidelines of this project - [X] I have performed a self-review of my code - [X] I have commented my code, particularly in hard-to-understand areas - [X] I have made corresponding changes to the documentation - [X] My changes generate no new warnings - [X] I have added tests that prove my fix is effective or that my feature works - [X] New and existing unit tests pass locally with my changes - [X] Any dependent changes have been merged and published in downstream modules --- .gitignore | 1 + tests/Earthfile | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/Earthfile diff --git a/.gitignore b/.gitignore index b3eb4c17b7..6a888d4651 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ result* .vscode **/.idea/ .temp/ +tests/tmp/ # std .std diff --git a/tests/Earthfile b/tests/Earthfile new file mode 100644 index 0000000000..6648477e76 --- /dev/null +++ b/tests/Earthfile @@ -0,0 +1,27 @@ +VERSION 0.7 + +FROM debian:stable-slim + +# BASH, CURL, GPG, NODEJS, NPM, JRE +dependencies: + RUN apt-get update + RUN apt-get install bash + RUN apt-get install curl -y + RUN apt-get install gpg -y + RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg + RUN apt-get install nodejs -y + RUN apt-get install npm -y + RUN apt-get install default-jre -y + +generate-client: + FROM +dependencies + + # TODO(@nicopado): Get the correct file from openapi doc generation target - https://github.com/input-output-hk/catalyst-core/issues/589 + ARG openapispec_file="./petstore.yaml" + COPY $openapispec_file . + + RUN npm install @openapitools/openapi-generator-cli -g + + RUN openapi-generator-cli validate -i $openapispec_file + + RUN openapi-generator-cli generate -i $openapispec_file -g rust -o ./tmp/client/ --package-name cat-data-service-client \ No newline at end of file From 83748f0c8cddc0b0977131e31fda4eaf04bf7b96 Mon Sep 17 00:00:00 2001 From: Stefano Cunego <93382903+kukkok3@users.noreply.github.com> Date: Wed, 4 Oct 2023 12:10:19 +0200 Subject: [PATCH 2/2] docs: Create tally docs | NPG-000 (#582) # Description Adding tally script docs --------- Co-authored-by: Oleksandr Prokhorenko --- scripts/tally/Readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 scripts/tally/Readme.md diff --git a/scripts/tally/Readme.md b/scripts/tally/Readme.md new file mode 100644 index 0000000000..69a24734a6 --- /dev/null +++ b/scripts/tally/Readme.md @@ -0,0 +1,8 @@ +# How to use tally script +### Offline +To run the offline tally script we need the committe key and the `active_plans.json` (voteplans encrypted file) to be in the folder where the script is executed. The committee key is generated by the vitup tool together with the other backend artifacts, the `active_plans.json` can be retrived from the api with `curl https://{url}/api/v0/vote/active/plans > active_plans.json` after vote ended. Also we need the jcli tool to be installed. We can then run the script passing the voteplan id of the voteplan we want to decrypt `./private_offline.sh 9a278b6f788278e5cd8dfd6de8b8b8699a7f6b4847c680843de6c02d5b3169b2` + + +### Online +To run the online tally script we need the committe key to be in the folder where the script is executed. We need to set the env variable `JORMUNGANDR_RESTAPI_URL` in the script. Also we need the jcli tool to be installed. We can then run the script passing the voteplan index of the voteplan we want to decrypt and the expiry block date. The expiry block date is obtained taking the field `"lastBlockDate"` from the response of `https://{url}/api/v0/node/stats` and rounding that up. So if `"lastBlockDate": "25.779"` the script would be called like `./private.sh 0 26.0` +The online tally script needs to be runned after voting ends and before tally time ends. The script will post the decrypted result back to the node as a transaction and it will appear in the `https://{url}/api/v0/vote/active/plans`