diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/evm/main.go | 29 | ||||
-rw-r--r-- | cmd/geth/main.go | 34 | ||||
-rw-r--r-- | cmd/utils/customflags.go | 9 | ||||
-rw-r--r-- | cmd/utils/customflags_test.go | 5 | ||||
-rw-r--r-- | cmd/utils/flags.go | 33 |
5 files changed, 88 insertions, 22 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go index 965994382..be6546c95 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -32,6 +32,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" + "github.com/ethereum/go-ethereum/logger/glog" ) var ( @@ -40,6 +41,14 @@ var ( Name: "debug", Usage: "output full trace logs", } + ForceJitFlag = cli.BoolFlag{ + Name: "forcejit", + Usage: "forces jit compilation", + } + DisableJitFlag = cli.BoolFlag{ + Name: "nojit", + Usage: "disabled jit compilation", + } CodeFlag = cli.StringFlag{ Name: "code", Usage: "EVM code", @@ -77,6 +86,8 @@ func init() { app = utils.NewApp("0.2", "the evm command line interface") app.Flags = []cli.Flag{ DebugFlag, + ForceJitFlag, + DisableJitFlag, SysStatFlag, CodeFlag, GasFlag, @@ -90,6 +101,10 @@ func init() { func run(ctx *cli.Context) { vm.Debug = ctx.GlobalBool(DebugFlag.Name) + vm.ForceJit = ctx.GlobalBool(ForceJitFlag.Name) + vm.DisableJit = ctx.GlobalBool(DisableJitFlag.Name) + + glog.SetToStderr(true) db, _ := ethdb.NewMemDatabase() statedb := state.New(common.Hash{}, db) @@ -110,11 +125,6 @@ func run(ctx *cli.Context) { ) vmdone := time.Since(tstart) - if e != nil { - fmt.Println(e) - os.Exit(1) - } - if ctx.GlobalBool(DumpFlag.Name) { fmt.Println(string(statedb.Dump())) } @@ -133,7 +143,11 @@ num gc: %d `, mem.Alloc, mem.TotalAlloc, mem.Mallocs, mem.HeapAlloc, mem.HeapObjects, mem.NumGC) } - fmt.Printf("OUT: 0x%x\n", ret) + fmt.Printf("OUT: 0x%x", ret) + if e != nil { + fmt.Printf(" error: %v", e) + } + fmt.Println() } func main() { @@ -192,6 +206,9 @@ func (self *VMEnv) StructLogs() []vm.StructLog { func (self *VMEnv) AddLog(log *state.Log) { self.state.AddLog(log) } +func (self *VMEnv) CanTransfer(from vm.Account, balance *big.Int) bool { + return from.Balance().Cmp(balance) >= 0 +} func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error { return vm.Transfer(from, to, amount) } diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 74f4e90c3..895e55b44 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -42,6 +42,8 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc/codec" "github.com/ethereum/go-ethereum/rpc/comms" "github.com/mattn/go-colorable" @@ -49,8 +51,11 @@ import ( ) const ( - ClientIdentifier = "Geth" + ClientIdentifier = "Geth " Version = "1.0.1" + VersionMajor = 1 + VersionMinor = 0 + VersionPatch = 1 ) var ( @@ -307,6 +312,9 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.ExecFlag, utils.WhisperEnabledFlag, utils.VMDebugFlag, + utils.VMForceJitFlag, + utils.VMJitCacheFlag, + utils.VMEnableJitFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, utils.VerbosityFlag, @@ -328,6 +336,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso } app.Before = func(ctx *cli.Context) error { utils.SetupLogger(ctx) + utils.SetupVM(ctx) if ctx.GlobalBool(utils.PProfEanbledFlag.Name) { utils.StartPProf(ctx) } @@ -346,6 +355,27 @@ func main() { } } +func makeDefaultExtra() []byte { + var clientInfo = struct { + Version uint + Name string + GoVersion string + Os string + }{uint(VersionMajor<<16 | VersionMinor<<8 | VersionPatch), ClientIdentifier, runtime.Version(), runtime.GOOS} + extra, err := rlp.EncodeToBytes(clientInfo) + if err != nil { + glog.V(logger.Warn).Infoln("error setting canonical miner information:", err) + } + + if uint64(len(extra)) > params.MaximumExtraDataSize.Uint64() { + glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize) + glog.V(logger.Debug).Infof("extra: %x\n", extra) + return nil + } + + return extra +} + func run(ctx *cli.Context) { utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name)) if ctx.GlobalBool(utils.OlympicFlag.Name) { @@ -353,6 +383,8 @@ func run(ctx *cli.Context) { } cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) + cfg.ExtraData = makeDefaultExtra() + ethereum, err := eth.New(cfg) if err != nil { utils.Fatalf("%v", err) diff --git a/cmd/utils/customflags.go b/cmd/utils/customflags.go index e7efed4e3..4450065c1 100644 --- a/cmd/utils/customflags.go +++ b/cmd/utils/customflags.go @@ -21,7 +21,7 @@ import ( "fmt" "os" "os/user" - "path/filepath" + "path" "strings" "github.com/codegangsta/cli" @@ -138,11 +138,8 @@ func (self *DirectoryFlag) Set(value string) { func expandPath(p string) string { if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") { if user, err := user.Current(); err == nil { - if err == nil { - p = strings.Replace(p, "~", user.HomeDir, 1) - } + p = user.HomeDir + p[1:] } } - - return filepath.Clean(os.ExpandEnv(p)) + return path.Clean(os.ExpandEnv(p)) } diff --git a/cmd/utils/customflags_test.go b/cmd/utils/customflags_test.go index 0fb0af63b..de39ca36a 100644 --- a/cmd/utils/customflags_test.go +++ b/cmd/utils/customflags_test.go @@ -23,18 +23,15 @@ import ( ) func TestPathExpansion(t *testing.T) { - user, _ := user.Current() - tests := map[string]string{ "/home/someuser/tmp": "/home/someuser/tmp", "~/tmp": user.HomeDir + "/tmp", + "~thisOtherUser/b/": "~thisOtherUser/b", "$DDDXXX/a/b": "/tmp/a/b", "/a/b/": "/a/b", } - os.Setenv("DDDXXX", "/tmp") - for test, expected := range tests { got := expandPath(test) if got != expected { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 815d48124..e7b30cfa0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -27,6 +27,7 @@ import ( "runtime" "strconv" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/metrics" "github.com/codegangsta/cli" @@ -172,6 +173,25 @@ var ( Value: "", } + // vm flags + VMDebugFlag = cli.BoolFlag{ + Name: "vmdebug", + Usage: "Virtual Machine debug output", + } + VMForceJitFlag = cli.BoolFlag{ + Name: "forcejit", + Usage: "Force the JIT VM to take precedence", + } + VMJitCacheFlag = cli.IntFlag{ + Name: "jitcache", + Usage: "Amount of cached JIT VM programs", + Value: 64, + } + VMEnableJitFlag = cli.BoolFlag{ + Name: "jitvm", + Usage: "Enable the JIT VM", + } + // logging and debug settings LogFileFlag = cli.StringFlag{ Name: "logfile", @@ -196,10 +216,6 @@ var ( Usage: "The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the \".go\" suffix) or \"glob\" pattern and N is a log verbosity level.", Value: glog.GetVModule(), } - VMDebugFlag = cli.BoolFlag{ - Name: "vmdebug", - Usage: "Virtual Machine debug output", - } BacktraceAtFlag = cli.GenericFlag{ Name: "backtrace_at", Usage: "If set to a file and line number (e.g., \"block.go:271\") holding a logging statement, a stack trace will be logged", @@ -434,6 +450,13 @@ func SetupLogger(ctx *cli.Context) { glog.SetLogDir(ctx.GlobalString(LogFileFlag.Name)) } +// SetupVM configured the VM package's global settings +func SetupVM(ctx *cli.Context) { + vm.DisableJit = !ctx.GlobalBool(VMEnableJitFlag.Name) + vm.ForceJit = ctx.GlobalBool(VMForceJitFlag.Name) + vm.SetJITCacheSize(ctx.GlobalInt(VMJitCacheFlag.Name)) +} + // MakeChain creates a chain manager from set command line flags. func MakeChain(ctx *cli.Context) (chain *core.ChainManager, blockDB, stateDB, extraDB common.Database) { datadir := ctx.GlobalString(DataDirFlag.Name) @@ -478,7 +501,7 @@ func MakeAccountManager(ctx *cli.Context) *accounts.Manager { } func IpcSocketPath(ctx *cli.Context) (ipcpath string) { - if common.IsWindows() { + if runtime.GOOS == "windows" { ipcpath = common.DefaultIpcPath() if ctx.GlobalIsSet(IPCPathFlag.Name) { ipcpath = ctx.GlobalString(IPCPathFlag.Name) |