Skip to content

Latest commit

 

History

History
128 lines (97 loc) · 11.9 KB

readme.md

File metadata and controls

128 lines (97 loc) · 11.9 KB

TFchain · Build & Tests

The ultimate solution for a more fair, sustainable, and accessible Internet for everyone.

Overview

TFchain is the official implementation of the ThreeFold blockchain, which is the ledger technology behind the ThreeFold Grid.

TFchain serves as a digitally distributed, decentralized, public ledger that tracks the storage and computing resources of ZOS nodes running on The ThreeFold Grid, manages the smart contracts that enable users to rent and use these resources and provides the incentive layer which ensures that the nodes are rewarded for their contributions to the network.

The ThreeFold Grid is a decentralized network of nodes that provide cloud resources without intermediaries. The nodes are operated by independent farmers who are incentivized by the ThreeFold Token (TFT). TFT is a utility token that is used to exchange resources on the network and to build and run digital workloads, also is used for paying transaction fees, staking, governance, and smart contract execution.

TFchain is based on Substrate, a framework for building blockchains in Rust. It has several custom pallets that implement its features.

TFchain also supports cross-chain transfers with other blockchains, such as Bitcoin, Binance Smart Chain and Stellar.

Code structure

The project consists of several components, each with a specific purpose and functionality.

  • activation-service: Contains all the GitHub workflows for this repository, such as testing, linting, and creating a release.
  • bridge: Contains a program that runs in the background scanning a Stellar vault address for deposits and TFchain for withdrawals and executes upon them. This allows cross-chain transfers between Stellar and TFchain.
  • clients: Contains various clients that provide all the functionality for interacting with TFchain.
  • docs: Contains all the development and production related documentation for TFchain, such as how to run a node, how to create an account, and how to upgrade the runtime.
    • architecture: Architecture Decision Records
    • development: Development docs, such as how to run a node, how to create an account.
    • misc: Other docs
    • production: Production related docs, such as release and runtime upgrade flows.
  • research: Contains some research around proof of stake, which is the consensus mechanism used by TFchain. Proof of stake is a way of securing the network by requiring validators to stake their tokens and participate in the consensus process.
  • tools: Contains tools for developing and testing TFchain.
    • fork-off-substrate: A tool that can fork a live network to be used in development for testing out runtime migrations or upgrades. Runtime migrations or upgrades are changes in the runtime logic that require updating all nodes on the network.
  • scripts: Contains JavaScript scripts for various purposes, such as subscribing to events.
  • substrate-node: Contains the actual node code that runs the blockchain. It is based on a reference implementation of Substrate called substrate-node-templat, which is kept up to date with the latest Substrate release. The node code defines how to initialize and run a Substrate node with the TFchain runtime and pallets.
    • chainspecs: Contains initial TFchain specifications for all live networks, such as testnet and mainnet. Chain specifications are JSON files that define the genesis state and configuration of each network. They must be used in order to spin up a node from scratch.
      • dev: Dev network chain specification
      • main: Main network chain specification
      • qanet: Quality assurance (QA) network chain specification
      • test: test network chain specification
    • charts: Contains Kubernetes charts for deploying and managing TFchain nodes on cloud platforms. Kubernetes is a system for automating deployment, scaling, and management of containerized applications.
    • node: Contains the application that allows users to participate in a blockchain network.
    • support: Contains a shared types and configuration crate that is used across the runtime, pallets, and node. It defines common types, traits and constants that are used by different components of TFchain, such as Farm. It also declares the Zos Node type, which is a special type of node that provides zero-os services on Tfgrid.
    • runtime: Contains the runtime crate that specifies what pallets are used by TFchain and their configuration. A crate is a compilation unit in Rust that can produce an executable or a library. The runtime crate is used by the node crate to run the blockchain with the desired logic and features.
    • tests: Contains integration tests crate for TFchain. Integration tests are tests that run the entire system or some of its parts together to check if they work as expected. See the docs on how to develop and run these tests.
    • target: Contains the compiled binary files of the Substrate node
    • pallets: Contains the actual runtime implementation of TFchain. Runtime is the core logic of the blockchain that defines how it works and what it can do. Runtime is composed of modules called pallets, which provide specific functionality and can be plugged into a runtime. TFchain has several custom pallets that implement its features, such as Tfgrid, TFT Price, Dao, Smart Contract modules and bridge. Check modules documentations for what each module is about.
    • Cargo.toml: Contains crate dependencies for the Substrate node project. These dependencies are shared across all sub-crates and specify what external libraries are used by TFchain. If you need to add dependencies for a specific runtime pallet use Cargo.toml file for that pallet instead.
  • scripts: Contains JavaScript scripts for various purposes, such as subscribing to events.

Runtime Architecture

The TFchain Runtime is built using FRAME and consists of pallets from substrate and pallet/

From substrate:

  • System: provide core functionality that all other pallets depend on.
  • Utility: Allows users to use derivative accounts, and batch calls.
  • Balances: Tracks TFT token balances.
  • Timestamp: On-Chain notion of time.
  • Transaction Payment: Provides the basic logic to compute pre-dispatch transaction fees.
  • Scheduler: Exposes capabilities for scheduling dispatches to occur at a specified block number or at a specified period.
  • Session: Allows validators to manage their session keys, provides a function for changing the session length, and handles session rotation.
  • Aura: Extends Aura consensus by managing offline reporting.
  • Grandpa: Manage the GRANDPA finality authority set.
  • Authorship: Tracks the current author of the block and recent uncles.
  • Collective: Allows Members of a set of account IDs to make their collective feelings known through dispatched calls from one of two origins.
  • Membership: Allows control of membership of a set of Account IDs.

The following pallets are stored in pallets/. They are designed for TFchain's specific requirements:

Docs

see docs for more information on how to work with TFchain.

Bridge

See bridge for more information on the bridge between TFchain TFT and Stellar TFT.

Scripts

See scripts for more information on how to use the scripts.

Deployed instances

Commit messages

In this repository conventional commits are used.

Releases

See releases for more information on how to create or validate a release.