Frequency is a Polkadot parachain designed to run Decentralized Social Network Protocol (DSNP), but it could run other things.
- Table of Contents
- Prerequisites
- Build
- Run
- Format, Lint and Audit Source Code
- Verify Runtime
- Local Runtime Upgrade
- Contributing
- Additional Resources
- Miscellaneous
- For Mac users, Docker Desktop engine also installs docker compose environment, so no need to install it separately.
We run benchmarks with and recommend the same reference hardware specified by Parity.
-
Install Rust using the official instructions.
-
Check out this repository
-
rust-toolchain.toml
specifies the standard toolchain to use. If you haverustup
installed, it will automatically install the correct toolchain when you run any cargo command. -
Running
make check
will run cargo checks for all Frequency features. This is the recommended way to check your code before committing. Alternatively, you can run following for specific features:make check-no-relay make check-local make check-rococo make check-mainnet
-
Build Wasm and native code.
Note, if you get errors complaining about missing dependencies (protobuf, cmake, yarn, node, jq, etc.) install them with your favorite package manager(e.g. Homebrew on macOS) and re-run the command again.
rustup update cargo clean make build
Above will build Frequency with all features. Alternatively you may run following command to build with specific features:
make build-no-relay make build-local make build-rococo make build-mainnet
To build local, rococo (testnet) or mainnet features respectively.
At this point you should have ./target/release
directory generated locally with compiled
project files.
Install the required plugins for asdf:
asdf plugin-add rust
asdf plugin-add make
asdf plugin-add cmake https://github.com/srivathsanmurali/asdf-cmake.git
asdf plugin-add protoc https://github.com/paxosglobal/asdf-protoc.git
Install the dependency versions declared in .tool-versions
asdf install
NOTE: I could find no clang plugin that worked so your system still needs clang to be installed.
For remote instances running Linux, if you want to check out and build such as on an AWS EC2 instance, the process is slightly different to what is in the Substrate documentation.
- Upgrade the instance and install missing packages with
apt
:
sudo apt upgrade
sudo apt upgrade git
sudo apt install —-assume-yes build-essential
sudo apt install --assume-yes clang curl libssl-dev cmake
- Follow official instructions to install Rust, but select
3. customize the installation
, then reply n toModify PATH variable? (Y/n)
- Follow steps 6-10 at Substrate: Linux development
- Proceed with checking out and building Frequency as above.
There are 2 options to run the chain locally:
Note, Running Frequency via following options does not require binary to be built or chain specs to be generated separately, and is programmed within the scripts for simplicity.
- Collator Node without a relay chain (in manual/instant sealing mode)
- Collator Node with a local relay chain
This option runs just one collator node without the need for a relay chain.
a. Blocks can be triggered by calling the engine_createBlock
RPC
curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d '{ \
"jsonrpc":"2.0", \
"id":1, \
"method":"engine_createBlock", \
"params": [true, true] \
}'
b. Use the "start-manual" make target to call the RPC Great for testing multiple items in the same block or other block formation tests.
make start-manual
Same as Manual Sealing, but will also automatically trigger the formation of a block whenever a transaction is added to the validated transaction pool. Great for most testing.
make start
Also available as a Docker image: frequencychain/instant-seal-node
docker run --rm -p 9944:9944 -p 9933:9933 -p 30333:30333 frequencychain/instant-seal-node
To stop running chain hit [Ctrl+C] in terminal where the chain was started.
Node | Ports | Explorer URL |
---|---|---|
Frequency Collator Node | ws:9944 , rpc:9933 , p2p:3033 |
127.0.0.1:9944 |
This option runs one collator node as local host process and two relay chain validator nodes in each own docker container.
-
Start relay chain validator nodes.
make start-relay
-
Register a new parachain slot (parachain id) for Frequency. Note, if parachain was previously registered on a running relay chain and no new registration is required, then you can skip the above step.
make register
-
Generate chain spec files. If this is your first time running the project or new pallets/runtime code changes have been made to Frequency, then the chain specs need to be generated. Refer to generation spec file for more details.
-
Start Frequency as parachain. This step will generate genesis/wasm and onboard the parachain.
make start-frequency
-
Onboard Frequency to the relay chain
make onboard
- Off-board Frequency from relay chain.:
make offboard
- To stop Frequency running in the terminal:
[Ctrl+C]
- Stop the relay chain.
make stop-relay
- Run to remove unused volumes.
make docker-prune
- Clean up temporary directory to avoid any conflicts with next onboarding:
rm -fr /tmp/frequency
❗ Currently does not work on M* series MacOS laptops. See frequency-chain#432
Start:
make start-frequency-docker
Stop:
make stop-frequency-docker
Node | Ports | Explorer URL |
---|---|---|
Frequency Relay Node | ws:9944 , rpc:9933 , p2p:30333 |
127.0.0.1:9944 |
Alice Relay Node | ws::9946 , rpc:9935 , p2p:30335 |
127.0.0.1:9946 |
Bob Relay Node | ws::9947 , rpc:9936 , p2p:30336 |
127.0.0.1:9947 |
# Run all the tests
make test
# Activate selected features
cargo test --features frequency
To run the integration tests, run make integration-test
.
make benchmarks
- Format code with
make format
according to style guidelines and configurations inrustfmt.toml
. - Lint code with
make lint
to catch common mistakes and improve your Rust code. - Alternatively, run
make format-lint
to run both at the same time. - Run
cargo-deny
to audit Cargo.lock files for crates with security vulnerabilities reported to the RustSec Advisory Database. See cargo-deny installation instructions
- Check out the commit at which the runtime was built.
- Use srtool to verify the runtime:
TARGET=build-runtime RUST_TOOLCHAIN=nightly cargo build --features frequency-no-relay
To upgrade the runtime, run the following command:
make upgrade-local
The current scripts follow this process for upgrading locally:
- Build new runtime and generate the compressed wasm:
make specs-rococo-2000
- Call
authorizeUpgrade
extrinsic from parachain system to initiate the upgrade. - Call
enactAuthorizedUpgrade
extrinsic from parachain system to enact the upgrade. - For testnet and mainnet, the upgrade is done slightly differently using
scheduler
and enactment is scheduled for a specific block number in the future.
Interested in contributing? Wonderful! Please check out the information here.
# Clean up local docker resources
make docker-prune
# View all listening ports
lsof -i -P | grep -i "listen"
# View ports Frequency node is listening on
lsof -i -P | grep -i "listen" | grep frequency