Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates README.md to make it easier to setup the powpeg node. #241

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ This node is used by Rootstock PowPeg signatories to interact with the Bridge co
## Software installation help
Disclaimer: this documentation will be specific for macOS operating system.

### **Java JDK 1.8**
### Setup Details
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we call this section "Quick setup for macOS"?


If you need a quick and easy, fool-proof way to setup the powpeg-node, you can follow the steps in the `quick_setup_samples/quick_setup_for_macos_x64.md` file.

#### **Java JDK 1.8**

Although optional we recommend to install jenv to manage different Java versions, to do that run: `brew install jenv`

Expand Down Expand Up @@ -49,7 +53,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 25.351-b10, mixed mode)

*If not, try closing the terminal and open a new one cause sometimes it stays cached.*

### Bitcoind
#### Bitcoind

To install version `24.0.1` follow instructions listed [here](https://bitcoincore.org/en/releases/24.0.1/)

Expand All @@ -59,12 +63,10 @@ It should output ```Bitcoin server starting```

Run `bitcoin-cli stop` afterwards.



## Setting up the project
#### Setting up the project
Create a directory (for example, “powpeg-project”) to hold the rskj node, the powpeg node and further configurations.

### Fetch the code
##### Fetch the code

Inside the `powpeg-project` directory clone the powpeg-node repository.

Expand All @@ -76,7 +78,7 @@ git clone https://github.com/rsksmart/powpeg-node
cd powpeg-node
```

### [Optional] Verify the code
##### [Optional] Verify the code

Before anything, you must ensure the security chain of the source code. For that, you must go through the following steps. For Linux based OS (Ubuntu for example) it’s recommended to install `gnupg-curl` to download the key through HTTPS.

Expand Down Expand Up @@ -141,18 +143,15 @@ configure.sh: OK
sha256sum: WARNING: 19 lines are improperly formatted
```

### Configure
##### Configure

Run configure script to configure secure environment.

```bash
./configure.sh
```



### Required configurations

##### Required configurations

**1. Pegnatory private key**

Expand All @@ -164,7 +163,6 @@ Set the desired value to it. (For example, `String generator = “federator1”;

- Run the class to generate a privateKey, publicKey, publicKeyCompressed, address and nodeId


You should get an output like the following:

```
Expand Down Expand Up @@ -255,24 +253,19 @@ includeBuild('<ABSOLUTE-PATH-TO-RSKJ-SOURCE-CODE>') {
}
```



### [Optional] Import and configure the project
##### [Optional] Import and configure the project

To import the project to IntelliJ IDEA go to `File > New > Project from existing sources...` Select `powpeg-node/build.gradle` and import.




### Build
##### Build

Then clean and build project using:

```bash
./gradlew clean build
```

### Run bitcoind
##### Run bitcoind

Create a new directory called datadir inside powpeg-project. In the next step you need to replace `<PATH_TO_DATA_DIR>` with this directory absolute path.

Expand Down Expand Up @@ -320,7 +313,7 @@ This should return an integer.

- For more references, check **[https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line)**

### Run PowPeg node!
##### Run PowPeg node!

You can run it either with the FedRunner configuration from IntelliJ or manually from the command line.

Expand Down
68 changes: 68 additions & 0 deletions quick_setup_samples/quck_setup_for_macos_x64.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Quick Setup for macos x64

In case you would like to try a fool-proof setup for macos from scratch, you can try the following steps.
You can also skip some of the steps if it is not applicable, for example, you don't need to install Java 1.8 if you have it already installed.

You can also try your own variations. But the example provided here makes it easy for anybody to setup a powpeg node from scratch in an easy way.

## Steps

1. Install Java OpenJDK 1.8 from the binaries (if it is not installed yet)
1. You can download it from here: `https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u-2021-05-08-08-14/OpenJDK8U-jdk_x64_mac_hotspot_2021-05-08-08-14.tar.gz`
1. `cd` to the directory where you want to download it. It could be like `cd /Library/Java/JavaVirtualMachines/`
2. Download it like this: `sudo curl -o adoptopenjdk-8.tar.gz -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u-2021-05-08-08-14/OpenJDK8U-jdk_x64_mac_hotspot_2021-05-08-08-14.tar.gz`
3. Unzip it like this: `sudo tar -zxvf adoptopenjdk-8.tar.gz`
4. The unzipped directory could be named like this `jdk8u302-b01`. Run an `ls` command to see it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about including here the output of the command?

2. Add it to the `.bash_profile`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last two macOS versions, the default shell in macOS has been zsh(https://support.apple.com/lv-lv/guide/terminal/trml113/2.14/mac/14.0). Therefore, I think this should be done in the zsh profile file, and the same applies to the rest of the configuration done in the bash env files.

1. Open the `.bash_profile` file with `nano` like this `nano ~/.bash_profile` and add the following 2 `export` lines:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Open the `.bash_profile` file with `nano` like this `nano ~/.bash_profile` and add the following 2 `export` lines:
1. Open the `.bash_profile` file with `nano` like this `nano ~/.bash_profile`(or do it using your favorite text editor) and add the following 2 `export` lines:

2. `export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk8u302-b01/Contents/Home/bin`
3. `export PATH="$JAVA_HOME/bin:$PATH"`
4. Save it and run the command: `source ~/.bash_profile` and restart the terminal. After this, the `java -version` command should return info.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here; I think we should add the output as a sample.

2. Install bitcoind
1. `cd` to the directory where you want to download it. It could be `/Library/Bitcoin` (if it doesn't exit, you can create it running the command `sudo mkdir /Library/Bitcoin`)
2. You can download version 0.18.1 (ideal for regtest) from here: `https://bitcoincore.org/bin/bitcoin-core-0.18.1/bitcoin-0.18.1-osx64.tar.gz`
3. You can download version 24.0.1 `https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-apple-darwin.tar.gz`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a secondary option when the user is not interested in the 0.18.1 version? If so, why numbered it as the second step when the rest of the steps refer to the 0.18.1 version?

4. Download it like this: `sudo curl -o bitcoind18.tar.gz -L https://bitcoincore.org/bin/bitcoin-core-0.18.1/bitcoin-0.18.1-osx64.tar.gz`
5. Unzip it like this: `sudo tar -zxvf bitcoind18.tar.gz`
6. Run the `ls` command to see the actual name of the unzipped directory. It should be like `bitcoin-0.18.1`
7. Add the path `export PATH="$PATH:/Library/Bitcoin/bitcoin-0.18.1/bin"` to the `/.zshrc` file
1. Open the `.zshrc` file with nano like this: `nano ~/.zshrc` and add the following line in it and save it: `export PATH="$PATH:/Library/Bitcoin/bitcoin-0.18.1/bin"`
8. Run `source ~/.zshrc` command, close and reopen the terminal.
9. Running an instance of bitcoind
1. To run it in regtest mode, run this command: `bitcoind -deprecatedrpc=generate -addresstype=legacy -regtest -printtoconsole -server -rpcuser=rsk -rpcpassword=rsk -rpcport=18332 -txindex -datadir=/Library/Bitcoin/data`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave this user and password by default?

2. You can also put this command into an `bitcoin-regtest.sh` file, make it executable with `sudo chmod +x bitcoin-regtest.sh` and run it like `./bitcoin-regtest.sh`
3. To run it in regular mode, simply run the command: `bitcoind`
10. Generate some blocks
1. To generate, for example, 200 regtest bitcoin blocks, run: `./btc-regtest.sh generate 200`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. To generate, for example, 200 regtest bitcoin blocks, run: `./btc-regtest.sh generate 200`
1. To generate, for example, 200 regtest bitcoin blocks, run: `./btc-regtest.sh generate 200`

Where is this script? It has not been created at this point, so it won't work.

3. Create a `powpeg-project` folder anywhere you like
1. For example: `mkdir /Library/powpeg-project`
4. Setup the rskj project
1. `cd` to the `powpeg-project` directory: `cd /Library/powpeg-project`
2. Clone it from here: `https://github.com/rsksmart/rskj`
1. `git clone https://github.com/rsksmart/rskj.git`
2. `cd` to the cloned `rskj` directory: `cd rskj`
3. Run the `configure.sh`
1. You will probably have to make it executable first with: `sudo chmod +x configure.sh`
2. And run it from a terminal like this: `./configure.sh`
5. Setup this project (powpeg-node: `https://github.com/rsksmart/powpeg-node`)
1. `cd` to the `powpeg-project` directory: `cd /Library/powpeg-project`
2. `git clone https://github.com/rsksmart/powpeg-node.git`
3. `cd` to the cloned `powpeg-node` directory: `cd powpeg-node`
4. Run the `configure.sh` file present in the root directory
1. You will probably have to make it executable with: `sudo chmod +x configure.sh`
2. And run it from a terminal like this: `./configure.sh`
5. Make a copy of the `development-settings.gradle.sample` file and rename it to `DONT-COMMIT-settings.gradle`
1. Remove the line `# Sample configuration to build rskj from the directory /home/user/another/dir/rskj`
2. Remove the line `# Rename it to DONT-COMMIT-settings.gradle for use in your local environment`
3. Replace the `'/home/user/another/dir/rskj/'` with the relative or absolute path where the `rskj` project is, for example: `/Library/powpeg-project/rskj`
6. Create a `fed.conf` file and set it up
1. Check the config file sample in `src/main/resources/config/fed-sample.conf`, copy it, rename it to `fed.conf` and update it as you need.
7. Optionally create a `logback.xml` file for the logging
1. Check the config file sample in `src/main/resources/config/logback-sample.xml`, copy it, rename it to `logback.xml` and update it as you need, adding or removing classes and their log level.
8. Build the powpeg project
1. Run: `./gradlew clean build`
2. To build it without running the tests, run: `./gradlew clean build -x test`
3. `cd` into `/Library/powpeg-project/powpeg-node/build/libs/` directory to see the version of the `federate-node-SNAPSHOT-<version>-all.jar` file, so you can run it in the following step.
9. Run the project
1. Resetting the rsk db (replace `<version>` with the actual version of the `.jar`): `java -cp /Library/powpeg-project/powpeg-node/build/libs/federate-node-SNAPSHOT-<version>-all.jar -Drsk.conf.file=/Library/powpeg-project/powpeg-node/src/main/resources/config/fed-sample.conf -Dlogback.configurationFile=/Library/powpeg-project/powpeg-node/logback.xml co.rsk.federate.FederateRunner --regtest --reset`
2. Without resetting the rsk db (replace `<version>` with the actual version of the `.jar`): `java -cp /Library/powpeg-project/powpeg-node/build/libs/federate-node-SNAPSHOT-<version>-all.jar -Drsk.conf.file=/Library/powpeg-project/powpeg-node/src/main/resources/config/fed-sample.conf -Dlogback.configurationFile=/Library/powpeg-project/powpeg-node/logback.xml co.rsk.federate.FederateRunner --regtest`
42 changes: 42 additions & 0 deletions src/main/resources/config/logback-sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>

<configuration INFO="false" scan="true" scanPeriod="3600 seconds">
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<Target>System.out</Target>
<encoder>
<pattern>%date{yyyy-MM-dd-HH:mm:ss.SSSS} %p [%c{1}] %m%n</pattern>
</encoder>
</appender>

<appender name="FILE-AUDIT"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/Users/your-user/path_to_logs/logs/rsk.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%date{yyyy-MM-dd-HH:mm:ss.SSS} %p [%c{1}] %m%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>./logs/rskj-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>100MB</maxFileSize>
<maxHistory>7</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>

<logger name="federatorSupport" level="TRACE"/>
<logger name="JsonRpcCustomServer" level="TRACE"/>
<logger name="web3" level="TRACE"/>
<logger name="bridge" level="TRACE"/>
<logger name="BtcToRskClient" level="TRACE"/>
<logger name="BridgeSupport" level="TRACE"/>
<logger name="co.rsk.peg.BridgeStorageProvider" level="ERROR"/>
<logger name="jsonrpc" level="TRACE"/>

<!-- more classes...-->

<root level="INFO">
<appender-ref ref="stdout"/>
<appender-ref ref="FILE-AUDIT"/>
</root>
</configuration>