main.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // Copyright 2014 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. // evm executes EVM code snippets.
  17. package main
  18. import (
  19. "fmt"
  20. "math/big"
  21. "os"
  22. "github.com/ethereum/go-ethereum/cmd/utils"
  23. "gopkg.in/urfave/cli.v1"
  24. )
  25. var gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags)
  26. var gitDate = ""
  27. var (
  28. app = utils.NewApp(gitCommit, gitDate, "the evm command line interface")
  29. DebugFlag = cli.BoolFlag{
  30. Name: "debug",
  31. Usage: "output full trace logs",
  32. }
  33. MemProfileFlag = cli.StringFlag{
  34. Name: "memprofile",
  35. Usage: "creates a memory profile at the given path",
  36. }
  37. CPUProfileFlag = cli.StringFlag{
  38. Name: "cpuprofile",
  39. Usage: "creates a CPU profile at the given path",
  40. }
  41. StatDumpFlag = cli.BoolFlag{
  42. Name: "statdump",
  43. Usage: "displays stack and heap memory information",
  44. }
  45. CodeFlag = cli.StringFlag{
  46. Name: "code",
  47. Usage: "EVM code",
  48. }
  49. CodeFileFlag = cli.StringFlag{
  50. Name: "codefile",
  51. Usage: "File containing EVM code. If '-' is specified, code is read from stdin ",
  52. }
  53. GasFlag = cli.Uint64Flag{
  54. Name: "gas",
  55. Usage: "gas limit for the evm",
  56. Value: 10000000000,
  57. }
  58. PriceFlag = utils.BigFlag{
  59. Name: "price",
  60. Usage: "price set for the evm",
  61. Value: new(big.Int),
  62. }
  63. ValueFlag = utils.BigFlag{
  64. Name: "value",
  65. Usage: "value set for the evm",
  66. Value: new(big.Int),
  67. }
  68. DumpFlag = cli.BoolFlag{
  69. Name: "dump",
  70. Usage: "dumps the state after the run",
  71. }
  72. InputFlag = cli.StringFlag{
  73. Name: "input",
  74. Usage: "input for the EVM",
  75. }
  76. VerbosityFlag = cli.IntFlag{
  77. Name: "verbosity",
  78. Usage: "sets the verbosity level",
  79. }
  80. CreateFlag = cli.BoolFlag{
  81. Name: "create",
  82. Usage: "indicates the action should be create rather than call",
  83. }
  84. GenesisFlag = cli.StringFlag{
  85. Name: "prestate",
  86. Usage: "JSON file with prestate (genesis) config",
  87. }
  88. MachineFlag = cli.BoolFlag{
  89. Name: "json",
  90. Usage: "output trace logs in machine readable format (json)",
  91. }
  92. SenderFlag = cli.StringFlag{
  93. Name: "sender",
  94. Usage: "The transaction origin",
  95. }
  96. ReceiverFlag = cli.StringFlag{
  97. Name: "receiver",
  98. Usage: "The transaction receiver (execution context)",
  99. }
  100. DisableMemoryFlag = cli.BoolFlag{
  101. Name: "nomemory",
  102. Usage: "disable memory output",
  103. }
  104. DisableStackFlag = cli.BoolFlag{
  105. Name: "nostack",
  106. Usage: "disable stack output",
  107. }
  108. EVMInterpreterFlag = cli.StringFlag{
  109. Name: "vm.evm",
  110. Usage: "External EVM configuration (default = built-in interpreter)",
  111. Value: "",
  112. }
  113. )
  114. func init() {
  115. app.Flags = []cli.Flag{
  116. CreateFlag,
  117. DebugFlag,
  118. VerbosityFlag,
  119. CodeFlag,
  120. CodeFileFlag,
  121. GasFlag,
  122. PriceFlag,
  123. ValueFlag,
  124. DumpFlag,
  125. InputFlag,
  126. MemProfileFlag,
  127. CPUProfileFlag,
  128. StatDumpFlag,
  129. GenesisFlag,
  130. MachineFlag,
  131. SenderFlag,
  132. ReceiverFlag,
  133. DisableMemoryFlag,
  134. DisableStackFlag,
  135. EVMInterpreterFlag,
  136. }
  137. app.Commands = []cli.Command{
  138. compileCommand,
  139. disasmCommand,
  140. runCommand,
  141. stateTestCommand,
  142. }
  143. }
  144. func main() {
  145. if err := app.Run(os.Args); err != nil {
  146. fmt.Fprintln(os.Stderr, err)
  147. os.Exit(1)
  148. }
  149. }