github.com/klaytn/klaytn@v1.12.1/cmd/homi/setup/flags.go (about) 1 // Copyright 2018 The klaytn Authors 2 // Copyright 2017 AMIS Technologies 3 // This file is part of the go-ethereum library. 4 // 5 // The go-ethereum library is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Lesser General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // The go-ethereum library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 17 18 package setup 19 20 import ( 21 "github.com/klaytn/klaytn/blockchain/system" 22 "github.com/klaytn/klaytn/params" 23 "github.com/urfave/cli/v2" 24 ) 25 26 var ( 27 dockerImageId string 28 outputPath string 29 ) 30 31 var ( 32 homiYamlFlag = &cli.StringFlag{ 33 Name: "homi-yaml", 34 Usage: "Import homi.yaml to generate the config files to run the nodes", 35 Aliases: []string{"yaml"}, 36 } 37 genTypeFlag = &cli.StringFlag{ 38 Name: "gen-type", 39 Usage: "Generate environment files according to the type (docker, local, remote, deploy)", 40 Value: "docker", 41 Aliases: []string{}, 42 } 43 44 cypressTestFlag = &cli.BoolFlag{ 45 Name: "cypress-test", 46 Usage: "Generate genesis.json similar to the one used for Cypress with shorter intervals for testing", 47 Aliases: []string{}, 48 } 49 cypressFlag = &cli.BoolFlag{ 50 Name: "cypress", 51 Usage: "Generate genesis.json similar to the one used for Cypress", 52 Aliases: []string{}, 53 } 54 baobabTestFlag = &cli.BoolFlag{ 55 Name: "baobab-test", 56 Usage: "Generate genesis.json similar to the one used for Baobab with shorter intervals for testing", 57 Aliases: []string{}, 58 } 59 baobabFlag = &cli.BoolFlag{ 60 Name: "baobab", 61 Usage: "Generate genesis.json similar to the one used for Baobab", 62 Aliases: []string{}, 63 } 64 serviceChainFlag = &cli.BoolFlag{ 65 Name: "servicechain", 66 Usage: "Generate genesis.json similar to the one used for Serivce Chain", 67 Aliases: []string{}, 68 } 69 serviceChainTestFlag = &cli.BoolFlag{ 70 Name: "servicechain-test", 71 Usage: "Generate genesis.json similar to the one used for Serivce Chain with shorter intervals for testing", 72 Aliases: []string{}, 73 } 74 cliqueFlag = &cli.BoolFlag{ 75 Name: "clique", 76 Usage: "Use Clique consensus", 77 Aliases: []string{"clique.enable"}, 78 } 79 80 numOfCNsFlag = &cli.IntFlag{ 81 Name: "cn-num", 82 Usage: "Number of consensus nodes", 83 Value: 0, 84 Aliases: []string{"topology.cn-num"}, 85 } 86 numOfValidatorsFlag = &cli.IntFlag{ 87 Name: "validators-num", 88 Usage: "Number of validators. If not set, it will be set the number of option cn-num", 89 Value: 0, 90 Aliases: []string{"topology.validators-num"}, 91 } 92 numOfPNsFlag = &cli.IntFlag{ 93 Name: "pn-num", 94 Usage: "Number of proxy node", 95 Value: 0, 96 Aliases: []string{"topology.pn-num"}, 97 } 98 numOfENsFlag = &cli.IntFlag{ 99 Name: "en-num", 100 Usage: "Number of end-point node", 101 Value: 0, 102 Aliases: []string{"topology.en-num"}, 103 } 104 numOfSCNsFlag = &cli.IntFlag{ 105 Name: "scn-num", 106 Usage: "Number of service chain nodes", 107 Value: 0, 108 Aliases: []string{"topology.scn-num"}, 109 } 110 numOfSPNsFlag = &cli.IntFlag{ 111 Name: "spn-num", 112 Usage: "Number of service chain proxy nodes", 113 Value: 0, 114 Aliases: []string{"topology.spn-num"}, 115 } 116 numOfSENsFlag = &cli.IntFlag{ 117 Name: "sen-num", 118 Usage: "Number of service chain end-point nodes", 119 Value: 0, 120 Aliases: []string{"topology.sen-num"}, 121 } 122 numOfTestKeyFlag = &cli.IntFlag{ 123 Name: "test-num", 124 Usage: "Number of test key", 125 Value: 0, 126 Aliases: []string{"topology.test-num"}, 127 } 128 129 genesisTypeFlag = &cli.StringFlag{ 130 Name: "genesis-type", 131 Usage: "Set the type of genesis.json to generate (cypress-test, cypress, baobab-test, baobab, clique, servicechain, servicechain-test, istanbul)", 132 Aliases: []string{"genesis.type"}, 133 } 134 mnemonic = &cli.StringFlag{ 135 Name: "mnemonic", 136 Usage: "Use given mnemonic to derive node keys", 137 Value: "", 138 } 139 140 mnemonicPath = &cli.StringFlag{ 141 Name: "mnemonic-path", 142 Usage: "Use given path/coin to derive node keys (format: m/44'/60'/0'/0/). Effective only if --mnemonic is given", 143 Value: "eth", 144 } 145 146 chainIDFlag = &cli.Uint64Flag{ 147 Name: "chainID", 148 Usage: "ChainID", 149 Value: 1000, 150 Aliases: []string{"genesis.chain-id"}, 151 } 152 153 serviceChainIDFlag = &cli.Uint64Flag{ 154 Name: "serviceChainID", 155 Usage: "Service Chain ID", 156 Value: 1001, 157 Aliases: []string{"genesis.service-chain-id"}, 158 } 159 160 unitPriceFlag = &cli.Uint64Flag{ 161 Name: "unitPrice", 162 Usage: "Price of unit", 163 Value: 0, 164 Aliases: []string{"genesis.unit-price"}, 165 } 166 167 deriveShaImplFlag = &cli.IntFlag{ 168 Name: "deriveShaImpl", 169 Usage: "Implementation of DeriveSha [0:Original, 1:Simple, 2:Concat]", 170 Value: 0, 171 Aliases: []string{"genesis.derive-sha-impl"}, 172 } 173 174 outputPathFlag = &cli.StringFlag{ 175 Name: "output", 176 Usage: "homi's result saved at this output folder", 177 Aliases: []string{"o"}, 178 Value: "homi-output", 179 Destination: &outputPath, 180 } 181 182 fundingAddrFlag = &cli.StringFlag{ 183 Name: "funding-addr", 184 Value: "", 185 Usage: "Give initial fund to the given addr", 186 Aliases: []string{"genesis.funding-addr"}, 187 } 188 189 patchAddressBookFlag = &cli.BoolFlag{ 190 Name: "patch-address-book", 191 Usage: "Patch genesis AddressBook's constructContract function", 192 Aliases: []string{"genesis.patched-address-book.enable"}, 193 } 194 195 patchAddressBookAddrFlag = &cli.StringFlag{ 196 Name: "patch-address-book-addr", 197 Usage: "The address to inject in AddressBook's constructContract function [default: first CN's address]", 198 Value: "", 199 Aliases: []string{"genesis.patched-address-book.addr"}, 200 } 201 // Deprecated: it doesn't used anymore 202 subGroupSizeFlag = &cli.IntFlag{ 203 Name: "subgroup-size", 204 Usage: "CN's Subgroup size", 205 Value: 21, 206 Aliases: []string{}, 207 } 208 209 addressBookMockFlag = &cli.BoolFlag{ 210 Name: "address-book-mock", 211 Usage: "Allocate an AddressBookMock at the genesis block", 212 } 213 214 dockerImageIdFlag = &cli.StringFlag{ 215 Name: "docker-image-id", 216 Value: "klaytn/klaytn:latest", // https://hub.docker.com/r/klaytn/klaytn 217 Usage: "Base docker image ID (Image[:tag]), e.g., klaytn/klaytn:v1.5.3", 218 Aliases: []string{"deploy.docker.image-id"}, 219 Destination: &dockerImageId, 220 } 221 fasthttpFlag = &cli.BoolFlag{ 222 Name: "fasthttp", 223 Usage: "(docker only) Use High performance http module", 224 Aliases: []string{"deploy.docker.fasthttp"}, 225 } 226 networkIdFlag = &cli.IntFlag{ 227 Name: "network-id", 228 Usage: "(docker only) network identifier (default : 2018)", 229 Value: 2018, 230 Aliases: []string{"deploy.docker.network-id"}, 231 } 232 nografanaFlag = &cli.BoolFlag{ 233 Name: "no-grafana", 234 Usage: "(docker only) Do not make grafana container", 235 Aliases: []string{"deploy.docker.no-grafana"}, 236 } 237 useTxGenFlag = &cli.BoolFlag{ 238 Name: "txgen", 239 Usage: "(docker only) Add txgen container", 240 Aliases: []string{"deploy.docker.tx-gen.enable"}, 241 } 242 txGenRateFlag = &cli.IntFlag{ 243 Name: "txgen-rate", 244 Usage: "(docker only) txgen's rate option [default : 2000]", 245 Value: 2000, 246 Aliases: []string{"deploy.docker.tx-gen.rate"}, 247 } 248 txGenConnFlag = &cli.IntFlag{ 249 Name: "txgen-conn", 250 Usage: "(docker only) txgen's connection size option [default : 100]", 251 Value: 100, 252 Aliases: []string{"deploy.docker.tx-gen.connetions"}, 253 } 254 txGenDurFlag = &cli.StringFlag{ 255 Name: "txgen-dur", 256 Usage: "(docker only) txgen's duration option [default : 1m]", 257 Value: "1m", 258 Aliases: []string{"deploy.docker.tx-gen.duration"}, 259 } 260 txGenThFlag = &cli.IntFlag{ 261 Name: "txgen-th", 262 Usage: "(docker-only) txgen's thread size option [default : 2]", 263 Value: 2, 264 Aliases: []string{"deploy.docker.tx-gen.thread"}, 265 } 266 267 rpcPortFlag = &cli.IntFlag{ 268 Name: "rpc-port", 269 Usage: "klay.conf - Klaytn node's rpc port [default: 8551] ", 270 Value: 8551, 271 Aliases: []string{"deploy.rpc-port"}, 272 } 273 274 wsPortFlag = &cli.IntFlag{ 275 Name: "ws-port", 276 Usage: "klay.conf - Klaytn node's ws port [default: 8552]", 277 Value: 8552, 278 Aliases: []string{"deploy.ws-port"}, 279 } 280 281 p2pPortFlag = &cli.IntFlag{ 282 Name: "p2p-port", 283 Usage: "klay.conf - Klaytn node's p2p port [default: 32323]", 284 Value: 32323, 285 Aliases: []string{"deploy.p2p-port"}, 286 } 287 288 dataDirFlag = &cli.StringFlag{ 289 Name: "data-dir", 290 Usage: "klay.conf - Klaytn node's data directory path [default : /var/klay/data]", 291 Value: "/var/klay/data", 292 Aliases: []string{"deploy.data-dir"}, 293 } 294 295 logDirFlag = &cli.StringFlag{ 296 Name: "log-dir", 297 Usage: "klay.conf - Klaytn node's log directory path [default : /var/klay/log]", 298 Value: "/var/klay/log", 299 Aliases: []string{"deploy.log-dir"}, 300 } 301 302 // Governance flags 303 governanceFlag = &cli.BoolFlag{ 304 Name: "governance", 305 Usage: "governance field is added in the genesis file if this flag is set", 306 Aliases: []string{"genesis.governance"}, 307 } 308 309 govModeFlag = &cli.StringFlag{ 310 Name: "gov-mode", 311 Usage: "governance mode (none, single, ballot) [default: none]", 312 Value: params.DefaultGovernanceMode, 313 Aliases: []string{"genesis.governance-mode"}, 314 } 315 316 governingNodeFlag = &cli.StringFlag{ 317 Name: "governing-node", 318 Usage: "the governing node [default: 0x0000000000000000000000000000000000000000]", 319 Value: params.DefaultGoverningNode, 320 Aliases: []string{"genesis.governing-node"}, 321 } 322 323 govParamContractFlag = &cli.StringFlag{ 324 Name: "gov-param-contract", 325 Usage: "the GovParam contract address [default: 0x0000000000000000000000000000000000000000]", 326 Value: params.DefaultGovParamContract, 327 } 328 329 rewardMintAmountFlag = &cli.StringFlag{ 330 Name: "reward-mint-amount", 331 Usage: "governance minting amount", 332 Value: "9600000000000000000", 333 Aliases: []string{"genesis.reward.mint-amount"}, 334 } 335 rewardRatioFlag = &cli.StringFlag{ 336 Name: "reward-ratio", 337 Usage: "governance ratio [default: 100/0/0]", 338 Value: params.DefaultRatio, 339 Aliases: []string{"genesis.reward.ratio"}, 340 } 341 342 rewardKip82RatioFlag = &cli.StringFlag{ 343 Name: "reward-kip82-ratio", 344 Usage: "kip82 ratio [default: 20/80]", 345 Value: params.DefaultKip82Ratio, 346 } 347 348 rewardGiniCoeffFlag = &cli.BoolFlag{ 349 Name: "reward-gini-coeff", 350 Usage: "governance gini-coefficient", 351 Aliases: []string{"genesis.reward.gini-coefficient"}, 352 } 353 rewardDeferredTxFeeFlag = &cli.BoolFlag{ 354 Name: "reward-deferred-tx", 355 Usage: "governance deferred transaction", 356 Aliases: []string{"genesis.reward.deferred-tx"}, 357 } 358 rewardStakingFlag = &cli.Uint64Flag{ 359 Name: "reward-staking-interval", 360 Usage: "reward staking update interval flag", 361 Value: 86400, 362 Aliases: []string{"genesis.reward.staking-interval"}, 363 } 364 rewardProposerFlag = &cli.Uint64Flag{ 365 Name: "reward-proposer-interval", 366 Usage: "reward proposer update interval flag", 367 Value: 3600, 368 Aliases: []string{"genesis.reward.proposer-inteval"}, 369 } 370 rewardMinimumStakeFlag = &cli.StringFlag{ 371 Name: "reward-minimum-stake", 372 Usage: "reward minimum stake flag", 373 Value: "2000000", 374 Aliases: []string{"genesis.reward.minimum-stake"}, 375 } 376 377 magmaLowerBoundBaseFeeFlag = &cli.Uint64Flag{ 378 Name: "lower-bound-base-fee", 379 Usage: "lower bound base fee flag", 380 Value: params.DefaultLowerBoundBaseFee, 381 Aliases: []string{"genesis.kip71.lower-bound-base-fee"}, 382 } 383 384 magmaUpperBoundBaseFeeFlag = &cli.Uint64Flag{ 385 Name: "upper-bound-base-fee", 386 Usage: "upper bound base fee flag", 387 Value: params.DefaultUpperBoundBaseFee, 388 Aliases: []string{"genesis.kip71.upper-bound-base-fee"}, 389 } 390 391 magmaGasTarget = &cli.Uint64Flag{ 392 Name: "gas-target", 393 Usage: "gas target flag", 394 Value: params.DefaultGasTarget, 395 Aliases: []string{"genesis.kip71.gas-target"}, 396 } 397 398 magmaMaxBlockGasUsedForBaseFee = &cli.Uint64Flag{ 399 Name: "block-gas-limit", 400 Usage: "block gas limit flag", 401 Value: params.DefaultMaxBlockGasUsedForBaseFee, 402 Aliases: []string{"genesis.kip71.block-gas-limit"}, 403 } 404 405 magmaBaseFeeDenominator = &cli.Uint64Flag{ 406 Name: "base-fee-denominator", 407 Usage: "base fee denominator flag", 408 Value: params.DefaultBaseFeeDenominator, 409 Aliases: []string{"genesis.kip71.base-fee-denominator"}, 410 } 411 412 istEpochFlag = &cli.Uint64Flag{ 413 Name: "ist-epoch", 414 Usage: "governance epoch [default: 604800]", 415 Value: params.DefaultEpoch, 416 Aliases: []string{"genesis.consensus.istanbul.epoch"}, 417 } 418 419 istProposerPolicyFlag = &cli.Uint64Flag{ 420 Name: "ist-proposer-policy", 421 Usage: "governance proposer policy (0: RoundRobin, 1: Sticky, 2: WeightedRandom) [default: 0]", 422 Value: params.DefaultProposerPolicy, 423 Aliases: []string{"genesis.consensus.istanbul.policy"}, 424 } 425 426 istSubGroupFlag = &cli.Uint64Flag{ 427 Name: "ist-subgroup", 428 Usage: "governance subgroup size [default: 21]", 429 Value: params.DefaultSubGroupSize, 430 Aliases: []string{"genesis.consensus.istanbul.subgroup"}, 431 } 432 433 cliqueEpochFlag = &cli.Uint64Flag{ 434 Name: "clique-epoch", 435 Usage: "clique epoch", 436 Value: params.DefaultEpoch, 437 Aliases: []string{"genesis.consensus.clique.epoch"}, 438 } 439 440 cliquePeriodFlag = &cli.Uint64Flag{ 441 Name: "clique-period", 442 Usage: "clique period", 443 Value: params.DefaultPeriod, 444 Aliases: []string{"genesis.consensus.clique.period"}, 445 } 446 447 istanbulCompatibleBlockNumberFlag = &cli.Int64Flag{ 448 Name: "istanbul-compatible-blocknumber", 449 Usage: "istanbulCompatible blockNumber", 450 Value: 0, 451 Aliases: []string{"genesis.hardfork.istanbul-compatible-blocknumber"}, 452 } 453 454 londonCompatibleBlockNumberFlag = &cli.Int64Flag{ 455 Name: "london-compatible-blocknumber", 456 Usage: "londonCompatible blockNumber", 457 Value: 0, 458 Aliases: []string{"genesis.hardfork.london-compatible-blocknumber"}, 459 } 460 461 ethTxTypeCompatibleBlockNumberFlag = &cli.Int64Flag{ 462 Name: "eth-tx-type-compatible-blocknumber", 463 Usage: "ethTxTypeCompatible blockNumber", 464 Value: 0, 465 Aliases: []string{"genesis.hardfork.eth-tx-type-compatible-blocknumber"}, 466 } 467 468 magmaCompatibleBlockNumberFlag = &cli.Int64Flag{ 469 Name: "magma-compatible-blocknumber", 470 Usage: "magmaCompatible blockNumber", 471 Value: 0, 472 Aliases: []string{"genesis.hardfork.magma-compatible-blocknumber"}, 473 } 474 475 koreCompatibleBlockNumberFlag = &cli.Int64Flag{ 476 Name: "kore-compatible-blocknumber", 477 Usage: "koreCompatible blockNumber", 478 Value: 0, 479 Aliases: []string{"genesis.hardfork.kore-compatible-blocknumber"}, 480 } 481 482 shanghaiCompatibleBlockNumberFlag = &cli.Int64Flag{ 483 Name: "shanghai-compatible-blocknumber", 484 Usage: "shanghaiCompatible blockNumber", 485 Value: 0, 486 Aliases: []string{"genesis.hardfork.shanghai-compatible-blocknumber"}, 487 } 488 489 cancunCompatibleBlockNumberFlag = &cli.Int64Flag{ 490 Name: "cancun-compatible-blocknumber", 491 Usage: "cancunCompatible blockNumber", 492 Value: 0, 493 Aliases: []string{"genesis.hardfork.cancun-compatible-blocknumber"}, 494 } 495 496 // KIP103 hardfork is optional 497 kip103CompatibleBlockNumberFlag = &cli.Int64Flag{ 498 Name: "kip103-compatible-blocknumber", 499 Usage: "kip103Compatible blockNumber", 500 Value: 0, 501 Aliases: []string{"genesis.hardfork.kip103-compatible-blocknumber"}, 502 } 503 504 kip103ContractAddressFlag = &cli.StringFlag{ 505 Name: "kip103-contract-address", 506 Usage: "kip103 contract address", 507 Aliases: []string{"genesis.hardfork.kip103-contract-address"}, 508 } 509 510 randaoCompatibleBlockNumberFlag = &cli.Int64Flag{ 511 Name: "randao-compatible-blocknumber", 512 Usage: "randaoCompatible blockNumber", 513 Value: 0, 514 Aliases: []string{"genesis.hardfork.randao-compatible-blocknumber"}, 515 } 516 517 kip113ProxyAddressFlag = &cli.StringFlag{ 518 Name: "kip113-proxy-contract-address", 519 Usage: "kip113 proxy contract address", 520 Value: system.Kip113ProxyAddrMock.String(), 521 Aliases: []string{"genesis.hardfork.kip113-proxy-contract-address"}, 522 } 523 524 kip113LogicAddressFlag = &cli.StringFlag{ 525 Name: "kip113-logic-contract-address", 526 Usage: "kip113 logic contract address", 527 Value: system.Kip113LogicAddrMock.String(), 528 Aliases: []string{"genesis.hardfork.kip113-logic-contract-address"}, 529 } 530 531 kip113MockFlag = &cli.BoolFlag{ 532 Name: "kip113-mock", 533 Usage: "Allocate an Kip113Mock at the genesis block", 534 } 535 536 registryMockFlag = &cli.BoolFlag{ 537 Name: "registry-mock", 538 Usage: "Allocate an RegistryMock at the genesis block", 539 } 540 )