Git Product home page Git Product logo

iq-scm / stacks-subnets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hirosystems/stacks-subnets

0.0 0.0 0.0 97.64 MB

Stacks Subnets: a layer-2 scaling solution for Stacks, intended for high-throughput, low-latency workloads

Home Page: http://docs.hiro.so

License: GNU General Public License v3.0

Shell 1.19% JavaScript 0.15% Rust 95.49% TypeScript 1.45% Dockerfile 0.06% Roff 0.01% Mustache 0.03% Clarity 1.62%

stacks-subnets's Introduction

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:

  • Each subnet may define its throughput settings. The default implementation should support at least 4x high throughput for transactions and may reduce confirmation time from 10 minutes to 1 minute.
  • Interacting with a subnet is similar to interacting with a different Stacks network (example: testnet vs. mainnet).
  • The Stacks blockchain can support many different subnets.
  • Each subnet may use the same or different consensus rules.
  • This repository implements a consensus mechanism that uses a two-phase commit among a federated pool of miners.
  • To deposit into a subnet, users submit a layer-1 transaction to invoke the deposit method on that subnet's smart contract.
  • For withdrawals, users commit the withdrawal on the subnet and then submit a layer-1 transaction to invoke the subnet's smart contract's withdraw method.

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:

  • Miners are responsible for issuing subnet blocks.
  • Users can validate, but subnet miners control withdrawals.
  • Trust can be federated with a 2-phase commit and BFT protocol for miner block issuance.
  • Federation requires a majority of miners to approve withdrawals.

Getting Started

You can build subnets using any of the following methods:

  • Build with Clarinet
    • You'll build with Clarinet using the NFT use case highlighting the deposit-withdraw features on subnets.
  • Build with Testnet
    • You can build with testnet to run your subnets-node.
  • Test Locally
    • You can test the deposit and withdrawal of funds in this method.

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

  • Copyright (C) Hiro Systems PBC
  • Copyright (C) Stacks Open Internet Foundation, Inc.

stacks-subnets's People

Contributors

asjad99 avatar charliec3 avatar diwakergupta avatar fpbgg avatar friedger avatar gregorycoppola avatar guylepage3 avatar hstove avatar ibrahimahmed443 avatar jackzampolin avatar jbencin avatar jcnelson avatar kantai avatar lacabra avatar lakshmilavanyakasturi avatar larrysalibra avatar lgalabru avatar mefrem avatar muneeb-ali avatar njordhov avatar obycode avatar pandu-rao avatar pavitthrap avatar psq avatar reedrosenbluth avatar shea256 avatar vsund avatar whoabuddy avatar wileyj avatar zone117x avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.