Skip to content

Commit

Permalink
breaking!: move share consts to celestia-app (#861)
Browse files Browse the repository at this point in the history
* breaking: move share consts to celestia-app

Closes #841

* remove remaining consts that are not used in celestia-core
  • Loading branch information
rootulp authored Sep 14, 2022
1 parent c10892a commit 97c3cce
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,9 @@ import (
"crypto/sha256"

"github.com/celestiaorg/nmt/namespace"
"github.com/celestiaorg/rsmt2d"
)

// This contains all constants of:
// https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/consensus.md#constants
const (
// ShareSize is the size of a share (in bytes).
// see: https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/consensus.md#constants
ShareSize = 256

// NamespaceSize is the namespace size in bytes.
NamespaceSize = 8

// ShareReservedBytes is the reserved bytes for contiguous appends.
ShareReservedBytes = 1

// TxShareSize is the number of bytes usable for tx/evidence/ISR shares.
TxShareSize = ShareSize - NamespaceSize - ShareReservedBytes
// MsgShareSize is the number of bytes usable for message shares.
MsgShareSize = ShareSize - NamespaceSize

// MaxSquareSize is the maximum number of
// rows/columns of the original data shares in square layout.
// Corresponds to AVAILABLE_DATA_ORIGINAL_SQUARE_MAX in the spec.
// 128*128*256 = 4 Megabytes
// TODO(ismail): settle on a proper max square
// if the square size is larger than this, the block producer will panic
MaxSquareSize = 128
// MaxShareCount is the maximum number of shares allowed in the original data square.
// if there are more shares than this, the block producer will panic.
MaxShareCount = MaxSquareSize * MaxSquareSize

// MinSquareSize depicts the smallest original square width. A square size smaller than this will
// cause block producer to panic
MinSquareSize = 1
// MinshareCount is the minimum shares required in an original data square.
MinSharecount = MinSquareSize * MinSquareSize

// TxInclusionProofQueryPath is the path used to query the application for a
// tx inclusion proof via the ABCI Query method. The desired transaction
// index must be formatted into the path.
Expand All @@ -55,32 +20,10 @@ var (

// TxNamespaceID is the namespace reserved for transaction data
TxNamespaceID = namespace.ID{0, 0, 0, 0, 0, 0, 0, 1}
// IntermediateStateRootsNamespaceID is the namespace reserved for
// intermediate state root data
// TODO(liamsi): code commented out but kept intentionally.
// IntermediateStateRootsNamespaceID = namespace.ID{0, 0, 0, 0, 0, 0, 0, 2}

// EvidenceNamespaceID is the namespace reserved for evidence
EvidenceNamespaceID = namespace.ID{0, 0, 0, 0, 0, 0, 0, 3}

// MaxReservedNamespace is the lexicographically largest namespace that is
// reserved for protocol use. It is derived from NAMESPACE_ID_MAX_RESERVED
// https://github.com/celestiaorg/celestia-specs/blob/master/src/specs/consensus.md#constants
MaxReservedNamespace = namespace.ID{0, 0, 0, 0, 0, 0, 0, 255}
// TailPaddingNamespaceID is the namespace ID for tail padding. All data
// with this namespace will be ignored
TailPaddingNamespaceID = namespace.ID{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE}
// ParitySharesNamespaceID indicates that share contains erasure data
ParitySharesNamespaceID = namespace.ID{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}

// NewBaseHashFunc change accordingly if another hash.Hash should be used as a base hasher in the NMT:
NewBaseHashFunc = sha256.New

// DefaultCodec is the default codec creator used for data erasure
// TODO(ismail): for better efficiency and a larger number shares
// we should switch to the rsmt2d.LeopardFF16 codec:
DefaultCodec = rsmt2d.NewRSGF8Codec

// DataCommitmentBlocksLimit is the limit to the number of blocks we can generate a data commitment for.
DataCommitmentBlocksLimit = 1000
)

0 comments on commit 97c3cce

Please sign in to comment.