From b047f05e7e9d941348cba960f8cc16a9874340d0 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 30 Jun 2015 02:30:26 +0200 Subject: cmd/geth: version bump 0.9.35 --- cmd/geth/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index f4d2f94fe..c46343a60 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -48,7 +48,7 @@ import ( const ( ClientIdentifier = "Geth" - Version = "0.9.34" + Version = "0.9.35" ) var ( -- cgit v1.2.3 From 393d675690923207746ac800568faacae723f251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 26 Jun 2015 16:54:27 +0300 Subject: cmd/geth, cmd/utils, eth: advertise both eth/60 and eth/61 --- cmd/geth/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index c46343a60..a7b769270 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -261,7 +261,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.ExecFlag, utils.WhisperEnabledFlag, utils.VMDebugFlag, - utils.ProtocolVersionFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, utils.VerbosityFlag, @@ -598,7 +597,7 @@ func version(c *cli.Context) { if gitCommit != "" { fmt.Println("Git Commit:", gitCommit) } - fmt.Println("Protocol Version:", c.GlobalInt(utils.ProtocolVersionFlag.Name)) + fmt.Println("Protocol Versions:", eth.ProtocolVersions) fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name)) fmt.Println("Go Version:", runtime.Version()) fmt.Println("OS:", runtime.GOOS) -- cgit v1.2.3 From 29ab1fa8a50db8aa16c5d707f1cab7dc201a4053 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Wed, 1 Jul 2015 00:52:44 +0200 Subject: core, cmd/geth: recover by number --- cmd/geth/main.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index c46343a60..a7d3a73ef 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -39,6 +39,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rpc/codec" "github.com/ethereum/go-ethereum/rpc/comms" @@ -68,6 +69,15 @@ func init() { app.Action = run app.HideVersion = true // we have a command to print the version app.Commands = []cli.Command{ + { + Action: blockRecovery, + Name: "recover", + Usage: "attempts to recover a corrupted database by setting a new block head by number", + Description: ` +The recover commands will attempt to read out the last +block based on that. +`, + }, blocktestCommand, importCommand, exportCommand, @@ -439,6 +449,20 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass return } +func blockRecovery(ctx *cli.Context) { + num := ctx.Args().First() + if len(ctx.Args()) < 1 { + glog.Fatal("recover requires block number") + } + + cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) + ethereum, err := eth.New(cfg) + if err != nil { + utils.Fatalf("%v", err) + } + ethereum.ChainManager().Recover(common.String2Big(num).Uint64()) +} + func startEth(ctx *cli.Context, eth *eth.Ethereum) { // Start Ethereum itself -- cgit v1.2.3 From 70d5d791cc695cff3b3448a1b4b47816a8bbd83f Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Wed, 1 Jul 2015 16:15:02 +0200 Subject: core, cmd/geth: improved recover functionality `geth recover` now accepts both hashes and numbers using "#" and no longer requires the ethereum instance. --- cmd/geth/main.go | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index a7d3a73ef..645f51b9a 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -37,7 +37,10 @@ import ( "github.com/ethereum/go-ethereum/accounts" "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/types" "github.com/ethereum/go-ethereum/eth" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" @@ -72,10 +75,13 @@ func init() { { Action: blockRecovery, Name: "recover", - Usage: "attempts to recover a corrupted database by setting a new block head by number", + Usage: "attempts to recover a corrupted database by setting a new block by number or hash. See help recover.", Description: ` The recover commands will attempt to read out the last block based on that. + +recover #number recovers by number +recover recovers by hash `, }, blocktestCommand, @@ -450,17 +456,33 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass } func blockRecovery(ctx *cli.Context) { - num := ctx.Args().First() - if len(ctx.Args()) < 1 { - glog.Fatal("recover requires block number") + 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) - ethereum, err := eth.New(cfg) + blockDb, err := ethdb.NewLDBDatabase(filepath.Join(cfg.DataDir, "blockchain")) if err != nil { - utils.Fatalf("%v", err) + glog.Fatalln("could not open db:", err) + } + + var block *types.Block + if arg[0] == '#' { + block = core.GetBlockByNumber(blockDb, common.String2Big(arg[1:]).Uint64()) + } else { + block = core.GetBlockByHash(blockDb, common.HexToHash(arg)) + } + + if block == nil { + glog.Fatalln("block not found. Recovery failed") + } + + err = core.WriteHead(blockDb, block) + if err != nil { + glog.Fatalln("block write err", err) } - ethereum.ChainManager().Recover(common.String2Big(num).Uint64()) + glog.Infof("Recovery succesful. New HEAD %x\n", block.Hash()) } func startEth(ctx *cli.Context, eth *eth.Ethereum) { -- cgit v1.2.3 From fc2e33c594449e38b90bad2bd7b5c50f03b7f69d Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 18 Jun 2015 16:20:00 +0100 Subject: unlock multiple passes and obsolete primary * multiple passwords allowed in password file * split on "\n", sideeffect: chop trailing slashes. fixes common mistake <(echo 'pass') * remove accounts.Primary method * do not fall back to primary account for mining --- cmd/geth/js_test.go | 2 +- cmd/geth/main.go | 38 ++++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 17 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index cfbe26bee..fc2444a7b 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -140,7 +140,7 @@ func TestAccounts(t *testing.T) { defer os.RemoveAll(tmp) checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`"]`) - checkEvalJSON(t, repl, `eth.coinbase`, `"`+testAddress+`"`) + checkEvalJSON(t, repl, `eth.coinbase`, `"`+common.Address{}.Hex()+`"`) val, err := repl.re.Run(`personal.newAccount("password")`) if err != nil { diff --git a/cmd/geth/main.go b/cmd/geth/main.go index be40d5137..b20c6d85d 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -153,9 +153,12 @@ Note that exporting your key in unencrypted format is NOT supported. Keys are stored under /keys. It is safe to transfer the entire directory or the individual keys therein -between ethereum nodes. +between ethereum nodes by simply copying. Make sure you backup your keys regularly. +In order to use your account to send transactions, you need to unlock them using the +'--unlock' option. The argument is a comma + And finally. DO NOT FORGET YOUR PASSWORD. `, Subcommands: []cli.Command{ @@ -430,7 +433,7 @@ func execJSFiles(ctx *cli.Context) { ethereum.WaitForShutdown() } -func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (passphrase string) { +func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string, i int) { var err error // Load startup keys. XXX we are going to need a different format @@ -441,7 +444,7 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass attempts := 3 for tries := 0; tries < attempts; tries++ { msg := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", account, tries+1, attempts) - passphrase = getPassPhrase(ctx, msg, false) + passphrase := getPassPhrase(ctx, msg, false, i) err = am.Unlock(common.HexToAddress(account), passphrase) if err == nil { break @@ -451,7 +454,6 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass utils.Fatalf("Unlock account failed '%v'", err) } fmt.Printf("Account '%s' unlocked.\n", account) - return } func blockRecovery(ctx *cli.Context) { @@ -492,16 +494,12 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) { account := ctx.GlobalString(utils.UnlockedAccountFlag.Name) accounts := strings.Split(account, " ") - for _, account := range accounts { + for i, account := range accounts { if len(account) > 0 { if account == "primary" { - primaryAcc, err := am.Primary() - if err != nil { - utils.Fatalf("no primary account: %v", err) - } - account = primaryAcc.Hex() + utils.Fatalf("the 'primary' keyword is deprecated. You can use indexes, but the indexes are not permanent, they can change if you add external keys, export your keys or copy your keystore to another node.") } - unlockAccount(ctx, am, account) + unlockAccount(ctx, am, account, i) } } // Start auxiliary services if enabled. @@ -535,7 +533,7 @@ func accountList(ctx *cli.Context) { } } -func getPassPhrase(ctx *cli.Context, desc string, confirmation bool) (passphrase string) { +func getPassPhrase(ctx *cli.Context, desc string, confirmation bool, i int) (passphrase string) { passfile := ctx.GlobalString(utils.PasswordFileFlag.Name) if len(passfile) == 0 { fmt.Println(desc) @@ -559,14 +557,22 @@ func getPassPhrase(ctx *cli.Context, desc string, confirmation bool) (passphrase if err != nil { utils.Fatalf("Unable to read password file '%s': %v", passfile, err) } - passphrase = string(passbytes) + // this is backwards compatible if the same password unlocks several accounts + // it also has the consequence that trailing newlines will not count as part + // of the password, so --password <(echo -n 'pass') will now work without -n + passphrases := strings.Split(string(passbytes), "\n") + if i >= len(passphrases) { + passphrase = passphrases[len(passphrases)-1] + } else { + passphrase = passphrases[i] + } } return } func accountCreate(ctx *cli.Context) { 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) + 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) if err != nil { utils.Fatalf("Could not create the account: %v", err) @@ -585,7 +591,7 @@ func importWallet(ctx *cli.Context) { } am := utils.MakeAccountManager(ctx) - passphrase := getPassPhrase(ctx, "", false) + passphrase := getPassPhrase(ctx, "", false, 0) acct, err := am.ImportPreSaleKey(keyJson, passphrase) if err != nil { @@ -600,7 +606,7 @@ func accountImport(ctx *cli.Context) { utils.Fatalf("keyfile must be given as argument") } 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) + 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.Import(keyfile, passphrase) if err != nil { utils.Fatalf("Could not create the account: %v", err) -- cgit v1.2.3 From 09b69831758cb1001027fbb59dff9b3fbe20bbb2 Mon Sep 17 00:00:00 2001 From: zelig Date: Sun, 21 Jun 2015 04:01:12 +0100 Subject: no primary when listing accounts --- cmd/geth/main.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index b20c6d85d..673a08d45 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -497,7 +497,7 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) { for i, account := range accounts { if len(account) > 0 { if account == "primary" { - utils.Fatalf("the 'primary' keyword is deprecated. You can use indexes, but the indexes are not permanent, they can change if you add external keys, export your keys or copy your keystore to another node.") + utils.Fatalf("the 'primary' keyword is deprecated. You can use integer indexes, but the indexes are not permanent, they can change if you add external keys, export your keys or copy your keystore to another node.") } unlockAccount(ctx, am, account, i) } @@ -526,10 +526,8 @@ func accountList(ctx *cli.Context) { if err != nil { utils.Fatalf("Could not list accounts: %v", err) } - name := "Primary" for i, acct := range accts { - fmt.Printf("%s #%d: %x\n", name, i, acct) - name = "Account" + fmt.Printf("Account #%d: %x\n", i, acct) } } -- cgit v1.2.3 From eb82ca4563cf80bef9b520673d3bd18283da3a1f Mon Sep 17 00:00:00 2001 From: zelig Date: Sun, 21 Jun 2015 20:33:51 +0100 Subject: rpc/js coinbase returns null if no etherbase set --- cmd/geth/js_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index fc2444a7b..5bdfb7048 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -140,7 +140,7 @@ func TestAccounts(t *testing.T) { defer os.RemoveAll(tmp) checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`"]`) - checkEvalJSON(t, repl, `eth.coinbase`, `"`+common.Address{}.Hex()+`"`) + checkEvalJSON(t, repl, `eth.coinbase`, `null`) val, err := repl.re.Run(`personal.newAccount("password")`) if err != nil { @@ -151,9 +151,7 @@ func TestAccounts(t *testing.T) { t.Errorf("address not hex: %q", addr) } - // skip until order fixed #824 // checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`", "`+addr+`"]`) - // checkEvalJSON(t, repl, `eth.coinbase`, `"`+testAddress+`"`) } func TestBlockChain(t *testing.T) { -- cgit v1.2.3 From a4df9d74eabb3bef8449744c4fe966572586dc39 Mon Sep 17 00:00:00 2001 From: zelig Date: Sun, 21 Jun 2015 22:17:17 +0100 Subject: accounts order by keyfile ctime --- cmd/geth/js_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 5bdfb7048..61e85d399 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -9,6 +9,7 @@ import ( "runtime" "strconv" "testing" + "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" @@ -20,8 +21,8 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" - "github.com/ethereum/go-ethereum/rpc/comms" "github.com/ethereum/go-ethereum/rpc/codec" + "github.com/ethereum/go-ethereum/rpc/comms" ) const ( @@ -141,7 +142,6 @@ func TestAccounts(t *testing.T) { checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`"]`) checkEvalJSON(t, repl, `eth.coinbase`, `null`) - val, err := repl.re.Run(`personal.newAccount("password")`) if err != nil { t.Errorf("expected no error, got %v", err) @@ -151,7 +151,7 @@ func TestAccounts(t *testing.T) { t.Errorf("address not hex: %q", addr) } - // checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`", "`+addr+`"]`) + checkEvalJSON(t, repl, `eth.accounts`, `["`+testAddress+`","`+addr+`"]`) } func TestBlockChain(t *testing.T) { -- cgit v1.2.3 From fc17a527bc2bd07fc30e16d161059a441042d5f1 Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 2 Jul 2015 22:58:00 +0100 Subject: fix account ordering * chronological order of creation * new naming scheme keystore/UTC---
* KeyStore2 -> KeyStore * backward compatibility * refactor keyStore methods --- cmd/geth/js_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 61e85d399..480f77c91 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -9,7 +9,6 @@ import ( "runtime" "strconv" "testing" - "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" @@ -128,6 +127,7 @@ func TestNodeInfo(t *testing.T) { } defer ethereum.Stop() defer os.RemoveAll(tmp) + want := `{"DiscPort":0,"IP":"0.0.0.0","ListenAddr":"","Name":"test","NodeID":"4cb2fc32924e94277bf94b5e4c983beedb2eabd5a0bc941db32202735c6625d020ca14a5963d1738af43b6ac0a711d61b1a06de931a499fe2aa0b1a132a902b5","NodeUrl":"enode://4cb2fc32924e94277bf94b5e4c983beedb2eabd5a0bc941db32202735c6625d020ca14a5963d1738af43b6ac0a711d61b1a06de931a499fe2aa0b1a132a902b5@0.0.0.0:0","TCPPort":0,"Td":"131072"}` checkEvalJSON(t, repl, `admin.nodeInfo`, want) } -- cgit v1.2.3 From 1959346793bdee469f68841843dd383cf801aba1 Mon Sep 17 00:00:00 2001 From: zelig Date: Fri, 3 Jul 2015 04:56:20 +0100 Subject: account update: migrate or change password * account.Update * KeyStore.Cleanup * fix dir rm for old format deleteKey --- cmd/geth/main.go | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 7 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 673a08d45..ffd26a7c2 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -189,6 +189,33 @@ Note, this is meant to be used for testing only, it is a bad idea to save your password to file or expose in any other way. `, }, + { + Action: accountUpdate, + Name: "update", + Usage: "update an existing account", + Description: ` + + ethereum account update
+ +Update an existing account. + +The account is saved in the newest version in encrypted format, you are prompted +for a passphrase to unlock the account and another to save the updated file. + +This same command can therefore be used to migrate an account of a deprecated +format to the newest format or change the password for an account. + +For non-interactive use the passphrase can be specified with the --password flag: + + ethereum --password account new + +Since only one password can be given, only format update can be performed, +changing your password is only possible interactively. + +Note that account update has the a side effect that the order of your accounts +changes. + `, + }, { Action: accountImport, Name: "import", @@ -433,19 +460,30 @@ func execJSFiles(ctx *cli.Context) { ethereum.WaitForShutdown() } -func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string, i int) { +func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) { var err error // Load startup keys. XXX we are going to need a different format - if !((len(account) == 40) || (len(account) == 42)) { // with or without 0x - utils.Fatalf("Invalid account address '%s'", account) + if !((len(addr) == 40) || (len(addr) == 42)) { // with or without 0x + var index int + index, err = strconv.Atoi(addr) + if err != nil { + utils.Fatalf("Invalid account address '%s'", addr) + } + + addrHex, err = am.AddressByIndex(index) + if err != nil { + utils.Fatalf("%v", err) + } + } else { + addrHex = addr } // Attempt to unlock the account 3 times attempts := 3 for tries := 0; tries < attempts; tries++ { - msg := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", account, tries+1, attempts) - passphrase := getPassPhrase(ctx, msg, false, i) - err = am.Unlock(common.HexToAddress(account), passphrase) + msg := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", addr, tries+1, attempts) + auth = getPassPhrase(ctx, msg, false, i) + err = am.Unlock(common.HexToAddress(addrHex), auth) if err == nil { break } @@ -453,7 +491,8 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string, i int if err != nil { utils.Fatalf("Unlock account failed '%v'", err) } - fmt.Printf("Account '%s' unlocked.\n", account) + fmt.Printf("Account '%s' unlocked.\n", addr) + return } func blockRecovery(ctx *cli.Context) { @@ -578,6 +617,21 @@ func accountCreate(ctx *cli.Context) { fmt.Printf("Address: %x\n", acct) } +func accountUpdate(ctx *cli.Context) { + am := utils.MakeAccountManager(ctx) + arg := ctx.Args().First() + if len(arg) == 0 { + utils.Fatalf("account address or index must be given as argument") + } + + addr, authFrom := unlockAccount(ctx, am, arg, 0) + authTo := getPassPhrase(ctx, "Please give a new password. Do not forget this password.", true, 0) + err := am.Update(common.HexToAddress(addr), authFrom, authTo) + if err != nil { + utils.Fatalf("Could not update the account: %v", err) + } +} + func importWallet(ctx *cli.Context) { keyfile := ctx.Args().First() if len(keyfile) == 0 { -- cgit v1.2.3 From 5615fc47149ea5db6ad6f5b1b716e5af9900f848 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 6 Jul 2015 15:01:13 +0200 Subject: cmd/geth, cmd/utils: improve interrupt handling The new strategy for interrupts is to handle them explicitly. Ethereum.Stop is now only called once, even if multiple interrupts are sent. Interrupting ten times in a row forces a panic. Fixes #869 Fixes #1359 --- cmd/geth/main.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index ffd26a7c2..3428bb4cf 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -347,7 +347,6 @@ func main() { } func run(ctx *cli.Context) { - utils.HandleInterrupt() cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx) ethereum, err := eth.New(cfg) if err != nil { @@ -527,10 +526,9 @@ func blockRecovery(ctx *cli.Context) { func startEth(ctx *cli.Context, eth *eth.Ethereum) { // Start Ethereum itself - utils.StartEthereum(eth) - am := eth.AccountManager() + am := eth.AccountManager() account := ctx.GlobalString(utils.UnlockedAccountFlag.Name) accounts := strings.Split(account, " ") for i, account := range accounts { -- cgit v1.2.3 From 35cd355c14d9a5266a7d4b11127d25eb7f961494 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 10:32:05 +0200 Subject: cmd,eth,rpc,tests: default coinbase --- cmd/geth/main.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 3428bb4cf..a05bb4db5 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -461,22 +461,7 @@ func execJSFiles(ctx *cli.Context) { func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) { var err error - // Load startup keys. XXX we are going to need a different format - - if !((len(addr) == 40) || (len(addr) == 42)) { // with or without 0x - var index int - index, err = strconv.Atoi(addr) - if err != nil { - utils.Fatalf("Invalid account address '%s'", addr) - } - - addrHex, err = am.AddressByIndex(index) - if err != nil { - utils.Fatalf("%v", err) - } - } else { - addrHex = addr - } + addrHex = utils.ParamToAddress(addr, am) // Attempt to unlock the account 3 times attempts := 3 for tries := 0; tries < attempts; tries++ { -- cgit v1.2.3 From 83ee39448e0f23d42dff27bccde27f828afa3707 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 23 Jun 2015 15:48:33 +0100 Subject: Registrar and contractInfo handling * resolver -> common/registrar * global registrar name registry interface * add Call to resolver backend interface * the hashReg and UrlHing contracts now initialised from global registry * initialization of contracts uniform * improve errors and more econsistent method names * common/registrar/ethreg: versioned registrar * integrate new naming and registrar in natspec * js console api: setGlobalRegistrar, setHashReg, setUrlHint * js test TestContract uses mining - tests fixed all pass * eth/backend: allow PoW test mode (small ethash DAG) * console jsre refers to resolver.abi/addr, * cmd/geth/contracts.go moved to common/registrar --- cmd/geth/blocktestcmd.go | 1 - cmd/geth/contracts.go | 6 -- cmd/geth/js.go | 12 +-- cmd/geth/js_test.go | 216 +++++++++++++++++++++++++++++++++++------------ cmd/geth/main.go | 6 -- 5 files changed, 168 insertions(+), 73 deletions(-) delete mode 100644 cmd/geth/contracts.go (limited to 'cmd/geth') diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go index 116eec2b3..ffea4400e 100644 --- a/cmd/geth/blocktestcmd.go +++ b/cmd/geth/blocktestcmd.go @@ -86,7 +86,6 @@ func runBlockTest(ctx *cli.Context) { } func runOneBlockTest(ctx *cli.Context, test *tests.BlockTest) (*eth.Ethereum, error) { - // TODO remove in favor of logic contained in tests package cfg := utils.MakeEthConfig(ClientIdentifier, Version, ctx) cfg.NewDB = func(path string) (common.Database, error) { return ethdb.NewMemDatabase() } cfg.MaxPeers = 0 // disable network diff --git a/cmd/geth/contracts.go b/cmd/geth/contracts.go deleted file mode 100644 index 1f27838d1..000000000 --- a/cmd/geth/contracts.go +++ /dev/null @@ -1,6 +0,0 @@ -package main - -var ( - globalRegistrar = `var GlobalRegistrar = web3.eth.contract([{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"name","outputs":[{"name":"o_name","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"content","outputs":[{"name":"","type":"bytes32"}],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"addr","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"subRegistrar","outputs":[{"name":"o_subRegistrar","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_newOwner","type":"address"}],"name":"transfer","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_registrar","type":"address"}],"name":"setSubRegistrar","outputs":[],"type":"function"},{"constant":false,"inputs":[],"name":"Registrar","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_a","type":"address"},{"name":"_primary","type":"bool"}],"name":"setAddress","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_content","type":"bytes32"}],"name":"setContent","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"disown","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"register","outputs":[{"name":"","type":"address"}],"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"}],"name":"Changed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"name","type":"bytes32"},{"indexed":true,"name":"addr","type":"address"}],"name":"PrimaryChanged","type":"event"}]);` - globalRegistrarAddr = "0xc6d9d2cd449a754c494264e1809c50e34d64562b" -) diff --git a/cmd/geth/js.go b/cmd/geth/js.go index 01840ebd9..5a5dd75f3 100644 --- a/cmd/geth/js.go +++ b/cmd/geth/js.go @@ -32,16 +32,17 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/docserver" "github.com/ethereum/go-ethereum/common/natspec" + "github.com/ethereum/go-ethereum/common/registrar" "github.com/ethereum/go-ethereum/eth" re "github.com/ethereum/go-ethereum/jsre" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc/api" "github.com/ethereum/go-ethereum/rpc/codec" "github.com/ethereum/go-ethereum/rpc/comms" + "github.com/ethereum/go-ethereum/rpc/shared" "github.com/ethereum/go-ethereum/xeth" "github.com/peterh/liner" "github.com/robertkrimen/otto" - "github.com/ethereum/go-ethereum/rpc/shared" ) type prompter interface { @@ -69,6 +70,7 @@ func (r dumbterm) PasswordPrompt(p string) (string, error) { func (r dumbterm) AppendHistory(string) {} type jsre struct { + ds *docserver.DocServer re *re.JSRE ethereum *eth.Ethereum xeth *xeth.XEth @@ -180,6 +182,7 @@ func newJSRE(ethereum *eth.Ethereum, libPath, corsDomain string, client comms.Et if f == nil { f = js } + js.ds = docserver.New("/") js.xeth = xeth.New(ethereum, f) js.wait = js.xeth.UpdateState() js.client = client @@ -331,15 +334,14 @@ func (js *jsre) apiBindings(f xeth.Frontend) error { utils.Fatalf("Error setting namespaces: %v", err) } - js.re.Eval(globalRegistrar + "registrar = GlobalRegistrar.at(\"" + globalRegistrarAddr + "\");") + js.re.Eval(`var GlobalRegistrar = eth.contract(` + registrar.GlobalRegistrarAbi + `); registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`) + return nil } -var ds, _ = docserver.New("/") - func (self *jsre) ConfirmTransaction(tx string) bool { if self.ethereum.NatSpec { - notice := natspec.GetNotice(self.xeth, tx, ds) + notice := natspec.GetNotice(self.xeth, tx, self.ds) fmt.Println(notice) answer, _ := self.Prompt("Confirm Transaction [y/n]") return strings.HasPrefix(strings.Trim(answer, " "), "y") diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 480f77c91..0b7045ff6 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -3,21 +3,22 @@ package main import ( "fmt" "io/ioutil" + "math/big" "os" "path/filepath" "regexp" "runtime" "strconv" "testing" + "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/compiler" "github.com/ethereum/go-ethereum/common/docserver" "github.com/ethereum/go-ethereum/common/natspec" - "github.com/ethereum/go-ethereum/common/resolver" + "github.com/ethereum/go-ethereum/common/registrar" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/rpc/codec" @@ -43,7 +44,6 @@ var ( type testjethre struct { *jsre - stateDb *state.StateDB lastConfirm string ds *docserver.DocServer } @@ -64,6 +64,10 @@ func (self *testjethre) ConfirmTransaction(tx string) bool { } func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) { + return testREPL(t, nil) +} + +func testREPL(t *testing.T, config func(*eth.Config)) (string, *testjethre, *eth.Ethereum) { tmp, err := ioutil.TempDir("", "geth-test") if err != nil { t.Fatal(err) @@ -74,14 +78,19 @@ func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) { ks := crypto.NewKeyStorePlain(filepath.Join(tmp, "keystore")) am := accounts.NewManager(ks) - ethereum, err := eth.New(ð.Config{ + conf := ð.Config{ NodeKey: testNodeKey, DataDir: tmp, AccountManager: am, MaxPeers: 0, Name: "test", SolcPath: testSolcPath, - }) + PowTest: true, + } + if config != nil { + config(conf) + } + ethereum, err := eth.New(conf) if err != nil { t.Fatal("%v", err) } @@ -102,25 +111,16 @@ func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) { } assetPath := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext") - ds, err := docserver.New("/") - if err != nil { - t.Errorf("Error creating DocServer: %v", err) - } - tf := &testjethre{ds: ds, stateDb: ethereum.ChainManager().State().Copy()} client := comms.NewInProcClient(codec.JSON) + ds := docserver.New("/") + tf := &testjethre{ds: ds} repl := newJSRE(ethereum, assetPath, "", client, false, tf) tf.jsre = repl return tmp, tf, ethereum } -// this line below is needed for transaction to be applied to the state in testing -// the heavy lifing is done in XEth.ApplyTestTxs -// this is fragile, overwriting xeth will result in -// process leaking since xeth loops cannot quit safely -// should be replaced by proper mining with testDAG for easy full integration tests -// txc, self.xeth = self.xeth.ApplyTestTxs(self.xeth.repl.stateDb, coinbase, txc) - func TestNodeInfo(t *testing.T) { + t.Skip("broken after p2p update") tmp, repl, ethereum := testJEthRE(t) if err := ethereum.Start(); err != nil { t.Fatalf("error starting ethereum: %v", err) @@ -254,7 +254,7 @@ func TestSignature(t *testing.T) { } func TestContract(t *testing.T) { - t.Skip() + // t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") tmp, repl, ethereum := testJEthRE(t) if err := ethereum.Start(); err != nil { t.Errorf("error starting ethereum: %v", err) @@ -263,12 +263,21 @@ func TestContract(t *testing.T) { defer ethereum.Stop() defer os.RemoveAll(tmp) - var txc uint64 coinbase := common.HexToAddress(testAddress) - resolver.New(repl.xeth).CreateContracts(coinbase) - // time.Sleep(1000 * time.Millisecond) + reg := registrar.New(repl.xeth) + err := reg.SetGlobalRegistrar("", coinbase) + if err != nil { + t.Errorf("error setting HashReg: %v", err) + } + err = reg.SetHashReg("", coinbase) + if err != nil { + t.Errorf("error setting HashReg: %v", err) + } + err = reg.SetUrlHint("", coinbase) + if err != nil { + t.Errorf("error setting HashReg: %v", err) + } - // checkEvalJSON(t, repl, `eth.getBlock("pending", true).transactions.length`, `2`) source := `contract test {\n` + " /// @notice Will multiply `a` by 7." + `\n` + ` function multiply(uint a) returns(uint d) {\n` + @@ -276,14 +285,20 @@ func TestContract(t *testing.T) { ` }\n` + `}\n` - checkEvalJSON(t, repl, `admin.contractInfo.stop()`, `true`) + if checkEvalJSON(t, repl, `admin.contractInfo.stop()`, `true`) != nil { + return + } contractInfo, err := ioutil.ReadFile("info_test.json") if err != nil { t.Fatalf("%v", err) } - checkEvalJSON(t, repl, `primary = eth.accounts[0]`, `"`+testAddress+`"`) - checkEvalJSON(t, repl, `source = "`+source+`"`, `"`+source+`"`) + if checkEvalJSON(t, repl, `primary = eth.accounts[0]`, `"`+testAddress+`"`) != nil { + return + } + if checkEvalJSON(t, repl, `source = "`+source+`"`, `"`+source+`"`) != nil { + return + } // if solc is found with right version, test it, otherwise read from file sol, err := compiler.New("") @@ -303,69 +318,160 @@ func TestContract(t *testing.T) { t.Errorf("%v", err) } } else { - checkEvalJSON(t, repl, `contract = eth.compile.solidity(source).test`, string(contractInfo)) + if checkEvalJSON(t, repl, `contract = eth.compile.solidity(source).test`, string(contractInfo)) != nil { + return + } } - checkEvalJSON(t, repl, `contract.code`, `"0x605880600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b603d6004803590602001506047565b8060005260206000f35b60006007820290506053565b91905056"`) + if checkEvalJSON(t, repl, `contract.code`, `"0x605880600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b603d6004803590602001506047565b8060005260206000f35b60006007820290506053565b91905056"`) != nil { + return + } - checkEvalJSON( + if checkEvalJSON( t, repl, - `contractaddress = eth.sendTransaction({from: primary, data: contract.code })`, - `"0x5dcaace5982778b409c524873b319667eba5d074"`, - ) + `contractaddress = eth.sendTransaction({from: primary, data: contract.code})`, + `"0x291293d57e0a0ab47effe97c02577f90d9211567"`, + ) != nil { + return + } + + if !processTxs(repl, t, 7) { + return + } callSetup := `abiDef = JSON.parse('[{"constant":false,"inputs":[{"name":"a","type":"uint256"}],"name":"multiply","outputs":[{"name":"d","type":"uint256"}],"type":"function"}]'); Multiply7 = eth.contract(abiDef); multiply7 = Multiply7.at(contractaddress); ` - // time.Sleep(1500 * time.Millisecond) _, err = repl.re.Run(callSetup) if err != nil { t.Errorf("unexpected error setting up contract, got %v", err) + return } - // checkEvalJSON(t, repl, `eth.getBlock("pending", true).transactions.length`, `3`) - - // why is this sometimes failing? - // checkEvalJSON(t, repl, `multiply7.multiply.call(6)`, `42`) expNotice := "" if repl.lastConfirm != expNotice { t.Errorf("incorrect confirmation message: expected %v, got %v", expNotice, repl.lastConfirm) + return } - txc, repl.xeth = repl.xeth.ApplyTestTxs(repl.stateDb, coinbase, txc) + if checkEvalJSON(t, repl, `admin.contractInfo.start()`, `true`) != nil { + return + } + if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0xcb08355dff8f8cadb5dc3d72e652ef5c33792cb0d871229dd1aef5db1c4ba1f2"`) != nil { + return + } + + if !processTxs(repl, t, 1) { + return + } - checkEvalJSON(t, repl, `admin.contractInfo.start()`, `true`) - checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary, gas: "1000000", gasPrice: "100000" })`, `undefined`) - expNotice = `About to submit transaction (no NatSpec info found for contract: content hash not found for '0x87e2802265838c7f14bb69eecd2112911af6767907a702eeaa445239fb20711b'): {"params":[{"to":"0x5dcaace5982778b409c524873b319667eba5d074","data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}]}` + expNotice = `About to submit transaction (no NatSpec info found for contract: content hash not found for '0x87e2802265838c7f14bb69eecd2112911af6767907a702eeaa445239fb20711b'): {"params":[{"to":"0x291293d57e0a0ab47effe97c02577f90d9211567","data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}]}` if repl.lastConfirm != expNotice { - t.Errorf("incorrect confirmation message: expected %v, got %v", expNotice, repl.lastConfirm) + t.Errorf("incorrect confirmation message: expected\n%v, got\n%v", expNotice, repl.lastConfirm) + return } - var contenthash = `"0x86d2b7cf1e72e9a7a3f8d96601f0151742a2f780f1526414304fbe413dc7f9bd"` - if sol != nil { + var contentHash = `"0x86d2b7cf1e72e9a7a3f8d96601f0151742a2f780f1526414304fbe413dc7f9bd"` + if sol != nil && solcVersion != sol.Version() { modContractInfo := versionRE.ReplaceAll(contractInfo, []byte(`"compilerVersion":"`+sol.Version()+`"`)) - _ = modContractInfo - // contenthash = crypto.Sha3(modContractInfo) + fmt.Printf("modified contractinfo:\n%s\n", modContractInfo) + contentHash = `"` + common.ToHex(crypto.Sha3([]byte(modContractInfo))) + `"` } - checkEvalJSON(t, repl, `filename = "/tmp/info.json"`, `"/tmp/info.json"`) - checkEvalJSON(t, repl, `contenthash = admin.contractInfo.register(primary, contractaddress, contract, filename)`, contenthash) - checkEvalJSON(t, repl, `admin.contractInfo.registerUrl(primary, contenthash, "file://"+filename)`, `true`) - if err != nil { - t.Errorf("unexpected error registering, got %v", err) + if checkEvalJSON(t, repl, `filename = "/tmp/info.json"`, `"/tmp/info.json"`) != nil { + return + } + if checkEvalJSON(t, repl, `contentHash = admin.contractInfo.saveInfo(contract.info, filename)`, contentHash) != nil { + return + } + if checkEvalJSON(t, repl, `admin.contractInfo.register(primary, contractaddress, contentHash)`, `true`) != nil { + return + } + if checkEvalJSON(t, repl, `admin.contractInfo.registerUrl(primary, contentHash, "file://"+filename)`, `true`) != nil { + return } - checkEvalJSON(t, repl, `admin.contractInfo.start()`, `true`) + if checkEvalJSON(t, repl, `admin.contractInfo.start()`, `true`) != nil { + return + } + + if !processTxs(repl, t, 3) { + return + } + + if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0xe773bf05b027e4485c8b28967c35c939a71c5f6c177db78b51db52e76760d903"`) != nil { + return + } - // update state - txc, repl.xeth = repl.xeth.ApplyTestTxs(repl.stateDb, coinbase, txc) + if !processTxs(repl, t, 1) { + return + } - checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary, gas: "1000000", gasPrice: "100000" })`, `undefined`) expNotice = "Will multiply 6 by 7." if repl.lastConfirm != expNotice { - t.Errorf("incorrect confirmation message: expected %v, got %v", expNotice, repl.lastConfirm) + t.Errorf("incorrect confirmation message: expected\n%v, got\n%v", expNotice, repl.lastConfirm) + return + } +} + +func pendingTransactions(repl *testjethre, t *testing.T) (txc int64, err error) { + txs := repl.ethereum.TxPool().GetTransactions() + return int64(len(txs)), nil +} + +func processTxs(repl *testjethre, t *testing.T, expTxc int) bool { + var txc int64 + var err error + for i := 0; i < 50; i++ { + txc, err = pendingTransactions(repl, t) + if err != nil { + t.Errorf("unexpected error checking pending transactions: %v", err) + return false + } + if expTxc < int(txc) { + t.Errorf("too many pending transactions: expected %v, got %v", expTxc, txc) + return false + } else if expTxc == int(txc) { + break + } + time.Sleep(100 * time.Millisecond) + } + if int(txc) != expTxc { + t.Errorf("incorrect number of pending transactions, expected %v, got %v", expTxc, txc) + return false } + err = repl.ethereum.StartMining(runtime.NumCPU()) + if err != nil { + t.Errorf("unexpected error mining: %v", err) + return false + } + defer repl.ethereum.StopMining() + + timer := time.NewTimer(100 * time.Second) + height := new(big.Int).Add(repl.xeth.CurrentBlock().Number(), big.NewInt(1)) + repl.wait <- height + select { + case <-timer.C: + // if times out make sure the xeth loop does not block + go func() { + select { + case repl.wait <- nil: + case <-repl.wait: + } + }() + case <-repl.wait: + } + txc, err = pendingTransactions(repl, t) + if err != nil { + t.Errorf("unexpected error checking pending transactions: %v", err) + return false + } + if txc != 0 { + t.Errorf("%d trasactions were not mined", txc) + return false + } + return true } func checkEvalJSON(t *testing.T, re *testjethre, expr, want string) error { diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 3428bb4cf..7773ba93b 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -319,12 +319,6 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.PProfPortFlag, utils.MetricsEnabledFlag, utils.SolcPathFlag, - utils.GpoMinGasPriceFlag, - utils.GpoMaxGasPriceFlag, - utils.GpoFullBlockRatioFlag, - utils.GpobaseStepDownFlag, - utils.GpobaseStepUpFlag, - utils.GpobaseCorrectionFactorFlag, } app.Before = func(ctx *cli.Context) error { utils.SetupLogger(ctx) -- cgit v1.2.3 From 27392337198b9287e9f6fe615510a1f30099e3d7 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 23 Jun 2015 15:48:33 +0100 Subject: Registrar and contractInfo handling * resolver -> common/registrar * global registrar name registry interface * add Call to resolver backend interface * the hashReg and UrlHing contracts now initialised from global registry * initialization of contracts uniform * improve errors and more econsistent method names * common/registrar/ethreg: versioned registrar * integrate new naming and registrar in natspec * js console api: setGlobalRegistrar, setHashReg, setUrlHint * js test TestContract uses mining - tests fixed all pass * eth/backend: allow PoW test mode (small ethash DAG) * console jsre refers to resolver.abi/addr, * cmd/geth/contracts.go moved to common/registrar --- cmd/geth/js.go | 2 +- cmd/geth/js_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js.go b/cmd/geth/js.go index 5a5dd75f3..06c923913 100644 --- a/cmd/geth/js.go +++ b/cmd/geth/js.go @@ -145,6 +145,7 @@ func newLightweightJSRE(libPath string, client comms.EthereumClient, interactive js := &jsre{ps1: "> "} js.wait = make(chan *big.Int) js.client = client + js.ds = docserver.New("/") if f == nil { f = js @@ -335,7 +336,6 @@ func (js *jsre) apiBindings(f xeth.Frontend) error { } js.re.Eval(`var GlobalRegistrar = eth.contract(` + registrar.GlobalRegistrarAbi + `); registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`) - return nil } diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 0b7045ff6..91b927dd3 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -254,7 +254,7 @@ func TestSignature(t *testing.T) { } func TestContract(t *testing.T) { - // t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") + t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") tmp, repl, ethereum := testJEthRE(t) if err := ethereum.Start(); err != nil { t.Errorf("error starting ethereum: %v", err) -- cgit v1.2.3 From 042c3290b390bc7941bd20dcbbe69253a9b6be95 Mon Sep 17 00:00:00 2001 From: zelig Date: Fri, 3 Jul 2015 08:18:01 +0100 Subject: fix GPO missing flags --- cmd/geth/main.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 7773ba93b..3428bb4cf 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -319,6 +319,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.PProfPortFlag, utils.MetricsEnabledFlag, utils.SolcPathFlag, + utils.GpoMinGasPriceFlag, + utils.GpoMaxGasPriceFlag, + utils.GpoFullBlockRatioFlag, + utils.GpobaseStepDownFlag, + utils.GpobaseStepUpFlag, + utils.GpobaseCorrectionFactorFlag, } app.Before = func(ctx *cli.Context) error { utils.SetupLogger(ctx) -- cgit v1.2.3 From 492e5049d7cfac3b172655ea25d9a03f91f76047 Mon Sep 17 00:00:00 2001 From: zelig Date: Fri, 3 Jul 2015 12:45:12 +0100 Subject: rename js methods in js_test for new console API + rebase fixes --- cmd/geth/js_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 91b927dd3..bde5d250f 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -254,7 +254,7 @@ func TestSignature(t *testing.T) { } func TestContract(t *testing.T) { - t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") + // t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") tmp, repl, ethereum := testJEthRE(t) if err := ethereum.Start(); err != nil { t.Errorf("error starting ethereum: %v", err) @@ -285,7 +285,7 @@ func TestContract(t *testing.T) { ` }\n` + `}\n` - if checkEvalJSON(t, repl, `admin.contractInfo.stop()`, `true`) != nil { + if checkEvalJSON(t, repl, `admin.stopNatSpec()`, `true`) != nil { return } @@ -355,7 +355,7 @@ multiply7 = Multiply7.at(contractaddress); return } - if checkEvalJSON(t, repl, `admin.contractInfo.start()`, `true`) != nil { + if checkEvalJSON(t, repl, `admin.startNatSpec()`, `true`) != nil { return } if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0xcb08355dff8f8cadb5dc3d72e652ef5c33792cb0d871229dd1aef5db1c4ba1f2"`) != nil { @@ -381,17 +381,17 @@ multiply7 = Multiply7.at(contractaddress); if checkEvalJSON(t, repl, `filename = "/tmp/info.json"`, `"/tmp/info.json"`) != nil { return } - if checkEvalJSON(t, repl, `contentHash = admin.contractInfo.saveInfo(contract.info, filename)`, contentHash) != nil { + if checkEvalJSON(t, repl, `contentHash = admin.saveInfo(contract.info, filename)`, contentHash) != nil { return } - if checkEvalJSON(t, repl, `admin.contractInfo.register(primary, contractaddress, contentHash)`, `true`) != nil { + if checkEvalJSON(t, repl, `admin.register(primary, contractaddress, contentHash)`, `true`) != nil { return } - if checkEvalJSON(t, repl, `admin.contractInfo.registerUrl(primary, contentHash, "file://"+filename)`, `true`) != nil { + if checkEvalJSON(t, repl, `admin.registerUrl(primary, contentHash, "file://"+filename)`, `true`) != nil { return } - if checkEvalJSON(t, repl, `admin.contractInfo.start()`, `true`) != nil { + if checkEvalJSON(t, repl, `admin.startNatSpec()`, `true`) != nil { return } -- cgit v1.2.3 From aa22cf323ef408f0562817352f68197f8b982f75 Mon Sep 17 00:00:00 2001 From: zelig Date: Sat, 4 Jul 2015 22:12:14 +0100 Subject: fix js arguments and TestContract passes --- cmd/geth/js_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index bde5d250f..791218997 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -255,7 +255,11 @@ func TestSignature(t *testing.T) { func TestContract(t *testing.T) { // t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") - tmp, repl, ethereum := testJEthRE(t) + coinbase := common.HexToAddress(testAddress) + tmp, repl, ethereum := testREPL(t, func(conf *eth.Config) { + conf.Etherbase = testAddress + conf.PowTest = true + }) if err := ethereum.Start(); err != nil { t.Errorf("error starting ethereum: %v", err) return @@ -263,7 +267,6 @@ func TestContract(t *testing.T) { defer ethereum.Stop() defer os.RemoveAll(tmp) - coinbase := common.HexToAddress(testAddress) reg := registrar.New(repl.xeth) err := reg.SetGlobalRegistrar("", coinbase) if err != nil { @@ -330,12 +333,12 @@ func TestContract(t *testing.T) { if checkEvalJSON( t, repl, `contractaddress = eth.sendTransaction({from: primary, data: contract.code})`, - `"0x291293d57e0a0ab47effe97c02577f90d9211567"`, + `"0x46d69d55c3c4b86a924a92c9fc4720bb7bce1d74"`, ) != nil { return } - if !processTxs(repl, t, 7) { + if !processTxs(repl, t, 8) { return } @@ -358,7 +361,7 @@ multiply7 = Multiply7.at(contractaddress); if checkEvalJSON(t, repl, `admin.startNatSpec()`, `true`) != nil { return } - if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0xcb08355dff8f8cadb5dc3d72e652ef5c33792cb0d871229dd1aef5db1c4ba1f2"`) != nil { + if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0x4ef9088431a8033e4580d00e4eb2487275e031ff4163c7529df0ef45af17857b"`) != nil { return } @@ -366,7 +369,7 @@ multiply7 = Multiply7.at(contractaddress); return } - expNotice = `About to submit transaction (no NatSpec info found for contract: content hash not found for '0x87e2802265838c7f14bb69eecd2112911af6767907a702eeaa445239fb20711b'): {"params":[{"to":"0x291293d57e0a0ab47effe97c02577f90d9211567","data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}]}` + expNotice = `About to submit transaction (no NatSpec info found for contract: content hash not found for '0x87e2802265838c7f14bb69eecd2112911af6767907a702eeaa445239fb20711b'): {"params":[{"to":"0x46d69d55c3c4b86a924a92c9fc4720bb7bce1d74","data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000006"}]}` if repl.lastConfirm != expNotice { t.Errorf("incorrect confirmation message: expected\n%v, got\n%v", expNotice, repl.lastConfirm) return @@ -399,7 +402,7 @@ multiply7 = Multiply7.at(contractaddress); return } - if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0xe773bf05b027e4485c8b28967c35c939a71c5f6c177db78b51db52e76760d903"`) != nil { + if checkEvalJSON(t, repl, `multiply7.multiply.sendTransaction(6, { from: primary })`, `"0x66d7635c12ad0b231e66da2f987ca3dfdca58ffe49c6442aa55960858103fd0c"`) != nil { return } -- cgit v1.2.3 From 1208ac83d5a93214f23bf3f9236e29869ee62407 Mon Sep 17 00:00:00 2001 From: zelig Date: Sun, 5 Jul 2015 19:19:42 +0100 Subject: fix natspec test * registar url string retrieval chop leading zeros now * rewrite test using test mining * remove temporary applyTxs from xeth --- cmd/geth/js_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 791218997..eaab3acaa 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -254,7 +254,7 @@ func TestSignature(t *testing.T) { } func TestContract(t *testing.T) { - // t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") + t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") coinbase := common.HexToAddress(testAddress) tmp, repl, ethereum := testREPL(t, func(conf *eth.Config) { conf.Etherbase = testAddress -- cgit v1.2.3 From c5cb6e8e70339b6641b7ce46cda04b83936213b3 Mon Sep 17 00:00:00 2001 From: zelig Date: Tue, 7 Jul 2015 06:00:58 +0100 Subject: fix/skip tests, adapt registrar to no contract address registry initialisers now return the txhash which caller can use to retrieve receipt --- cmd/geth/js_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index eaab3acaa..646ca404a 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -268,18 +268,24 @@ func TestContract(t *testing.T) { defer os.RemoveAll(tmp) reg := registrar.New(repl.xeth) - err := reg.SetGlobalRegistrar("", coinbase) + _, err := reg.SetGlobalRegistrar("", coinbase) if err != nil { t.Errorf("error setting HashReg: %v", err) } - err = reg.SetHashReg("", coinbase) + _, err = reg.SetHashReg("", coinbase) if err != nil { t.Errorf("error setting HashReg: %v", err) } - err = reg.SetUrlHint("", coinbase) + _, err = reg.SetUrlHint("", coinbase) if err != nil { t.Errorf("error setting HashReg: %v", err) } + /* TODO: + * lookup receipt and contract addresses by tx hash + * name registration for HashReg and UrlHint addresses + * mine those transactions + * then set once more SetHashReg SetUrlHint + */ source := `contract test {\n` + " /// @notice Will multiply `a` by 7." + `\n` + -- cgit v1.2.3 From 3016f238646510ed309b76d571addf381e341af4 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 12:18:05 +0200 Subject: cmd/geth: fixed test --- cmd/geth/js_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/geth') diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 646ca404a..48a6c1c73 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -257,7 +257,7 @@ func TestContract(t *testing.T) { t.Skip("contract testing is implemented with mining in ethash test mode. This takes about 7seconds to run. Unskip and run on demand") coinbase := common.HexToAddress(testAddress) tmp, repl, ethereum := testREPL(t, func(conf *eth.Config) { - conf.Etherbase = testAddress + conf.Etherbase = coinbase conf.PowTest = true }) if err := ethereum.Start(); err != nil { -- cgit v1.2.3 From ea54283b304a1d308141d21e3ef75b7de0f4519d Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Jul 2015 02:54:22 +0200 Subject: all: update license information --- cmd/geth/blocktestcmd.go | 16 ++++++++++++++++ cmd/geth/chaincmd.go | 16 ++++++++++++++++ cmd/geth/js.go | 21 ++++++++++----------- cmd/geth/js_test.go | 16 ++++++++++++++++ cmd/geth/main.go | 32 ++++++++++++++++---------------- cmd/geth/monitorcmd.go | 16 ++++++++++++++++ 6 files changed, 90 insertions(+), 27 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/blocktestcmd.go b/cmd/geth/blocktestcmd.go index ffea4400e..494a4d474 100644 --- a/cmd/geth/blocktestcmd.go +++ b/cmd/geth/blocktestcmd.go @@ -1,3 +1,19 @@ +// 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 . + package main import ( diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 8586e3b81..b23a74809 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -1,3 +1,19 @@ +// 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 . + package main import ( diff --git a/cmd/geth/js.go b/cmd/geth/js.go index 06c923913..cc4c14c2e 100644 --- a/cmd/geth/js.go +++ b/cmd/geth/js.go @@ -1,19 +1,18 @@ -// Copyright (c) 2013-2014, Jeffrey Wilcke. All rights reserved. +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. // -// 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. +// 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. // -// This library is distributed in the hope that it will be useful, +// 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. +// 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 +// along with go-ethereum. If not, see . package main diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 48a6c1c73..db2c5ca03 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -1,3 +1,19 @@ +// 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 . + package main import ( diff --git a/cmd/geth/main.go b/cmd/geth/main.go index a05bb4db5..b266f6774 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -1,19 +1,19 @@ -/* - 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 . -*/ +// Copyright 2014 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 . + /** * @authors * Jeffrey Wilcke diff --git a/cmd/geth/monitorcmd.go b/cmd/geth/monitorcmd.go index 6593b3614..affe3b75d 100644 --- a/cmd/geth/monitorcmd.go +++ b/cmd/geth/monitorcmd.go @@ -1,3 +1,19 @@ +// 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 . + package main import ( -- cgit v1.2.3 From e813626ee1d5d7397c2a8e670ab8c372df921bbb Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Jul 2015 04:29:50 +0200 Subject: all: remove @author comments --- cmd/geth/main.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index b266f6774..251121030 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -14,10 +14,6 @@ // You should have received a copy of the GNU General Public License // along with go-ethereum. If not, see . -/** - * @authors - * Jeffrey Wilcke - */ package main import ( -- cgit v1.2.3 From bdae4fd573dbc163bab3d0e2d1a5c457892037cd Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Jul 2015 05:08:16 +0200 Subject: all: add some godoc synopsis comments --- cmd/geth/main.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 251121030..bb6ddc1e2 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with go-ethereum. If not, see . +// geth is the official command-line client for Ethereum. package main import ( -- cgit v1.2.3 From 4b5c99d97fa885352f11007adbb5c3e2c194e353 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 12:21:36 +0200 Subject: cmd/geth: version number 0.9.36 --- cmd/geth/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index bb6ddc1e2..b9e9cd346 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -49,7 +49,7 @@ import ( const ( ClientIdentifier = "Geth" - Version = "0.9.35" + Version = "0.9.36" ) var ( -- cgit v1.2.3 From ee04b718876438feb0ed6d794f0caf72d24f777a Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 12:53:36 +0200 Subject: cmd/geth, cmd/utils: changed ParamsToAddress to return error ParamsToAddress no longer aborts the process, it now returns an error instead so that the caller can handle the error properly. --- cmd/geth/main.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'cmd/geth') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index b9e9cd346..5ac93a983 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -458,17 +458,20 @@ func execJSFiles(ctx *cli.Context) { func unlockAccount(ctx *cli.Context, am *accounts.Manager, addr string, i int) (addrHex, auth string) { var err error - addrHex = utils.ParamToAddress(addr, am) - // Attempt to unlock the account 3 times - attempts := 3 - for tries := 0; tries < attempts; tries++ { - msg := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", addr, tries+1, attempts) - auth = getPassPhrase(ctx, msg, false, i) - err = am.Unlock(common.HexToAddress(addrHex), auth) - if err == nil { - break + addrHex, err = utils.ParamToAddress(addr, am) + if err == nil { + // Attempt to unlock the account 3 times + attempts := 3 + for tries := 0; tries < attempts; tries++ { + msg := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", addr, tries+1, attempts) + auth = getPassPhrase(ctx, msg, false, i) + err = am.Unlock(common.HexToAddress(addrHex), auth) + if err == nil { + break + } } } + if err != nil { utils.Fatalf("Unlock account failed '%v'", err) } -- cgit v1.2.3