main.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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/common/fdlimit"
  23. "github.com/ethereum/go-ethereum/internal/flags"
  24. "github.com/ethereum/go-ethereum/log"
  25. "gopkg.in/urfave/cli.v1"
  26. )
  27. var (
  28. // Git SHA1 commit hash of the release (set via linker flags)
  29. gitCommit = ""
  30. gitDate = ""
  31. )
  32. var app *cli.App
  33. func init() {
  34. app = flags.NewApp(gitCommit, gitDate, "ethereum checkpoint helper tool")
  35. app.Commands = []cli.Command{
  36. commandStatus,
  37. commandDeploy,
  38. commandSign,
  39. commandPublish,
  40. }
  41. app.Flags = []cli.Flag{
  42. oracleFlag,
  43. nodeURLFlag,
  44. }
  45. cli.CommandHelpTemplate = flags.OriginCommandHelpTemplate
  46. }
  47. // Commonly used command line flags.
  48. var (
  49. indexFlag = cli.Int64Flag{
  50. Name: "index",
  51. Usage: "Checkpoint index (query latest from remote node if not specified)",
  52. }
  53. hashFlag = cli.StringFlag{
  54. Name: "hash",
  55. Usage: "Checkpoint hash (query latest from remote node if not specified)",
  56. }
  57. oracleFlag = cli.StringFlag{
  58. Name: "oracle",
  59. Usage: "Checkpoint oracle address (query from remote node if not specified)",
  60. }
  61. thresholdFlag = cli.Int64Flag{
  62. Name: "threshold",
  63. Usage: "Minimal number of signatures required to approve a checkpoint",
  64. }
  65. nodeURLFlag = cli.StringFlag{
  66. Name: "rpc",
  67. Value: "http://localhost:8545",
  68. Usage: "The rpc endpoint of a local or remote geth node",
  69. }
  70. clefURLFlag = cli.StringFlag{
  71. Name: "clef",
  72. Value: "http://localhost:8550",
  73. Usage: "The rpc endpoint of clef",
  74. }
  75. signerFlag = cli.StringFlag{
  76. Name: "signer",
  77. Usage: "Signer address for clef signing",
  78. }
  79. signersFlag = cli.StringFlag{
  80. Name: "signers",
  81. Usage: "Comma separated accounts of trusted checkpoint signers",
  82. }
  83. signaturesFlag = cli.StringFlag{
  84. Name: "signatures",
  85. Usage: "Comma separated checkpoint signatures to submit",
  86. }
  87. )
  88. func main() {
  89. log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
  90. fdlimit.Raise(2048)
  91. if err := app.Run(os.Args); err != nil {
  92. fmt.Fprintln(os.Stderr, err)
  93. os.Exit(1)
  94. }
  95. }