Categorygithub.com/celestiaorg/go-square/v2
modulepackage
2.1.0
Repository: https://github.com/celestiaorg/go-square.git
Documentation: pkg.go.dev

# README

go-square

Go Reference

go-square is a Go module that provides data structures and utilities for interacting with data squares in the Celestia network. The data square is a special form of block serialization in the Celestia blockchain designed for sampling. This repo deals with the original data square which is distinct from the extended data square. Operations on the extended data square are handled by rsmt2d.

PackageDescription
inclusionPackage inclusion contains functions to generate the blob share commitment from a given blob.
protoPackage contains proto definitions and go generated code
sharePackage share contains encoding and decoding logic from blobs to shares.
squarePackage square implements the logic to construct the original data square based on a list of transactions.
txPackage tx contains BlobTx and IndexWrapper types

Installation

To use go-square as a dependency in your Go project, you can use go get:

go get github.com/celestiaorg/go-square/v2

Branches and Releasing

This repo has one long living development branch main, for changes targeting the next major version as well as long living branches for each prior major version i.e. v1.x. Non breaking changes may be backported to these branches. This repo follows semver versioning.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

This repo attempts to conform to conventional commits so PR titles should ideally start with fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, or test: because this helps with semantic versioning and changelog generation. It is especially important to include an ! (e.g. feat!:) if the PR includes a breaking change.

Tools

  1. Install Go 1.22.5
  2. Install golangci-lint
  3. Fork this repo
  4. Make your changes
  5. Submit a pull request

Helpful Commands

# Display all available make commands
make help

# Run tests
make test

# Run linter
make lint

# Perform benchmarking
make bench

# Packages

Package inclusion contains functions to generate the blob share commitment from a given blob.
No description provided by the author
Package share is an encoding and decoding protocol that takes blobs, a struct containing arbitrary data based on a namespace and coverts them into a slice of shares, bytes 512 in length.
No description provided by the author

# Functions

BlobShareRange returns the range of share indexes that the blob, identified by txIndex and blobIndex, occupies.
Build takes an arbitrary long list of (prioritized) transactions and builds a square that is never greater than maxSquareSize.
Construct takes the exact list of ordered transactions and constructs a square, validating that - all blobTxs are ordered after non-blob transactions - the transactions don't collectively exceed the maxSquareSize.
Deconstruct takes a square and returns the ordered list of block transactions that constructed that square This method uses the wrapped pfbs in the PFB namespace to identify and decode the blobs.
EmptySquare returns a 1x1 square with a single tail padding share.
IsPowerOfTwo returns true if input is a power of two.
No description provided by the author
RoundUpPowerOfTwo returns the next power of two greater than or equal to input.
Size returns the size of the row or column in shares of a square.
TxShareRange returns the range of share indexes that the tx, specified by txIndex, occupies.
No description provided by the author

# Structs

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
Square is a 2D square of shares with symmetrical sides that are always a power of 2.