From aad4890082c1624795991d534db9497c8b63630d Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Sun, 20 Nov 2016 12:18:39 +0100 Subject: [PATCH] cmd/geth, core, light, mobile: removed state account StartingNonce All account's nonce start at 0. --- cmd/geth/chaincmd.go | 3 --- cmd/geth/main.go | 5 ----- cmd/utils/flags.go | 3 --- core/genesis.go | 4 ++-- core/state/statedb.go | 8 ++------ light/state.go | 5 +---- mobile/geth.go | 10 ---------- 7 files changed, 5 insertions(+), 33 deletions(-) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 19e723bfa..1a7a9eb18 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -99,9 +99,6 @@ func importChain(ctx *cli.Context) error { if len(ctx.Args()) != 1 { utils.Fatalf("This command requires an argument.") } - if ctx.GlobalBool(utils.TestNetFlag.Name) { - state.StartingNonce = 1048576 // (2**20) - } stack := makeFullNode(ctx) chain, chainDb := utils.MakeChain(ctx, stack) defer chainDb.Close() diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 0eab77f7e..13d771790 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -34,7 +34,6 @@ import ( "github.com/ethereum/go-ethereum/console" "github.com/ethereum/go-ethereum/contracts/release" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/internal/debug" "github.com/ethereum/go-ethereum/logger" @@ -237,10 +236,6 @@ func initGenesis(ctx *cli.Context) error { utils.Fatalf("must supply path to genesis JSON file") } - if ctx.GlobalBool(utils.TestNetFlag.Name) { - state.StartingNonce = 1048576 // (2**20) - } - stack := makeFullNode(ctx) chaindb := utils.MakeChainDatabase(ctx, stack) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index dd18fd78c..fcdd08737 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -38,7 +38,6 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/les" - "github.com/ethereum/go-ethereum/light" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" @@ -754,8 +753,6 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) { ethConf.NetworkId = 2 } ethConf.Genesis = core.TestNetGenesisBlock() - state.StartingNonce = 1048576 // (2**20) - light.StartingNonce = 1048576 // (2**20) case ctx.GlobalBool(DevModeFlag.Name): ethConf.Genesis = core.OlympicGenesisBlock() diff --git a/core/genesis.go b/core/genesis.go index 8509f664d..44a83f236 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -43,7 +43,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block, } var genesis struct { - ChainConfig *params.ChainConfig `json:"config"` + ChainConfig params.ChainConfig `json:"config"` Nonce string Timestamp string ParentHash string @@ -115,7 +115,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block, if err := WriteHeadBlockHash(chainDb, block.Hash()); err != nil { return nil, err } - if err := WriteChainConfig(chainDb, block.Hash(), genesis.ChainConfig); err != nil { + if err := WriteChainConfig(chainDb, block.Hash(), &genesis.ChainConfig); err != nil { return nil, err } diff --git a/core/state/statedb.go b/core/state/statedb.go index 1c4af0295..3742c178b 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -34,10 +34,6 @@ import ( lru "github.com/hashicorp/golang-lru" ) -// The starting nonce determines the default nonce when new accounts are being -// created. -var StartingNonce uint64 - // Trie cache generation limit after which to evic trie nodes from memory. var MaxTrieCacheGen = uint16(120) @@ -239,7 +235,7 @@ func (self *StateDB) GetNonce(addr common.Address) uint64 { return stateObject.Nonce() } - return StartingNonce + return 0 } func (self *StateDB) GetCode(addr common.Address) []byte { @@ -423,7 +419,7 @@ func (self *StateDB) MarkStateObjectDirty(addr common.Address) { func (self *StateDB) createObject(addr common.Address) (newobj, prev *StateObject) { prev = self.GetStateObject(addr) newobj = newObject(self, addr, Account{}, self.MarkStateObjectDirty) - newobj.setNonce(StartingNonce) // sets the object to dirty + newobj.setNonce(0) // sets the object to dirty if prev == nil { if glog.V(logger.Core) { glog.Infof("(+) %x\n", addr) diff --git a/light/state.go b/light/state.go index 88f60efbb..3c38f165b 100644 --- a/light/state.go +++ b/light/state.go @@ -26,9 +26,6 @@ import ( "golang.org/x/net/context" ) -// StartingNonce determines the default nonce when new accounts are being created. -var StartingNonce uint64 - // LightState is a memory representation of a state. // This version is ODR capable, caching only the already accessed part of the // state, retrieving unknown parts on-demand from the ODR backend. Changes are @@ -238,7 +235,7 @@ func (self *LightState) newStateObject(addr common.Address) *StateObject { } stateObject := NewStateObject(addr, self.odr) - stateObject.SetNonce(StartingNonce) + stateObject.SetNonce(0) self.stateObjects[addr.Str()] = stateObject return stateObject diff --git a/mobile/geth.go b/mobile/geth.go index e209b667c..738c0c548 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -25,11 +25,9 @@ import ( "path/filepath" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/les" - "github.com/ethereum/go-ethereum/light" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/params" @@ -63,10 +61,6 @@ type NodeConfig struct { // empty genesis state is equivalent to using the mainnet's state. EthereumGenesis string - // EthereumTestnetNonces specifies whether to use account nonces from the testnet - // range (2^20) or from the mainnet one (0). - EthereumTestnetNonces bool - // EthereumDatabaseCache is the system memory in MB to allocate for database caching. // A minimum of 16MB is always reserved. EthereumDatabaseCache int @@ -151,10 +145,6 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) { GpobaseStepUp: 100, GpobaseCorrectionFactor: 110, } - if config.EthereumTestnetNonces { - state.StartingNonce = 1048576 // (2**20) - light.StartingNonce = 1048576 // (2**20) - } if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { return les.New(ctx, ethConf) }); err != nil {