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
6060e098
Commit
6060e098
authored
Jul 07, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd, core, eth, params: implement flags to control dao fork blocks
parent
aa1e052c
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
354 additions
and
46 deletions
+354
-46
dao_test.go
cmd/geth/dao_test.go
+306
-0
main.go
cmd/geth/main.go
+2
-7
usage.go
cmd/geth/usage.go
+0
-1
flags.go
cmd/utils/flags.go
+40
-36
config.go
core/config.go
+2
-2
backend.go
eth/backend.go
+2
-0
util.go
params/util.go
+2
-0
No files found.
cmd/geth/dao_test.go
0 → 100644
View file @
6060e098
This diff is collapsed.
Click to expand it.
cmd/geth/main.go
View file @
6060e098
...
...
@@ -150,7 +150,6 @@ participating.
utils
.
IdentityFlag
,
utils
.
UnlockedAccountFlag
,
utils
.
PasswordFileFlag
,
utils
.
GenesisFileFlag
,
utils
.
BootnodesFlag
,
utils
.
DataDirFlag
,
utils
.
KeyStoreDirFlag
,
...
...
@@ -165,6 +164,8 @@ participating.
utils
.
MaxPendingPeersFlag
,
utils
.
EtherbaseFlag
,
utils
.
GasPriceFlag
,
utils
.
SupportDAOFork
,
utils
.
OpposeDAOFork
,
utils
.
MinerThreadsFlag
,
utils
.
MiningEnabledFlag
,
utils
.
MiningGPUFlag
,
...
...
@@ -225,12 +226,6 @@ participating.
eth
.
EnableBadBlockReporting
=
true
utils
.
SetupNetwork
(
ctx
)
// Deprecation warning.
if
ctx
.
GlobalIsSet
(
utils
.
GenesisFileFlag
.
Name
)
{
common
.
PrintDepricationWarning
(
"--genesis is deprecated. Switch to use 'geth init /path/to/file'"
)
}
return
nil
}
...
...
cmd/geth/usage.go
View file @
6060e098
...
...
@@ -68,7 +68,6 @@ var AppHelpFlagGroups = []flagGroup{
utils
.
OlympicFlag
,
utils
.
TestNetFlag
,
utils
.
DevModeFlag
,
utils
.
GenesisFileFlag
,
utils
.
IdentityFlag
,
utils
.
FastSyncFlag
,
utils
.
LightKDFFlag
,
...
...
cmd/utils/flags.go
View file @
6060e098
...
...
@@ -126,10 +126,6 @@ var (
Name
:
"dev"
,
Usage
:
"Developer mode: pre-configured private network with several debugging flags"
,
}
GenesisFileFlag
=
cli
.
StringFlag
{
Name
:
"genesis"
,
Usage
:
"Insert/overwrite the genesis block (JSON format)"
,
}
IdentityFlag
=
cli
.
StringFlag
{
Name
:
"identity"
,
Usage
:
"Custom node name"
,
...
...
@@ -161,6 +157,15 @@ var (
Name
:
"lightkdf"
,
Usage
:
"Reduce key-derivation RAM & CPU usage at some expense of KDF strength"
,
}
// Fork settings
SupportDAOFork
=
cli
.
BoolFlag
{
Name
:
"support-dao-fork"
,
Usage
:
"Updates the chain rules to support the DAO hard-fork"
,
}
OpposeDAOFork
=
cli
.
BoolFlag
{
Name
:
"oppose-dao-fork"
,
Usage
:
"Updates the chain rules to oppose the DAO hard-fork"
,
}
// Miner settings
// TODO: refactor CPU vs GPU mining flags
MiningEnabledFlag
=
cli
.
BoolFlag
{
...
...
@@ -534,20 +539,6 @@ func MakeWSRpcHost(ctx *cli.Context) string {
return
ctx
.
GlobalString
(
WSListenAddrFlag
.
Name
)
}
// MakeGenesisBlock loads up a genesis block from an input file specified in the
// command line, or returns the empty string if none set.
func
MakeGenesisBlock
(
ctx
*
cli
.
Context
)
string
{
genesis
:=
ctx
.
GlobalString
(
GenesisFileFlag
.
Name
)
if
genesis
==
""
{
return
""
}
data
,
err
:=
ioutil
.
ReadFile
(
genesis
)
if
err
!=
nil
{
Fatalf
(
"Failed to load custom genesis file: %v"
,
err
)
}
return
string
(
data
)
}
// MakeDatabaseHandles raises out the number of allowed file handles per process
// for Geth and returns half of the allowance to assign to the database.
func
MakeDatabaseHandles
()
int
{
...
...
@@ -689,7 +680,6 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte,
ethConf
:=
&
eth
.
Config
{
ChainConfig
:
MustMakeChainConfig
(
ctx
),
Genesis
:
MakeGenesisBlock
(
ctx
),
FastSync
:
ctx
.
GlobalBool
(
FastSyncFlag
.
Name
),
BlockChainVersion
:
ctx
.
GlobalInt
(
BlockchainVersionFlag
.
Name
),
DatabaseCache
:
ctx
.
GlobalInt
(
CacheFlag
.
Name
),
...
...
@@ -722,17 +712,13 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte,
if
!
ctx
.
GlobalIsSet
(
NetworkIdFlag
.
Name
)
{
ethConf
.
NetworkId
=
1
}
if
!
ctx
.
GlobalIsSet
(
GenesisFileFlag
.
Name
)
{
ethConf
.
Genesis
=
core
.
OlympicGenesisBlock
()
}
ethConf
.
Genesis
=
core
.
OlympicGenesisBlock
()
case
ctx
.
GlobalBool
(
TestNetFlag
.
Name
)
:
if
!
ctx
.
GlobalIsSet
(
NetworkIdFlag
.
Name
)
{
ethConf
.
NetworkId
=
2
}
if
!
ctx
.
GlobalIsSet
(
GenesisFileFlag
.
Name
)
{
ethConf
.
Genesis
=
core
.
TestNetGenesisBlock
()
}
ethConf
.
Genesis
=
core
.
TestNetGenesisBlock
()
state
.
StartingNonce
=
1048576
// (2**20)
case
ctx
.
GlobalBool
(
DevModeFlag
.
Name
)
:
...
...
@@ -747,9 +733,7 @@ func MakeSystemNode(name, version string, relconf release.Config, extra []byte,
stackConf
.
ListenAddr
=
":0"
}
// Override the Ethereum protocol configs
if
!
ctx
.
GlobalIsSet
(
GenesisFileFlag
.
Name
)
{
ethConf
.
Genesis
=
core
.
OlympicGenesisBlock
()
}
ethConf
.
Genesis
=
core
.
OlympicGenesisBlock
()
if
!
ctx
.
GlobalIsSet
(
GasPriceFlag
.
Name
)
{
ethConf
.
GasPrice
=
new
(
big
.
Int
)
}
...
...
@@ -813,24 +797,44 @@ func MustMakeChainConfig(ctx *cli.Context) *core.ChainConfig {
// MustMakeChainConfigFromDb reads the chain configuration from the given database.
func
MustMakeChainConfigFromDb
(
ctx
*
cli
.
Context
,
db
ethdb
.
Database
)
*
core
.
ChainConfig
{
genesis
:=
core
.
GetBlock
(
db
,
core
.
GetCanonicalHash
(
db
,
0
),
0
)
if
genesis
!=
nil
{
// Existing genesis block, use stored config if available.
// If the chain is already initialized, use any existing chain configs
if
genesis
:=
core
.
GetBlock
(
db
,
core
.
GetCanonicalHash
(
db
,
0
),
0
);
genesis
!=
nil
{
storedConfig
,
err
:=
core
.
GetChainConfig
(
db
,
genesis
.
Hash
())
if
err
==
nil
{
// Force override any existing configs if explicitly requested
switch
{
case
storedConfig
.
DAOForkBlock
==
nil
&&
ctx
.
GlobalBool
(
SupportDAOFork
.
Name
)
&&
ctx
.
GlobalBool
(
TestNetFlag
.
Name
)
:
storedConfig
.
DAOForkBlock
=
params
.
TestNetDAOForkBlock
case
storedConfig
.
DAOForkBlock
==
nil
&&
ctx
.
GlobalBool
(
SupportDAOFork
.
Name
)
:
storedConfig
.
DAOForkBlock
=
params
.
MainNetDAOForkBlock
case
ctx
.
GlobalBool
(
OpposeDAOFork
.
Name
)
:
storedConfig
.
DAOForkBlock
=
nil
}
return
storedConfig
}
else
if
err
!=
core
.
ChainConfigNotFoundErr
{
Fatalf
(
"Could not make chain configuration: %v"
,
err
)
}
}
var
homesteadBlockNo
*
big
.
Int
// If the chain is uninitialized nor no configs are present, create one
var
homesteadBlock
*
big
.
Int
if
ctx
.
GlobalBool
(
TestNetFlag
.
Name
)
{
homesteadBlock
No
=
params
.
TestNetHomesteadBlock
homesteadBlock
=
params
.
TestNetHomesteadBlock
}
else
{
homesteadBlockNo
=
params
.
MainNetHomesteadBlock
homesteadBlock
=
params
.
MainNetHomesteadBlock
}
var
daoForkBlock
*
big
.
Int
switch
{
case
ctx
.
GlobalBool
(
SupportDAOFork
.
Name
)
&&
ctx
.
GlobalBool
(
TestNetFlag
.
Name
)
:
daoForkBlock
=
params
.
TestNetDAOForkBlock
case
ctx
.
GlobalBool
(
SupportDAOFork
.
Name
)
:
daoForkBlock
=
params
.
MainNetDAOForkBlock
case
ctx
.
GlobalBool
(
OpposeDAOFork
.
Name
)
:
daoForkBlock
=
nil
}
return
&
core
.
ChainConfig
{
HomesteadBlock
:
homesteadBlock
,
DAOForkBlock
:
daoForkBlock
,
}
return
&
core
.
ChainConfig
{
HomesteadBlock
:
homesteadBlockNo
}
}
// MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
...
...
core/config.go
View file @
6060e098
...
...
@@ -31,7 +31,8 @@ var ChainConfigNotFoundErr = errors.New("ChainConfig not found") // general conf
// that any network, identified by its genesis block, can have its own
// set of configuration options.
type
ChainConfig
struct
{
HomesteadBlock
*
big
.
Int
// homestead switch block
HomesteadBlock
*
big
.
Int
`json:"homesteadBlock"`
// homestead switch block (0 = already homestead)
DAOForkBlock
*
big
.
Int
`json:"daoForkBlock"`
// TheDAO hard-fork block (nil = no fork)
VmConfig
vm
.
Config
`json:"-"`
}
...
...
@@ -41,6 +42,5 @@ func (c *ChainConfig) IsHomestead(num *big.Int) bool {
if
num
==
nil
{
return
false
}
return
num
.
Cmp
(
c
.
HomesteadBlock
)
>=
0
}
eth/backend.go
View file @
6060e098
...
...
@@ -205,6 +205,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
if
config
.
ChainConfig
==
nil
{
return
nil
,
errors
.
New
(
"missing chain config"
)
}
core
.
WriteChainConfig
(
chainDb
,
genesis
.
Hash
(),
config
.
ChainConfig
)
eth
.
chainConfig
=
config
.
ChainConfig
eth
.
chainConfig
.
VmConfig
=
vm
.
Config
{
EnableJit
:
config
.
EnableJit
,
...
...
params/util.go
View file @
6060e098
...
...
@@ -21,4 +21,6 @@ import "math/big"
var
(
TestNetHomesteadBlock
=
big
.
NewInt
(
494000
)
// testnet homestead block
MainNetHomesteadBlock
=
big
.
NewInt
(
1150000
)
// mainnet homestead block
TestNetDAOForkBlock
=
big
.
NewInt
(
8888888
)
// testnet dao hard-fork block
MainNetDAOForkBlock
=
big
.
NewInt
(
9999999
)
// mainnet dao hard-fork block
)
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