Skip to content

Commit

Permalink
Merge branch 'dev' into fix-vc-di-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kailai-Wang committed Sep 15, 2023
2 parents a8b27da + 534e85a commit 78ba9df
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 27 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ inherits = "release"
[profile.production]
codegen-units = 1
inherits = "release"
lto = true
lto = "thin"
strip = "symbols"
incremental = false
158 changes: 132 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# litentry-parachain
# Litentry Parachain
![](https://res.cloudinary.com/brandpad/image/upload/c_scale,dpr_auto,f_auto,w_768/v1673016042/19618/parachain-logo-color-black-t)

[![general ci](https://github.com/litentry/litentry-parachain/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/litentry/litentry-parachain/actions/workflows/ci.yml)
[![release](https://github.com/litentry/litentry-parachain/actions/workflows/create-release-draft.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/create-release-draft.yml)
[![runtime upgrade](https://github.com/litentry/litentry-parachain/actions/workflows/runtime-upgrade-simulation.yml/badge.svg)](https://github.com/litentry/litentry-parachain/actions/workflows/runtime-upgrade-simulation.yml)

The Litentry parachain.

Similar to polkadot, different chain-specs/runtimes are compiled into one single binary: in our case it's:
A parachain is an application-specific data structure that is globally coherent and validatable by the validators of the relaychain. They take their name from the concept of parallelized chains that run parallel to the relaychain. Most commonly, a parachain will take the form of a blockchain, but there is no specific need for them to be actual blockchains.

Basically, parachains are layer-1 blockchains that connect to the relaychains (Polkadot or Kusama), which validates the state transition of connected parachains, providing a shared state across the entire ecosystem. Since the validator set on the relaychain is expected to be secure with a large amount of stake put up to back it, it is desirable for parachains to benefit from this shared security.

To achieve identity aggregation, Litentry has a requirement to store sensitive user data, like web3 addresses, computed credit scores, and VCs in the trusted execution environment (TEE). Litentry builds a TEE side chain for this purpose and it is composed of multiple TEE-equipped nodes, to guarantee the security of data storage and data processing without exposing users' private data. A core component of this is the Litentry TEE worker which is based on Integritee's worker. It executes functions with specified inputs and resource limits in response to TEE calls and operations to ensure a sufficient level of scaling.

Overall, our architecture is made of up Relaychains ( Polkadot and Kusama), Parachains (Litentry and Litmus), and the TEE sidechain which is supported by and enables the runtime to execute in an SGX secure run environment.

To serve as the backbone platform for various Litentry products and achieve a transparent and decentralized user experience, we have different chain-specs/runtimes compiled into one single binary. They are:

- litentry-parachain-runtime (on polkadot)
- litmus-parachain-runtime (on kusama)
- rococo-parachain-runtime (on rococo)
- rococo-parachain-runtime (on rococo testnet)

Therefore, when building node binary or docker image, no distinction is required. But when building runtime/starting binary/running tests, the chain type must be explicitly given. See the examples below.

Expand All @@ -24,7 +32,7 @@ make help

to see the full lists of market targets and their short descriptions.

## manual builds
## Manual builds

To build the litentry-parachain raw binary manually:

Expand Down Expand Up @@ -52,23 +60,14 @@ The wasms should be located under `target/release/wbuild/litentry-parachain-runt

Similarly, use `make build-runtime-litmus` and `make build-runtime-rococo` to build the litmus-parachain-runtime and rococo-parachain-runtime, respectively.

## launch a standalone node

Simply run

```
make launch-standalone
```

A standalone node will be launched without relaychain, where blocks are finalised immediately. The node is accessible via ws 9944 port.
## Launch a local network with relaychain + parachain

## launch a local network with relaychain + parachain

The following steps take rococo-parachain for example, because `sudo` will be removed for litentry-parachain and [was removed](https://github.com/litentry/litentry-parachain/issues/775) for litmus-parachain. But generally speaking, lauching a local network works with either of the three chain-settings.
Take rococo-parachain for example, but generally speaking, launching a local network works with either of the three chain-settings.

To start a local network with 2 relaychain nodes and 1 parachain node, there're two ways:

### 1. use docker images for both polkadot and parachain (preferred)
### 1. Use docker images for both polkadot and parachain (preferred)

```
make launch-docker-rococo
Expand All @@ -86,11 +85,11 @@ make clean-docker-rococo

to stop the processes and tidy things up.

### 2. use raw binaries for both polkadot and parachain
### 2. Use raw binaries for both polkadot and parachain

Only when option 1 doesn't work and you suspect the docker-image went wrong.

In this case we could try to launch the network with raw binaries.
In this case, try to launch the network with raw binaries.

**On Linux host:**

Expand All @@ -113,7 +112,7 @@ make clean-binary
to stop the processes and tidy things up.
Note this command should work for all parachain types (you don't have to differentiate them).

## run ts tests locally
## Run ts Tests Locally

To run the ts tests locally, similar to launching the networks, it's possible to run them in either docker or binary mode.

Expand All @@ -136,14 +135,121 @@ make test-ts-binary-rococo
./scripts/run-ts-test.sh rococo
```

Remember to run the clean-up afterwards.
Remember to run the clean-up afterward.

## extend the leasing period
## License

The default leasing duration for parachain is 1 day, in case you want to extend it (even after it's downgraded to parathread), simply do a `forceLease` via sudo, it should be upgraded to parachain soon again and start to produce blocks.
GPLv3


## How to Build and Run Parachain and Tee-worker

## Preparation

- Env: [Setup **SGX TEE** Environment](https://web3builders.notion.site/Setup-SGX-TEE-Environment-68066770831b45b7b632e682cf159477?pvs=4)

## Build

The `Litentry-worker` needs to be built before the launch of the entire system

```
git clone https://github.com/litentry/litentry-parachain
cd ./litentry-parachain/tee-worker
source /opt/intel/sgxsdk/environment
SGX_MODE=SW make
```

## Launch

### 1. Start a local docker setup

In order to create a local docker setup, you can run the following command
```
./local-setup/launch.py --config ./local-setup/github-action-config-one-worker.json
```
This will create three docker containers, 2 Relay Chain Validators, and 1 Parachain Collator. However, it will use the default ports as present in .env.dev. If you want to run the system by offsetting the default ports, you can run this command instead:

```
./local-setup/launch.py --config local-setup/development-worker.json --offset 100
```
This will run the same containers and use the offset value of 100.

### 2. Start a local binary setup

In order to create a local binary setup, using default ports, you can run the following command:
```
/local-setup/launch.py --config ./local-setup/github-action-config-one-worker.json --parachain local-binary
```

If you want to launch the same system by offsetting the port values, you can use this command:
```
/local-setup/launch.py --config ./local-setup/github-action-config-one-worker.json --parachain local-binary --offset 100
```
In case you receive the following error:
```ModuleNotFoundError: No module named 'pycurl'```

Fix it manually by installing pycurl using pip3.

### 3. Remote <> Integritee Node

If you are running the integritee node manually, then be mindful of the port that is being set while launching the integritee node, for example:
```
cargo build --release --features "skip-extrinsic-filtering skip-ias-check skip-scheduled-enclave-check"
./target/release/integritee-node --rpc-cors=all --ws-external --tmp --dev --state-pruning archive --blocks-pruning archive --rpc-port 9933 --ws-port 9944
```

`--rpc-port` is used to set the rpc port and `--ws-port` is used to set the ws port for the node. You then have to update the `config.json` with the port that is being used and then run the command

**Note: The `Integritee-Node` is not maintained by Parachain Team actively, Please check the [repository]([url](https://github.com/litentry/integritee-node/tree/litentry-runtime)) if it has all the latest updates from `Litentry-Parachain` .**

### TEE Worker Tests

Refer to [tee-worker ts-tests](https://github.com/litentry/litentry-parachain/blob/dev/tee-worker/ts-tests/README.md)

### Clean-up

In the worker launch terminal, `Ctrl + C` should interrupt and clean everything up automatically.
Additionally, if you launch the parentchain with binaries (integritee-node or parachain), you have to stop the parentchain by `Ctrl + C` too, or using `kill`

If you want to still call the scripts responsible for cleaning up the process,
If launched via docker
```
make clean-docker-rococo
```
Docker can sometimes still leave behind remnants of an old build, run:
```
docker system prune
docker builder prune
```

If launched via binary

```
make clean-binary
```

### How to know the Worker is Working

![image (2)](https://github.com/cryptoade1/litentry-parachain/assets/88367184/87dd72f6-0124-4007-9b14-dddc97d3d252)
Waiting for block production to start

![image (3)](https://github.com/cryptoade1/litentry-parachain/assets/88367184/83872a38-abfe-4dc3-878f-9e25b7da6c2d)
Block produced

![image (4)](https://github.com/cryptoade1/litentry-parachain/assets/88367184/d04c76f7-484a-4172-ac10-53a6d4714766)
Parachain up; waiting for the worker to start

![image (5)](https://github.com/cryptoade1/litentry-parachain/assets/88367184/cb1cea60-bc5d-4b62-bae7-503583a135ee)
Worker started!

![image (6)](https://github.com/cryptoade1/litentry-parachain/assets/88367184/21ff630c-baa3-439d-b70a-03f621f49258)
In logs, you’ll see the sidechain starts to produce blocks

### Additional Info:

1. Change the RUST_LOG level: `litentry-parachain/tee-worker/local-setup/py/worker.py`
2. Check existing ts-tests: `litentry-parachain/tee-worker/ts-tests/package.json`
3. JSON config parameters: `litentry-parachain/tee-worker/service/src/cli.yml`

![image](https://user-images.githubusercontent.com/7630809/135689832-1f57cd5c-7f83-4fce-9bb0-832b77a38dcc.png)

## License

GPLv3

0 comments on commit 78ba9df

Please sign in to comment.