Skip to content

LimeChain/Fruzhin

Repository files navigation

Fruzhin-Cover-Black

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

Status

  • Light Client
  • Full Node
  • Authoring Node
  • Relaying Node

Getting started

Clone

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

./gradlew build

Running Fruzhin

Sync with official chain

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:
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>"
    ]
}'
  1. 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>

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:
      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)

Get docker image

  docker image pull limechain/fruzhin
  docker volume create rocksdb

Run Fruzhin on docker

  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. 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.

Automated script

  1. Install 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

    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

{
  "genesis": {
    "raw": {
      "top": {},
      "childrenDefault": {}
    }
  }
}

Desired chain spec

{
  "genesis": {
     "top": {},
     "childrenDefault": {}
  }
}
  1. 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 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
    

About

Java implementation of the Polkadot Host

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 12

Languages