Skip to content

Commit

Permalink
Move consts, ipfs, and ipld to pkg (#508)
Browse files Browse the repository at this point in the history
* move ipfs and ipld packages to new pkg/da/

* moved consts to pkg

* clean up
  • Loading branch information
evan-forbes committed Sep 16, 2021
1 parent 2104203 commit 66cc610
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package consts

import (
"crypto/sha256"

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

// This contains all constants of:
// https://github.com/celestiaorg/celestia-specs/blob/master/specs/consensus.md#constants
const (
// ShareSize is the size of a share (in bytes).
// see: https://github.com/celestiaorg/celestia-specs/blob/master/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
MaxSquareSize = 128

// MinSquareSize depicts the smallest original square width.
MinSquareSize = 1
MinSharecount = MinSquareSize * MinSquareSize
)

var (
// See spec for further details on the types of available data
// https://github.com/celestiaorg/celestia-specs/blob/master/specs/consensus.md#reserved-namespace-ids
// https://github.com/celestiaorg/celestia-specs/blob/de5f4f74f56922e9fa735ef79d9e6e6492a2bad1/specs/data_structures.md#availabledata

// 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
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/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
)

0 comments on commit 66cc610

Please sign in to comment.