Skip to content

Commit 918488d

Browse files
authored
chore: add readme (#4)
1 parent 46af5cb commit 918488d

File tree

7 files changed

+297
-13
lines changed

7 files changed

+297
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ authors = [
66
"Victor Farazdagi <[email protected]>",
77
"Ivan Reshetnikov <[email protected]>",
88
"Nodar Darksome <[email protected]>",
9+
"Daniel Martinez <[email protected]>",
910
]
1011
license = "Apache-2.0"
1112
publish = false

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# irn-node
2+
3+
Inter-Relay-Network Node. Implemented in Rust.
4+
5+
## Running Locally
6+
7+
Setup:
8+
9+
- Install [`rust`](https://www.rust-lang.org/tools/install);
10+
- Install [`docker`](https://docs.docker.com/get-docker/);
11+
- Install [`just`](https://github.com/casey/just#packages);
12+
- Copy the env file:
13+
```sh
14+
$ cp .env.example .env
15+
```
16+
- Fill `.env` file with necessary values - access keys for AWS and other services. No changes are necessary if just running locally.
17+
18+
Running the IRN Node:
19+
20+
```sh
21+
just run
22+
```
23+
24+
Running checks & tests:
25+
26+
```sh
27+
just devloop
28+
```
29+
30+
Running all checks & tests including storage tests:
31+
32+
```sh
33+
just devloop test-all
34+
```
35+
36+
## Running a sandbox cluster
37+
38+
Running dockerized sandbox cluster:
39+
40+
```sh
41+
$ just run-docker
42+
```
43+
44+
## Contributing
45+
46+
If you would like to contribute to the project, please read
47+
the [Contributing](./docs/Contributing.md) guide.
48+
49+
## License
50+
51+
Licensed under [Apache License, Version 2.0](./LICENSE).
52+
53+
Unless you explicitly state otherwise, any contribution intentionally submitted
54+
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
55+
be licensed as above, without any additional terms or conditions.

crates/relay_irn/Cargo.toml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,22 @@ tokio-stream = { version = "0.1", features = ["time"] }
2121
futures-util = "0.3"
2222
tokio-util = { version = "0.7", features = ["codec"] }
2323
thiserror = "1.0"
24-
derive_more = { workspace = true, features = ["as_ref", "display", "from", "try_into"] }
24+
derive_more = { workspace = true, features = [
25+
"as_ref",
26+
"display",
27+
"from",
28+
"try_into",
29+
] }
2530
futures = "0.3"
2631
dashmap = "5.4"
2732
tap = "1.0"
2833
async-trait = "0.1"
2934
bitflags = { version = "2.3", default-features = false, features = ["serde"] }
30-
chrono = { version = "0.4", default-features = false, features = ["alloc", "std", "clock"] }
35+
chrono = { version = "0.4", default-features = false, features = [
36+
"alloc",
37+
"std",
38+
"clock",
39+
] }
3140
rand = "0.7"
3241
once_cell = "1.17"
3342
smallvec = { version = "1.11", features = ["serde", "write"] }
@@ -46,7 +55,10 @@ test_utils = { path = "../test_utils" }
4655
tui = "0.19"
4756
structopt = { version = "0.3", default-features = false }
4857
better-panic = "0.3"
49-
tracing-subscriber = { version = "0.3", features = ["env-filter", "parking_lot"] }
58+
tracing-subscriber = { version = "0.3", features = [
59+
"env-filter",
60+
"parking_lot",
61+
] }
5062
tracing-appender = "0.2"
5163
hex = "0.4"
5264
difference = "2.0"

docker-compose.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
version: "3.9"
2+
services:
3+
node1:
4+
container_name: irn-node-1
5+
image: irn:master
6+
pull_policy: build
7+
build:
8+
dockerfile: ./Dockerfile
9+
context: ./
10+
args:
11+
PROFILE: debug
12+
volumes:
13+
- irn-node-1:/irn
14+
ports:
15+
- 3001:3000
16+
- 3101:3001
17+
- 3201:3002
18+
env_file:
19+
- ./irn.common.env
20+
environment:
21+
- SECRET_KEY=00000000000000000000000000000001
22+
- PEER_12D3KooWKCjCtAy1myLoPbeUrVS6BBhzVHjLRHKvMS4gCoobyBbb=/dns4/node2/tcp/3000
23+
- PEER_12D3KooWMeFudZutoDEqKAsZ51HzyUELGsUUX5rmWSRwxMq3spYL=/dns4/node3/tcp/3000
24+
- PEER_12D3KooWSfyLo174Etqyr9a4VWhyfZG2wA8T6tB1MFDAZYhLanFz=/dns4/node4/tcp/3000
25+
- PEER_12D3KooWBgLHcVYcyUP7eDVDzJonXVhCEhDtkNAMrWrkdjQSSLic=/dns4/node5/tcp/3000
26+
node2:
27+
container_name: irn-node-2
28+
image: irn:master
29+
pull_policy: build
30+
build:
31+
dockerfile: ./Dockerfile
32+
context: ./
33+
args:
34+
PROFILE: debug
35+
volumes:
36+
- irn-node-2:/irn
37+
ports:
38+
- 3002:3000
39+
- 3102:3001
40+
- 3202:3002
41+
env_file:
42+
- ./irn.common.env
43+
environment:
44+
- SECRET_KEY=00000000000000000000000000000002
45+
- PEER_12D3KooWBnTyEyBVeYpZJobw78rb85nNamrYQR3Tc6gJmfQ76pG4=/dns4/node1/tcp/3000
46+
- PEER_12D3KooWMeFudZutoDEqKAsZ51HzyUELGsUUX5rmWSRwxMq3spYL=/dns4/node3/tcp/3000
47+
- PEER_12D3KooWSfyLo174Etqyr9a4VWhyfZG2wA8T6tB1MFDAZYhLanFz=/dns4/node4/tcp/3000
48+
- PEER_12D3KooWBgLHcVYcyUP7eDVDzJonXVhCEhDtkNAMrWrkdjQSSLic=/dns4/node5/tcp/3000
49+
node3:
50+
container_name: irn-node-3
51+
image: irn:master
52+
pull_policy: build
53+
build:
54+
dockerfile: ./Dockerfile
55+
context: ./
56+
args:
57+
PROFILE: debug
58+
volumes:
59+
- irn-node-3:/irn
60+
ports:
61+
- 3003:3000
62+
- 3103:3001
63+
- 3203:3002
64+
env_file:
65+
- ./irn.common.env
66+
environment:
67+
- SECRET_KEY=00000000000000000000000000000003
68+
- PEER_12D3KooWBnTyEyBVeYpZJobw78rb85nNamrYQR3Tc6gJmfQ76pG4=/dns4/node1/tcp/3000
69+
- PEER_12D3KooWKCjCtAy1myLoPbeUrVS6BBhzVHjLRHKvMS4gCoobyBbb=/dns4/node2/tcp/3000
70+
- PEER_12D3KooWSfyLo174Etqyr9a4VWhyfZG2wA8T6tB1MFDAZYhLanFz=/dns4/node4/tcp/3000
71+
- PEER_12D3KooWBgLHcVYcyUP7eDVDzJonXVhCEhDtkNAMrWrkdjQSSLic=/dns4/node5/tcp/3000
72+
node4:
73+
container_name: irn-node-4
74+
image: irn:master
75+
pull_policy: build
76+
build:
77+
dockerfile: ./Dockerfile
78+
context: ./
79+
args:
80+
PROFILE: debug
81+
volumes:
82+
- irn-node-4:/irn
83+
ports:
84+
- 3004:3000
85+
- 3104:3001
86+
- 3204:3002
87+
env_file:
88+
- ./irn.common.env
89+
environment:
90+
- SECRET_KEY=00000000000000000000000000000004
91+
- PEER_12D3KooWBnTyEyBVeYpZJobw78rb85nNamrYQR3Tc6gJmfQ76pG4=/dns4/node1/tcp/3000
92+
- PEER_12D3KooWKCjCtAy1myLoPbeUrVS6BBhzVHjLRHKvMS4gCoobyBbb=/dns4/node2/tcp/3000
93+
- PEER_12D3KooWMeFudZutoDEqKAsZ51HzyUELGsUUX5rmWSRwxMq3spYL=/dns4/node3/tcp/3000
94+
- PEER_12D3KooWBgLHcVYcyUP7eDVDzJonXVhCEhDtkNAMrWrkdjQSSLic=/dns4/node5/tcp/3000
95+
node5:
96+
container_name: irn-node-5
97+
image: irn:master
98+
pull_policy: build
99+
build:
100+
dockerfile: ./Dockerfile
101+
context: ./
102+
args:
103+
PROFILE: debug
104+
volumes:
105+
- irn-node-5:/irn
106+
ports:
107+
- 3005:3000
108+
- 3105:3001
109+
- 3205:3002
110+
env_file:
111+
- ./irn.common.env
112+
environment:
113+
- SECRET_KEY=00000000000000000000000000000005
114+
- PEER_12D3KooWBnTyEyBVeYpZJobw78rb85nNamrYQR3Tc6gJmfQ76pG4=/dns4/node1/tcp/3000
115+
- PEER_12D3KooWKCjCtAy1myLoPbeUrVS6BBhzVHjLRHKvMS4gCoobyBbb=/dns4/node2/tcp/3000
116+
- PEER_12D3KooWMeFudZutoDEqKAsZ51HzyUELGsUUX5rmWSRwxMq3spYL=/dns4/node3/tcp/3000
117+
- PEER_12D3KooWSfyLo174Etqyr9a4VWhyfZG2wA8T6tB1MFDAZYhLanFz=/dns4/node4/tcp/3000
118+
volumes:
119+
irn-node-1:
120+
irn-node-2:
121+
irn-node-3:
122+
irn-node-4:
123+
irn-node-5:

docs/Contributing.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Contributing
2+
3+
Thank you for taking an interest in the project! Described below is what you need
4+
to get up to speed with this program.
5+
6+
## Table of contents
7+
8+
<details>
9+
<summary>Expand</summary>
10+
11+
- [Build](#build)
12+
- [Test](#test)
13+
- [Local Dev](#local-dev)
14+
- [Documentation](#documentation)
15+
- [Style](#style)
16+
- [Format](#format)
17+
- [Linting](#linting)
18+
- [Code documentation](#code-documentation)
19+
- [Git hygiene](#git-hygiene)
20+
- [Conventional commits](#conventional-commits)
21+
22+
</details>
23+
24+
## Build
25+
26+
Building the project locally is as easy as `cargo build`, and you can just as easily
27+
run the project via `cargo run` (ctrl+c to exit).
28+
29+
## Test
30+
31+
Testing the entire project can be done via `cargo test --all-features` from the
32+
repo root.
33+
34+
Note that our current convention is to _avoid_ writing unit tests. We only write functional tests.
35+
(`cargo test` calls these "integration tests".)
36+
We believe unit tests slow you down when refactoring, don't provide regression
37+
safety because they require changes whenever you change the related code, and ultimately only become
38+
a maintenance burden that yields very little benefit. We test from the program interface level,
39+
which are the REST and websocket API.
40+
41+
## Local Dev
42+
43+
While working on code locally sometimes is convenient to have a hot reload to improve code changes and build time. Rust on it's own doesn't provide
44+
a hot reload mechanism but community has built [cargo-watch](https://crates.io/crates/cargo-watch) as a plugin for cargo.
45+
46+
## Documentation
47+
48+
You can generate and open this repo's full documentation via:
49+
50+
```
51+
cargo +nightly doc --all-features --document-private-items --open
52+
```
53+
54+
_NOTE:_ You must have a nightly toolchain installed (`rustup install nightly`).
55+
56+
## Style
57+
58+
### Format
59+
60+
This project uses [`rustfmt`](https://github.com/rust-lang/rustfmt) for code formatting.
61+
You can format your code via:
62+
63+
```bash
64+
cargo +nightly fmt --all
65+
```
66+
67+
### Linting
68+
69+
This project uses [`clippy`](https://github.com/rust-lang/rust-clippy) for linting, and
70+
it's enforced by CI. You can run it locally via:
71+
72+
```bash
73+
cargo clippy
74+
```
75+
76+
### Code documentation
77+
78+
All of a crate's public items are expected to be properly documented via Rust
79+
[doc comments](https://doc.rust-lang.org/rust-by-example/meta/doc.html#documentation).
80+
Private items are more flexible, but should still be documented unless the item's
81+
purpose is obvious.
82+
83+
### Git hygiene
84+
85+
This repo expects expressive commits where 1 commit = 1 logical change, with a
86+
clear status message and body explaining the purpose of the commit.
87+
88+
We use [conventional commits](https://www.conventionalcommits.org) which are enforced by CI.

irn.common.env

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
ADDR=/ip4/0.0.0.0/tcp/3000
2+
API_ADDR=0.0.0.0:3001
3+
METRICS_ADDR=0.0.0.0:3002
4+
BOOTSTRAP_NODES=12D3KooWBnTyEyBVeYpZJobw78rb85nNamrYQR3Tc6gJmfQ76pG4,12D3KooWKCjCtAy1myLoPbeUrVS6BBhzVHjLRHKvMS4gCoobyBbb,12D3KooWMeFudZutoDEqKAsZ51HzyUELGsUUX5rmWSRwxMq3spYL,12D3KooWSfyLo174Etqyr9a4VWhyfZG2wA8T6tB1MFDAZYhLanFz,12D3KooWBgLHcVYcyUP7eDVDzJonXVhCEhDtkNAMrWrkdjQSSLic
5+
RAFT_DIR=/irn/raft
6+
ROCKSDB_DIR=/irn/rocksdb
7+
REPLICATION_STRATEGY_FACTOR=3
8+
REPLICATION_STRATEGY_LEVEL=Quorum
9+
LOG_LEVEL=info

justfile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,28 @@ clean-tmp:
5757
# Build IRN docker image
5858
build-docker:
5959
@echo '=> Build IRN docker image'
60-
docker compose -f ./ops/docker-compose.irn-sandbox-cluster.yml build
60+
docker compose -f ./docker-compose.yml build
6161

6262
# Start IRN sandbox cluster on docker
6363
run-docker:
6464
@echo '==> Start IRN sandbox cluster on docker'
65-
docker compose -f ./ops/docker-compose.irn-sandbox-cluster.yml up -d
65+
docker compose -f ./docker-compose.yml up -d
6666

6767
# Stop IRN sandbox cluster on docker
6868
stop-docker:
6969
@echo '==> Stop IRN sandbox cluster on docker'
70-
docker compose -f ./ops/docker-compose.irn-sandbox-cluster.yml down
70+
docker compose -f ./docker-compose.yml down
7171

7272
# Clean up docker IRN sandbox cluster
7373
clean-docker:
7474
@echo '==> Clean IRN sandbox cluster on docker'
75-
docker compose -f ./ops/docker-compose.irn-sandbox-cluster.yml stop
76-
docker compose -f ./ops/docker-compose.irn-sandbox-cluster.yml rm -f
75+
docker compose -f ./docker-compose.yml stop
76+
docker compose -f ./docker-compose.yml rm -f
7777

7878
# List services running on docker
7979
ps-docker:
8080
@echo '==> List services on docker'
81-
docker compose -f ./ops/docker-compose.irn-sandbox-cluster.yml ps
82-
83-
run-jaeger:
84-
@echo '==> Run opentelemetry jaeger docker container'
85-
docker run --rm -p4317:4317 -p16686:16686 jaegertracing/all-in-one:latest
81+
docker compose -f ./docker-compose.yml ps
8682

8783
# Bumps the binary version to the given version
8884
bump-version to: (_bump-cargo-version to irn-binary-crate + "/Cargo.toml")

0 commit comments

Comments
 (0)