forked from bisq-network/bisq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Makefile for automating localnet setup
Problem: contributors old and new must read and follow many manual steps spread across three documents (docs/{build,dev-setup,dao-setup}.md) in order to get up and running with a local regtest Bisq network deployment suitable for isolated development and end-to-end testing. This process is not only manual, but requires considerable trial and error for most contributors, and can amount to hours of effort. Perhaps most detrimental is that this friction makes it much less likely that we get "all hands on deck" to cover test scenarios at release time. Getting up and running with what this change refers to as a "localnet" should be among the very first things a new contributor does. It should be fast and easy, maximizing the contributor's ability to get productive right away. Solution: this commit introduces a simple and well-documented makefile to the root of the source tree. It instructs the user to issue a series of simple `make` commands, at the end of which they'll have a fully functional localnet deployment. Caveats: - No support for Windows unless the user is running Git Bash, Cygwin or similar. In any case, the makefile serves as clear documentation about what a Windows user would need to do manually, i.e. without the benefit of `make` automating it all. - The aforementioned setup documents should be updated to point to this makefile instead of explaining everything in prose. The dev-setup.md and dao-setup.md documents may actually be candidates for deletion if this new approach proves successful. - These changes do not include passing the new -peerbloomfilters=1 option to bitcoin versions 0.19 and above. Those who have already upgraded should take care to add that option. Notes: - The introduction of this makefile has no impact on Bisq's use of Gradle as a build system. Everything there is as it has been. This makefile is a completely optional convenience being added into the mix. It has the added benefit of being a "friendly face" to those not familiar with the Java / JVM ecosystem. Developers from many different backgrounds are familiar with make and makefiles, and they may find this one a pleasant and inviting surprise.
- Loading branch information
Showing
2 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ deploy | |
/monitor/TorHiddenServiceStartupTimeTests/* | ||
/monitor/monitor-tor/* | ||
.java-version | ||
localnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
# | ||
# INTRODUCTION | ||
# | ||
# This makefile is designed to help Bisq contributors get up and running | ||
# as quickly as possible with a local regtest Bisq network deployment, | ||
# or 'localnet' for short. A localnet is a complete and self-contained | ||
# "mini Bisq network" suitable for development and end-to-end testing | ||
# efforts. | ||
# | ||
# | ||
# REQUIREMENTS | ||
# | ||
# You'll need the following to proceed: | ||
# | ||
# - Linux, macOS or similar *nix with standard tools like `make` | ||
# - bitcoind and bitcoin-cli (`brew install bitcoin` on macOS) | ||
# - JDK 10 to build and run Bisq binaries; see | ||
# https://www.oracle.com/java/technologies/java-archive-javase10-downloads.html | ||
# | ||
# | ||
# USAGE | ||
# | ||
# The following commands (and a couple manual instructions) will get your | ||
# localnet up and running quickly. | ||
# | ||
# STEP 1: Build all Bisq binaries and set up localnet resources. This will | ||
# take a few minutes the first time through. | ||
# | ||
# $ make | ||
# | ||
# Notes: | ||
# | ||
# - When complete, you'll have a number of scripts available in the | ||
# root directory. They will be used in the make targets below to start | ||
# the various Bisq seed and desktop nodes that will make up your | ||
# localnet: | ||
# | ||
# $ ls -1 bisq-* | ||
# bisq-desktop | ||
# bisq-monitor | ||
# bisq-pricenode | ||
# bisq-relay | ||
# bisq-seednode | ||
# bisq-statsnode | ||
# | ||
# - You will see a new 'localnet' directory containing the data dirs | ||
# for your regtest Bitcoin and Bisq nodes. Once you've deployed | ||
# them in the step below, the directory will look as follows: | ||
# | ||
# $ tree -d -L 1 localnet | ||
# localnet | ||
# ├── alice | ||
# ├── bitcoind | ||
# ├── bob | ||
# ├── mediator | ||
# ├── seednode | ||
# └── seednode2 | ||
# | ||
# STEP 2: Deploy the Bitcoin and Bisq nodes that make up the localnet. | ||
# Run each of the following in a SEPARATE TERMINAL WINDOW, as they are | ||
# long-running processes. | ||
# | ||
# $ make bitcoind | ||
# $ make seednode | ||
# $ make seednode2 | ||
# $ make mediator | ||
# $ make alice | ||
# $ make bob | ||
# | ||
# Tip: Those familiar with the `screen` terminal multiplexer can | ||
# automate the above by running the `deploy` target found below. | ||
# | ||
# Notes: | ||
# | ||
# - The 'seednode' targets launch headless Bisq nodes that help | ||
# desktop nodes discover other peers, as well as storing and | ||
# forwarding p2p network messages for nodes as they go on and | ||
# offline. | ||
# | ||
# - As you run the 'mediator', 'alice' and 'bob' targets above, | ||
# you'll see a Bisq desktop node window appear for each. The Alice | ||
# and Bob instances represent two traders who can make and take | ||
# offers with one another. The Mediator instance represents a Bisq | ||
# contributor who can help resolve any technical problems or disputes | ||
# that come up between the two traders. | ||
# | ||
# STEP 3: Configure the mediator Bisq node. In order to make and take | ||
# offers, Alice and Bob will need to have a mediator and a refund agent | ||
# registered on the network. Follow the instructions below to complete | ||
# that process: | ||
# | ||
# a) Go to the Account screen in the Mediator instance and press CMD+N | ||
# and a popup will appear. Click 'Unlock' and then click 'Register' to | ||
# register the instance as a mediator. | ||
# | ||
# b) While still in the Account screen, press CMD+D and follow the same | ||
# steps as above to register the instance as a refund agent. | ||
# | ||
# When the steps above are complete, your localnet should be up and | ||
# ready to use. You can now test in isolation all Bisq features and use | ||
# cases. | ||
# | ||
|
||
|
||
# Set up everything necessary for deploying your localnet. This is the | ||
# default target. | ||
setup: build localnet | ||
|
||
clean: clean-build clean-localnet | ||
|
||
clean-build: | ||
./gradlew clean | ||
|
||
clean-localnet: | ||
rm -rf localnet | ||
|
||
# Build all Bisq binaries and generate the shell scripts used to run | ||
# them in the targets below | ||
build: | ||
./gradlew build | ||
|
||
# Unpack and customize a Bitcoin regtest node and Alice and Bob Bisq | ||
# nodes that have been preconfigured with a blockchain containing the | ||
# BSQ genesis transaction | ||
localnet: | ||
# Unpack the old dao-setup.zip and move things around for more concise | ||
# and intuitive naming. This is a temporary measure until we clean these | ||
# resources up more thoroughly. | ||
unzip docs/dao-setup.zip | ||
mv dao-setup localnet | ||
mv localnet/Bitcoin-regtest localnet/bitcoind | ||
mv localnet/bisq-BTC_REGTEST_Alice_dao localnet/alice | ||
mv localnet/bisq-BTC_REGTEST_Bob_dao localnet/bob | ||
# Remove the preconfigured bitcoin.conf in favor of explicitly | ||
# parameterizing the invocation of bitcoind in the target below | ||
rm -v localnet/bitcoind/bitcoin.conf | ||
# Avoid spurious 'runCommand' errors in the bitcoind log when nc | ||
# fails to bind to one of the listed block notification ports | ||
echo exit 0 >> localnet/bitcoind/blocknotify | ||
|
||
# Deploy a complete localnet by running all required Bitcoin and Bisq | ||
# nodes, each in their own named screen window. If you are not a screen | ||
# user, you'll need to run each of the make commands manually in a | ||
# separate terminal or as a background job. | ||
# | ||
# NOTE: You MUST already be attached to a screen session for the | ||
# following commands to work properly. | ||
deploy: setup | ||
screen -t bitcoin make bitcoind | ||
sleep 2 # wait for bitcoind rpc server to start | ||
make block # generate a block to ensure Bisq nodes get dao-synced | ||
screen -t seednode make seednode | ||
screen -t seednode2 make seednode2 | ||
screen -t alice make alice | ||
screen -t bob make bob | ||
screen -t mediator make mediator | ||
|
||
bitcoind: localnet | ||
bitcoind \ | ||
-regtest \ | ||
-prune=0 \ | ||
-txindex=1 \ | ||
-server \ | ||
-rpcuser=bisqdao \ | ||
-rpcpassword=bsq \ | ||
-datadir=localnet/bitcoind \ | ||
-blocknotify='localnet/bitcoind/blocknotify %s' | ||
|
||
seednode: build | ||
./bisq-seednode \ | ||
--baseCurrencyNetwork=BTC_REGTEST \ | ||
--useLocalhostForP2P=true \ | ||
--useDevPrivilegeKeys=true \ | ||
--fullDaoNode=true \ | ||
--rpcUser=bisqdao \ | ||
--rpcPassword=bsq \ | ||
--rpcBlockNotificationPort=5120 \ | ||
--nodePort=2002 \ | ||
--userDataDir=localnet \ | ||
--appName=seednode | ||
|
||
seednode2: build | ||
./bisq-seednode \ | ||
--baseCurrencyNetwork=BTC_REGTEST \ | ||
--useLocalhostForP2P=true \ | ||
--useDevPrivilegeKeys=true \ | ||
--fullDaoNode=true \ | ||
--rpcUser=bisqdao \ | ||
--rpcPassword=bsq \ | ||
--rpcBlockNotificationPort=5121 \ | ||
--nodePort=3002 \ | ||
--userDataDir=localnet \ | ||
--appName=seednode2 | ||
|
||
mediator: build | ||
./bisq-desktop \ | ||
--baseCurrencyNetwork=BTC_REGTEST \ | ||
--useLocalhostForP2P=true \ | ||
--useDevPrivilegeKeys=true \ | ||
--nodePort=4444 \ | ||
--appDataDir=localnet/mediator \ | ||
--appName=Mediator | ||
|
||
alice: setup | ||
./bisq-desktop \ | ||
--baseCurrencyNetwork=BTC_REGTEST \ | ||
--useLocalhostForP2P=true \ | ||
--useDevPrivilegeKeys=true \ | ||
--nodePort=5555 \ | ||
--fullDaoNode=true \ | ||
--rpcUser=bisqdao \ | ||
--rpcPassword=bsq \ | ||
--rpcBlockNotificationPort=5122 \ | ||
--genesisBlockHeight=111 \ | ||
--genesisTxId=30af0050040befd8af25068cc697e418e09c2d8ebd8d411d2240591b9ec203cf \ | ||
--appDataDir=localnet/alice \ | ||
--appName=Alice | ||
|
||
bob: setup | ||
./bisq-desktop \ | ||
--baseCurrencyNetwork=BTC_REGTEST \ | ||
--useLocalhostForP2P=true \ | ||
--useDevPrivilegeKeys=true \ | ||
--nodePort=6666 \ | ||
--appDataDir=localnet/bob \ | ||
--appName=Bob | ||
|
||
# Generate a new block on your Bitcoin regtest network. Requires that | ||
# bitcoind is already running. See the `bitcoind` target above. | ||
block: | ||
bitcoin-cli \ | ||
-regtest \ | ||
-rpcuser=bisqdao \ | ||
-rpcpassword=bsq \ | ||
getnewaddress \ | ||
| xargs bitcoin-cli \ | ||
-regtest \ | ||
-rpcuser=bisqdao \ | ||
-rpcpassword=bsq \ | ||
generatetoaddress 1 | ||
|
||
.PHONY: seednode |