hirosystems / stacks-subnets

Stacks Subnets: a layer-2 scaling solution for Stacks, intended for high-throughput, low-latency workloads
http://docs.hiro.so
GNU General Public License v3.0
51 stars 13 forks source link
stacks

Subnets

Subnets are a layer-2 scaling solution in the Stacks blockchain that offers low latency and high throughput workloads. It enables developers to build fast and reliable experiences on Stacks.

Overview

Subnets are designed to transact on Stacks assets, meaning users can move assets in and out of subnets. While a user’s assets are in a subnet, they trust that subnet’s consensus rules. This subnet will interact with the Stacks chain using a smart contract specific to that subnet.

NOTE:

The current implementation of subnets uses a 2-phase commit protocol amongst a fully-trusted pool of miners.

Below are some of the features of subnets:

Architecture

This diagram outlines the interaction between a subnet and the Stacks layer-1 chain.

Architecture of subnets.

When a miner proposes a block to the other miners, the other miners must approve and sign the block before it can be committed to the subnet.

Screenshot of subnet miners proposing and approving the blocks.

Trust models in Subnets

The current implementation of subnets uses a federated system of miners. This federation is fully-trusted, but future work on subnets will explore alternative trust models.

In a fully - trusted model:

Getting Started

You can build subnets using any of the following methods:

NOTE:

Hyperchains have been renamed "subnets" due to the trademark for "hyperchains" already being registered. Learn more here.

Build with Clarinet

You can start building with Clarinet using the instructions noted here. You can run through all the six steps indicated in the Setup section of the NFT_USE_CASE.md document to finish the deposit and withdrawal of NFT.

Build with Testnet

You can set up configurations for subnet miners on testnet using the instructions noted here.

Test locally

You can launch your contracts, deposit funds to your subnets layer and withdraw funds using the instructions noted here.

Run Tests

In your terminal, you can run tests by navigating to the testnet/stacks-node/ directory and running the following command:

cargo test

If you want to ignore some tests, you can use the following command:

cargo test -- --ignored --num-threads=1

Resources

License information