cmd/geth, core, light, mobile: removed state account StartingNonce
All account's nonce start at 0.
This commit is contained in:
parent
a0e42aa4e2
commit
aad4890082
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user