Skip to content

Instantly share code, notes, and snippets.

@luisbebop
Last active January 31, 2022 14:29
Show Gist options
  • Save luisbebop/afb3f492196660a0349212d847143d63 to your computer and use it in GitHub Desktop.
Save luisbebop/afb3f492196660a0349212d847143d63 to your computer and use it in GitHub Desktop.

Here are the instructions to build the CloudWalk Testnet. This chain is EVM compatible based on Substrate.

I have used Amazon Linux 2 AMI. You will need at least 40GB, 4CPU, 8GB mem to start. Need to go further in transactions benchmarks and see how the nodes will behave at scale.

First install compiler utils on the machine you will generate the node binary for the network. I recommend you use a faster machine to compile (it takes time 20-30 minutes). Then use the binary on the nodes on the network that don't need to be that fast.

sudo yum install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl

Then install rust

curl https://sh.rustup.rs -sSf | sh

source ~/.cargo/env

rustup default stable
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly

Then clone frontier, that is the EVM compatible platform on top of substrate

git clone https://github.com/paritytech/frontier.git
cd frontier/template/node

Change the chain id. The CloudWalk network will be 144

sed -i 's/42/144/g' runtime/src/lib.rs

Change block time. Initially we are testing with 1 second. Haven't discovered the consequences of that yet.

sed -i 's/6000/1000/g' runtime/src/lib.rs

Then compile the project. It will take time (20-30 minutes dependending on the machine)

cargo build --release

After finished you can pretty easily launch a development network with the command

cd frontier/target/release
./frontier-template-node \
--dev \
--port 30333 \
--ws-port 9944 \
--rpc-port 9933 \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--rpc-cors=all \
--unsafe-ws-external \
--unsafe-rpc-external

I recomend use the development network to test your EVM contracts. There is an account with a bunch of ether you can important on Metamask to use Remix, or use Hardhat, Truffle ...

genesis_account_address=0x6be02d1d3665660d22ff9624b7be0551ee1ac91b
genesis_account_private_key=0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342

If you want to purge your dev network to start from scratch use

./frontier-template-node purge-chain --dev

You can also connect your dev node to the public explorer using https://polkadot.js.org/apps/ . If you are using Chrome you need to enable insecure websocket connections from https. Go to chrome://settings, Security and Privacy, Site settings, Additional content settings, Insecure content, add https://polkadot.js.org to Allowed to show insecure content list.

Now that you have tested your network, I recommend to export the binary to the production nodes to start the configuration of testnet network

Testnet network

Testnet can be used to test performance and new features. The first thing you need to do is to generate the Aura and Granpa keys for the validators of your network.

First, Aura

./frontier-template-node key generate --scheme Sr25519 --password-interactive
Secret phrase:       usage lawsuit absorb leave hurt orphan jaguar series general plug hand romance
  Secret seed:       0x0aa0781a9d0aeaf160e3e7020798b4f876bae47dd0e6e890e623e178f7fd382b
  Public key (hex):  0xb220a9d199f6c74901d4184719198b81191363952cdd2d4c89a899f0c76c3d09
  Account ID:        0xb220a9d199f6c74901d4184719198b81191363952cdd2d4c89a899f0c76c3d09
  Public key (SS58): 5G6G5oknyXpY2vHjHGyfWcyYknkEoQFDxHVQHSHjgHCVfN5f
  SS58 Address:      5G6G5oknyXpY2vHjHGyfWcyYknkEoQFDxHVQHSHjgHCVfN5f

Then you derive it to Grandpa keys

./frontier-template-node key inspect --password-interactive --scheme Ed25519 "usage lawsuit absorb leave hurt orphan jaguar series general plug hand romance"

After that create the chain spec

./frontier-template-node build-spec --disable-default-bootnode --chain local > customSpec.json

And change the Aura and Grandpa keys on the bottom of the file. You should add the Public key you have generated for Aura and Grandpa, for each initial set of validator nodes.

      "aura": {
        "authorities": [
          "5G6G5oknyXpY2vHjHGyfWcyYknkEoQFDxHVQHSHjgHCVfN5f",
          "5GNZH7CZ46cL79HP5et86xhEPbTTDxiS31KyVng9anGmGzms"
        ]
      },
      "grandpa": {
        "authorities": [
          [
            "5CF1fbBiAKYhLWGSEUL4c1nhsCBnvDzxZc8GkvmtGWXdCM7z",
            1
          ],
          [
            "5F7VbM9GiyBycAdVKgAFb9MrePagfso2gVbUfQubmA9Bi27C",
            1
          ]
        ]
      },

Then you compile the chain spec to a raw format

./frontier-template-node build-spec --chain=customSpec.json --raw --disable-default-bootnode > customSpecRaw.json

Then get the chain spec and the binary, go to your first node, start it and add the granpda and aura keys, and restart.

./frontier-template-node \
--base-path /tmp/node01 \
--chain ./customSpecRaw.json \
--port 30333 \
--ws-port 9944 \
--rpc-port 9933 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator \
--rpc-cors=all \
--unsafe-ws-external \
--unsafe-rpc-external \
--name CloudWalk-01

./frontier-template-node key insert --base-path /tmp/node01 \
--chain customSpecRaw.json \
--scheme Sr25519 \
--suri "usage lawsuit absorb leave hurt orphan jaguar series general plug hand romance" \
--password-interactive \
--key-type aura

./frontier-template-node key insert --base-path /tmp/node01 \
--chain customSpecRaw.json \
--scheme Ed25519 \
--suri "usage lawsuit absorb leave hurt orphan jaguar series general plug hand romance" \
--password-interactive \
--key-type gran

You can check the keys in your keystore if you need it.

ls /tmp/node01/chains/local_testnet/keystore

To the same for the subsequent nodes. Start, add keys, restart.

./frontier-template-node \
--base-path /tmp/node02 \
--chain ./customSpecRaw.json \
--port 30333 \
--ws-port 9944 \
--rpc-port 9933 \
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
--validator \
--rpc-cors=all \
--unsafe-ws-external \
--unsafe-rpc-external \
--name CloudWalk-02 \
--bootnodes /ip4/3.84.17.196/tcp/30333/p2p/12D3KooWN3Kh4VZAyeUXgvf2Z3XmEP13JNSM4Rpi6yL9rqdx8cjB

./frontier-template-node key insert --base-path /tmp/node02 \
--chain customSpecRaw.json \
--scheme Sr25519 \
--suri "syrup ribbon fruit guide path develop rain nominee immune ride bullet exclude" \
--password-interactive \
--key-type aura

./frontier-template-node key insert --base-path /tmp/node02 \
--chain customSpecRaw.json \
--scheme Ed25519 \
--suri "syrup ribbon fruit guide path develop rain nominee immune ride bullet exclude" \
--password-interactive \
--key-type gran

Now you should have a functional substrate tesnet, with frontier that supports EVM smart contracts. As next steps I recommend go deeper on the security implications of

--unsafe-ws-external \
--unsafe-rpc-external \

And add https proxy on front of these endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment