github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/app/utils/sanity/start.go (about) 1 package sanity 2 3 import ( 4 "github.com/spf13/viper" 5 6 "github.com/fibonacci-chain/fbc/app/config" 7 apptype "github.com/fibonacci-chain/fbc/app/types" 8 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/server" 9 cosmost "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/store/types" 10 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 11 "github.com/fibonacci-chain/fbc/libs/tendermint/consensus" 12 "github.com/fibonacci-chain/fbc/libs/tendermint/state" 13 "github.com/fibonacci-chain/fbc/libs/tendermint/types" 14 "github.com/fibonacci-chain/fbc/x/evm/watcher" 15 "github.com/fibonacci-chain/fbc/x/infura" 16 ) 17 18 // CheckStart check start command's flags. if user set conflict flags return error. 19 // the conflicts flags are: 20 // --fast-query conflict with --pruning=nothing 21 // --enable-preruntx conflict with --download-delta 22 // 23 // based the conflicts above and node-mode below 24 // --node-mode=rpc manage the following flags: 25 // --disable-checktx-mutex=true 26 // --disable-query-mutex=true 27 // --enable-bloom-filter=true 28 // --fast-lru=10000 29 // --fast-query=true 30 // --iavl-enable-async-commit=true 31 // --max-open=20000 32 // --mempool.enable_pending_pool=true 33 // --cors=* 34 // 35 // --node-mode=validator manage the following flags: 36 // --disable-checktx-mutex=true 37 // --disable-query-mutex=true 38 // --dynamic-gp-mode=2 39 // --iavl-enable-async-commit=true 40 // --iavl-cache-size=10000000 41 // --pruning=everything 42 // 43 // --node-mode=archive manage the following flags: 44 // --pruning=nothing 45 // --disable-checktx-mutex=true 46 // --disable-query-mutex=true 47 // --enable-bloom-filter=true 48 // --iavl-enable-async-commit=true 49 // --max-open=20000 50 // --cors=* 51 // 52 // then 53 // --node-mode=archive(--pruning=nothing) conflicts with --fast-query 54 55 var ( 56 startDependentElems = []dependentPair{ 57 { // if infura.FlagEnable=true , watcher.FlagFastQuery must be set to true 58 config: boolItem{name: infura.FlagEnable, expect: true}, 59 reliedConfig: boolItem{name: watcher.FlagFastQuery, expect: true}, 60 }, 61 } 62 // conflicts flags 63 startConflictElems = []conflictPair{ 64 // --fast-query conflict with --pruning=nothing 65 { 66 configA: boolItem{name: watcher.FlagFastQuery, expect: true}, 67 configB: stringItem{name: server.FlagPruning, expect: cosmost.PruningOptionNothing}, 68 }, 69 // --enable-preruntx conflict with --download-delta 70 { 71 configA: boolItem{name: consensus.EnablePrerunTx, expect: true}, 72 configB: boolItem{name: types.FlagDownloadDDS, expect: true}, 73 }, 74 // --multi-cache conflict with --download-delta 75 { 76 configA: boolItem{name: sdk.FlagMultiCache, expect: true}, 77 configB: boolItem{name: types.FlagDownloadDDS, expect: true}, 78 }, 79 { 80 configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.RpcNode)}, 81 configB: stringItem{name: server.FlagPruning, expect: cosmost.PruningOptionNothing}, 82 }, 83 // --node-mode=archive(--pruning=nothing) conflicts with --fast-query 84 { 85 configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.ArchiveNode)}, 86 configB: boolItem{name: watcher.FlagFastQuery, expect: true}, 87 }, 88 { 89 configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.RpcNode)}, 90 configB: boolItem{name: config.FlagEnablePGU, expect: true}, 91 }, 92 { 93 configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.ArchiveNode)}, 94 configB: boolItem{name: config.FlagEnablePGU, expect: true}, 95 }, 96 { 97 configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.InnertxNode)}, 98 configB: boolItem{name: config.FlagEnablePGU, expect: true}, 99 }, 100 } 101 102 checkRangeItems = []rangeItem{ 103 { 104 enumRange: []int{int(state.DeliverTxsExecModeSerial), state.DeliverTxsExecModeParallel}, 105 name: state.FlagDeliverTxsExecMode, 106 }, 107 } 108 ) 109 110 // CheckStart check start command.If it has conflict pair above. then return the conflict error 111 func CheckStart() error { 112 if viper.GetBool(FlagDisableSanity) { 113 return nil 114 } 115 for _, v := range startDependentElems { 116 if err := v.check(); err != nil { 117 return err 118 } 119 } 120 for _, v := range startConflictElems { 121 if err := v.check(); err != nil { 122 return err 123 } 124 } 125 126 for _, v := range checkRangeItems { 127 if err := v.checkRange(); err != nil { 128 return err 129 } 130 } 131 132 return nil 133 }