Compile and Run the Algorand Node Natively on Windows
This tutorial explains building the Algorand node software and devtools natively on Microsoft Windows then run them without the need of emulators, virtual machines and even WSL.
Requirements
- Microsoft Windows 10 x64
- MSYS2
- Go Language
- 8GB RAM
Important
The steps below explains how to build the node and utilities with code located in master
branch of the go-algorand repository. This branch contains the latest features but also contains code that is in testing stage. A subset of this code is used to release MainNet and TestNet nodes and, while the compiled node usually works on these networks, 100% compatibility is not guaranteed.
Background
MSYS2 is a collection of tools and libraries that provides an easy-to-use environment for building, installing and running native Windows software. It also gives us a bash-like interface suitable to run the scripts used in the build process.
Steps
1. Environment setup
Installation MSYS2
First download and install the MSYS2
package from here and follow the instructions on it.
Update all the packages to their latest versions. The link above shows how to do it.
Info
MSYS2
uses pacman
package manager to install libraries and updates but their servers are usually slower than OS upgrade repositories. I strongly recomment to add the --disable-download-timeout
to every execution of the pacman
utility.
Update the MSYS2
environment:
pacman -Syu --disable-download-timeout
Info
By default, MSYS2
is installed on C:\msys64
and the home folder $
is physically located at C:\msys64\home\{user-name}
. Although not used in the scope of this tutorial, from the bash console, you are able to access the whole disk using the following path format: /c/your-target-folder
.
Now close all the MSYS2
windows by typing exit
(enter) or by clicking on the window’s close button.
Installation of GIT and GO
On Microsoft Windows Startup menu you will find an entry named MSYS2 MinGW 64-bit
. Run it and a bash-like console window will appear.
Type the following command and press enter:
pacman -S --disable-download-timeout --noconfirm git mingw-w64-x86_64-go
GOPATH variable setup
The $GOPATH environment variable is not explicitly set by Go installer as it is not needed anymore in recent versions. But this leads go
to use
%USERPROFILE%\Go
as default in Windows systems, causing the build stage to fail
if not set accordingly, as the module installation scripts will look for modules in the $HOME
directory instead.
Setup the GOPATH variable in your bash shell startup script, or just paste this into your MSYS2 command prompt.:
echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
In order to ensure the GOPATH
is correct, you can restart the MSYS2 MinGW 64-bit
shell console, execute go env
command and inspect the output.
Warning
You must close this terminal window before proceeding to cloning the repository.
Close this terminal window:
exit
Cloning repository
From the Windows Startup, launch a new terminal by clicking the MSYS2 MinGW 64-bit
program.
Clone the Algorand node repository by running the following command:
git clone https://github.com/algorand/go-algorand
And switch to source code directory with:
cd go-algorand
2. Install prerequisites
Type the following command and press enter to install required dependencies:
./scripts/configure_dev.sh
The above script will do the following actions:
- Install the latest version of
GCC
,AutoMake
,Python 3
and other utilities required to build the project. - Download and install the Windows version of
shellcheck
from the authors repository because it isn’t available inMSYS2
package repo. - Install some
GO
utilities like a code linter and the swagger used in the RestAPI documentation.
Note
This procedure may take several minutes to complete. You will see a large output in the process.
3. Building the project
To build the node and the whole set of utilities just run the following command and press enter:
make
Note
While the build process runs, you might see some warnings related to SQLite C++ code and HID device management. Don’t worry because they are false alarms and code is safe. If you are a developer, you can corroborate this.
4. Installing the node
When the build process ends, you will find all the binaries and dependant dlls in the ~/go/bin
folder.
At this point, MSYS2
environment is not required any more and you can close the console window by typing exit
and pressing the enter key.
Currently, there is no installer package for Microsoft Windows so we will do a manual installation by opening the Windows Start Menu and locating the Command Prompt application (you can type cmd
as a shortcut). Start it.
Like before, I’ll assume you installed MSYS2
in the default folder C:\msys64
. If not your case, adjust the commands according.
-
Create a folder in the location you wish to run the node, i.e.
C:\AlgorandNode
, and switch to it.MD C:\AlgorandNode CD C:\AlgorandNode
-
Copy compiled files there.
COPY /Y C:\msys64\home\%USERNAME%\go\bin .
-
Create the data folder and switch to it.
MD data CD data
-
Copy the genesis file there. I’ll pick the TestNet genesis file but you can find mainnet and betanet files inside
installer\genesis\mainnet
andinstaller\genesis\betanet
respectively.COPY /Y C:\msys64\home\%USERNAME%\go-algorand\installer\genesis\testnet\genesis.json .
-
Copy the configuration example file and rename to
config.json
.COPY /Y C:\msys64\home\%USERNAME%\go-algorand\installer\config.json.example config.json
-
Open the copied configuration settings to make some adjustments.
NOTEPAD config.json
-
Locate the
EndpointAddress
entry and replace the value with some fixed port number you would like to use. For e.g., set the value to"127.0.0.1:8101"
to use port 8101.
If you want the node to be accessible from outside, set the value to just the port like this":8101"
. -
To connect to the TestNet network, change the
DNSBootstrapID
entry from"<network>.algorand.network"
to"testnet.algodev.network"
. -
(recommended) If you are a developer, you will want to enable the Developer API by setting the
EnableDeveloperAPI
value to fromfalse
totrue
. -
(optional) If you want to enable archival mode (storing all the blockchain instead of only the latest 1000 blocks), change the
Archival
entry fromfalse
totrue
.Warning
If you enable archival mode, ensure you have at least 200GB of free disk space.
-
(required) Save the configuration file and close notepad.
Information
Here you can find the explanation of the rest of the configuration options.
-
-
Back in the command prompt window go back to the node folder.
CD ..
5. Running the node
At this point we are ready to start the node. Type the following command and press enter.
goal node start -d data
You can verify the node is running by waiting for a minute and executing this
goal node status -d data
You will see an output similar to this:
For the more information about using the Fast Catchup feature to quickly sync your non-archival node, please reference this document
6. Running the devtools
All of the devtools are also available within the C:\AlgorandNode
folder including, goal
, kmd
, algokey
, etc.