HOPR
A project by the HOPR Association
HOPR is a privacy-preserving messaging protocol which enables the creation of a secure communication network via relay nodes powered by economic incentives using digital tokens.
Table of Contents
About
This repository contains the core HOPR protocol library and supporting crates.
- hopr-lib
- A fully self-contained referential implementation of the HOPR protocol over a libp2p based connection mechanism that can be incorporated into other projects as a transport layer.
The hoprd daemon (HOPR node with REST API) lives in the hoprd repository.
Develop
Either setup nix and flake to use the nix environment, or install Rust toolchain from the rust-toolchain.toml, as well as foundry-rs binaries (forge, anvil).
Nix environment setup
Install nix from the official website at https://nix.dev/install-nix.html.
Create a nix configuration file at ~/.config/nix/nix.conf with the following content:
experimental-features = nix-command flakes
Install the nix-direnv package to introduce the direnv:
nix-env -i nix-direnv
Append the following line to the shell rc file (depending on the shell used it can be ~\.zshrc, ~\.bashrc, ~\.cshrc, etc.). Modify the <shell> variable inside the below command with the currently used (zsh, bash, csh, etc.):
eval "$(direnv hook <shell>)"
From within the hoprnet repository's directory, execute the following command.
direnv allow .
Nix flake outputs
We provide a couple of packages, apps and shells to make building and development easier. You may get the full list like so:
nix flake show
Code Formatting
All nix, rust, solidity and python code can be automatically formatted:
nix fmt
These formatters are also automatically run as a Git pre-commit check.
Code Linting
All linters can be executed via a Nix flake helper app:
nix run .#check
This will in particular run clippy for the entire Rust codebase.
Test
Run all tests: cargo test.
Run only unit tests: cargo test --lib
Github Actions CI
We run a fair amount of automation using Github Actions. Too see the full list of workflows checkout workflow docs
Code Coverage
Coverage reports are generated using LLVM source-based instrumentation and uploaded to Codecov. See docs/coverage.md for workspace-wide and single-crate usage.
Profiling & Instrumentation
Profiling Criterion benchmarks via flamegraph
Prerequisites
perfinstalled on the host system- flamegraph (install via e.g.
cargo install flamegraph)
Profiling the benchmarking binaries
Perform a build of your chosen benchmark with
--no-rosegmentlinker flag:RUSTFLAGS="-Clink-arg=-fuse-ld=lld -Clink-arg=-Wl,--no-rosegment" cargo bench --no-run -p hopr-crypto-packetUse
moldinstead oflldif needed.Find the built benchmarking binary and check if it contains debug symbols:
readelf -S target/release/deps/packet_benches-ce70d68371e6d19a | grep debugThe output of the above command should contain AT LEAST:
.debug_line,.debug_infoand.debug_locRun
flamegraphon the benchmarking binary of a selected benchmark with a fixed profile time (e.g.: 30 seconds):flamegraph -- ./target/release/deps/packet_benches-ce70d68371e6d19a --bench --exact packet_sending_no_precomputation/0_hop_0_surbs --profile-time 30The
flamegraph.svgwill be generated in the project root directory and can be opened in a browser.
Contact
License
GPL v3 HOPR Association