Skip to content

Commit 9625da4

Browse files
authored
Merge pull request #520 from AmbireTech/sentry-dummy-adapter-deposits
Sentry dummy adapter deposits
2 parents 50ab6ab + dedabb5 commit 9625da4

File tree

28 files changed

+510
-250
lines changed

28 files changed

+510
-250
lines changed

Makefile.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
33
CARGO_MAKE_CLIPPY_ARGS = "--all-features -- -D warnings"
44
CARGO_MAKE_RUN_TOML_FORMAT = "true"
5+
CARGO_MAKE_RUN_CHECK_FORMAT = "true"
6+
CARGO_MAKE_RUN_CLIPPY = "true"
57

68
[tasks.dev-test-flow]
79
dependencies = [

README.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Two services are needed to run `Sentry`: `Postgres` and `Redis`.
3030

3131
The easiest way to run these services locally is by using the provided `docker-compose` file:
3232

33-
`docker-compose -f ../docker-compose.harness.yml up -d adex-redis adex-postgres`
33+
`docker-compose -f docker-compose.harness.yml up -d adex-redis adex-postgres`
3434

3535
If you want to run them manually without `docker-compose`:
3636

@@ -81,7 +81,7 @@ POSTGRES_DB="sentry_leader" PORT=8005 KEYSTORE_PWD=ganache0 \
8181
cargo run -p sentry -- \
8282
--adapter ethereum \
8383
--keystoreFile ./adapter/tests/resources/0x80690751969B234697e9059e04ed72195c3507fa_keystore.json \
84-
./docs/config/prod.toml
84+
./docs/config/ganache.toml
8585
```
8686

8787
##### Follower (`0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7`)
@@ -93,11 +93,26 @@ IP_ADDR=127.0.0.1 REDIS_URL="redis://127.0.0.1:6379/2" \
9393
POSTGRES_DB="sentry_follower" PORT=8006 KEYSTORE_PWD=ganache1 cargo run -p sentry -- \
9494
--adapter ethereum \
9595
--keystoreFile ./adapter/test/resources/0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7_keystore.json
96-
./docs/config/prod.toml
96+
./docs/config/ganache.toml
9797
```
9898

9999
#### Using the `Dummy` adapter
100100

101+
Using the dummy adapter you get access to additional route
102+
for adding deposits to the dummy adapter. The authenticated address
103+
is used to set the deposit in the adapter for the given Chain id.
104+
105+
##### `POST /v5/channel/dummy-deposit` (auth required)
106+
107+
Request body (`JSON`):
108+
109+
```json
110+
{
111+
"channel": { "leader": "0x000..", ...},
112+
"deposit": { "total": "10000000" }
113+
}
114+
```
115+
101116
**Dummy** identities:
102117

103118
##### Leader (`0x80690751969B234697e9059e04ed72195c3507fa`)
@@ -107,7 +122,7 @@ IP_ADDR=127.0.0.1 REDIS_URL="redis://127.0.0.1:6379/1" \
107122
POSTGRES_DB="sentry_leader" PORT=8005 cargo run -p sentry -- \
108123
--adapter dummy \
109124
--dummyIdentity 0x80690751969B234697e9059e04ed72195c3507fa \
110-
./docs/config/prod.toml
125+
./docs/config/ganache.toml
111126
```
112127
##### Follower (`0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7`)
113128

@@ -116,12 +131,12 @@ IP_ADDR=127.0.0.1 REDIS_URL="redis://127.0.0.1:6379/2" \
116131
POSTGRES_DB="sentry_follower" PORT=8006 cargo run -p sentry -- \
117132
--adapter dummy \
118133
--dummyIdentity 0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7 \
119-
./docs/config/prod.toml
134+
./docs/config/ganache.toml
120135
```
121136

122137
#### Environment variables
123138

124-
- `ENV` - `production` or `development`; *default*: `development` - passing this env. variable will 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`). Otherwise you can pass your own configuration file path to the binary (check `cargo run -p sentry --help` for more information). In `development` it will make sure Sentry to seed the database.
139+
- `ENV` - `production` or `development`; *default*: `development` - passing this env. variable will use the default configuration paths - [`docs/config/ganache.toml`](./docs/config/ganache.toml) (for `development`) or [`docs/config/prod.toml`](./docs/config/prod.toml) (for `production`). Otherwise you can pass your own configuration file path to the binary (check `cargo run -p sentry --help` for more information). ~~In `development` it will make sure Sentry to seed the database~~ (seeding is disabled, see #514).
125140
- `PORT` - *default*: `8005` - The local port that Sentry API will be accessible at
126141
- `IP_ADDR` - *default*: `0.0.0.0` - the IP address that the API should be listening to
127142

@@ -154,14 +169,14 @@ cargo run -p validator_worker -- --help
154169
The password for the Keystore file can be set using the environment variable `KEYSTORE_PWD`.
155170

156171
##### Validator Leader (`0x80690751969B234697e9059e04ed72195c3507fa`)
157-
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Leader** on port `8005`:
172+
Assuming you have [Sentry API running](#running-sentry-rest-api) for the **Leader** on port `8005`:
158173

159174
```bash
160175
KEYSTORE_PWD=ganache0 cargo run -p validator_worker -- \
161176
--adapter ethereum \
162177
--keystoreFile ./adapter/test/resources/0x80690751969B234697e9059e04ed72195c3507fa_keystore.json \
163178
--sentryUrl http://127.0.0.1:8005 \
164-
./docs/config/prod.toml
179+
./docs/config/ganache.toml
165180
```
166181

167182
##### Validator Follower
@@ -173,7 +188,7 @@ KEYSTORE_PWD=ganache1 cargo run -p validator_worker -- \
173188
--adapter ethereum \
174189
--keystoreFile ./adapter/test/resources/0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7_keystore.json \
175190
--sentryUrl http://127.0.0.1:8006 \
176-
./docs/config/prod.toml
191+
./docs/config/ganache.toml
177192
```
178193

179194
#### Using the `Dummy` adapter
@@ -187,7 +202,7 @@ cargo run -p validator_worker -- \
187202
--adapter dummy \
188203
--dummyIdentity 0x80690751969B234697e9059e04ed72195c3507fa \
189204
--sentryUrl http://127.0.0.1:8005 \
190-
./docs/config/prod.toml
205+
./docs/config/ganache.toml
191206
```
192207

193208
##### Follower: `0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7`
@@ -199,13 +214,12 @@ cargo run -p validator_worker -- \
199214
--adapter dummy \
200215
--dummyIdentity 0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7 \
201216
--sentryUrl http://127.0.0.1:8006 \
202-
./docs/config/prod.toml
217+
./docs/config/ganache.toml
203218
```
204219

205220
#### Environment variables
206221

207-
- `ENV` - `production` or `development` - *default*: `development` - passing this env. variable will 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`). Otherwise you can pass your own configuration file path to the binary (check `cargo run -p sentry --help` for more information). In `development` it will make sure that Sentry seeds the database.
208-
- `PORT` - The local port that Sentry API will accessible at
222+
- `ENV` - `production` or `development`; *default*: `development` - passing this env. variable will use the default configuration paths - [`docs/config/ganache.toml`](./docs/config/ganache.toml) (for `development`) or [`docs/config/prod.toml`](./docs/config/prod.toml) (for `production`). Otherwise you can pass your own configuration file path to the binary (check `cargo run -p sentry --help` for more information).
209223

210224
##### Adapter
211225

adapter/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "AGPL-3.0"
1212

1313
[features]
1414

15-
# Enables testing untilites for working with Ganache.
15+
# Enables testing untilites for working with Ganache
1616
test-util = ["primitives/test-util"]
1717

1818
[dependencies]
@@ -39,6 +39,9 @@ once_cell = "1.8"
3939
parse-display = "0.5"
4040

4141
[dev-dependencies]
42+
# we require the test-util future for testing
43+
primitives = { path = "../primitives", features = ["test-util"] }
44+
4245
byteorder = "1.4"
4346
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
4447
pretty_assertions = "1"

adapter/Makefile.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
extend = "../Makefile.toml"
2+
13
[tasks.dev-test-flow]
24
description = "Development testing flow will first format the code, and than run cargo build and test"
35
category = "Development"

0 commit comments

Comments
 (0)