Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
315a422b
Commit
315a422b
authored
Oct 09, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1888 from obscuren/testnet
cmd, core, eth: added official testnet
parents
9e915791
1de796f1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
1 deletion
+62
-1
main.go
cmd/geth/main.go
+1
-0
flags.go
cmd/utils/flags.go
+18
-0
genesis.go
core/genesis.go
+21
-0
statedb.go
core/state/statedb.go
+5
-0
backend.go
eth/backend.go
+17
-1
No files found.
cmd/geth/main.go
View file @
315a422b
...
...
@@ -314,6 +314,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils
.
ExecFlag
,
utils
.
WhisperEnabledFlag
,
utils
.
DevModeFlag
,
utils
.
TestNetFlag
,
utils
.
VMDebugFlag
,
utils
.
VMForceJitFlag
,
utils
.
VMJitCacheFlag
,
...
...
cmd/utils/flags.go
View file @
315a422b
...
...
@@ -127,6 +127,10 @@ var (
Name
:
"dev"
,
Usage
:
"Developer mode. This mode creates a private network and sets several debugging flags"
,
}
TestNetFlag
=
cli
.
BoolFlag
{
Name
:
"testnet"
,
Usage
:
"Testnet mode. This enables your node to operate on the testnet"
,
}
IdentityFlag
=
cli
.
StringFlag
{
Name
:
"identity"
,
Usage
:
"Custom node name"
,
...
...
@@ -454,6 +458,17 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config {
AutoDAG
:
ctx
.
GlobalBool
(
AutoDAGFlag
.
Name
)
||
ctx
.
GlobalBool
(
MiningEnabledFlag
.
Name
),
}
if
ctx
.
GlobalBool
(
DevModeFlag
.
Name
)
&&
ctx
.
GlobalBool
(
TestNetFlag
.
Name
)
{
glog
.
Fatalf
(
"%s and %s are mutually exclusive
\n
"
,
DevModeFlag
.
Name
,
TestNetFlag
.
Name
)
}
if
ctx
.
GlobalBool
(
TestNetFlag
.
Name
)
{
// testnet is always stored in the testnet folder
cfg
.
DataDir
+=
"/testnet"
cfg
.
NetworkId
=
2
cfg
.
TestNet
=
true
}
if
ctx
.
GlobalBool
(
DevModeFlag
.
Name
)
{
if
!
ctx
.
GlobalIsSet
(
VMDebugFlag
.
Name
)
{
cfg
.
VmDebug
=
true
...
...
@@ -555,6 +570,9 @@ func MakeChain(ctx *cli.Context) (chain *core.BlockChain, chainDb ethdb.Database
// MakeChain creates an account manager from set command line flags.
func
MakeAccountManager
(
ctx
*
cli
.
Context
)
*
accounts
.
Manager
{
dataDir
:=
MustDataDir
(
ctx
)
if
ctx
.
GlobalBool
(
TestNetFlag
.
Name
)
{
dataDir
+=
"/testnet"
}
ks
:=
crypto
.
NewKeyStorePassphrase
(
filepath
.
Join
(
dataDir
,
"keystore"
))
return
accounts
.
NewManager
(
ks
)
}
...
...
core/genesis.go
View file @
315a422b
...
...
@@ -158,6 +158,27 @@ func WriteGenesisBlockForTesting(db ethdb.Database, accounts ...GenesisAccount)
}
func
WriteTestNetGenesisBlock
(
chainDb
ethdb
.
Database
,
nonce
uint64
)
(
*
types
.
Block
,
error
)
{
testGenesis
:=
fmt
.
Sprintf
(
`{
"nonce": "0x%x",
"difficulty": "0x20000",
"mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x2FEFD8",
"alloc": {
"0000000000000000000000000000000000000001": { "balance": "1" },
"0000000000000000000000000000000000000002": { "balance": "1" },
"0000000000000000000000000000000000000003": { "balance": "1" },
"0000000000000000000000000000000000000004": { "balance": "1" },
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376" }
}
}`
,
types
.
EncodeNonce
(
nonce
))
return
WriteGenesisBlock
(
chainDb
,
strings
.
NewReader
(
testGenesis
))
}
func
WriteOlympicGenesisBlock
(
chainDb
ethdb
.
Database
,
nonce
uint64
)
(
*
types
.
Block
,
error
)
{
testGenesis
:=
fmt
.
Sprintf
(
`{
"nonce":"0x%x",
"gasLimit":"0x%x",
...
...
core/state/statedb.go
View file @
315a422b
...
...
@@ -28,6 +28,10 @@ import (
"github.com/ethereum/go-ethereum/trie"
)
// The starting nonce determines the default nonce when new accounts are being
// created.
var
StartingNonce
uint64
// StateDBs within the ethereum protocol are used to store anything
// within the merkle trie. StateDBs take care of caching and storing
// nested states. It's the general query interface to retrieve:
...
...
@@ -263,6 +267,7 @@ func (self *StateDB) newStateObject(addr common.Address) *StateObject {
}
stateObject
:=
NewStateObject
(
addr
,
self
.
db
)
stateObject
.
SetNonce
(
StartingNonce
)
self
.
stateObjects
[
addr
.
Str
()]
=
stateObject
return
stateObject
...
...
eth/backend.go
View file @
315a422b
...
...
@@ -34,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
...
...
@@ -69,12 +70,17 @@ var (
discover
.
MustParseNode
(
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303"
),
}
defaultTestNetBootNodes
=
[]
*
discover
.
Node
{
discover
.
MustParseNode
(
"enode://5374c1bff8df923d3706357eeb4983cd29a63be40a269aaa2296ee5f3b2119a8978c0ed68b8f6fc84aad0df18790417daadf91a4bfbb786a16c9b0a199fa254a@92.51.165.126:30303"
),
}
staticNodes
=
"static-nodes.json"
// Path within <datadir> to search for the static node list
trustedNodes
=
"trusted-nodes.json"
// Path within <datadir> to search for the trusted node list
)
type
Config
struct
{
DevMode
bool
TestNet
bool
Name
string
NetworkId
int
...
...
@@ -133,6 +139,10 @@ type Config struct {
func
(
cfg
*
Config
)
parseBootNodes
()
[]
*
discover
.
Node
{
if
cfg
.
BootNodes
==
""
{
if
cfg
.
TestNet
{
return
defaultTestNetBootNodes
}
return
defaultBootNodes
}
var
ns
[]
*
discover
.
Node
...
...
@@ -309,7 +319,13 @@ func New(config *Config) (*Ethereum, error) {
glog
.
V
(
logger
.
Error
)
.
Infoln
(
"Starting Olympic network"
)
fallthrough
case
config
.
DevMode
:
_
,
err
:=
core
.
WriteTestNetGenesisBlock
(
chainDb
,
42
)
_
,
err
:=
core
.
WriteOlympicGenesisBlock
(
chainDb
,
42
)
if
err
!=
nil
{
return
nil
,
err
}
case
config
.
TestNet
:
state
.
StartingNonce
=
1048576
// (2**20)
_
,
err
:=
core
.
WriteTestNetGenesisBlock
(
chainDb
,
0x6d6f7264656e
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment