-
Notifications
You must be signed in to change notification settings - Fork 264
/
consts.go
81 lines (66 loc) · 3.54 KB
/
consts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package consts
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/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
// 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
)
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
// 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/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
)