Sparq subnet source code. See the docs for a more thorough look at the project.
If you are a developer, fill this form out for free support and additional incentives: https://forms.gle/m83ceG3XoJY3fpwU9
The project has a Dockerfile at the root of the repository that will build the project and deploy the network. It will also install tmux and vim for convenience. To develop on Docker, follow these steps:
docker build -t bdk-cpp-dev:latest
(if using Linux or Mac, run as sudo
)
bdk-cpp-dev:latest
- you can change the tag to whatever you want, but remember to change it on the next stepsudo docker run -it -v $(pwd):/orbitersdk-volume -p 8080-8099:8080-8099 -p 8110-8111:8110-8111 orbitersdk-cpp-dev:latest
docker run -it -v %cd%:/orbitersdk-volume -p 8080-8099:8080-8099 -p 8110-8111:8110-8111 orbitersdk-cpp-dev:latest
Remember that we are using our local SDK repo as a volume, so every change in the local folder will be reflected to the container in real time, and vice-versa.
Also, you can integrate the container with your favorite IDE or editor, e.g. VSCode + Docker extension.
Install the following dependencies on your system:
If building with AvalancheGo support, you'll also need:
For Debian 12 Bookworm or newer:
sudo apt install build-essential cmake tmux clang-tidy autoconf libtool pkg-config libabsl-dev libboost-all-dev libc-ares-dev libcrypto++-dev libgrpc-dev libgrpc++-dev libscrypt-dev libssl-dev zlib1g-dev openssl protobuf-compiler protobuf-compiler-grpc
We use Doxygen to generate documentation over the current source code. Run doxygen
inside the project's root folder. Docs should be inside docs/html
.
You should do this after running cmake ..
in the build directory, as some header files need to be generated first.
For a more detailed explanation of the project's structure, check the docs repository.
cd orbitersdk-cpp && mkdir build && cd build
cmake
inside the build folder: cmake ..
-DCMAKE_BUILD_TYPE={Debug,RelWithDebInfo,Release}
to set the respective debug/release builds (Debug by default)-DDEBUG=OFF
to build without debug flags (ON by default)-DUSE_LINT=ON
to run clang-tidy along the build (OFF by default, WILL TAKE SIGNIFICANTLY LONGER TO COMPILE)cmake --build . -- -j$(nproc)
cmake --build . -- -j$(nproc) 2> log.txt
)Go back to the project's root directory and run ./scripts/AIO-setup.sh
. The script will deploy a local testnet with 5 Validator nodes, 6 normal nodes and 1 discovery node. All of them will be rdPoS. Run the script again to re-deploy, or call tmux kill-server
to stop it entirely.
You can use the following flags on the script to customize deployment:
Flag | Description | Default Value |
---|---|---|
--clean | Clean the build folder before building | false |
--no-deploy | Only build the project, don't deploy the network | false |
--debug=\<bool> | Build in debug mode | true |
--cores=\<int> | Number of cores to use for building | Maximum available |
Example: ./scripts/AIO-setup.sh --clean --no-deploy --debug=false --cores=4
will clean the build folder, only build the project, build in release mode and use 4 cores for building. Remember that GCC uses around 1.5GB of RAM per core, so, for stability, it is recommended to adjust the number of cores to the available RAM on your system.
Once deployed, you can connect any Web3 client to it (we recommend Metamask). See below for details.
Note that, when re-deploying, if your wallet or RPC client keeps track of account nonce data, you must reset it as a network reset would set back their nonces to 0. Here's how to do it in MetaMask, for example.
The deployed chain will have the following information by default:
Nodes are all deployed on the same machine, under the following ports and tmux sessions:
Session Name | Node Type | P2P Port | HTTP Port | Validator Key |
---|---|---|---|---|
local_testnet_discovery | Discovery | 8080 | 8090 | XXXX |
local_testnet_validator1 | Validator | 8081 | 8090 | 0xba5e6e9dd9cbd263969b94ee385d885c2d303dfc181db2a09f6bf19a7ba26759 |
local_testnet_validator2 | Validator | 8082 | 8091 | 0xfd84d99aa18b474bf383e10925d82194f1b0ca268e7a339032679d6e3a201ad4 |
local_testnet_validator3 | Validator | 8083 | 8092 | 0x66ce71abe0b8acd92cfd3965d6f9d80122aed9b0e9bdd3dbe018230bafde5751 |
local_testnet_validator4 | Validator | 8084 | 8093 | 0x856aeb3b9c20a80d1520a2406875f405d336e09475f43c478eb4f0dafb765fe7 |
local_testnet_validator5 | Validator | 8085 | 8094 | 0x81f288dd776f4edfe256d34af1f7d719f511559f19115af3e3d692e741faadc6 |
local_testnet_normal1 | Normal | 8086 | 8095 | XXXX |
local_testnet_normal2 | Normal | 8087 | 8096 | XXXX |
local_testnet_normal3 | Normal | 8088 | 8097 | XXXX |
local_testnet_normal4 | Normal | 8089 | 8098 | XXXX |
local_testnet_normal5 | Normal | 8110 | 8099 | XXXX |
local_testnet_normal6 | Normal | 8111 | 8100 | XXXX |