-
Notifications
You must be signed in to change notification settings - Fork 182
/
start.go
107 lines (101 loc) · 3.54 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
package sanity
import (
apptype "github.com/okex/exchain/app/types"
"github.com/okex/exchain/libs/cosmos-sdk/server"
cosmost "github.com/okex/exchain/libs/cosmos-sdk/store/types"
"github.com/okex/exchain/libs/tendermint/consensus"
"github.com/okex/exchain/libs/tendermint/state"
"github.com/okex/exchain/libs/tendermint/types"
"github.com/okex/exchain/x/evm/watcher"
"github.com/spf13/viper"
)
// CheckStart check start command's flags. if user set conflict flags return error.
// the conflicts flags are:
// --fast-query conflict with --paralleled-tx=true
// --fast-query conflict with --pruning=nothing
// --enable-preruntx conflict with --download-delta
// --upload-delta conflict with --paralleled-tx=true
//
// 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
// --enable-dynamic-gp=false
// --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=rpc(--fast-query) conflicts with --paralleled-tx=true and --pruning=nothing
// --node-mode=archive(--pruning=nothing) conflicts with --fast-query
var (
// conflicts flags
startConflictElems = []conflictPair{
// --fast-query conflict with --paralleled-tx=true
{
configA: boolItem{name: watcher.FlagFastQuery, value: true},
configB: boolItem{name: state.FlagParalleledTx, value: true},
},
// --fast-query conflict with --pruning=nothing
{
configA: boolItem{name: watcher.FlagFastQuery, value: true},
configB: stringItem{name: server.FlagPruning, value: cosmost.PruningOptionNothing},
},
// --enable-preruntx conflict with --download-delta
{
configA: boolItem{name: consensus.EnablePrerunTx, value: true},
configB: boolItem{name: types.FlagDownloadDDS, value: true},
},
// --upload-delta conflict with --paralleled-tx=true
{
configA: boolItem{name: types.FlagUploadDDS, value: true},
configB: boolItem{name: state.FlagParalleledTx, value: true},
},
// --node-mode=rpc(--fast-query) conflicts with --paralleled-tx=true and --pruning=nothing
{
configA: stringItem{name: apptype.FlagNodeMode, value: string(apptype.RpcNode)},
configB: boolItem{name: state.FlagParalleledTx, value: true},
},
{
configA: stringItem{name: apptype.FlagNodeMode, value: string(apptype.RpcNode)},
configB: stringItem{name: server.FlagPruning, value: cosmost.PruningOptionNothing},
},
// --node-mode=archive(--pruning=nothing) conflicts with --fast-query
{
configA: stringItem{name: apptype.FlagNodeMode, value: string(apptype.ArchiveNode)},
configB: boolItem{name: watcher.FlagFastQuery, value: true},
},
}
)
// 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 startConflictElems {
if err := v.checkConflict(); err != nil {
return err
}
}
return nil
}