Giter Site home page Giter Site logo

plug-blockchain's Introduction

Plug

Building

Linux and Mac

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.

Windows

If you are trying to set up Plug on Windows, you should do the following:

  1. 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.

    • image

    • Restart your computer.

  2. 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.

  3. 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
  4. Next, you install wasm-gc, which is used to slim down Wasm files:

    cargo install --git https://github.com/alexcrichton/wasm-gc --force
  5. Then, you need to install LLVM: https://releases.llvm.org/download.html

  6. 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
  7. 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)
  8. Finally, you need to install cmake: https://cmake.org/download/

Shared Steps

Then, grab the Plug source code:

git clone [email protected]: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.

plug-blockchain's People

Contributors

gavofyork avatar rphmeier avatar tomaka avatar arkpar avatar bkchr avatar pepyakin avatar tomusdrw avatar svyatonik avatar gui1117 avatar andresilva avatar stanislav-tkach avatar sorpaas avatar xlc avatar ltfschoen avatar gnunicorn avatar chevdor avatar gabreal avatar shawntabrizi avatar gguoss avatar ascjones avatar cmichi avatar gterzian avatar marcio-diaz avatar cheme avatar shaunxw avatar joepetrowski avatar kianenigma avatar 0x7cfe avatar dvdplm avatar jordy25519 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.