Skip to content

Commit

Permalink
Merge pull request #24 from Cybersecurity-LINKS/docs-mediterraneus
Browse files Browse the repository at this point in the history
Docs mediterraneus
  • Loading branch information
mikeus9908 authored Oct 14, 2024
2 parents 93c39f4 + 7e21fa6 commit 2764bd4
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 24 deletions.
53 changes: 46 additions & 7 deletions docs_mediterraneus/running-the-protocol/connector-rs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,61 @@ description: Agent system that handles user identity and assets.

## Prepare environment

0. Generate contract bindings (to be done once or if contract change)
```bash
# assuming the mediterraneus-smart-contracts folder is located in the same root folder of mediterraneus-connector-rs
cd abigen
cargo run -- --contract ServiceBase --abi-source "../../mediterraneus-smart-contracts/artifacts/contracts/ServiceBase.sol/ServiceBase.json"
```
0. Add the ABI source for generating contract bindings. This procedure is requested only when the contract definition changes. You just need to copy the `artifacts/contracts/ServiceBase.sol/ServiceBase.json` ABI file in the `smart-contracts` directory.
Abi sources are generated in the [smart contracts repo](smart-contracts.md).

1. In `connector-rs/env` folder, create a `.env` file starting from `.env.example` and update the values accordingly to your development enviroment.

```editorconfig
RUST_BACKTRACE=1
RUST_LOG=debug # info
# HTTP SERVER CONFIG
HOST_ADDRESS=127.0.0.1 # "0.0.0.0" for deploying, "127.0.0.1" for dev
HOST_PORT=8085
# DLT CONFIG
NODE_URL="https://api.testnet.shimmer.network"
FAUCET_API_ENDPOINT="https://faucet.testnet.shimmer.network/api/enqueue"
EXPLORER_URL=""
RPC_PROVIDER="https://json-rpc.evm.testnet.shimmer.network"
CHAIN_ID=1073
# KEY STORAGE CONFIG
KEY_STORAGE_STRONGHOLD_SNAPSHOT_PATH="./key_storage.stronghold"
KEY_STORAGE_STRONGHOLD_PASSWORD="some_hopefully_secure_password"
KEY_STORAGE_MNEMONIC="grace eye hour away retire put crunch burger bracket coyote twist cherry glare collect retreat"
# DATABASE CONNECTION CONFIG
DB_USER="postgres"
DB_PASSWORD="connector"
DB_NAME="connector"
DB_HOST=127.0.0.1 # "postgres" for deploying, "127.0.0.1 " for dev
DB_PORT=5432
DB_MAX_POOL_SIZE=16
# IPFS CONFIG
IPFS_URL="http://ipfs:5001"
```

## Running the Application

1. Launch [IPFS desktop](https://docs.ipfs.tech/install/ipfs-desktop/) and start up the database by running:
1. Start up the database and IPFS by running:
```bash
docker compose --profile dev up -d
```
2. Run the connector service:
```bash
cd connector-rs
cargo run --profile develop
```

Sometimes it may be useful to **override** `.env` parameters using cli args.
The complete list of parameters is available typing the `cargo run --profile develop -- --help` command

For example, it is possible to define parameters for testing on different nodes:

```bash
# For local node Provider
cargo run --release -- --rpc-provider "http://127.0.0.1:8545/" --chain-id 31337

Expand All @@ -43,6 +81,7 @@ cargo run --release -- --rpc-provider https://sepolia.infura.io/v3/<API_KEY> --c
## Run everything via Docker

Beware of the configuration of the environment variables. Note: Modify `.env` and `postgres.env` reasonably. (`ADDR` and `PG.HOST` *must* be changed for the deployment use case).
(The connector uses the Shimmer provider, change CMD command in the Dockerfile to change the network).

Copy the smart contract json files to create the Rust bindings (mandatory if the smart contracts change. There is already a copy in this repo).

Expand Down
66 changes: 49 additions & 17 deletions docs_mediterraneus/running-the-protocol/issuer-rs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,43 @@ description: Issuer of verifiable credentials using smart contracts to bind Exte

## Prepare environment

0. Generate contract bindings (to be done once or if contract change)
```bash
# assuming the mediterraneus-smart-contracts folder is located in the same root folder of mediterraneus-connector-rs
cd abigen
cargo run -- --contract Identity --abi-source "../../mediterraneus-smart-contracts/artifacts/contracts/Identity.sol/Identity.json"
```
0. Add the ABI source for generating contract bindings. This procedure is requested only when the contract definition changes. You just need to copy the `artifacts/contracts/IDentity.sol/Identity.json` ABI file in the `smart-contracts` directory.
Abi sources are generated in the [smart contracts repo](smart-contracts.md).

1. Create a `.env` file starting from `.env.example` and update the values accordingly to your development enviroment.

```editorconfig
L2_PRIVATE_KEY='<issuer private key>'
NON_SECURE_MNEMONIC='<iota wallet mnemonic>'
KEY_STORAGE_MNEMONIC='<identity key storage mnemonic>'
IDENTITY_SC_ADDRESS='<address of the Identity smart contract>'
# Example from .env.example
# Rust flags
RUST_BACKTRACE=1
RUST_LOG=debug # minimum level of logging, also "info" is a possible value
# HTTP SERVER SETUP
HOST_ADDRESS=127.0.0.1 # "0.0.0.0" for deploying, "127.0.0.1" for dev
HOST_PORT=3213
# DLT CONFIG
NODE_URL="https://api.testnet.shimmer.network"
FAUCET_API_ENDPOINT="https://faucet.testnet.shimmer.network/api/enqueue"
RPC_PROVIDER="https://json-rpc.evm.testnet.shimmer.network"
CHAIN_ID=1073
# KEY STORAGE CONFIGURATION
KEY_STORAGE_STRONGHOLD_SNAPSHOT_PATH="./key_storage.stronghold"
KEY_STORAGE_STRONGHOLD_PASSWORD="some_hopefully_secure_password"
KEY_STORAGE_MNEMONIC="<key storage mnemonic>"
ISSUER_PRIVATE_KEY="<issuer_private_key>"
IDENTITY_SC_ADDRESS="<address of the Identity smart contract>"
# DATABASE CONNECTION CONFIG
DB_USER="<db_user>"
DB_PASSWORD="<db_password>"
DB_NAME="identity"
DB_HOST=<issuer db hostname> # "issuer-postgres" for deploying, "127.0.0.1 " for dev
DB_PORT=5432 # "5432" for deploying, "5433" for dev
DB_MAX_POOL_SIZE=16
```
<!--
Optional:
- Update the `abi/identity_sc.json` file if there are changes to the Identity Smart Contract. -->

## Running the Application

Expand All @@ -40,16 +59,27 @@ docker compose --profile dev up -d
```

2. Run the issuer service
```shell
# Run command in debug mode
cd server
cargo run --profile develop
```

Sometimes it may be useful to **override** `.env` parameters using cli args.
The complete list of parameters is available typing the `cargo run --profile develop -- --help` command

For example, it is possible to define parameters for testing on different nodes:

```shell
cd server
# For local node Provider
cargo run --release -- --rpc-provider "http://127.0.0.1:8545/" --chain-id 31337
cargo run --profile develop -- --rpc-provider "http://127.0.0.1:8545/" --chain-id 31337

# For Shimmer Provider
cargo run --release -- --rpc-provider "https://json-rpc.evm.testnet.shimmer.network" --chain-id 1073
cargo run --profile develop -- --rpc-provider "https://json-rpc.evm.testnet.shimmer.network" --chain-id 1073

# For Sepolia
cargo run --release -- --rpc-provider https://sepolia.infura.io/v3/<API_KEY> --chain-id 11155111
cargo run --profile develop -- --rpc-provider https://sepolia.infura.io/v3/<API_KEY> --chain-id 11155111
```

<!-- Keep in mind that when using the local node setup, the Identity ABI needs to be manually copied into the `abi` folder. Additionally, ensure that the file is named `idsc_abi.json`. On the other hand, when working with a public network, consider publishing the ABI and dynamically loading it through an API. -->
Expand All @@ -72,7 +102,9 @@ Before issuing a VC the Issuer must perform the following operations:

## Run everything via Docker

Beware of the configuration of the environment variables. Note: Modify `.env` reasonably. (`ADDR` and `PG.HOST` *must* be changed for the deployment use case).
Beware of the configuration of the environment variables. In addition, update the `docker-compose.yaml` accordingly.
<!-- Note: Modify `.env` reasonably. (`ADDR` and `PG.HOST` *must* be changed for the deployment use case).
(The issuer uses the Shimmer provider, change CMD command in the Dockerfile to change the network). -->

Copy the smart contract json files to create the Rust bindings (mandatory if the smart contracts change. There is already a copy in this repo).

Expand Down

0 comments on commit 2764bd4

Please sign in to comment.