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

Make Readme more readable #4

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 67 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

Use `Pyo3` Lib to wrap the `integritee-cli` into a Python lib.

## Installation
## Table of Contents

Get started with the project setup and initial configuration.
- [Getting Started](#getting-started)
- [Run as Command Line Tool](#run-as-command-line-tool)
- [Managing Environment Variables for Command Line Execution](#managing-environment-variables-for-command-line-execution)
- [Get help](#get-help)
- [Available Commands and Examples](#available-commands-and-examples)

- ### Prerequisites
## Getting Started

Get started with the setup of the client module.

**Prerequisites**

In order to use the features, the nightly version of the compiler has
to be setup beforehand:
Expand All @@ -15,7 +23,13 @@ to be setup beforehand:
$ rustup override set nightly
```

- ### Updating Git Submodules
Common error: **wasmtime**: error[E0463]: can't find crate for `std`

```
rustup target add --toolchain nightly wasm32-unknown-unknown
```

**Installation**

`Cargo.toml` states the relative dependencies at the `shared` folder.
The submodules have to be initialized and updated before building:
Expand All @@ -24,8 +38,6 @@ The submodules have to be initialized and updated before building:
$ git submodule update --init --recursive
```

- ### Creating and Activating venv

Install `integritee_cli_py` as lib into virtual environment:

```
Expand All @@ -35,34 +47,22 @@ $ source venv/bin/activate
$ conda deactivate
```

- ### Managing Environment Variables

Please follow these steps to set up and use environment variables:

1. Copy the `.env.example` file and rename it to `.env`:

```bash
$ cp .env.example .env
```

2. Open the `.env` file and provide values for the environment variables.

- ### Installing Dependencies

Install the necessary dependencies using the provided `requirements.txt` file:

```bash
$ pip install -r requirements.txt
pip install maturin
```

- ### Using maturin

To install the lib to your current python environment use:

```
$ maturin develop
```

**Usage**

See `run_integritee_cli.py` how to import and use the module. This
script also includes a command line tool, to be used as explained
in the following section.

## Run as Command Line Tool

Test import and execution of `integritee_cli_py` in python:
Expand All @@ -71,18 +71,36 @@ Test import and execution of `integritee_cli_py` in python:
$ python run_integritee_cli.py --command <COMMAND-NAME> --params <PARAMETER-NAME>
```

The `integritee-cli-py` provides the following CLI commands:
### Managing Environment Variables for Command Line Execution

- ### Get Help
Please follow these steps to set up and use environment variables:

1. Copy the `.env.example` file and rename it to `.env`:

```bash
$ cp .env.example .env
```

2. Open the `.env` file and provide values for the environment variables.

**Syntax:**
3. Installing Dependencies

Install the necessary dependencies using the provided `requirements.txt` file:

```bash
$ pip install -r requirements.txt
```


### Get help

- Syntax:

```bash
$ python3 run_integritee_cli.py --help
```

**Output:**
- Output:

```bash

Expand All @@ -98,82 +116,76 @@ options:
Parameters for the command
```

- ### Create a new account:
### Available Commands and Examples

The `integritee-cli-py` provides the following CLI commands:

**Syntax:**
**Create a new account:**

- Syntax:

```bash
$ python3 run_integritee_cli.py --command new_account_cmd
```

- ### Create a new trusted account:
**Create a new trusted account:**

**Syntax:**
- Syntax:

```bash
$ python3 run_integritee_cli.py --command new_trusted_account_cmd --params <MRENCLAVE>
```

- ### Pay As Bid:

**Syntax:**
**Pay As Bid:**

- Syntax:
```bash
$ python3 run_integritee_cli.py --command pay_as_bid_cmd --params <MRENCLAVE> <ACCOUNT> <ORDERS_STRING>
```

**Example:**

- Example:
```bash
$ python3 run_integritee_cli.py --command pay_as_bid_cmd --params 9PPeGELLdD9Uw1mVJbUGTeRpGzPBGb1bdEk6TCL4pPCE 5Dsni69ozXZZwpxyCGjLq8KQnBpGrtPnbykepgst2Tbh7NuY "[{\"id\":0,\"order_type\":\"ask\",\"time_slot\":\"2022-10-04T05:06:07+00:00\",\"actor_id\":\"actor_0\",\"cluster_index\":0,\"energy_kwh\":5,\"price_euro_per_kwh\":0.19},{\"id\":1,\"order_type\":\"bid\",\"time_slot\":\"2022-10-04T05:06:07+00:00\",\"actor_id\":\"actor_1\",\"cluster_index\":0,\"energy_kwh\":8.8,\"price_euro_per_kwh\":0.23}]"
```

- ### Get Market Results:
**Get Market Results:**

**Syntax:**
- Syntax:

```bash
$ python3 run_integritee_cli.py --command get_market_results_cmd --params <MRENCLAVE> <ACCOUNT> <TIMESTAMP>
```

**Example:**
- Example:

```bash
$ python3 run_integritee_cli.py --command get_market_results_cmd --params 9PPeGELLdD9Uw1mVJbUGTeRpGzPBGb1bdEk6TCL4pPCE 5Dsni69ozXZZwpxyCGjLq8KQnBpGrtPnbykepgst2Tbh7NuY 2022-10-04T05:06:07+00:00
```

- ### Get Bid Proof:
**Get Bid Proof:**

**Syntax:**
- Syntax:

```bash
$ python3 run_integritee_cli.py --command pay_as_bid_proof_cmd --params <MRENCLAVE> <ACCOUNT> <TIMESTAMP> <ACTOR_ID>
```

**Example:**
- Example:

```bash
$ python3 run_integritee_cli.py --command pay_as_bid_proof_cmd --params 9PPeGELLdD9Uw1mVJbUGTeRpGzPBGb1bdEk6TCL4pPCE 5Dsni69ozXZZwpxyCGjLq8KQnBpGrtPnbykepgst2Tbh7NuY 2022-10-04T05:06:07+00:00 actor_0
```

- ### Verify Proof:
**Verify Proof:**

**Syntax:**
- Syntax:

```bash
$ python3 run_integritee_cli.py --command verify_proof_cmd --params <MRENCLAVE> <ACCOUNT> <MERKLE_PROOF_JSON>
```

**Example:**
- Example:

```bash
python3 run_integritee_cli.py --command verify_proof_cmd --params 9PPeGELLdD9Uw1mVJbUGTeRpGzPBGb1bdEk6TCL4pPCE 5Dsni69ozXZZwpxyCGjLq8KQnBpGrtPnbykepgst2Tbh7NuY "{\"root\":\"0xeae9131721b25db95622605c99a62f56f2e3b47e7f54f9b0653055b11b8d37b8\",\"proof\":[\"0xf147000d21d56a303b688da5bf1294d865518a8fb889af48ca21d12af5a6d823\"],\"number_of_leaves\":2,\"leaf_index\":0,\"leaf\":[0,0,0,0,0,0,0,0,1,100,50,48,50,50,45,49,48,45,48,52,84,48,53,58,48,54,58,48,55,43,48,48,58,48,48,28,97,99,116,111,114,95,48,1,0,0,0,0,0,0,0,0,0,0,20,64,82,184,30,133,235,81,200,63]}"
```

## Troubleshooting

- **wasmtime**: error[E0463]: can't find crate for `std`

```
rustup target add --toolchain nightly wasm32-unknown-unknown
```