Skip to content

Commit 7eb8357

Browse files
committed
README.md & Dockerfile update
1 parent 81482de commit 7eb8357

File tree

2 files changed

+118
-25
lines changed

2 files changed

+118
-25
lines changed

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ WORKDIR /usr/src/app
77

88
COPY . .
99

10-
RUN cargo install --path validator_worker --all-features
10+
# We intall the validator_worker binary with all features in Release mode
11+
# Inlcude the full backtrace for easier debugging
12+
RUN RUST_BACKTRACE=full cargo install --path validator_worker --all-features
1113

1214
WORKDIR /usr/local/bin
1315

README.md

+115-24
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,155 @@ Reference implementation of the [AdEx validator stack](https://github.com/adexne
66

77
Components:
88

9-
* Sentry
10-
* Validator worker
9+
* [Sentry](#sentry)
10+
* [Validator worker](#validator-worker)
1111
* Adapter
1212
* AdView manager
1313

1414
## Local & Testing setup
1515

16+
Requirements:
17+
18+
- Rust
19+
20+
Check the [`rust-toolchain`](./rust-toolchain) file for specific version of rust.
21+
- [`cargo-make`](https://github.com/sagiegurari/cargo-make)
22+
- Docker
23+
1624
#### Linux
1725
- `build-essentials` is required to build the project (error: `linker ``cc`` not found`)
1826
- The crate `openssl-sys` requires `libssl-dev` and `pkg-config` for Ubuntu.
1927

20-
### Run Postgres
28+
## Sentry
29+
30+
`Sentry` is the REST API that the [`Validator worker`](#validator-worker) uses for storing and retrieving information.
31+
We need two services to be able to run `Sentry`: `Postgres` and `Redis`.
2132

22-
`docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres`
33+
### Running Postgres
34+
35+
`docker run --rm --name adex-validator-postgres -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres`
2336

2437
- `$HOME/docker/volumes/postgres` - your local storage for postgres (persist the data when we remove the container)
2538
- `POSTGRES_PASSWORD=docker` - the password of `postgres` user
2639

27-
### Run Redis:
40+
### Running Redis
2841

29-
`docker run --name some-redis -d redis`
42+
`docker run --rm --name adex-validator-redis -d redis`
3043

31-
### Run automated tests
44+
### Running Sentry Rest API
3245

33-
Since we have integration tests that require Redis & Postgres,
34-
you need to be running those in order to run the automated tests:
46+
For a full list of all available CLI options on Sentry run `--help`:
3547

36-
`cargo make test`
48+
```bash
49+
cargo run -p sentry -- --help
50+
```
51+
52+
#### Using the `Ethereum Adapter`
53+
54+
The password for the Keystore file can be set using the environment variable `KEYSTORE_PWD`.
55+
56+
- Leader
57+
```bash
58+
POSTGRES_DB="sentry_leader" PORT=8006 cargo run -p sentry -- --adapter ethereum --keystoreFile ./adapter/resources/keystore.json ./docs/config/dev.toml
59+
```
60+
61+
- Follower
62+
```bash
63+
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- --adapter ethereum --keystoreFile ./adapter/resources/keystore.json ./docs/config/dev.toml
64+
```
65+
66+
#### Using the `Dummy Adapter`:
67+
68+
Dummy identities:
69+
70+
- Leader: `ce07CbB7e054514D590a0262C93070D838bFBA2e`
71+
72+
```bash
73+
POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- --adapter dummy --dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e ./docs/config/dev.toml
74+
```
75+
- Follower: `c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3`
76+
77+
```bash
78+
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- --adapter dummy --dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 ./docs/config/dev.toml
79+
```
3780

38-
### Run Sentry Rest API
81+
For full list, check out (primitives/src/util/tests/prep_db.rs#L29-L43)[./primitives/src/util/tests/prep_db.rs#L29-L43]
3982

40-
* With the DummyAdapter(replace the `DummyIdentity`):
83+
#### Environment variables:
4184

42-
`export PORT=8006; cargo run -p sentry -- -a dummy -i DummyIdentity`
85+
- `ENV`: `production` or `development` - pass this env. variable if you want to use the default configuration paths - [`docs/config/dev.toml`](./docs/config/dev.toml) (for development) or [`docs/config/prod.toml`](./docs/config/prod.toml) (for production)
86+
- `PORT`
87+
- `KEYSTORE_PWD`
88+
- `POSTGRES_DB`
4389

44-
* With the EthereumAdapter:
90+
### Running the Validator Worker
4591

46-
TODO
92+
For a full list of all available CLI options on the Validator worker run `--help`:
4793

48-
### Bug
94+
```bash
95+
cargo run -p validator_worker -- --help
96+
```
4997

98+
#### Using the `Ethereum Adapter`:
99+
TODO: Update Keystore file and Keystore password for Leader/Follower as they are using the same at the moment.
50100

101+
The password for the Keystore file can be set using the environment variable `KEYSTORE_PWD`.
51102

103+
- Leader
104+
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Leader** on port `8005`:
52105

53-
### Run Validator Worker
106+
```bash
107+
cargo run -p validator_worker --adapter ethereum --keystoreFile ./adapter/resources/keystore.json --sentryUrl http://127.0.0.1:8005 ./docs/config/dev.toml
108+
```
54109

55-
TODO
110+
- Follower
111+
112+
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Follower** on port `8006`:
113+
114+
```bash
115+
cargo run -p validator_worker --adapter ethereum --keystoreFile ./adapter/resources/keystore.json --sentryUrl http://127.0.0.1:8006 ./docs/config/dev.toml
116+
```
117+
118+
#### Using the `Dummy Adapter`:
119+
- Leader: `ce07CbB7e054514D590a0262C93070D838bFBA2e`
120+
121+
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Leader** on port `8005`:
122+
123+
```bash
124+
cargo run -p validator_worker --adapter dummy --dummyIdentity ce07CbB7e054514D590a0262C93070D838bFBA2e --sentryUrl http://127.0.0.1:8005 ./docs/config/dev.toml
125+
```
126+
127+
- Follower: `c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3`
128+
129+
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Follower** on port `8006`:
130+
131+
```bash
132+
cargo run -p validator_worker --adapter dummy --dummyIdentity c91763d7f14ac5c5ddfbcd012e0d2a61ab9bded3 --sentryUrl http://127.0.0.1:8006 ./docs/config/dev.toml
133+
```
56134

57135
## Development environment
58136

59-
We use [cargo-make](https://github.com/sagiegurari/cargo-make) for running the checks and build project locally
60-
as well as on CI. For a complete list of out-of-the-box commands you can check
137+
We use [`cargo-make`](https://github.com/sagiegurari/cargo-make#overview) for running automated checks (tests, builds, formatting, code linting, etc.) and building the project locally
138+
as well as on our Continuous Integration (CI). For a complete list of out-of-the-box commands you can check
61139
[Makefile.stable.toml](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/Makefile.stable.toml).
62140

63-
Locally it's enough to ensure that `cargo make` command (it will execute the default dev. command) is passing.
64-
It will run `rustfmt` for you, it will fail on `clippy` warnings and it will run all the tests.
141+
### Local development
65142

66-
*Note:* You need to have setup Redis and Postgres as well.
143+
Locally it's enough to ensure that the default development command is executing successfully:
144+
145+
```bash
146+
cargo make
147+
```
148+
149+
It will run `rustfmt` for you as well as `clippy` (it will fail on warnings) and it will run all the tests thanks to `cargo` (doc tests, unit tests, integration tests, etc.).
150+
151+
This will also run the [Automated tests](#automated-tests), so you must have `Redis` & `Postgres` running.
152+
153+
#### Automated tests
154+
155+
This requires [`cargo-make`](https://github.com/sagiegurari/cargo-make#overview) and since we have integration tests that require `Redis` ([see `Running Redis`](#running-redis)) & `Postgres` (see [`Running Postgres`](#running-postgres)), you need to be running those in order to run the automated tests:
156+
157+
`cargo make test`
67158
68-
You can related to the [Makefile.stable.toml](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/Makefile.stable.toml)
159+
You can relate to the [`Makefile.stable.toml`](https://github.com/sagiegurari/cargo-make/blob/master/src/lib/Makefile.stable.toml)
69160
for more commands and cargo-make as a whole.

0 commit comments

Comments
 (0)