github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/cmd/evm/main.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:27</date>
    10  //</624342590010953728>
    11  
    12  
    13  //EVM执行EVM代码段。
    14  package main
    15  
    16  import (
    17  	"fmt"
    18  	"math/big"
    19  	"os"
    20  
    21  	"github.com/ethereum/go-ethereum/cmd/utils"
    22  	"gopkg.in/urfave/cli.v1"
    23  )
    24  
    25  var gitCommit = "" //git sha1提交发布的哈希(通过链接器标志设置)
    26  
    27  var (
    28  	app = utils.NewApp(gitCommit, "the evm command line interface")
    29  
    30  	DebugFlag = cli.BoolFlag{
    31  		Name:  "debug",
    32  		Usage: "output full trace logs",
    33  	}
    34  	MemProfileFlag = cli.StringFlag{
    35  		Name:  "memprofile",
    36  		Usage: "creates a memory profile at the given path",
    37  	}
    38  	CPUProfileFlag = cli.StringFlag{
    39  		Name:  "cpuprofile",
    40  		Usage: "creates a CPU profile at the given path",
    41  	}
    42  	StatDumpFlag = cli.BoolFlag{
    43  		Name:  "statdump",
    44  		Usage: "displays stack and heap memory information",
    45  	}
    46  	CodeFlag = cli.StringFlag{
    47  		Name:  "code",
    48  		Usage: "EVM code",
    49  	}
    50  	CodeFileFlag = cli.StringFlag{
    51  		Name:  "codefile",
    52  		Usage: "File containing EVM code. If '-' is specified, code is read from stdin ",
    53  	}
    54  	GasFlag = cli.Uint64Flag{
    55  		Name:  "gas",
    56  		Usage: "gas limit for the evm",
    57  		Value: 10000000000,
    58  	}
    59  	PriceFlag = utils.BigFlag{
    60  		Name:  "price",
    61  		Usage: "price set for the evm",
    62  		Value: new(big.Int),
    63  	}
    64  	ValueFlag = utils.BigFlag{
    65  		Name:  "value",
    66  		Usage: "value set for the evm",
    67  		Value: new(big.Int),
    68  	}
    69  	DumpFlag = cli.BoolFlag{
    70  		Name:  "dump",
    71  		Usage: "dumps the state after the run",
    72  	}
    73  	InputFlag = cli.StringFlag{
    74  		Name:  "input",
    75  		Usage: "input for the EVM",
    76  	}
    77  	VerbosityFlag = cli.IntFlag{
    78  		Name:  "verbosity",
    79  		Usage: "sets the verbosity level",
    80  	}
    81  	CreateFlag = cli.BoolFlag{
    82  		Name:  "create",
    83  		Usage: "indicates the action should be create rather than call",
    84  	}
    85  	GenesisFlag = cli.StringFlag{
    86  		Name:  "prestate",
    87  		Usage: "JSON file with prestate (genesis) config",
    88  	}
    89  	MachineFlag = cli.BoolFlag{
    90  		Name:  "json",
    91  		Usage: "output trace logs in machine readable format (json)",
    92  	}
    93  	SenderFlag = cli.StringFlag{
    94  		Name:  "sender",
    95  		Usage: "The transaction origin",
    96  	}
    97  	ReceiverFlag = cli.StringFlag{
    98  		Name:  "receiver",
    99  		Usage: "The transaction receiver (execution context)",
   100  	}
   101  	DisableMemoryFlag = cli.BoolFlag{
   102  		Name:  "nomemory",
   103  		Usage: "disable memory output",
   104  	}
   105  	DisableStackFlag = cli.BoolFlag{
   106  		Name:  "nostack",
   107  		Usage: "disable stack output",
   108  	}
   109  )
   110  
   111  func init() {
   112  	app.Flags = []cli.Flag{
   113  		CreateFlag,
   114  		DebugFlag,
   115  		VerbosityFlag,
   116  		CodeFlag,
   117  		CodeFileFlag,
   118  		GasFlag,
   119  		PriceFlag,
   120  		ValueFlag,
   121  		DumpFlag,
   122  		InputFlag,
   123  		MemProfileFlag,
   124  		CPUProfileFlag,
   125  		StatDumpFlag,
   126  		GenesisFlag,
   127  		MachineFlag,
   128  		SenderFlag,
   129  		ReceiverFlag,
   130  		DisableMemoryFlag,
   131  		DisableStackFlag,
   132  	}
   133  	app.Commands = []cli.Command{
   134  		compileCommand,
   135  		disasmCommand,
   136  		runCommand,
   137  		stateTestCommand,
   138  	}
   139  }
   140  
   141  func main() {
   142  	if err := app.Run(os.Args); err != nil {
   143  		fmt.Fprintln(os.Stderr, err)
   144  		os.Exit(1)
   145  	}
   146  }
   147