diff --git a/README.md b/README.md index 4be7b5555..34c5ee670 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ -# Welcome to RskJ Powpeg Node - - +# Welcome to RskJ PowPeg Node ## About -Powpeg node is a specialized rskj node which interacts with both Rootstock and Bitcoin. +PowPeg node is a specialized rskj node which interacts with both Rootstock and Bitcoin. This node is used by Rootstock PowPeg signatories to interact with the Bridge contract and to broadcast peg-out transactions to Bitcoin. - ## Software Requirements 1. Java JDK 1.8 2. Bitcoin Core daemon (bitcoind) 24.0.1 3. A Java compatible IDE. Recommended [IntelliJ IDEA](https://www.jetbrains.com/idea/download) as this guide covers the setup with it - **Not sure how to install any of these? See [software installation help](#software-installation-help)** - ## Software installation help + Disclaimer: this documentation will be specific for macOS operating system. +### Quick setup for macOS x64 + +A quick and easy, fool-proof way to setup the powpeg-node using macOS x64 is available [here](docs/QuickSetupMacOsx64.md). + ### **Java JDK 1.8** Although optional we recommend to install jenv to manage different Java versions, to do that run: `brew install jenv` @@ -59,8 +59,6 @@ It should output ```Bitcoin server starting``` Run `bitcoin-cli stop` afterwards. - - ## Setting up the project Create a directory (for example, “powpeg-project”) to hold the rskj node, the powpeg node and further configurations. @@ -149,11 +147,8 @@ Run configure script to configure secure environment. ./configure.sh ``` - - ### Required configurations - **1. Pegnatory private key** You will need a private key file to be used by the pegnatory to sign BTC/RSK transactions. Follow these steps to generate it: @@ -164,7 +159,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: ``` @@ -255,15 +249,10 @@ includeBuild('<ABSOLUTE-PATH-TO-RSKJ-SOURCE-CODE>') { } ``` - - ### [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 Then clean and build project using: diff --git a/docs/QuickSetupMacOsx64.md b/docs/QuickSetupMacOsx64.md new file mode 100644 index 000000000..66bfb41fa --- /dev/null +++ b/docs/QuickSetupMacOsx64.md @@ -0,0 +1,62 @@ +# Quick Setup for macOS x64 + +The following steps provide a quick setup guide for macOS x64. Some of the steps may be skipped if it is not applicable. For example, no need to install Java 1.8 if already installed. + +## Steps + +1. Install Java OpenJDK 1.8 from the binaries (if not installed yet) + 1. Download link: `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` into the directory to download it. Example: `cd /Library/Java/JavaVirtualMachines/` + 2. Download: `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: `sudo tar -zxvf adoptopenjdk-8.tar.gz` + 2. Add JAVA_HOME environment variable to bash + 1. Open `.bash_profile` file with some text editor. Example: `nano ~/.bash_profile` + 2. Add the following 2 `export` lines: + 1. `export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk8u302-b01/Contents/Home/bin` (replace the path with the actual path) + 2. `export PATH="$JAVA_HOME/bin:$PATH"` + 3. Restart the terminal. Run command `java -version` to validate the system detects the installed version of Java. +2. Install bitcoind + 1. `cd` into the directory to download it. Example: `cd /Library/Bitcoin/` + 2. Download version 24.0.1: `sudo curl -o bitcoind18.tar.gz -L https://bitcoincore.org/bin/bitcoin-core-0.18.1/bitcoin-0.18.1-osx64.tar.gz` + 3. Unzip: `sudo tar -zxvf bitcoind18.tar.gz` + 4. Add bitcoind to bash PATH + 1. Open `.bash_profile` file with some text editor. Example: `nano ~/.bash_profile` + 2. Add the following line: `export PATH="$PATH:/Library/Bitcoin/bitcoin-0.18.1/bin"` (replace the path with the actual path) + 3. Restart the terminal + 5. Running an instance of bitcoind + 1. To run in regtest mode, run the following command: `bitcoind -deprecatedrpc=generate -addresstype=legacy -regtest -printtoconsole -server -rpcuser=rsk -rpcpassword=rsk -rpcport=18332 -txindex -datadir=/Library/Bitcoin/data` + 2. To simplify, the command can be included in a bash file `bitcoin-regtest.sh`. To make it executable run `sudo chmod +x bitcoin-regtest.sh` + 6. Generate some blocks + 1. To generate, for example, 200 regtest bitcoin blocks, run: `./btc-regtest.sh generate 200` // TODO: where did btc-regtest.sh file come from? +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` diff --git a/src/main/resources/config/logback-sample.xml b/src/main/resources/config/logback-sample.xml new file mode 100644 index 000000000..42236d884 --- /dev/null +++ b/src/main/resources/config/logback-sample.xml @@ -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>