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.
Warning Fruzhin is in pre-production state
- Light Client
- Full Node
- Authoring Node
- Relaying Node
git clone https://github.com/LimeChain/Fruzhin.git
cd Fruzhin
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`
./gradlew build
java -jar build/libs/Fruzhin-0.1.0.jar -n polkadot --node-mode full --sync-mode full
-n
(network) could bewestend
,polkadot
,kusama
orlocal
--node-mode
could befull
orlight
--sync-mode
could befull
orwarp
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 form0xb94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
to a shortened format like0xb94...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.
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:
- Use author_insertKey via RPC after the node is started:
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",
"<suri>",
"<public-key>"
]
}'
- 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.
export BABE_PUB_KEY=<key>
export BABE_SURI=<suri>
export GRAN_PUB_KEY=<key>
export GRAN_SURI=<suri>
export BEEF_PUB_KEY=<key>
export BEEF_SURI=<suri>
Fruzhin supports running validators on a local network using the provided chainspecs in the genesis/zombienet
directory. There are two chainspecs available:
-
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.
-
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:
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:
subkey inspect <seed> --scheme (sr25519 | ed25519 | ecdsa)
docker image pull limechain/fruzhin
docker volume create rocksdb
docker run -d -v rocksdb:/usr/app/rocks-db limechain/fruzhin -n polkadot --node-mode full --sync-mode full
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. If you are not familiar with how to run a node see this.
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.
-
Install JQ.
sudo apt-get install jq
Ubuntubrew install jq
MacOS -
Head to the main directory of Fruzhin execute the script
./local_dev.sh
.
-
Fetch the chain spec
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 -
Create a new
westend-local.json
inside of thegenesis
project directory. -
Copy the contents of the
result
field from the fetched chain spec into the newly createdwestend-local.json
. -
In order to comply with the project requirements change the json structured as follows:
Fetched chain spec
{
"genesis": {
"raw": {
"top": {},
"childrenDefault": {}
}
}
}
Desired chain spec
{
"genesis": {
"top": {},
"childrenDefault": {}
}
}
-
Fetch the local boot nodes.
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 thewestend-local.json
chain spec.
- Build project
./gradlew build
- 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