cmd/geth, core, light, mobile: removed state account StartingNonce

All account's nonce start at 0.
This commit is contained in:
Jeffrey Wilcke 2016-11-20 12:18:39 +01:00
parent a0e42aa4e2
commit aad4890082
7 changed files with 5 additions and 33 deletions

@ -99,9 +99,6 @@ func importChain(ctx *cli.Context) error {
if len(ctx.Args()) != 1 { if len(ctx.Args()) != 1 {
utils.Fatalf("This command requires an argument.") utils.Fatalf("This command requires an argument.")
} }
if ctx.GlobalBool(utils.TestNetFlag.Name) {
state.StartingNonce = 1048576 // (2**20)
}
stack := makeFullNode(ctx) stack := makeFullNode(ctx)
chain, chainDb := utils.MakeChain(ctx, stack) chain, chainDb := utils.MakeChain(ctx, stack)
defer chainDb.Close() defer chainDb.Close()

@ -34,7 +34,6 @@ import (
"github.com/ethereum/go-ethereum/console" "github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/contracts/release" "github.com/ethereum/go-ethereum/contracts/release"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/internal/debug" "github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/logger" "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") utils.Fatalf("must supply path to genesis JSON file")
} }
if ctx.GlobalBool(utils.TestNetFlag.Name) {
state.StartingNonce = 1048576 // (2**20)
}
stack := makeFullNode(ctx) stack := makeFullNode(ctx)
chaindb := utils.MakeChainDatabase(ctx, stack) chaindb := utils.MakeChainDatabase(ctx, stack)

@ -38,7 +38,6 @@ import (
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics"
@ -754,8 +753,6 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
ethConf.NetworkId = 2 ethConf.NetworkId = 2
} }
ethConf.Genesis = core.TestNetGenesisBlock() ethConf.Genesis = core.TestNetGenesisBlock()
state.StartingNonce = 1048576 // (2**20)
light.StartingNonce = 1048576 // (2**20)
case ctx.GlobalBool(DevModeFlag.Name): case ctx.GlobalBool(DevModeFlag.Name):
ethConf.Genesis = core.OlympicGenesisBlock() ethConf.Genesis = core.OlympicGenesisBlock()

@ -43,7 +43,7 @@ func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block,
} }
var genesis struct { var genesis struct {
ChainConfig *params.ChainConfig `json:"config"` ChainConfig params.ChainConfig `json:"config"`
Nonce string Nonce string
Timestamp string Timestamp string
ParentHash 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 { if err := WriteHeadBlockHash(chainDb, block.Hash()); err != nil {
return nil, err 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 return nil, err
} }

@ -34,10 +34,6 @@ import (
lru "github.com/hashicorp/golang-lru" 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. // Trie cache generation limit after which to evic trie nodes from memory.
var MaxTrieCacheGen = uint16(120) var MaxTrieCacheGen = uint16(120)
@ -239,7 +235,7 @@ func (self *StateDB) GetNonce(addr common.Address) uint64 {
return stateObject.Nonce() return stateObject.Nonce()
} }
return StartingNonce return 0
} }
func (self *StateDB) GetCode(addr common.Address) []byte { 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) { func (self *StateDB) createObject(addr common.Address) (newobj, prev *StateObject) {
prev = self.GetStateObject(addr) prev = self.GetStateObject(addr)
newobj = newObject(self, addr, Account{}, self.MarkStateObjectDirty) 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 prev == nil {
if glog.V(logger.Core) { if glog.V(logger.Core) {
glog.Infof("(+) %x\n", addr) glog.Infof("(+) %x\n", addr)

@ -26,9 +26,6 @@ import (
"golang.org/x/net/context" "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. // LightState is a memory representation of a state.
// This version is ODR capable, caching only the already accessed part of the // 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 // 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 := NewStateObject(addr, self.odr)
stateObject.SetNonce(StartingNonce) stateObject.SetNonce(0)
self.stateObjects[addr.Str()] = stateObject self.stateObjects[addr.Str()] = stateObject
return stateObject return stateObject

@ -25,11 +25,9 @@ import (
"path/filepath" "path/filepath"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
@ -63,10 +61,6 @@ type NodeConfig struct {
// empty genesis state is equivalent to using the mainnet's state. // empty genesis state is equivalent to using the mainnet's state.
EthereumGenesis string 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. // EthereumDatabaseCache is the system memory in MB to allocate for database caching.
// A minimum of 16MB is always reserved. // A minimum of 16MB is always reserved.
EthereumDatabaseCache int EthereumDatabaseCache int
@ -151,10 +145,6 @@ func NewNode(datadir string, config *NodeConfig) (*Node, error) {
GpobaseStepUp: 100, GpobaseStepUp: 100,
GpobaseCorrectionFactor: 110, 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) { if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return les.New(ctx, ethConf) return les.New(ctx, ethConf)
}); err != nil { }); err != nil {