aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-08-06 00:08:52 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-08-06 00:08:52 +0800
commit80e5f507130a926ea62dde07c2b98d6f8a0ba3e2 (patch)
tree750fe404c14b6f5e8ef03a07cf3357787c6c9683 /cmd
parent98f4c936f25de27dbc90f36f2c1ffd1f23b114e9 (diff)
parent26f838796b8793f38268f3a8911ec2b71913153c (diff)
downloadgo-tangerine-80e5f507130a926ea62dde07c2b98d6f8a0ba3e2.tar
go-tangerine-80e5f507130a926ea62dde07c2b98d6f8a0ba3e2.tar.gz
go-tangerine-80e5f507130a926ea62dde07c2b98d6f8a0ba3e2.tar.bz2
go-tangerine-80e5f507130a926ea62dde07c2b98d6f8a0ba3e2.tar.lz
go-tangerine-80e5f507130a926ea62dde07c2b98d6f8a0ba3e2.tar.xz
go-tangerine-80e5f507130a926ea62dde07c2b98d6f8a0ba3e2.tar.zst
go-tangerine-80e5f507130a926ea62dde07c2b98d6f8a0ba3e2.zip
Merge branch 'develop'
Diffstat (limited to 'cmd')
-rw-r--r--cmd/LICENSE16
-rw-r--r--cmd/bootnode/main.go4
-rw-r--r--cmd/disasm/main.go4
-rw-r--r--cmd/ethtest/main.go18
-rw-r--r--cmd/evm/main.go116
-rw-r--r--cmd/geth/blocktestcmd.go4
-rw-r--r--cmd/geth/chaincmd.go4
-rw-r--r--cmd/geth/js.go23
-rw-r--r--cmd/geth/js_test.go13
-rw-r--r--cmd/geth/main.go45
-rw-r--r--cmd/geth/monitorcmd.go4
-rw-r--r--cmd/rlpdump/main.go4
-rw-r--r--cmd/utils/cmd.go52
-rw-r--r--cmd/utils/customflags.go4
-rw-r--r--cmd/utils/customflags_test.go4
-rw-r--r--cmd/utils/flags.go47
-rw-r--r--cmd/utils/legalese.go41
17 files changed, 291 insertions, 112 deletions
diff --git a/cmd/LICENSE b/cmd/LICENSE
deleted file mode 100644
index 00cdb415d..000000000
--- a/cmd/LICENSE
+++ /dev/null
@@ -1,16 +0,0 @@
-Copyright (c) 2013-2015, The go-ethereum Authors. All rights reserved.
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-MA 02110-1301 USA
diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go
index 397fa099c..0cad5321b 100644
--- a/cmd/bootnode/main.go
+++ b/cmd/bootnode/main.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// bootnode runs a bootstrap node for the Ethereum Discovery Protocol.
package main
diff --git a/cmd/disasm/main.go b/cmd/disasm/main.go
index 4bcd8608a..ba1295ba1 100644
--- a/cmd/disasm/main.go
+++ b/cmd/disasm/main.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// disasm is a pretty-printer for EVM bytecode.
package main
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go
index 61276b177..5429cab31 100644
--- a/cmd/ethtest/main.go
+++ b/cmd/ethtest/main.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// ethtest executes Ethereum JSON tests.
package main
@@ -35,7 +35,8 @@ var (
testExtension = ".json"
defaultTest = "all"
defaultDir = "."
- allTests = []string{"BlockTests", "StateTests", "TransactionTests", "VMTests"}
+ allTests = []string{"BlockTests", "StateTests", "TransactionTests", "VMTests", "RLPTests"}
+ testDirMapping = map[string]string{"BlockTests": "BlockchainTests"}
skipTests = []string{}
TestFlag = cli.StringFlag{
@@ -75,6 +76,8 @@ func runTestWithReader(test string, r io.Reader) error {
err = tests.RunTransactionTestsWithReader(r, skipTests)
case "vm", "vmtest", "vmtests":
err = tests.RunVmTestWithReader(r, skipTests)
+ case "rlp", "rlptest", "rlptests":
+ err = tests.RunRLPTestWithReader(r, skipTests)
default:
err = fmt.Errorf("Invalid test type specified: %v", test)
}
@@ -133,8 +136,13 @@ func runSuite(test, file string) {
var err error
var files []string
if test == defaultTest {
- files, err = getFiles(filepath.Join(file, curTest))
-
+ // check if we have an explicit directory mapping for the test
+ if _, ok := testDirMapping[curTest]; ok {
+ files, err = getFiles(filepath.Join(file, testDirMapping[curTest]))
+ } else {
+ // otherwise assume test name
+ files, err = getFiles(filepath.Join(file, curTest))
+ }
} else {
files, err = getFiles(file)
}
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
index 6420c83be..965994382 100644
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -8,89 +8,139 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// evm executes EVM code snippets.
package main
import (
- "flag"
"fmt"
- "log"
"math/big"
"os"
"runtime"
"time"
+ "github.com/codegangsta/cli"
+ "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"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"
)
var (
- code = flag.String("code", "", "evm code")
- loglevel = flag.Int("log", 4, "log level")
- gas = flag.String("gas", "1000000000", "gas amount")
- price = flag.String("price", "0", "gas price")
- value = flag.String("value", "0", "tx value")
- dump = flag.Bool("dump", false, "dump state after run")
- data = flag.String("data", "", "data")
+ app *cli.App
+ DebugFlag = cli.BoolFlag{
+ Name: "debug",
+ Usage: "output full trace logs",
+ }
+ CodeFlag = cli.StringFlag{
+ Name: "code",
+ Usage: "EVM code",
+ }
+ GasFlag = cli.StringFlag{
+ Name: "gas",
+ Usage: "gas limit for the evm",
+ Value: "10000000000",
+ }
+ PriceFlag = cli.StringFlag{
+ Name: "price",
+ Usage: "price set for the evm",
+ Value: "0",
+ }
+ ValueFlag = cli.StringFlag{
+ Name: "value",
+ Usage: "value set for the evm",
+ Value: "0",
+ }
+ DumpFlag = cli.BoolFlag{
+ Name: "dump",
+ Usage: "dumps the state after the run",
+ }
+ InputFlag = cli.StringFlag{
+ Name: "input",
+ Usage: "input for the EVM",
+ }
+ SysStatFlag = cli.BoolFlag{
+ Name: "sysstat",
+ Usage: "display system stats",
+ }
)
-func perr(v ...interface{}) {
- fmt.Println(v...)
- //os.Exit(1)
+func init() {
+ app = utils.NewApp("0.2", "the evm command line interface")
+ app.Flags = []cli.Flag{
+ DebugFlag,
+ SysStatFlag,
+ CodeFlag,
+ GasFlag,
+ PriceFlag,
+ ValueFlag,
+ DumpFlag,
+ InputFlag,
+ }
+ app.Action = run
}
-func main() {
- flag.Parse()
-
- logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, log.LstdFlags, logger.LogLevel(*loglevel)))
+func run(ctx *cli.Context) {
+ vm.Debug = ctx.GlobalBool(DebugFlag.Name)
- vm.Debug = true
db, _ := ethdb.NewMemDatabase()
statedb := state.New(common.Hash{}, db)
sender := statedb.CreateAccount(common.StringToAddress("sender"))
receiver := statedb.CreateAccount(common.StringToAddress("receiver"))
- receiver.SetCode(common.Hex2Bytes(*code))
+ receiver.SetCode(common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name)))
- vmenv := NewEnv(statedb, common.StringToAddress("evmuser"), common.Big(*value))
+ vmenv := NewEnv(statedb, common.StringToAddress("evmuser"), common.Big(ctx.GlobalString(ValueFlag.Name)))
tstart := time.Now()
+ ret, e := vmenv.Call(
+ sender,
+ receiver.Address(),
+ common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)),
+ common.Big(ctx.GlobalString(GasFlag.Name)),
+ common.Big(ctx.GlobalString(PriceFlag.Name)),
+ common.Big(ctx.GlobalString(ValueFlag.Name)),
+ )
+ vmdone := time.Since(tstart)
- ret, e := vmenv.Call(sender, receiver.Address(), common.Hex2Bytes(*data), common.Big(*gas), common.Big(*price), common.Big(*value))
-
- logger.Flush()
if e != nil {
- perr(e)
+ fmt.Println(e)
+ os.Exit(1)
}
- if *dump {
+ if ctx.GlobalBool(DumpFlag.Name) {
fmt.Println(string(statedb.Dump()))
}
-
vm.StdErrFormat(vmenv.StructLogs())
- var mem runtime.MemStats
- runtime.ReadMemStats(&mem)
- fmt.Printf("vm took %v\n", time.Since(tstart))
- fmt.Printf(`alloc: %d
+ if ctx.GlobalBool(SysStatFlag.Name) {
+ var mem runtime.MemStats
+ runtime.ReadMemStats(&mem)
+ fmt.Printf("vm took %v\n", vmdone)
+ fmt.Printf(`alloc: %d
tot alloc: %d
no. malloc: %d
heap alloc: %d
heap objs: %d
num gc: %d
`, mem.Alloc, mem.TotalAlloc, mem.Mallocs, mem.HeapAlloc, mem.HeapObjects, mem.NumGC)
+ }
- fmt.Printf("%x\n", ret)
+ fmt.Printf("OUT: 0x%x\n", ret)
+}
+
+func main() {
+ if err := app.Run(os.Args); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
}
type VMEnv struct {
diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go
index 494a4d474..4eff82e3d 100644
--- a/cmd/geth/blocktestcmd.go
+++ b/cmd/geth/blocktestcmd.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package main
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index b23a74809..2d8eb15c2 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package main
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index cc4c14c2e..bf56423ec 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -23,6 +23,7 @@ import (
"os"
"os/signal"
"path/filepath"
+ "regexp"
"strings"
"sort"
@@ -44,6 +45,10 @@ import (
"github.com/robertkrimen/otto"
)
+var passwordRegexp = regexp.MustCompile("personal.[nu]")
+
+const passwordRepl = ""
+
type prompter interface {
AppendHistory(string)
Prompt(p string) (string, error)
@@ -413,8 +418,10 @@ func (self *jsre) interactive() {
str += input + "\n"
self.setIndent()
if indentCount <= 0 {
- hist := str[:len(str)-1]
- self.AppendHistory(hist)
+ hist := hidepassword(str[:len(str)-1])
+ if len(hist) > 0 {
+ self.AppendHistory(hist)
+ }
self.parseInput(str)
str = ""
}
@@ -422,6 +429,14 @@ func (self *jsre) interactive() {
}
}
+func hidepassword(input string) string {
+ if passwordRegexp.MatchString(input) {
+ return passwordRepl
+ } else {
+ return input
+ }
+}
+
func (self *jsre) withHistory(op func(*os.File)) {
datadir := common.DefaultDataDir()
if self.ethereum != nil {
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index db2c5ca03..67c36dfe7 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -37,6 +37,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/comms"
)
@@ -89,9 +90,9 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth
t.Fatal(err)
}
- // set up mock genesis with balance on the testAddress
- core.GenesisAccounts = []byte(testGenesis)
+ db, _ := ethdb.NewMemDatabase()
+ core.WriteGenesisBlockForTesting(db, common.HexToAddress(testAddress), common.String2Big(testBalance))
ks := crypto.NewKeyStorePlain(filepath.Join(tmp, "keystore"))
am := accounts.NewManager(ks)
conf := &eth.Config{
@@ -102,6 +103,7 @@ func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth
Name: "test",
SolcPath: testSolcPath,
PowTest: true,
+ NewDB: func(path string) (common.Database, error) { return db, nil },
}
if config != nil {
config(conf)
@@ -157,7 +159,7 @@ func TestAccounts(t *testing.T) {
defer os.RemoveAll(tmp)
checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`"]`)
- checkEvalJSON(t, repl, `eth.coinbase`, `null`)
+ checkEvalJSON(t, repl, `eth.coinbase`, `"`+testAddress+`"`)
val, err := repl.re.Run(`personal.newAccount("password")`)
if err != nil {
t.Errorf("expected no error, got %v", err)
@@ -168,6 +170,7 @@ func TestAccounts(t *testing.T) {
}
checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`","`+addr+`"]`)
+
}
func TestBlockChain(t *testing.T) {
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 3805f3386..00dd8f753 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// geth is the official command-line client for Ethereum.
package main
@@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
+ "github.com/ethereum/go-ethereum/fdtrack"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/metrics"
@@ -49,7 +50,7 @@ import (
const (
ClientIdentifier = "Geth"
- Version = "0.9.38"
+ Version = "1.0.0"
)
var (
@@ -276,10 +277,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.IdentityFlag,
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
- utils.GenesisNonceFlag,
+ utils.GenesisFileFlag,
utils.BootnodesFlag,
utils.DataDirFlag,
utils.BlockchainVersionFlag,
+ utils.OlympicFlag,
+ utils.CacheFlag,
utils.JSpathFlag,
utils.ListenPortFlag,
utils.MaxPeersFlag,
@@ -344,6 +347,11 @@ func main() {
}
func run(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+ if ctx.GlobalBool(utils.OlympicFlag.Name) {
+ utils.InitOlympic()
+ }
+
cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
ethereum, err := eth.New(cfg)
if err != nil {
@@ -356,6 +364,8 @@ func run(ctx *cli.Context) {
}
func attach(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
// Wrap the standard output with a colorified stream (windows)
if isatty.IsTerminal(os.Stdout.Fd()) {
if pr, pw, err := os.Pipe(); err == nil {
@@ -394,6 +404,8 @@ func attach(ctx *cli.Context) {
}
func console(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
// Wrap the standard output with a colorified stream (windows)
if isatty.IsTerminal(os.Stdout.Fd()) {
if pr, pw, err := os.Pipe(); err == nil {
@@ -432,6 +444,8 @@ func console(ctx *cli.Context) {
}
func execJSFiles(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
ethereum, err := eth.New(cfg)
if err != nil {
@@ -457,6 +471,8 @@ func execJSFiles(ctx *cli.Context) {
}
func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
var err error
addrHex, err = utils.ParamToAddress(addr, am)
if err == nil {
@@ -480,13 +496,17 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (
}
func blockRecovery(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
arg := ctx.Args().First()
if len(ctx.Args()) < 1 && len(arg) > 0 {
glog.Fatal("recover requires block number or hash")
}
cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
- blockDb, err := ethdb.NewLDBDatabase(filepath.Join(cfg.DataDir, "blockchain"))
+ utils.CheckLegalese(cfg.DataDir)
+
+ blockDb, err := ethdb.NewLDBDatabase(filepath.Join(cfg.DataDir, "blockchain"), cfg.DatabaseCache)
if err != nil {
glog.Fatalln("could not open db:", err)
}
@@ -513,6 +533,9 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
// Start Ethereum itself
utils.StartEthereum(eth)
+ // Start logging file descriptor stats.
+ fdtrack.Start()
+
am := eth.AccountManager()
account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
accounts := strings.Split(account, " ")
@@ -543,6 +566,8 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
}
func accountList(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
am := utils.MakeAccountManager(ctx)
accts, err := am.Accounts()
if err != nil {
@@ -591,6 +616,8 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (pas
}
func accountCreate(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
am := utils.MakeAccountManager(ctx)
passphrase := getPassPhrase(ctx, "Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0)
acct, err := am.NewAccount(passphrase)
@@ -601,6 +628,8 @@ func accountCreate(ctx *cli.Context) {
}
func accountUpdate(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
am := utils.MakeAccountManager(ctx)
arg := ctx.Args().First()
if len(arg) == 0 {
@@ -616,6 +645,8 @@ func accountUpdate(ctx *cli.Context) {
}
func importWallet(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
keyfile := ctx.Args().First()
if len(keyfile) == 0 {
utils.Fatalf("keyfile must be given as argument")
@@ -636,6 +667,8 @@ func importWallet(ctx *cli.Context) {
}
func accountImport(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
keyfile := ctx.Args().First()
if len(keyfile) == 0 {
utils.Fatalf("keyfile must be given as argument")
@@ -650,6 +683,8 @@ func accountImport(ctx *cli.Context) {
}
func makedag(ctx *cli.Context) {
+ utils.CheckLegalese(ctx.GlobalString(utils.DataDirFlag.Name))
+
args := ctx.Args()
wrongArgs := func() {
utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`)
diff --git a/cmd/geth/monitorcmd.go b/cmd/geth/monitorcmd.go
index affe3b75d..a7c099532 100644
--- a/cmd/geth/monitorcmd.go
+++ b/cmd/geth/monitorcmd.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package main
diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go
index 2f74c073d..10eea1fde 100644
--- a/cmd/rlpdump/main.go
+++ b/cmd/rlpdump/main.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// rlpdump is a pretty-printer for RLP data.
package main
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 2949d2470..f8f7f6376 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// Package utils contains internal helper functions for go-ethereum commands.
package utils
@@ -21,6 +21,7 @@ import (
"bufio"
"fmt"
"io"
+ "math/big"
"os"
"os/signal"
"regexp"
@@ -32,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/peterh/liner"
)
@@ -58,15 +60,16 @@ func PromptConfirm(prompt string) (bool, error) {
)
prompt = prompt + " [y/N] "
- if liner.TerminalSupported() {
- lr := liner.NewLiner()
- defer lr.Close()
- input, err = lr.Prompt(prompt)
- } else {
- fmt.Print(prompt)
- input, err = bufio.NewReader(os.Stdin).ReadString('\n')
- fmt.Println()
- }
+ // if liner.TerminalSupported() {
+ // fmt.Println("term")
+ // lr := liner.NewLiner()
+ // defer lr.Close()
+ // input, err = lr.Prompt(prompt)
+ // } else {
+ fmt.Print(prompt)
+ input, err = bufio.NewReader(os.Stdin).ReadString('\n')
+ fmt.Println()
+ // }
if len(input) > 0 && strings.ToUpper(input[:1]) == "Y" {
return true, nil
@@ -92,12 +95,12 @@ func PromptPassword(prompt string, warnTerm bool) (string, error) {
return input, err
}
-func initDataDir(Datadir string) {
- _, err := os.Stat(Datadir)
- if err != nil {
- if os.IsNotExist(err) {
- fmt.Printf("Data directory '%s' doesn't exist, creating it\n", Datadir)
- os.Mkdir(Datadir, 0777)
+func CheckLegalese(datadir string) {
+ // check "first run"
+ if !common.FileExist(datadir) {
+ r, _ := PromptConfirm(legalese)
+ if !r {
+ Fatalf("Must accept to continue. Shutting down...\n")
}
}
}
@@ -142,6 +145,15 @@ func StartEthereum(ethereum *eth.Ethereum) {
}()
}
+func InitOlympic() {
+ params.DurationLimit = big.NewInt(8)
+ params.GenesisGasLimit = big.NewInt(3141592)
+ params.MinGasLimit = big.NewInt(125000)
+ params.MaximumExtraDataSize = big.NewInt(1024)
+ NetworkIdFlag.Value = 0
+ core.BlockReward = big.NewInt(1.5e+18)
+}
+
func FormatTransactionData(data string) []byte {
d := common.StringToByteFunc(data, func(s string) (ret []byte) {
slice := regexp.MustCompile("\\n|\\s").Split(s, 1000000000)
@@ -202,6 +214,11 @@ func ImportChain(chain *core.ChainManager, fn string) error {
} else if err != nil {
return fmt.Errorf("at block %d: %v", n, err)
}
+ // don't import first block
+ if b.NumberU64() == 0 {
+ i--
+ continue
+ }
blocks[i] = &b
n++
}
@@ -217,6 +234,7 @@ func ImportChain(chain *core.ChainManager, fn string) error {
batch, blocks[0].Hash().Bytes()[:4], blocks[i-1].Hash().Bytes()[:4])
continue
}
+
if _, err := chain.InsertChain(blocks[:i]); err != nil {
return fmt.Errorf("invalid block %d: %v", n, err)
}
diff --git a/cmd/utils/customflags.go b/cmd/utils/customflags.go
index 6aeec448c..e7efed4e3 100644
--- a/cmd/utils/customflags.go
+++ b/cmd/utils/customflags.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package utils
diff --git a/cmd/utils/customflags_test.go b/cmd/utils/customflags_test.go
index 726d1ab47..0fb0af63b 100644
--- a/cmd/utils/customflags_test.go
+++ b/cmd/utils/customflags_test.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package utils
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 903c97e71..815d48124 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -8,11 +8,11 @@
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
package utils
@@ -114,6 +114,10 @@ var (
Usage: "Sets the genesis nonce",
Value: 42,
}
+ GenesisFileFlag = cli.StringFlag{
+ Name: "genesis",
+ Usage: "Inserts/Overwrites the genesis block (json format)",
+ }
IdentityFlag = cli.StringFlag{
Name: "identity",
Usage: "Custom node name",
@@ -122,6 +126,15 @@ var (
Name: "natspec",
Usage: "Enable NatSpec confirmation notice",
}
+ CacheFlag = cli.IntFlag{
+ Name: "cache",
+ Usage: "Megabytes of memory allocated to internal caching",
+ Value: 0,
+ }
+ OlympicFlag = cli.BoolFlag{
+ Name: "olympic",
+ Usage: "Use olympic style protocol",
+ }
// miner settings
MinerThreadsFlag = cli.IntFlag{
@@ -145,7 +158,7 @@ var (
GasPriceFlag = cli.StringFlag{
Name: "gasprice",
Usage: "Sets the minimal gasprice when mining transactions",
- Value: new(big.Int).Mul(big.NewInt(1), common.Szabo).String(),
+ Value: new(big.Int).Mul(big.NewInt(50), common.Shannon).String(),
}
UnlockedAccountFlag = cli.StringFlag{
@@ -305,12 +318,12 @@ var (
GpoMinGasPriceFlag = cli.StringFlag{
Name: "gpomin",
Usage: "Minimum suggested gas price",
- Value: new(big.Int).Mul(big.NewInt(1), common.Szabo).String(),
+ Value: new(big.Int).Mul(big.NewInt(50), common.Shannon).String(),
}
GpoMaxGasPriceFlag = cli.StringFlag{
Name: "gpomax",
Usage: "Maximum suggested gas price",
- Value: new(big.Int).Mul(big.NewInt(100), common.Szabo).String(),
+ Value: new(big.Int).Mul(big.NewInt(500), common.Shannon).String(),
}
GpoFullBlockRatioFlag = cli.IntFlag{
Name: "gpofull",
@@ -378,7 +391,9 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
Name: common.MakeName(clientID, version),
DataDir: ctx.GlobalString(DataDirFlag.Name),
GenesisNonce: ctx.GlobalInt(GenesisNonceFlag.Name),
+ GenesisFile: ctx.GlobalString(GenesisFileFlag.Name),
BlockChainVersion: ctx.GlobalInt(BlockchainVersionFlag.Name),
+ DatabaseCache: ctx.GlobalInt(CacheFlag.Name),
SkipBcVersionCheck: false,
NetworkId: ctx.GlobalInt(NetworkIdFlag.Name),
LogFile: ctx.GlobalString(LogFileFlag.Name),
@@ -391,6 +406,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
MaxPeers: ctx.GlobalInt(MaxPeersFlag.Name),
MaxPendingPeers: ctx.GlobalInt(MaxPendingPeersFlag.Name),
Port: ctx.GlobalString(ListenPortFlag.Name),
+ Olympic: ctx.GlobalBool(OlympicFlag.Name),
NAT: MakeNAT(ctx),
NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name),
Discovery: !ctx.GlobalBool(NoDiscoverFlag.Name),
@@ -420,22 +436,31 @@ func SetupLogger(ctx *cli.Context) {
// MakeChain creates a chain manager from set command line flags.
func MakeChain(ctx *cli.Context) (chain *core.ChainManager, blockDB, stateDB, extraDB common.Database) {
- dd := ctx.GlobalString(DataDirFlag.Name)
+ datadir := ctx.GlobalString(DataDirFlag.Name)
+ cache := ctx.GlobalInt(CacheFlag.Name)
+
var err error
- if blockDB, err = ethdb.NewLDBDatabase(filepath.Join(dd, "blockchain")); err != nil {
+ if blockDB, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "blockchain"), cache); err != nil {
Fatalf("Could not open database: %v", err)
}
- if stateDB, err = ethdb.NewLDBDatabase(filepath.Join(dd, "state")); err != nil {
+ if stateDB, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "state"), cache); err != nil {
Fatalf("Could not open database: %v", err)
}
- if extraDB, err = ethdb.NewLDBDatabase(filepath.Join(dd, "extra")); err != nil {
+ if extraDB, err = ethdb.NewLDBDatabase(filepath.Join(datadir, "extra"), cache); err != nil {
Fatalf("Could not open database: %v", err)
}
+ if ctx.GlobalBool(OlympicFlag.Name) {
+ InitOlympic()
+ _, err := core.WriteTestNetGenesisBlock(stateDB, blockDB, 42)
+ if err != nil {
+ glog.Fatalln(err)
+ }
+ }
eventMux := new(event.TypeMux)
pow := ethash.New()
- genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB)
- chain, err = core.NewChainManager(genesis, blockDB, stateDB, extraDB, pow, eventMux)
+ //genesis := core.GenesisBlock(uint64(ctx.GlobalInt(GenesisNonceFlag.Name)), blockDB)
+ chain, err = core.NewChainManager(blockDB, stateDB, extraDB, pow, eventMux)
if err != nil {
Fatalf("Could not start chainmanager: %v", err)
}
diff --git a/cmd/utils/legalese.go b/cmd/utils/legalese.go
new file mode 100644
index 000000000..09e687c17
--- /dev/null
+++ b/cmd/utils/legalese.go
@@ -0,0 +1,41 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of go-ethereum.
+//
+// go-ethereum is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// go-ethereum is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+
+package utils
+
+const (
+ legalese = `
+=======================================
+Disclaimer of Liabilites and Warranties
+=======================================
+
+THE USER EXPRESSLY KNOWS AND AGREES THAT THE USER IS USING THE ETHEREUM PLATFORM AT THE USER’S SOLE
+RISK. THE USER REPRESENTS THAT THE USER HAS AN ADEQUATE UNDERSTANDING OF THE RISKS, USAGE AND
+INTRICACIES OF CRYPTOGRAPHIC TOKENS AND BLOCKCHAIN-BASED OPEN SOURCE SOFTWARE, ETH PLATFORM AND ETH.
+THE USER ACKNOWLEDGES AND AGREES THAT, TO THE FULLEST EXTENT PERMITTED BY ANY APPLICABLE LAW, THE
+DISCLAIMERS OF LIABILITY CONTAINED HEREIN APPLY TO ANY AND ALL DAMAGES OR INJURY WHATSOEVER CAUSED
+BY OR RELATED TO RISKS OF, USE OF, OR INABILITY TO USE, ETH OR THE ETHEREUM PLATFORM UNDER ANY CAUSE
+OR ACTION WHATSOEVER OF ANY KIND IN ANY JURISDICTION, INCLUDING, WITHOUT LIMITATION, ACTIONS FOR
+BREACH OF WARRANTY, BREACH OF CONTRACT OR TORT (INCLUDING NEGLIGENCE) AND THAT NEITHER STIFTUNG
+ETHEREUM NOR ETHEREUM TEAM SHALL BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR
+CONSEQUENTIAL DAMAGES, INCLUDING FOR LOSS OF PROFITS, GOODWILL OR DATA. SOME JURISDICTIONS DO NOT
+ALLOW THE EXCLUSION OF CERTAIN WARRANTIES OR THE LIMITATION OR EXCLUSION OF LIABILITY FOR CERTAIN
+TYPES OF DAMAGES. THEREFORE, SOME OF THE ABOVE LIMITATIONS IN THIS SECTION MAY NOT APPLY TO A USER.
+IN PARTICULAR, NOTHING IN THESE TERMS SHALL AFFECT THE STATUTORY RIGHTS OF ANY USER OR EXCLUDE
+INJURY ARISING FROM ANY WILLFUL MISCONDUCT OR FRAUD OF STIFTUNG ETHEREUM.
+
+Do you accept this agreement?`
+)