For Unix-based operating systems, you should run the following commands:
curl https://sh.rustup.rs -sSf | sh
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
rustup update stable
cargo install --git https://github.com/alexcrichton/wasm-gc
You will also need to install the following packages:
-
Linux:
sudo apt install cmake pkg-config libssl-dev git clang libclang-dev
-
Mac:
brew install cmake pkg-config openssl git llvm
To finish installation of Plug, jump down to shared steps.
If you are trying to set up Plug on Windows, you should do the following:
-
First, you will need to download and install "Build Tools for Visual Studio:"
-
You can get it at this link: https://aka.ms/buildtools
-
Run the installation file:
vs_buildtools.exe
-
Please ensure the Windows 10 SDK component is included when installing the Visual C++ Build Tools.
-
Restart your computer.
-
-
Next, you need to install Rust:
-
Detailed instructions are provided by the Rust Book.
-
Download from: https://www.rust-lang.org/tools/install
-
Run the installation file:
rustup-init.exe
> Note that it should not prompt you to install vs_buildtools since you did it in step 1. -
Choose "Default Installation."
-
To get started, you need Cargo’s bin directory (%USERPROFILE%\.cargo\bin) in your PATH environment variable. Future applications will automatically have the correct environment, but you may need to restart your current shell.
-
-
Then, you will need to run some commands in CMD to set up your Wasm Build Environment:
rustup update nightly rustup update stable rustup target add wasm32-unknown-unknown --toolchain nightly
-
Next, you install wasm-gc, which is used to slim down Wasm files:
cargo install --git https://github.com/alexcrichton/wasm-gc --force
-
Then, you need to install LLVM: https://releases.llvm.org/download.html
-
Next, you need to install OpenSSL, which we will do with
vcpkg
:mkdir \Tools cd \Tools git clone https://github.com/Microsoft/vcpkg.git cd vcpkg .\bootstrap-vcpkg.bat .\vcpkg.exe install openssl:x64-windows-static
-
After, you need to add OpenSSL to your System Variables:
$env:OPENSSL_DIR = 'C:\Tools\vcpkg\installed\x64-windows-static' $env:OPENSSL_STATIC = 'Yes' [System.Environment]::SetEnvironmentVariable('OPENSSL_DIR', $env:OPENSSL_DIR, [System.EnvironmentVariableTarget]::User) [System.Environment]::SetEnvironmentVariable('OPENSSL_STATIC', $env:OPENSSL_STATIC, [System.EnvironmentVariableTarget]::User)
-
Finally, you need to install
cmake
: https://cmake.org/download/
Then, grab the Plug source code:
git clone git@github.com:cennznet/plug-blockchain.git
cd plug-blockchain
Then build the code:
./scripts/build.sh # Builds the WebAssembly binaries
cargo build # Builds all native code
You can run all the tests if you like:
cargo test --all
Or just run the tests of a specific package (i.e. cargo test -p srml-assets
)
You can start a development chain with:
cargo run \-- --dev
Detailed logs may be shown by running the node with the following environment variables set: RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev
.
If you want to see the multi-node consensus algorithm in action locally, then you can create a local testnet with two validator nodes for Alice and Bob, who are the initial authorities of the genesis chain specification that have been endowed with a testnet DOTs. We’ll give each node a name and expose them so they are listed on Telemetry . You’ll need two terminals windows open.
We’ll start Alice’s plug node first on default TCP port 30333 with her chain database stored locally at /tmp/alice
. The Bootnode ID of her node is QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN
, which is generated from the --node-key
value that we specify below:
cargo run --release \-- \
--base-path /tmp/alice \
--chain=local \
--alice \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
--telemetry-url ws://telemetry.polkadot.io:1024 \
--validator
In the second terminal, we’ll run the following to start Bob’s plug node on a different TCP port of 30334, and with his chain database stored locally at /tmp/bob
. We’ll specify a value for the --bootnodes
option that will connect his node to Alice’s Bootnode ID on TCP port 30333:
cargo run --release \-- \
--base-path /tmp/bob \
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN \
--chain=local \
--bob \
--port 30334 \
--telemetry-url ws://telemetry.polkadot.io:1024 \
--validator
Additional Plug CLI usage options are available and may be shown by running cargo run -- --help
.