main.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright 2019 The go-ethereum Authors
  2. // This file is part of go-ethereum.
  3. //
  4. // go-ethereum is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // go-ethereum is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
  16. // checkpoint-admin is a utility that can be used to query checkpoint information
  17. // and register stable checkpoints into an oracle contract.
  18. package main
  19. import (
  20. "fmt"
  21. "os"
  22. "github.com/ethereum/go-ethereum/cmd/utils"
  23. "github.com/ethereum/go-ethereum/common/fdlimit"
  24. "github.com/ethereum/go-ethereum/log"
  25. "gopkg.in/urfave/cli.v1"
  26. )
  27. const (
  28. commandHelperTemplate = `{{.Name}}{{if .Subcommands}} command{{end}}{{if .Flags}} [command options]{{end}} [arguments...]
  29. {{if .Description}}{{.Description}}
  30. {{end}}{{if .Subcommands}}
  31. SUBCOMMANDS:
  32. {{range .Subcommands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
  33. {{end}}{{end}}{{if .Flags}}
  34. OPTIONS:
  35. {{range $.Flags}}{{"\t"}}{{.}}
  36. {{end}}
  37. {{end}}`
  38. )
  39. var (
  40. // Git SHA1 commit hash of the release (set via linker flags)
  41. gitCommit = ""
  42. gitDate = ""
  43. )
  44. var app *cli.App
  45. func init() {
  46. app = utils.NewApp(gitCommit, gitDate, "ethereum checkpoint helper tool")
  47. app.Commands = []cli.Command{
  48. commandStatus,
  49. commandDeploy,
  50. commandSign,
  51. commandPublish,
  52. }
  53. app.Flags = []cli.Flag{
  54. oracleFlag,
  55. nodeURLFlag,
  56. }
  57. cli.CommandHelpTemplate = commandHelperTemplate
  58. }
  59. // Commonly used command line flags.
  60. var (
  61. indexFlag = cli.Int64Flag{
  62. Name: "index",
  63. Usage: "Checkpoint index (query latest from remote node if not specified)",
  64. }
  65. hashFlag = cli.StringFlag{
  66. Name: "hash",
  67. Usage: "Checkpoint hash (query latest from remote node if not specified)",
  68. }
  69. oracleFlag = cli.StringFlag{
  70. Name: "oracle",
  71. Usage: "Checkpoint oracle address (query from remote node if not specified)",
  72. }
  73. thresholdFlag = cli.Int64Flag{
  74. Name: "threshold",
  75. Usage: "Minimal number of signatures required to approve a checkpoint",
  76. }
  77. nodeURLFlag = cli.StringFlag{
  78. Name: "rpc",
  79. Value: "http://localhost:8545",
  80. Usage: "The rpc endpoint of a local or remote geth node",
  81. }
  82. clefURLFlag = cli.StringFlag{
  83. Name: "clef",
  84. Value: "http://localhost:8550",
  85. Usage: "The rpc endpoint of clef",
  86. }
  87. signerFlag = cli.StringFlag{
  88. Name: "signer",
  89. Usage: "Signer address for clef signing",
  90. }
  91. signersFlag = cli.StringFlag{
  92. Name: "signers",
  93. Usage: "Comma separated accounts of trusted checkpoint signers",
  94. }
  95. signaturesFlag = cli.StringFlag{
  96. Name: "signatures",
  97. Usage: "Comma separated checkpoint signatures to submit",
  98. }
  99. )
  100. func main() {
  101. log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
  102. fdlimit.Raise(2048)
  103. if err := app.Run(os.Args); err != nil {
  104. fmt.Fprintln(os.Stderr, err)
  105. os.Exit(1)
  106. }
  107. }