Skip to content

Compile and run a RSK node locally

Martin Medina edited this page May 22, 2017 · 8 revisions

In order to compile the code and run it, you will need to:

  • Install Java 8 JDK. (if you are using Windows remember that JAVA_HOME environment variable needs to be set.)
  • Clone RskJ source code from here
  • Ensure the security chain of the downloaded source code as explained here.

After the previous steps you can compile and run the code either from the command line or using IntelliJ IDEA.

Finally, you can start working on a local RSK network. See the here instructions on how to monitor it .

Running RSK node from command line

From the root directory where the code was downloaded execute

./gradlew build shadow -x test

and after building run

java -Drsk.conf.file=node1.conf -cp rsk.jar co.rsk.Start

  • rsk.jar is the name of the fatjar generated by the gradle shadow command. It can be found on rskj-core/build/lib
  • node1.conf is a configuration file for the node. A sample configuration file can be found on: /classes/production/rskj-core/config/rsk-sample.conf. Some settings need to be initialized and you can learn to do that here.

Running RSK node using IntelliJ IDEA

Let's download IntelliJ IDEA

Once IDEA is installed in your system you can procede to compile and run the node.

Opening IDEA

After opening IDEA we need to load the RskJ project, this can be done by using the Import project option in IDEA To do that follow the next steps:

  • Go to File -> New -> Project from Existing Sources...
  • Browse the RskJ code and select Import project from external model -> Gradle
  • Within the dialog select Use default gradle wrapper and then press Finish.

img

IDEA Build/Run configuration

We need to create a new configuration profile to run the node from IDEA. Part of the configuration information that needs to be provided is related to the node itself, you can find a sample configuration file on: /classes/production/rskj-core/config/rsk-sample.conf. Some settings need to be initialized and you can learn to do that here.

Next step is to create a new configuration profile on IDEA, that can be done by clicking on Run -> Edit Configurations or as shown in the following picture:

img

Then set the options as shown below:

img

  • Main Class: co.rsk.Start
  • VM Options: -Drsk.conf.file=/path/to/rsk-sample.conf
  • Working directory: /path/to/code/rskJ
  • Use classpath of module: rskj-core_main

Running the node

We are ready to run the node using IDEA, just press the Start button at the right of the configuration we've just created.

img

If everything is OK you should see the debug information like that

img

Congratulations! you're running a local RSK node :)

Running your own mining local network

In the previous steps we configured a single node and it was great but not very useful since the configuration used was not set for mining. As we know, mining is needed in order to publish contracts so let's configure our node to mine.

A sample configuration for mining is miner1.conf. Don't forget to fill the missing settings in miner1.conf just like we did in the RSK configuration created for IDEA or for the command line.

In IDEA copy the existing RSK configuration

img

And change the VM options for the miner node

img

To setup more mining nodes two more configurations (miner2.conf and miner3.conf) can be found on the utilities repo. Repeat the same process used for miner1 and your local mining network is ready to go!

Running miners

We have now three configurations for different miners, now the funny part, let's run our local RSK Smart network. Go to Run configuration button again and start all the miners configurations one after the other.

Congratulations! you're running a local RSK mining party :)

Checking the local network using the monitor

First step is to setup and run the monitor app as explained here

If everything is correct you will see the app running and synchronizing like this

ExplorerStart

and the welcome page as shown below

ExplorerBrowser

Note. By default the Monitor app is connected to port 4444 this is the default port for miner 1, you can change this value to connect to any other of the miners

  • Miner 1: 4444
  • Miner 2: 4445
  • Miner 3: 4446
Clone this wiki locally