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 --- eth/backend.go | 59 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index 4644b8a93..23d76dfd1 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -57,10 +57,9 @@ var ( ) type Config struct { - Name string - ProtocolVersion int - NetworkId int - GenesisNonce int + Name string + NetworkId int + GenesisNonce int BlockChainVersion int SkipBcVersionCheck bool // e.g. blockchain export @@ -226,7 +225,6 @@ type Ethereum struct { autodagquit chan bool etherbase common.Address clientVersion string - ethVersionId int netVersionId int shhVersionId int } @@ -291,14 +289,20 @@ func New(config *Config) (*Ethereum, error) { nodeDb := filepath.Join(config.DataDir, "nodes") // Perform database sanity checks - d, _ := blockDb.Get([]byte("ProtocolVersion")) - protov := int(common.NewValue(d).Uint()) - if protov != config.ProtocolVersion && protov != 0 { - path := filepath.Join(config.DataDir, "blockchain") - return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path) - } - saveProtocolVersion(blockDb, config.ProtocolVersion) - glog.V(logger.Info).Infof("Protocol Version: %v, Network Id: %v", config.ProtocolVersion, config.NetworkId) + /* + // The databases were previously tied to protocol versions. Currently we + // are moving away from this decision as approaching Frontier. The below + // check was left in for now but should eventually be just dropped. + + d, _ := blockDb.Get([]byte("ProtocolVersion")) + protov := int(common.NewValue(d).Uint()) + if protov != config.ProtocolVersion && protov != 0 { + path := filepath.Join(config.DataDir, "blockchain") + return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path) + } + saveProtocolVersion(blockDb, config.ProtocolVersion) + */ + glog.V(logger.Info).Infof("Protocol Versions: %v, Network Id: %v", ProtocolVersions, config.NetworkId) if !config.SkipBcVersionCheck { b, _ := blockDb.Get([]byte("BlockchainVersion")) @@ -321,7 +325,6 @@ func New(config *Config) (*Ethereum, error) { DataDir: config.DataDir, etherbase: common.HexToAddress(config.Etherbase), clientVersion: config.Name, // TODO should separate from Name - ethVersionId: config.ProtocolVersion, netVersionId: config.NetworkId, NatSpec: config.NatSpec, MinerThreads: config.MinerThreads, @@ -345,7 +348,7 @@ func New(config *Config) (*Ethereum, error) { eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.chainManager, eth.EventMux()) eth.chainManager.SetProcessor(eth.blockProcessor) - eth.protocolManager = NewProtocolManager(config.ProtocolVersion, config.NetworkId, eth.eventMux, eth.txPool, eth.pow, eth.chainManager) + eth.protocolManager = NewProtocolManager(config.NetworkId, eth.eventMux, eth.txPool, eth.pow, eth.chainManager) eth.miner = miner.New(eth, eth.EventMux(), eth.pow) eth.miner.SetGasPrice(config.GasPrice) @@ -358,7 +361,7 @@ func New(config *Config) (*Ethereum, error) { if err != nil { return nil, err } - protocols := []p2p.Protocol{eth.protocolManager.SubProtocol} + protocols := append([]p2p.Protocol{}, eth.protocolManager.SubProtocols...) if config.Shh { protocols = append(protocols, eth.whisper.Protocol()) } @@ -495,7 +498,7 @@ func (s *Ethereum) PeerCount() int { return s.net.PeerCoun func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() } func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers } func (s *Ethereum) ClientVersion() string { return s.clientVersion } -func (s *Ethereum) EthVersion() int { return s.ethVersionId } +func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) } func (s *Ethereum) NetVersion() int { return s.netVersionId } func (s *Ethereum) ShhVersion() int { return s.shhVersionId } func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader } @@ -504,7 +507,7 @@ func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolMana func (s *Ethereum) Start() error { jsonlogger.LogJson(&logger.LogStarting{ ClientString: s.net.Name, - ProtocolVersion: ProtocolVersion, + ProtocolVersion: s.EthVersion(), }) err := s.net.Start() if err != nil { @@ -560,7 +563,7 @@ done: func (s *Ethereum) StartForTest() { jsonlogger.LogJson(&logger.LogStarting{ ClientString: s.net.Name, - ProtocolVersion: ProtocolVersion, + ProtocolVersion: s.EthVersion(), }) } @@ -667,14 +670,20 @@ func (self *Ethereum) StopAutoDAG() { glog.V(logger.Info).Infof("Automatic pregeneration of ethash DAG OFF (ethash dir: %s)", ethash.DefaultDir) } -func saveProtocolVersion(db common.Database, protov int) { - d, _ := db.Get([]byte("ProtocolVersion")) - protocolVersion := common.NewValue(d).Uint() +/* + // The databases were previously tied to protocol versions. Currently we + // are moving away from this decision as approaching Frontier. The below + // code was left in for now but should eventually be just dropped. + + func saveProtocolVersion(db common.Database, protov int) { + d, _ := db.Get([]byte("ProtocolVersion")) + protocolVersion := common.NewValue(d).Uint() - if protocolVersion == 0 { - db.Put([]byte("ProtocolVersion"), common.NewValue(protov).Bytes()) + if protocolVersion == 0 { + db.Put([]byte("ProtocolVersion"), common.NewValue(protov).Bytes()) + } } -} +*/ func saveBlockchainVersion(db common.Database, bcVersion int) { d, _ := db.Get([]byte("BlockchainVersion")) -- cgit v1.2.3 From f43c07cb3ca0d96fd005aa7ce2ddd40876a06d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 30 Jun 2015 19:05:06 +0300 Subject: eth, eth/downloader: transition to eth 61 --- eth/backend.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index 23d76dfd1..d6ad3381d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -11,8 +11,6 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" @@ -26,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/discover" -- 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 --- eth/backend.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index d6ad3381d..ce774ba1b 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -464,15 +464,8 @@ func (s *Ethereum) StartMining(threads int) error { func (s *Ethereum) Etherbase() (eb common.Address, err error) { eb = s.etherbase if (eb == common.Address{}) { - primary, err := s.accountManager.Primary() - if err != nil { - return eb, err - } - if (primary == common.Address{}) { - err = fmt.Errorf("no accounts found") - return eb, err - } - eb = primary + err = fmt.Errorf("no accounts found") + return eb, err } return eb, nil } -- cgit v1.2.3 From 65a26e40a886c48031a7936d3cc9bf341e7165f4 Mon Sep 17 00:00:00 2001 From: zelig Date: Wed, 17 Jun 2015 11:25:42 +0100 Subject: require explicit etherbase address for mining. Falling back to primary is risky given it is inconsistent if keys are imported/merged/created or copied/transfered --- eth/backend.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index ce774ba1b..8195110de 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -464,10 +464,9 @@ func (s *Ethereum) StartMining(threads int) error { func (s *Ethereum) Etherbase() (eb common.Address, err error) { eb = s.etherbase if (eb == common.Address{}) { - err = fmt.Errorf("no accounts found") - return eb, err + err = fmt.Errorf("etherbase address must be explicitly specified") } - return eb, nil + return } func (s *Ethereum) StopMining() { s.miner.Stop() } -- cgit v1.2.3 From 29e2fb38f8e80dfa077d139d8ff563169c644d74 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Fri, 3 Jul 2015 11:24:42 +0200 Subject: core, miner: miner header validation, transaction & receipt writing * Miners do now verify their own header, not their state. * Changed old putTx and putReceipts to be exported * Moved writing of transactions and receipts out of the block processer in to the chain manager. Closes #1386 * Miner post ChainHeadEvent & ChainEvent. Closes #1388 --- eth/backend.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index d6ad3381d..618eec9fb 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -339,7 +339,7 @@ func New(config *Config) (*Ethereum, error) { eth.pow = ethash.New() genesis := core.GenesisBlock(uint64(config.GenesisNonce), stateDb) - eth.chainManager, err = core.NewChainManager(genesis, blockDb, stateDb, eth.pow, eth.EventMux()) + eth.chainManager, err = core.NewChainManager(genesis, blockDb, stateDb, extraDb, eth.pow, eth.EventMux()) if err != nil { return nil, err } -- 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 --- eth/backend.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index e62252b6c..2c6f5b80c 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -87,7 +87,7 @@ type Config struct { Shh bool Dial bool - Etherbase string + Etherbase common.Address GasPrice *big.Int MinerThreads int AccountManager *accounts.Manager @@ -322,7 +322,7 @@ func New(config *Config) (*Ethereum, error) { eventMux: &event.TypeMux{}, accountManager: config.AccountManager, DataDir: config.DataDir, - etherbase: common.HexToAddress(config.Etherbase), + etherbase: config.Etherbase, clientVersion: config.Name, // TODO should separate from Name netVersionId: config.NetworkId, NatSpec: config.NatSpec, @@ -469,6 +469,11 @@ func (s *Ethereum) Etherbase() (eb common.Address, err error) { return } +// set in js console via admin interface or wrapper from cli flags +func (self *Ethereum) SetEtherbase(etherbase common.Address) { + self.etherbase = etherbase +} + func (s *Ethereum) StopMining() { s.miner.Stop() } func (s *Ethereum) IsMining() bool { return s.miner.Mining() } func (s *Ethereum) Miner() *miner.Miner { return s.miner } -- 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 --- eth/backend.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index e62252b6c..38e06bcf8 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -70,6 +70,7 @@ type Config struct { VmDebug bool NatSpec bool AutoDAG bool + PowTest bool MaxPeers int MaxPendingPeers int @@ -221,6 +222,7 @@ type Ethereum struct { NatSpec bool DataDir string AutoDAG bool + PowTest bool autodagquit chan bool etherbase common.Address clientVersion string @@ -329,6 +331,7 @@ func New(config *Config) (*Ethereum, error) { MinerThreads: config.MinerThreads, SolcPath: config.SolcPath, AutoDAG: config.AutoDAG, + PowTest: config.PowTest, GpoMinGasPrice: config.GpoMinGasPrice, GpoMaxGasPrice: config.GpoMaxGasPrice, GpoFullBlockRatio: config.GpoFullBlockRatio, @@ -337,7 +340,15 @@ func New(config *Config) (*Ethereum, error) { GpobaseCorrectionFactor: config.GpobaseCorrectionFactor, } - eth.pow = ethash.New() + if config.PowTest { + glog.V(logger.Info).Infof("ethash used in test mode") + eth.pow, err = ethash.NewForTesting() + if err != nil { + return nil, err + } + } else { + eth.pow = ethash.New() + } genesis := core.GenesisBlock(uint64(config.GenesisNonce), stateDb) eth.chainManager, err = core.NewChainManager(genesis, blockDb, stateDb, extraDb, eth.pow, eth.EventMux()) if err != nil { -- cgit v1.2.3 From 37c1a8f69de44827a60296342189b6719a49dbc3 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 7 Jul 2015 10:58:47 +0200 Subject: eth,miner,rpc: set coinbase --- eth/backend.go | 1 + 1 file changed, 1 insertion(+) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index 2c6f5b80c..e5466bbc2 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -472,6 +472,7 @@ func (s *Ethereum) Etherbase() (eb common.Address, err error) { // set in js console via admin interface or wrapper from cli flags func (self *Ethereum) SetEtherbase(etherbase common.Address) { self.etherbase = etherbase + self.miner.SetEtherbase(etherbase) } func (s *Ethereum) StopMining() { s.miner.Stop() } -- 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 --- eth/backend.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index 9f7a297f1..ede8af88f 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -1,3 +1,19 @@ +// 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package eth 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 --- eth/backend.go | 1 + 1 file changed, 1 insertion(+) (limited to 'eth/backend.go') diff --git a/eth/backend.go b/eth/backend.go index ede8af88f..391a610e3 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with go-ethereum. If not, see . +// Package eth implements the Ethereum protocol. package eth import ( -- cgit v1.2.3