Frequency is a Polkadot parachain for data distribution protocols such as DSNP.
- Table of Contents
- Prerequisites
- Build
- Run
- Format, Lint and Audit Source Code
- Runtime
- Contributing
- Security Issue Reporting
- 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 for Validators.
-
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/debug
directory generated locally with compiled project files. (or ./target/release
for make build-*-release
)
Frequency optionally supports asdf for managing dependencies of the following tools: Install the required plugins for asdf: Please note that if you use rustup, asdf may conflict and cause issues. It is recommended to use one or the other, but not both for rust.
asdf plugin-add rust
asdf plugin-add make
asdf plugin-add cmake https://github.com/srivathsanmurali/asdf-cmake.git
Install the dependency versions declared in .tool-versions
asdf install
NOTE: asdf does not support clang and it needs to be installed separately.
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/interval 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:9944 -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 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 and rpc:9944 , p2p:3033 |
127.0.0.1:9944 |
This sealing mode will automatically trigger the formation of a block at a specified interval (default is every 12 seconds.)
make start-interval
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
-
Start Frequency as parachain. This step will generate genesis/wasm and start the parachain collator.
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 LibertyDSNP#432
Start:
make start-frequency-docker
Stop:
make stop-frequency-docker
Node | Ports | Explorer URL |
---|---|---|
Frequency Relay Node | ws and rpc: 9944 , p2p:30333 |
127.0.0.1:9944 |
Alice Relay Node | ws and rpc: 9946 , p2p:30335 |
127.0.0.1:9946 |
Bob Relay Node | ws and rpc: 9947 , 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._Note, if you get errors complaining about the wasm build, then you may need to install the wasm target for rust. You can do this with
rustup target add wasm32-unknown-unknown
-
Alternatively, run
make format-lint
to run both at the same time. -
Run
cargo-deny
to auditCargo.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 and srtool-cli to verify the runtime:
SRTOOL_TAG="1.66.1" srtool build \ --build-opts="'--features on-chain-release-build,no-metadata-docs,frequency'" \ --profile=release \ --package=frequency-runtime \ --root
To upgrade the runtime, run the following command:
make upgrade-local
make upgrade-no-relay
Interested in contributing? Wonderful! Please check out the information here.
Do you know of an on-chain vulnerability (or possible one) that can lead to economic loss, privacy loss, or instability of the network? Please report it to security@frequency.xyz
# 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