-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.go
114 lines (106 loc) · 3.38 KB
/
start.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package sanity
import (
"github.com/spf13/viper"
"github.com/brc20-collab/brczero/app/config"
apptype "github.com/brc20-collab/brczero/app/types"
"github.com/brc20-collab/brczero/libs/cosmos-sdk/server"
cosmost "github.com/brc20-collab/brczero/libs/cosmos-sdk/store/types"
"github.com/brc20-collab/brczero/libs/tendermint/state"
"github.com/brc20-collab/brczero/x/evm/watcher"
)
// CheckStart check start command's flags. if user set conflict flags return error.
// the conflicts flags are:
// --fast-query conflict with --pruning=nothing
// --enable-preruntx conflict with --download-delta
//
// based the conflicts above and node-mode below
// --node-mode=rpc manage the following flags:
// --disable-checktx-mutex=true
// --disable-query-mutex=true
// --enable-bloom-filter=true
// --fast-lru=10000
// --fast-query=true
// --iavl-enable-async-commit=true
// --max-open=20000
// --mempool.enable_pending_pool=true
// --cors=*
//
// --node-mode=validator manage the following flags:
// --disable-checktx-mutex=true
// --disable-query-mutex=true
// --dynamic-gp-mode=2
// --iavl-enable-async-commit=true
// --iavl-cache-size=10000000
// --pruning=everything
//
// --node-mode=archive manage the following flags:
// --pruning=nothing
// --disable-checktx-mutex=true
// --disable-query-mutex=true
// --enable-bloom-filter=true
// --iavl-enable-async-commit=true
// --max-open=20000
// --cors=*
//
// then
// --node-mode=archive(--pruning=nothing) conflicts with --fast-query
var (
startDependentElems = []dependentPair{}
// conflicts flags
startConflictElems = []conflictPair{
// --fast-query conflict with --pruning=nothing
{
configA: boolItem{name: watcher.FlagFastQuery, expect: true},
configB: stringItem{name: server.FlagPruning, expect: cosmost.PruningOptionNothing},
},
{
configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.RpcNode)},
configB: stringItem{name: server.FlagPruning, expect: cosmost.PruningOptionNothing},
},
// --node-mode=archive(--pruning=nothing) conflicts with --fast-query
{
configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.ArchiveNode)},
configB: boolItem{name: watcher.FlagFastQuery, expect: true},
},
{
configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.RpcNode)},
configB: boolItem{name: config.FlagEnablePGU, expect: true},
},
{
configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.ArchiveNode)},
configB: boolItem{name: config.FlagEnablePGU, expect: true},
},
{
configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.InnertxNode)},
configB: boolItem{name: config.FlagEnablePGU, expect: true},
},
}
checkRangeItems = []rangeItem{
{
enumRange: []int{int(state.DeliverTxsExecModeSerial), state.DeliverTxsExecModeParallel},
name: state.FlagDeliverTxsExecMode,
},
}
)
// CheckStart check start command.If it has conflict pair above. then return the conflict error
func CheckStart() error {
if viper.GetBool(FlagDisableSanity) {
return nil
}
for _, v := range startDependentElems {
if err := v.check(); err != nil {
return err
}
}
for _, v := range startConflictElems {
if err := v.check(); err != nil {
return err
}
}
for _, v := range checkRangeItems {
if err := v.checkRange(); err != nil {
return err
}
}
return nil
}