Skip to content

Development

witnet-rust is built using The Rust Programming language and following the Rust 2018 Edition Guide as its code styling convention.

Contributing

We have a dedicated contributing guide that will walk you through the process of making your first contribution to the witnet-rust project.

Installing

We have installation guides for several operating systems:

Components

witnet-rust comprises many different components that can be run separately but share a single entry point, which can be run by executing any of the witnet distributable binaries for your operating system or directly using cargo on the source code.

witnet <component> [<args>]
cargo run <component> [<args>]

Node

witnet node is a fully validating and archival Witnet blockchain node.

witnet node [--config <config_file_path>]
witnet node [-c <config_file_path>]

Unless disabled in the configuration, node will also start a local JSON-RPC server that provides many management methods.

The configuration .toml file is common to all components in the witnet-rust project.

Wallet

witnet wallet is a separate server for managing Witnet keys and abstracting the complexity of creating transactions.

witnet wallet [--config <config_file_path>]
witnet wallet [-c <config_file_path>]

The wallet component acts as a client of the JSON-RPC server that the node component starts. This component will in turn start a WebSockets server exposing its own Wallet API.

The configuration .toml file is common to all components in the witnet-rust project.

CLI

witnet cli is a command line interface for interacting with

witnet cli <method> [--config <config_file_path>]
witnet cli <method> [-c <config_file_path>]

The cli component acts as a client for: - the JSON-RPC server that the node component starts. - the WebSockets server that the wallet component starts.

The configuration .toml file is common to all components in the witnet-rust project.

Libraries

The witnet-rust project also comprises many other components in form of libraries that are used as static dependencies:

  • crypto: library implementing all the crypto-related operations used by Witnet, including signatures, hash functions and verifiable random functions.
  • rad: an interpreter for [RADON] scripts included in Witnet data requests.
  • storage: the convenient local storage solution used by node and wallet.
  • p2p: modules for managing peer sessions and connections.
  • data_structures: data structures common to all other components.
  • validations: functions that validate Witnet protocol data structures.
  • schemas: Protocol Buffer schemas for the Witnet protocol.

These other related Rust crates are also developed or maintained by members of the witnet-rust project:

  • protobuf-convert: macros for convenient serialization of Rust data structures into/from Protocol Buffers.
  • async-jsonrpc-client: event-driven JSON-RPC client with support for multiple transports

Development Scripts

There are some useful scripts to run with the just tool:

  • just ci: run the same sequence of commands as used for continuous integration (Travis CI).
  • just clippy: run clippy style checking.
  • just cross-compile <target>: cross compile witnet-rust for the chosen target, which should be one of the supported targets.
  • just cross-compile-all: cross compile witnet-rust for all the supported targets.
  • just docker-ci <target>: run just docker-ci inside a docker container named witnet-rust/<target> (target defaults to x86_64-unknown-linux-gnu).
  • just docker-image-build <target>: create a docker image for one of the supported targets in the local docker installation.
  • just docker-image-build-all: create docker images for all the supported targets in the local docker installation.
  • just docs-build: compile docs into static files.
  • just docs-deploy: deploy compiled docs into gh-pages branch.
  • just docs-dev: run local documentation server at localhost:8000.
  • just fmt: run code formatter.
  • just install-clippy: install clippy code quality tool.
  • just install-rustfmt: install rustfmt code formatter tool.
  • just install-setup: install all deverlopment tools (clippy and rustfmt).
  • just node: run witnet-rust's node component.
  • just node: print installed versions of rustc, fmt and clippy.

Installing the just tool

just is a command runner tool widely used in the Rust ecosystem. You can install it with a single line:

cargo install just