github.com/daethereum/go-dae@v2.2.3+incompatible/cmd/checkpoint-admin/main.go (about)

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