Skip to content

Commit

Permalink
feat: add rpc subnet
Browse files Browse the repository at this point in the history
  • Loading branch information
MohsenNz committed Feb 19, 2025
1 parent 45842c8 commit de4042c
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
- [Run Monitor node](builders/run-monitor.md)
- [Create a Subnet](builders/create-a-subnet.md)
- [Run Jungochain RPC node](builders/run-jungochain-rpc-node.md)
- [RPC Subnet](builders/rpc-subnet.md)
- [Run an RPC Worker/Monitor](builders/run-rpc-worker-monitor.md)

# Tools

Expand Down
2 changes: 1 addition & 1 deletion src/builders/register-uid.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You should have `hotkey`. Follow [here](create-a-hotkey.md) to create a new one.

## Get JUNGO Token

Currently you can get token by requesting in our [Telegram Builder group](https://t.me/+I41xetD5BPNlZjVk).
Currently you can get token by requesting in our [Telegram group](https://t.me/+I41xetD5BPNlZjVk).

## Register UID

Expand Down
28 changes: 28 additions & 0 deletions src/builders/rpc-subnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# RPC Subnet

It is the RPC provider subnet of JungoAI and functions as a decentralized, free and
open-source solution. It could serve as a replacement for centralized solutions such as
Infura, Alchemy, and others.

Key features:
- **Permissionless**: Anyone can run an RPC node and receive rewards in JUNGO.
- **Trustless**: Requests propagate to all nodes, and the result follows the majority.
Thus, the results from minority nodes are considered invalid in the presence of malicious nodes.
- **Efficient**: Nodes are ranked based on performance, latency, and trust, ensuring that
clients receive responses from the node with the lowest latency and highest trust.

Note: Currently just Ethereum RPC supported.

## How it works?

Worker nodes are RPC providers that anyone can run. On the other hand,
monitor nodes measure the performance of worker nodes. Workers with
higher uptime and accuracy gain more trust. On the client side, they can
see the ranking of workers based on performance and trust. Additionally,
the client receives responses from the geographically closest node with
the lowest latency.

In the end, the client can choose to receive results in two ways:
- **Optimistic**: The client receives the result and processes it immediately. After a short delay, it receives validation.
This method is more efficient and can be used on nodes with high trust.
- **Pessimistic**: The client receives a validated result, ensuring it follows the majority of nodes.
4 changes: 2 additions & 2 deletions src/builders/run-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ You need to have `rye` on your system.<br> You can install it by running `curl -
To demonstrate how to run a worker node, we are going to do it on subnet 1001 (echo subnet) on
devnet as an example.

Install echo-subnet:
Install/Update echo-subnet:

```
rye install echo-subnet --git https://github.com/jungoai/jungo-echo-subnet.git
rye tools install -f echo-subnet --git https://github.com/jungoai/jungo-echo-subnet.git
```

Run echo-worker:
Expand Down
67 changes: 67 additions & 0 deletions src/builders/run-rpc-worker-monitor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Run RPC Worker/Monitor

<div class="warning">
Pre requirements

Before continuing make sure you have met [Registering UID](register-uid.md).
</div>

Clone rpc-subnet:
```bash
git clone https://github.com/jungoai/rpc-subnet.git
```
```bash
cd rpc-subnet
```

## Configuration

Create `.env` file
```bash
cp .env.example .env
```

Customize the parameters in the .env file. Some of these parameters are for Workers,
others are for Monitors, and some are needed for both.

Create `.providers.json`
```bash
cp ./.providers.json ~/.providers.json
```

Open `.providers.json` in your favorite editor and add your RPC endpoints under `providers` field.
```bash
code ~/.providers.json
```

E.g:
```json
{
"providers": [
"https://eth-mainnet.public.blastapi.io",
"https://eth.llamarpc.com",
]
}
```

## Run with Docker

Run Worker:
```bash
. ./scripts/run_rpc_worker_docker.sh
```

Run Monitor:
```bash
. ./scripts/run_rpc_monitor_docker.sh
```

**Note**:
If you are connecting to a local jungochain node with `fast-blocks` enabled, you should pass
`--fast_blocks` into `./scripts/run_rpc_monitor_docker.sh`

Also you can customize scripts.

## Development

See [here](https://github.com/jungoai/rpc-subnet?tab=readme-ov-file#rpc-subnet).
4 changes: 2 additions & 2 deletions src/builders/run-worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ You need to have `rye` on your system.<br> You can install it by running `curl -
To demonstrate how to run a monitor node, we are going to do it on subnet 1001 (echo subnet) on
devnet as an example.

Install echo-subnet:
Install/Update echo-subnet:

```
rye install echo-subnet --git https://github.com/jungoai/jungo-echo-subnet.git
rye tools install -f echo-subnet --git https://github.com/jungoai/jungo-echo-subnet.git
```

Run echo-monitor:
Expand Down

0 comments on commit de4042c

Please sign in to comment.