Requirements
In order to compile and run an Arweave node or Gateway. You will need to be running a Unix based operating system. This guide has been primarily tested on Ubuntu 18.04 and 20.04, if you do have problems compiling from scratch on a different OS, try using Docker instead. Lastly, for reference purposes, you may want to check out the Arweave Github to learn more about the source code.
For Compilation
Before we begin, make sure you have the required packages for Erlang, SQLite, GCC, CMake and Make. You can install the packages on Ubuntu by running the following snippet.
# Get the Erlang Debian package
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
# Install the Erlang OTP package
sudo apt-get update
sudo apt-get install erlang -y
# Install the rest of the packages
sudo apt-get install gcc clang g++ cmake make libsqlite3-dev -y
For Docker
Implementation currently pending...
Compilation
Building with rebar
When you compile the project with rebar. Please make sure that you clone the Github repo with the --recursive flag. This is necessary in order to clone the submodules for the project as well.
# Clone the Arweave Github repo
git clone --recursive https://github.com/ArweaveTeam/arweave.git
cd arweave
# Run the rebar3 binary
./rebar3 as prod tar
# After a few minutes, it should output something like:
===> tarball ~/arweave/_build/prod/rel/arweave/arweave-2.3.0.0.tar.gz successfully created!
Decompressing the tar.gz file
While it's not necessary to decompress the tar.gz file as the source files will still be readily available in the _build/prod/rel/arweave folder. You may want to migrate the binaries to a different computer. Just keep in mind this step isn't necessary unless you intend to migrate the binary to a new computer.
# Confirm the .tar.gz exists
ls -la _build/prod/rel/arweave
# Uncompress the file by specifying the exact file
tar -xvf _build/prod/rel/arweave/arweave-2.3.0.0.tar.gz
# Or for convenience use the * operator to decompress
tar -xvf _build/prod/rel/arweave/*.tar.gz
Adjusting The File Descriptor Limit
Given the nature of Arweave. It's very important to update your open file limit to over 10,000. Assuming you have access to the ulimit command. Run the following snippet to update your open file limit.
# review your existing file limits
ulimit -a
# update the open file limit to 10240
ulimit -n 10240
# Confirm the open file limit has been updated to 10240
ulimit -n
Running Commands
Confirm you can run the actual binary in the prod folder. When you run the start binary, it should output all the options that you can use to run an Arweave node.
# go to the prod build folder
cd _build/prod/rel/arweave
# Confirm you can run the start command
./bin/start --help
# Should output
Usage: arweave-server [options]
Compatible with network: arweave.N.1
Options:
config_file (path) Load configuration from specified file.
peer (ip:port) Join a network on a peer (or set of peers).
start_from_block_index Start the node from the latest stored block index.
mine Automatically start mining once the netwok has been joined.
port The local port to use for mining. This port must be accessible by remote peers.
data_dir The directory for storing the weave and the wallets (when generated).
metrics_dir The directory for persisted metrics.
polling Poll peers for new blocks every 10 seconds. Useful in environments where port forwarding is not possible. When the flag is not set, the node still polls if it does not receive blocks for a minute.
clean Clear the block cache before starting.
no_auto_join Do not automatically join the network of your peers.
mining_addr (addr) The address that mining rewards should be credited to.
max_miners (num) The maximum number of mining processes.
max_emitters (num) The maximum number of transaction propagation processes (default 2).
tx_propagation_parallelization (num) The maximum number of best peers to propagate transactions to at a time (default 4).
max_propagation_peers (num) The maximum number of best peers to propagate blocks and transactions to. Default is 50.
sync_jobs (num) The number of data syncing jobs to run. Default: 2. Each job periodically picks a range and downloads it from peers.
new_mining_key Generate a new keyfile, apply it as the reward address
load_mining_key (file) Load the address that mining rewards should be credited to from file.
ipfs_pin Pin incoming IPFS tagged transactions on your local IPFS node.
transaction_blacklist (file) A file containing blacklisted transactions. One Base64 encoded transaction ID per line.
transaction_blacklist_url An HTTP endpoint serving a transaction blacklist.
transaction_whitelist (file) A file containing whitelisted transactions. One Base64 encoded transaction ID per line. If a transaction is in both lists, it is considered whitelisted.
transaction_whitelist_url An HTTP endpoint serving a transaction whitelist.
disk_space (num) Max size (in GB) for the disk partition containing the Arweave data directory (blocks, txs, etc) when the miner stops writing files to disk.
init Start a new weave.
internal_api_secret (secret) Enables the internal API endpoints, only accessible with this secret. Min. 16 chars.
enable (feature) Enable a specific (normally disabled) feature. For example, subfield_queries.
disable (feature) Disable a specific (normally enabled) feature.
gateway (domain) Run a gateway on the specified domain
custom_domain (domain) Add a domain to the list of supported custom domains.
requests_per_minute_limit (number) Limit the maximum allowed number of HTTP requests per IP address per minute. Default is 900.
max_connections The number of connections to be handled concurrently. Its purpose is to prevent your system from being overloaded and ensuring all the connections are handled optimally. Default is 1024.
max_gateway_connections The number of gateway connections to be handled concurrently. Default is 128.
max_poa_option_depth The number of PoA alternatives to try until the recall data is found. Has to be an integer > 1. The mining difficulty grows linearly as a function of the alternative as (0.75 + 0.25 * number) * diff, up to (0.75 + 0.25 * max_poa_option_depth) * diff. Default is 500.
disk_pool_data_root_expiration_time The time in seconds of how long a pending or orphaned data root is kept in the disk pool. The
default is 2 * 60 * 60 (2 hours).
max_disk_pool_buffer_mb The max total size in mebibytes of the pending chunks in the disk pool.The default is 2000 (2 GiB).
max_disk_pool_data_root_buffer_mb The max size in mebibytes per data root of the pending chunks in the disk pool. The default is 50.
randomx_bulk_hashing_iterations The number of hashes RandomX generates before reporting the result back to the Arweave miner. The faster CPU hashes, the higher this value should be.
Start Mining
Now that you've successfully compiled and configured your Arweave environment. You can now officially start mining! Use the following snippet to start earning Arweave tokens by mining blocks for the network.
# go to the prod build folder
cd _build/prod/rel/arweave
# Confirm you can run the start command
./bin/start --help
# Start mining
./bin/start mine