-
Notifications
You must be signed in to change notification settings - Fork 365
/
Copy pathversioned_consts.go
99 lines (86 loc) · 2.56 KB
/
versioned_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package appconsts
import (
"strconv"
"time"
v1 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v1"
v2 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v2"
v3 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v3"
)
const (
LatestVersion = v3.Version
)
// SubtreeRootThreshold works as a target upper bound for the number of subtree
// roots in the share commitment. If a blob contains more shares than this
// number, then the height of the subtree roots will increase by one so that the
// number of subtree roots in the share commitment decreases by a factor of two.
// This step is repeated until the number of subtree roots is less than the
// SubtreeRootThreshold.
//
// The rationale for this value is described in more detail in ADR-013.
func SubtreeRootThreshold(_ uint64) int {
return v3.SubtreeRootThreshold
}
// SquareSizeUpperBound imposes an upper bound on the max effective square size.
func SquareSizeUpperBound(_ uint64) int {
if OverrideSquareSizeUpperBoundStr != "" {
parsedValue, err := strconv.Atoi(OverrideSquareSizeUpperBoundStr)
if err != nil {
panic("Invalid OverrideSquareSizeUpperBoundStr value")
}
return parsedValue
}
return v3.SquareSizeUpperBound
}
func TxSizeCostPerByte(_ uint64) uint64 {
return v3.TxSizeCostPerByte
}
func GasPerBlobByte(_ uint64) uint32 {
return v3.GasPerBlobByte
}
func MaxTxSize(_ uint64) int {
return v3.MaxTxSize
}
var (
DefaultSubtreeRootThreshold = SubtreeRootThreshold(LatestVersion)
DefaultSquareSizeUpperBound = SquareSizeUpperBound(LatestVersion)
DefaultTxSizeCostPerByte = TxSizeCostPerByte(LatestVersion)
DefaultGasPerBlobByte = GasPerBlobByte(LatestVersion)
)
func GetTimeoutPropose(v uint64) time.Duration {
switch v {
case v1.Version:
return v1.TimeoutPropose
case v2.Version:
return v2.TimeoutPropose
default:
return v3.TimeoutPropose
}
}
func GetTimeoutCommit(v uint64) time.Duration {
switch v {
case v1.Version:
return v1.TimeoutCommit
case v2.Version:
return v2.TimeoutCommit
default:
return v3.TimeoutCommit
}
}
// UpgradeHeightDelay returns the delay in blocks after a quorum has been reached that the chain should upgrade to the new version.
func UpgradeHeightDelay(v uint64) int64 {
if OverrideUpgradeHeightDelayStr != "" {
parsedValue, err := strconv.ParseInt(OverrideUpgradeHeightDelayStr, 10, 64)
if err != nil {
panic("Invalid OverrideUpgradeHeightDelayStr value")
}
return parsedValue
}
switch v {
case v1.Version:
return v1.UpgradeHeightDelay
case v2.Version:
return v2.UpgradeHeightDelay
default:
return v3.UpgradeHeightDelay
}
}