Skip to content

Commit

Permalink
Add auditor client capability (Node.js) (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnmt authored Jul 29, 2021
1 parent 5987a81 commit 0761e64
Show file tree
Hide file tree
Showing 11 changed files with 1,850 additions and 6,011 deletions.
50 changes: 41 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2.1
jobs:
build:
machine:
image: ubuntu-2004:202101-01
image: ubuntu-2004:202104-01

working_directory: ~/scalardl-node-client-sdk

Expand All @@ -23,13 +19,12 @@ jobs:
echo ${GHCR_PAT} | docker login https://ghcr.io -u ${GHCR_USERNAME} --password-stdin
- run:
name: checkout scalar-samples repository as it contains the script to spin up scalardl environment and easier for us to maintain the CI
name: checkout scalardl-samples repository as it contains the script to spin up scalardl environment and easier for us to maintain the CI
command: |
git init
git pull https://${GHCR_USERNAME}:${GHCR_PAT}@github.com/scalar-labs/scalardl-samples.git
working_directory: .circleci/


- run:
name: Start Scalar DL environment
command: docker-compose -f docker-compose.yml -f docker-compose-open-cassandra-port.yml up -d
Expand Down Expand Up @@ -72,13 +67,45 @@ jobs:
paths:
- ./node_modules

# run tests!
- run:
name: Run tests without auditor
command: npm test
environment:
MOCHA_FILE: "~/scalardl-node-client-sdk/mochawesome-report/mochawesome.html"
when: always

- run:
name: Restart Scalar DL environment with auditor
command: |
docker-compose -f docker-compose.yml -f docker-compose-open-cassandra-port.yml down -v
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up -d cassandra
echo -n "Wait for C* "
until docker exec scalardl-samples-cassandra-1 cqlsh 2> /dev/null ; do
sleep 0.5
echo -n "#"
done
echo ""
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up scalardl-ledger-schema-loader-cassandra
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up scalardl-auditor-schema-loader-cassandra
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up -d scalar-ledger
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up -d scalar-auditor
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up -d ledger-envoy
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up -d auditor-envoy
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up -d scalar-ledger-as-client
docker-compose -f docker-compose.yml -f docker-compose-auditor.yml up -d scalar-audior-as-client
sleep 5
docker restart scalardl-samples-scalar-ledger-1 # just in case
docker restart scalardl-samples-scalar-auditor-1 # just in case
sleep 5
working_directory: .circleci/

- run:
name: Run tests with auditor
command: npm run test-auditor
environment:
MOCHA_FILE: "~/scalardl-node-client-sdk/mochawesome-report/mochawesome-auditor.html"
when: always

- store_test_results:
path: ~/scalardl-node-client-sdk/mochawesome-report

Expand All @@ -103,10 +130,15 @@ workflows:
jobs:
- build:
context: "scalar"
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
- deploy:
context: "scalar"
requires:
- build
filters:
tags:
only: /v[0-9]+\.[0-9]+\.[0-9]+/
branches:
only: master
ignore: /.*/
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const clientService = new ClientService(clientProperties);
```

The `clientProperties` argument is mandatory for the constructor.
This is a properties example that a user `[email protected]` would use to try to connect to the server `scalardl.example.com:50051` of the Scalar DL network.
This is a properties example that a user `[email protected]` would use to try to connect to the server `scalardl-server.example.com:50051` of the Scalar DL network.
```javascript
{
'scalar.dl.client.server.host': 'scalardl.example.com',
'scalar.dl.client.server.host': 'scalardl-server.example.com',
'scalar.dl.client.server.port': 50051,
'scalar.dl.client.server.privileged_port': 50052,
'scalar.dl.client.cert_holder_id': '[email protected]',
Expand All @@ -56,6 +56,17 @@ This is a properties example that a user `[email protected]` would use to try to c
}
```

If the auditor capability is enabled on the Scalar DL network, specify additional properties like the following example. In this example, the client interacts with the auditor `scalardl-auditor.example.com` and detects Byzantine faults including data tampering when executing contracts.

```javascript
{
'scalar.dl.client.auditor.enabled': true,
'scalar.dl.client.auditor.host': 'scalardl-auditor.example.com',
'scalar.dl.client.auditor.port': 40051,
'scalar.dl.client.auditor.privileged_port': 40052,
}
```

In what follows assume that we have a clientService instance.

### Register the certificate
Expand Down
Loading

0 comments on commit 0761e64

Please sign in to comment.