The quickest way to get started developing Conclave is with the following setup which involves Docker and CLion. Conclave has a lot of dependencies and you may not want to clog up your base system with these, so Docker fixes that problem, however, some extra setup is required for CLion to "see into" the docker container and resolve toolchains, libraries, header files, and so forth.
The following setup uses CLion's remote feature which makes CLion behave as if it's running inside the container.
Currently the docker image is based on Ubuntu 18.04. In future we plan to target multiple Unices, Windows, and possibly other OSes.
This guide assumes you already have Docker and CLion installed.
You may have done this already. Skip this step if so.
Clone the Conclave codebase from Github:
git clone https://github.com/conclave-network/conclave.git
- Open CLion.
- File > Open.
- Navigate to the
conclave
directory. - Click OK.
Open a the terminal tab in CLion (located at the bottom of the CLion window) or an external terminal program if you
prefer. Execute the following docker build command, which will build the clion-dev
stage, creating an image called
conclave-clion
:
docker build --target clion-dev -t conclave-clion .
This command may take a while - possibly over an hour.
Create a container called conclave-clion-ctr
based on the conclave-clion
image:
docker create \
-it \
--cap-add sys_ptrace \
-p 127.0.0.1:2222:22 \
-p 127.0.0.1:8008:8008 \
--name conclave-clion-ctr \
conclave-clion
Start the container:
docker start conclave-clion-ctr
The CLion development container contains an SSH server listening on port 22, which is exposed on the docker host as port
- It also has a user called
conclave
with passwordbitcoin
. Ensure you can SSH into the container:
ssh conclave@localhost -p 2222
You may need to run the following command to remove cached SSH keys:
ssh-keygen -f "$HOME/.ssh/known_hosts" -R "[localhost]:2222"
Once you've successfully logged into the container, you can run whoami
to ensure you are the conclave
user:
$ whoami
conclave
- File > Settings > Build, Execution, Deployment > Toolchains.
- Click + to add a new configuration and choose Remote Host.
- Set Name to
conclave-docker
. - Press the gear icon beside Credentials to create a new SSH config.
- Press + to add a new SSH config.
- Set Host to
localhost
. - Set Port to
2222
. - Set User name to
conclave
. - Set Authentication type to Password
- Set Password to
bitcoin
. - Click Test connection. Ensure it works.
- Set CMake to
/usr/local/bin/cmake
- Set C Compiler to Let Cmake detect
- Set C++ Compiler to Let Cmake detect
- Set Debugger to Remote host GDB
- Wait a few seconds until compilers and debugger are all detected.
- Click Apply.
- Click OK.
- File > Settings > Build, Execution, Deployment > CMake.
- Highlight the existing Debug profile.
- Set Toolchain to conclave-docker.
- Click Apply.
- Click OK.
CLion will now start copying files into the container. Wait until it's finished.
This will make conclaved
run with the config inside the codebase's etc
directory, so any changes made
to etc/conclaved-config.json
will immediately be picked up on the next run.
- Run > Edit Configurations...
- Under CMake Application highlight conclaved.
- Set Program arguments to
-c ../../etc/conclaved-config.json
. - Click Apply.
- Click OK.
- At the top right of the CMake window, on the right of the green hammer icon, set the active configuration to conclaved | Debug-conclave-docker.
- Click the green hammer icon to build
conclaved
. - Wait for the build to complete.
- Open the source file
src/conclaved.cpp
. - Navigate to the
main
function. - Click on the green triangle and select Run 'conclaved'.
conclaved
should now run and in the Run tab you should see something like:
/tmp/tmp.3x3L2lJ8HH/cmake-build-debug-conclave-docker/bin/conclaved -c ../../etc/conclaved-config.json
CONCLAVE - Scaling Bitcoin Simply.
Copyright (C) 2019-2021 Conclave development team
This software is protected by the GNU General Public License v3
https://www.gnu.org/licenses/gpl-3.0.en.html
https://conclave.network
Current path is: "/tmp/tmp.3x3L2lJ8HH/cmake-build-debug-conclave-docker/bin"
Config loaded from ../../etc/conclaved-config.json
ChainwatchManager ctor
Starting node: Callan
Public key: 021d5219a13f0f23ebbd8e88abe9ab9eac77f9daaa859cfff0580279a15d9aa12b
ChainwatchManager prepare
Starting RPC manager...
Created RPC processor 0
Created RPC processor 1
Created RPC processor 2
Created 3 RPC processors. Starting them now...
RPC dispatcher 0 waiting for next response...
RPC processor 0 waiting for next request...
Started RPC processor 0
RPC processor 1 waiting for next request...
Started RPC processor 1
RPC processor 2 waiting for next request...
Started RPC processor 2
Started 3 RPC processors
RpcAcceptor: listening on 0.0.0.0:8008
Make a test cURL request from your dev machine:
curl -d '{"method": "NodeInfo"}' http://127.0.0.1:8008/
You should get something like:
{
"DisplayName": "Callan",
"PublicKey": "021d5219a13f0f23ebbd8e88abe9ab9eac77f9daaa859cfff0580279a15d9aa12b"
}
If you did, congratulations! You're now ready to hack on Conclave!
Stop the container:
docker stop conclave-clion-ctr
Delete the container:
docker rm conclave-clion-ctr
If you need to rebuild the image you'll first need to delete it:
docker rmi conclave-clion
- If the run configuration does not appear to be active and you can not see the green hammer icon or other green icons:
- Ensure the container is running with
docker ps | grep conclave-clion-ctr
- Failing that, File > Reload CMake Project can sometimes help.
- Ensure the container is running with