https://github.com/limechain/fruzhin
Java implementation of the Polkadot Host
https://github.com/limechain/fruzhin
blockchain java libp2p polkadot wasm
Last synced: about 2 months ago
JSON representation
Java implementation of the Polkadot Host
- Host: GitHub
- URL: https://github.com/limechain/fruzhin
- Owner: LimeChain
- License: apache-2.0
- Created: 2023-02-23T13:37:28.000Z (over 2 years ago)
- Default Branch: dev
- Last Pushed: 2025-08-18T09:08:24.000Z (2 months ago)
- Last Synced: 2025-08-18T11:20:34.627Z (2 months ago)
- Topics: blockchain, java, libp2p, polkadot, wasm
- Language: Java
- Homepage:
- Size: 157 MB
- Stars: 35
- Watchers: 5
- Forks: 1
- Open Issues: 41
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README

Fruzhin is a Java Implementation of the Polkadot Host. The ultimate goal for Fruzhin is to be able to function as an
authoring and relaying node, increasing security of the Polkadot Protocol. It's been funded by
[Polkadot Pioneers Prize](https://polkadot.polkassembly.io/child_bounty/238).
> **Warning**
> Fruzhin is in pre-production state
# Status
- [x] Light Client
- [x] Full Node
- [x] Authoring Node
- [ ] Relaying Node
# Getting started
## Clone
```bash
git clone https://github.com/LimeChain/Fruzhin.git
cd Fruzhin
```
## Setup & Build steps
### Java Version
Fruzhin works with Java 22.
If you have multiple java version installed please make sure you're using 22:
```
export JAVA_HOME=`/usr/libexec/java_home -v 22`
```
### Build
```bash
./gradlew build
```
## Running Fruzhin
### Sync with official chain
```bash
java -jar build/libs/Fruzhin-0.1.0.jar -n polkadot --node-mode full --sync-mode full
```
- `-n`(network) could be `westend`, `polkadot`, `kusama` or `local`
- `--node-mode` could be `full` or `light`
- `--sync-mode` could be `full` or `warp`
Optional program arguments:
- `-dbc` cleans database
- `-prometheus-port` can specify custom port for running prometheus server [default: 9090]
Optional environment variables:
- When `SHORT_HASH_LOGS` is set without a value, block hashes in logs are abbreviated from full form
`0xb94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9` to a shortened format like `0xb94...efcde9`
- `BABE_PUB_KEY`, `BABE_SURI`, `GRAN_PUB_KEY`, `GRAN_SURI`, `BEEF_PUB_KEY`, `BEEF_SURI` are available
(not recommended for production) for injecting keys into the keystore.
### Running as a Validator
If you're running a Fruzhin node as a validator, you need to inject the required session keys (`babe`, `gran`, `beef`)
so the node can actively participate in all consensuses.
There are two main ways to provide these keys:
1. Use author_insertKey via RPC after the node is started:
```shell
curl -X POST http://127.0.0.1:9922 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "author_insertKey",
"params": [
"gran",
"",
""
]
}'
```
2. Use Environment variables (Not Recommended for Production)
You can set the keys via environment variables before starting the node. This may be convenient for local
testing or quick setups.
```shell
export BABE_PUB_KEY=
export BABE_SURI=
export GRAN_PUB_KEY=
export GRAN_SURI=
export BEEF_PUB_KEY=
export BEEF_SURI=
```
### Running Validators on Local Network
Fruzhin supports running validators on a local network using the provided chainspecs in the `genesis/zombienet`
directory. There are two chainspecs available:
1. **Single Validator (Alice)**: This chainspec is configured with only Alice as a validator.
It's designed for single-validator setups where Alice can make progress independently since it meets the 2/3 + 1
threshold requirement. The bootnodes array is empty in this configuration.
2. **Multiple Validators (Alice and Bob)**: This chainspec includes both Alice and Bob as validators. Before
using this configuration:
- Start another node first
- Make an RPC call to get the node's address:
```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_localListenAddresses"}' http://localhost:9944
```
- Add the returned address to the bootnodes array in the chainspec
- Then start Fruzhin, which will connect to the other node
You can specify which chainspec to use by configuring the `application.properties` file.
The keys for Alice and Bob in these chainspecs are generated using the `subkey` tool with the following command:
```bash
subkey inspect --scheme (sr25519 | ed25519 | ecdsa)
```
## Get docker image
```bash
docker image pull limechain/fruzhin
docker volume create rocksdb
```
### Run Fruzhin on docker
```bash
docker run -d -v rocksdb:/usr/app/rocks-db limechain/fruzhin -n polkadot --node-mode full --sync-mode full
```
### Local development
In order to use the Fruzhin node for local development you will first need to start another node that would serve as a
peer.
For the sake of this example we will use [Paritytech's implementation](https://github.com/paritytech/polkadot-sdk).
If you are not familiar with how to run a node see [this](https://wiki.polkadot.network/docs/maintain-sync#setup-instructions).
Once you have successfully built the Polkadot project run the node via ``polkadot --dev``.
(The node starts on port 9944 by default)
Now you have 2 options:
- Use the automated `local_dev.sh` script
- Manual setup.
#### Automated script
1. Install [JQ](https://github.com/jqlang/jq).
`sudo apt-get install jq` Ubuntu
`brew install jq` MacOS
2. Head to the main directory of Fruzhin execute the script `./local_dev.sh`.
#### Manual setup
1. Fetch the chain spec
```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "sync_state_genSyncSpec", "params": [true]}' http://localhost:9944
```
The `lightSyncState` field is important for the light client to
work. Without it, the light client won't have a checkpoint to start from
and could be long-range attacked
2. Create a new `westend-local.json` inside of the `genesis` project directory.
3. Copy the contents of the `result` field from the fetched chain spec into the newly created `westend-local.json`.
4. In order to comply with the project requirements change the json structured as follows:
Fetched chain spec
```JSON
{
"genesis": {
"raw": {
"top": {},
"childrenDefault": {}
}
}
}
```
Desired chain spec
```JSON
{
"genesis": {
"top": {},
"childrenDefault": {}
}
}
```
5. Fetch the local boot nodes.
```bash
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_localListenAddresses"}' http://localhost:9944
```
Paste the response into the `bootNodes` field of the `westend-local.json` chain spec.
#### Build & Run
1. Build project
```
./gradlew build
```
2. Run Fruzhin
```
java -jar build/libs/Fruzhin-0.1.0.jar -n 'local' --node-mode 'full'/'light' --sync-mode 'full'/'warp' --db-recreate true/false
```