main.go 3.4 KB

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