main.go 2.8 KB

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