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
80be5e54
Unverified
Commit
80be5e54
authored
Oct 26, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/puppeth: store genesis locally to persist restarts
parent
7abf968d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
64 additions
and
49 deletions
+64
-49
module_dashboard.go
cmd/puppeth/module_dashboard.go
+12
-12
wizard.go
cmd/puppeth/wizard.go
+5
-5
wizard_explorer.go
cmd/puppeth/wizard_explorer.go
+3
-3
wizard_faucet.go
cmd/puppeth/wizard_faucet.go
+2
-2
wizard_genesis.go
cmd/puppeth/wizard_genesis.go
+28
-13
wizard_intro.go
cmd/puppeth/wizard_intro.go
+2
-2
wizard_netstats.go
cmd/puppeth/wizard_netstats.go
+3
-3
wizard_node.go
cmd/puppeth/wizard_node.go
+6
-6
wizard_wallet.go
cmd/puppeth/wizard_wallet.go
+3
-3
No files found.
cmd/puppeth/module_dashboard.go
View file @
80be5e54
...
...
@@ -608,7 +608,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
}
template.Must(template.New("").Parse(dashboardContent)).Execute(indexfile, map[string]interface{}{
"Network": network,
"NetworkID"
:
conf
.
g
enesis
.
Config
.
ChainId
,
"NetworkID": conf.
G
enesis.Config.ChainId,
"NetworkTitle": strings.Title(network),
"EthstatsPage": config.ethstats,
"ExplorerPage": config.explorer,
...
...
@@ -620,7 +620,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
"BootnodesFullFlat": strings.Join(conf.bootFull, ","),
"BootnodesLightFlat": strings.Join(conf.bootLight, ","),
"Ethstats": statsLogin,
"Ethash"
:
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
,
"Ethash": conf.
G
enesis.Config.Ethash != nil,
"CppGenesis": network + "-cpp.json",
"CppBootnodes": strings.Join(bootCpp, " "),
"HarmonyGenesis": network + "-harmony.json",
...
...
@@ -628,36 +628,36 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
"ParityGenesis": network + "-parity.json",
"PythonGenesis": network + "-python.json",
"PythonBootnodes": strings.Join(bootPython, ","),
"Homestead"
:
conf
.
g
enesis
.
Config
.
HomesteadBlock
,
"Tangerine"
:
conf
.
g
enesis
.
Config
.
EIP150Block
,
"Spurious"
:
conf
.
g
enesis
.
Config
.
EIP155Block
,
"Byzantium"
:
conf
.
g
enesis
.
Config
.
ByzantiumBlock
,
"Homestead": conf.
G
enesis.Config.HomesteadBlock,
"Tangerine": conf.
G
enesis.Config.EIP150Block,
"Spurious": conf.
G
enesis.Config.EIP155Block,
"Byzantium": conf.
G
enesis.Config.ByzantiumBlock,
})
files[filepath.Join(workdir, "index.html")] = indexfile.Bytes()
// Marshal the genesis spec files for go-ethereum and all the other clients
genesis
,
_
:=
conf
.
g
enesis
.
MarshalJSON
()
genesis, _ := conf.
G
enesis.MarshalJSON()
files[filepath.Join(workdir, network+".json")] = genesis
if
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
{
cppSpec
,
err
:=
newCppEthereumGenesisSpec
(
network
,
conf
.
g
enesis
)
if conf.
G
enesis.Config.Ethash != nil {
cppSpec, err := newCppEthereumGenesisSpec(network, conf.
G
enesis)
if err != nil {
return nil, err
}
cppSpecJSON, _ := json.Marshal(cppSpec)
files[filepath.Join(workdir, network+"-cpp.json")] = cppSpecJSON
harmonySpecJSON
,
_
:=
conf
.
g
enesis
.
MarshalJSON
()
harmonySpecJSON, _ := conf.
G
enesis.MarshalJSON()
files[filepath.Join(workdir, network+"-harmony.json")] = harmonySpecJSON
paritySpec
,
err
:=
newParityChainSpec
(
network
,
conf
.
g
enesis
,
conf
.
bootFull
)
paritySpec, err := newParityChainSpec(network, conf.
G
enesis, conf.bootFull)
if err != nil {
return nil, err
}
paritySpecJSON, _ := json.Marshal(paritySpec)
files[filepath.Join(workdir, network+"-parity.json")] = paritySpecJSON
pyethSpec
,
err
:=
newPyEthereumGenesisSpec
(
network
,
conf
.
g
enesis
)
pyethSpec, err := newPyEthereumGenesisSpec(network, conf.
G
enesis)
if err != nil {
return nil, err
}
...
...
cmd/puppeth/wizard.go
View file @
80be5e54
...
...
@@ -40,11 +40,11 @@ import (
// between sessions.
type
config
struct
{
path
string
// File containing the configuration values
genesis
*
core
.
Genesis
// Genesis block to cache for node deploys
bootFull
[]
string
// Bootnodes to always connect to by full nodes
bootLight
[]
string
// Bootnodes to always connect to by light nodes
ethstats
string
// Ethstats settings to cache for node deploys
Genesis
*
core
.
Genesis
`json:"genesis,omitempty"`
// Genesis block to cache for node deploys
Servers
map
[
string
][]
byte
`json:"servers,omitempty"`
}
...
...
cmd/puppeth/wizard_explorer.go
View file @
80be5e54
...
...
@@ -27,7 +27,7 @@ import (
// deployExplorer creates a new block explorer based on some user input.
func
(
w
*
wizard
)
deployExplorer
()
{
// Do some sanity check before the user wastes time on input
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
log
.
Error
(
"No genesis block configured"
)
return
}
...
...
@@ -35,7 +35,7 @@ func (w *wizard) deployExplorer() {
log
.
Error
(
"No ethstats server configured"
)
return
}
if
w
.
conf
.
g
enesis
.
Config
.
Ethash
==
nil
{
if
w
.
conf
.
G
enesis
.
Config
.
Ethash
==
nil
{
log
.
Error
(
"Only ethash network supported"
)
return
}
...
...
@@ -51,7 +51,7 @@ func (w *wizard) deployExplorer() {
if
err
!=
nil
{
infos
=
&
explorerInfos
{
nodePort
:
30303
,
webPort
:
80
,
webHost
:
client
.
server
}
}
chainspec
,
err
:=
newParityChainSpec
(
w
.
network
,
w
.
conf
.
g
enesis
,
w
.
conf
.
bootFull
)
chainspec
,
err
:=
newParityChainSpec
(
w
.
network
,
w
.
conf
.
G
enesis
,
w
.
conf
.
bootFull
)
if
err
!=
nil
{
log
.
Error
(
"Failed to create chain spec for explorer"
,
"err"
,
err
)
return
...
...
cmd/puppeth/wizard_faucet.go
View file @
80be5e54
...
...
@@ -47,8 +47,8 @@ func (w *wizard) deployFaucet() {
tiers
:
3
,
}
}
infos
.
node
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
infos
.
node
.
network
=
w
.
conf
.
g
enesis
.
Config
.
ChainId
.
Int64
()
infos
.
node
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
infos
.
node
.
network
=
w
.
conf
.
G
enesis
.
Config
.
ChainId
.
Int64
()
// Figure out which port to listen on
fmt
.
Println
()
...
...
cmd/puppeth/wizard_genesis.go
View file @
80be5e54
...
...
@@ -124,7 +124,10 @@ func (w *wizard) makeGenesis() {
genesis
.
Config
.
ChainId
=
new
(
big
.
Int
)
.
SetUint64
(
uint64
(
w
.
readDefaultInt
(
rand
.
Intn
(
65536
))))
// All done, store the genesis and flush to disk
w
.
conf
.
genesis
=
genesis
log
.
Info
(
"Configured new genesis block"
)
w
.
conf
.
Genesis
=
genesis
w
.
conf
.
flush
()
}
// manageGenesis permits the modification of chain configuration parameters in
...
...
@@ -134,44 +137,56 @@ func (w *wizard) manageGenesis() {
fmt
.
Println
()
fmt
.
Println
(
" 1. Modify existing fork rules"
)
fmt
.
Println
(
" 2. Export genesis configuration"
)
fmt
.
Println
(
" 3. Remove genesis configuration"
)
choice
:=
w
.
read
()
switch
{
case
choice
==
"1"
:
// Fork rule updating requested, iterate over each fork
fmt
.
Println
()
fmt
.
Printf
(
"Which block should Homestead come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
HomesteadBlock
)
w
.
conf
.
genesis
.
Config
.
HomesteadBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
HomesteadBlock
)
fmt
.
Printf
(
"Which block should Homestead come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
HomesteadBlock
)
w
.
conf
.
Genesis
.
Config
.
HomesteadBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
HomesteadBlock
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP150 come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
EIP150Block
)
w
.
conf
.
genesis
.
Config
.
EIP150Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
EIP150Block
)
fmt
.
Printf
(
"Which block should EIP150 come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
EIP150Block
)
w
.
conf
.
Genesis
.
Config
.
EIP150Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
EIP150Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP155 come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
EIP155Block
)
w
.
conf
.
genesis
.
Config
.
EIP155Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
EIP155Block
)
fmt
.
Printf
(
"Which block should EIP155 come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
EIP155Block
)
w
.
conf
.
Genesis
.
Config
.
EIP155Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
EIP155Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP158 come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
EIP158Block
)
w
.
conf
.
genesis
.
Config
.
EIP158Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
EIP158Block
)
fmt
.
Printf
(
"Which block should EIP158 come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
EIP158Block
)
w
.
conf
.
Genesis
.
Config
.
EIP158Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
EIP158Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should Byzantium come into effect? (default = %v)
\n
"
,
w
.
conf
.
g
enesis
.
Config
.
ByzantiumBlock
)
w
.
conf
.
genesis
.
Config
.
ByzantiumBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
g
enesis
.
Config
.
ByzantiumBlock
)
fmt
.
Printf
(
"Which block should Byzantium come into effect? (default = %v)
\n
"
,
w
.
conf
.
G
enesis
.
Config
.
ByzantiumBlock
)
w
.
conf
.
Genesis
.
Config
.
ByzantiumBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
G
enesis
.
Config
.
ByzantiumBlock
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
.
Config
,
""
,
" "
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
.
Config
,
""
,
" "
)
fmt
.
Printf
(
"Chain configuration updated:
\n\n
%s
\n
"
,
out
)
case
choice
==
"2"
:
// Save whatever genesis configuration we currently have
fmt
.
Println
()
fmt
.
Printf
(
"Which file to save the genesis into? (default = %s.json)
\n
"
,
w
.
network
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
if
err
:=
ioutil
.
WriteFile
(
w
.
readDefaultString
(
fmt
.
Sprintf
(
"%s.json"
,
w
.
network
)),
out
,
0644
);
err
!=
nil
{
log
.
Error
(
"Failed to save genesis file"
,
"err"
,
err
)
}
log
.
Info
(
"Exported existing genesis block"
)
case
choice
==
"3"
:
// Make sure we don't have any services running
if
len
(
w
.
conf
.
servers
())
>
0
{
log
.
Error
(
"Genesis reset requires all services and servers torn down"
)
return
}
log
.
Info
(
"Genesis block destroyed"
)
w
.
conf
.
Genesis
=
nil
w
.
conf
.
flush
()
default
:
log
.
Error
(
"That's not something I can do"
)
}
...
...
cmd/puppeth/wizard_intro.go
View file @
80be5e54
...
...
@@ -107,7 +107,7 @@ func (w *wizard) run() {
fmt
.
Println
()
fmt
.
Println
(
"What would you like to do? (default = stats)"
)
fmt
.
Println
(
" 1. Show network stats"
)
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
fmt
.
Println
(
" 2. Configure new genesis"
)
}
else
{
fmt
.
Println
(
" 2. Manage existing genesis"
)
...
...
@@ -129,7 +129,7 @@ func (w *wizard) run() {
w
.
networkStats
()
case
choice
==
"2"
:
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
w
.
makeGenesis
()
}
else
{
w
.
manageGenesis
()
...
...
cmd/puppeth/wizard_netstats.go
View file @
80be5e54
...
...
@@ -32,7 +32,7 @@ import (
// configuration set to give users hints on how to do various tasks.
func
(
w
*
wizard
)
networkStats
()
{
if
len
(
w
.
servers
)
==
0
{
log
.
Error
(
"No remote machines to gather stats from"
)
log
.
Info
(
"No remote machines to gather stats from"
)
return
}
// Clear out some previous configs to refill from current scan
...
...
@@ -173,12 +173,12 @@ func (w *wizard) gatherStats(server string, pubkey []byte, client *sshClient) *s
w
.
lock
.
Lock
()
defer
w
.
lock
.
Unlock
()
if
genesis
!=
""
&&
w
.
conf
.
g
enesis
==
nil
{
if
genesis
!=
""
&&
w
.
conf
.
G
enesis
==
nil
{
g
:=
new
(
core
.
Genesis
)
if
err
:=
json
.
Unmarshal
([]
byte
(
genesis
),
g
);
err
!=
nil
{
log
.
Error
(
"Failed to parse remote genesis"
,
"err"
,
err
)
}
else
{
w
.
conf
.
g
enesis
=
g
w
.
conf
.
G
enesis
=
g
}
}
if
ethstats
!=
""
{
...
...
cmd/puppeth/wizard_node.go
View file @
80be5e54
...
...
@@ -29,7 +29,7 @@ import (
// deployNode creates a new node configuration based on some user input.
func
(
w
*
wizard
)
deployNode
(
boot
bool
)
{
// Do some sanity check before the user wastes time on input
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
log
.
Error
(
"No genesis block configured"
)
return
}
...
...
@@ -53,8 +53,8 @@ func (w *wizard) deployNode(boot bool) {
infos
=
&
nodeInfos
{
portFull
:
30303
,
peersTotal
:
50
,
peersLight
:
0
,
gasTarget
:
4.7
,
gasPrice
:
18
}
}
}
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
g
enesis
.
Config
.
ChainId
.
Int64
()
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
G
enesis
.
Config
.
ChainId
.
Int64
()
// Figure out where the user wants to store the persistent data
fmt
.
Println
()
...
...
@@ -65,7 +65,7 @@ func (w *wizard) deployNode(boot bool) {
fmt
.
Printf
(
"Where should data be stored on the remote machine? (default = %s)
\n
"
,
infos
.
datadir
)
infos
.
datadir
=
w
.
readDefaultString
(
infos
.
datadir
)
}
if
w
.
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
&&
!
boot
{
if
w
.
conf
.
G
enesis
.
Config
.
Ethash
!=
nil
&&
!
boot
{
fmt
.
Println
()
if
infos
.
ethashdir
==
""
{
fmt
.
Printf
(
"Where should the ethash mining DAGs be stored on the remote machine?
\n
"
)
...
...
@@ -101,7 +101,7 @@ func (w *wizard) deployNode(boot bool) {
}
// If the node is a miner/signer, load up needed credentials
if
!
boot
{
if
w
.
conf
.
g
enesis
.
Config
.
Ethash
!=
nil
{
if
w
.
conf
.
G
enesis
.
Config
.
Ethash
!=
nil
{
// Ethash based miners only need an etherbase to mine against
fmt
.
Println
()
if
infos
.
etherbase
==
""
{
...
...
@@ -116,7 +116,7 @@ func (w *wizard) deployNode(boot bool) {
fmt
.
Printf
(
"What address should the miner user? (default = %s)
\n
"
,
infos
.
etherbase
)
infos
.
etherbase
=
w
.
readDefaultAddress
(
common
.
HexToAddress
(
infos
.
etherbase
))
.
Hex
()
}
}
else
if
w
.
conf
.
g
enesis
.
Config
.
Clique
!=
nil
{
}
else
if
w
.
conf
.
G
enesis
.
Config
.
Clique
!=
nil
{
// If a previous signer was already set, offer to reuse it
if
infos
.
keyJSON
!=
""
{
if
key
,
err
:=
keystore
.
DecryptKey
([]
byte
(
infos
.
keyJSON
),
infos
.
keyPass
);
err
!=
nil
{
...
...
cmd/puppeth/wizard_wallet.go
View file @
80be5e54
...
...
@@ -27,7 +27,7 @@ import (
// deployWallet creates a new web wallet based on some user input.
func
(
w
*
wizard
)
deployWallet
()
{
// Do some sanity check before the user wastes time on input
if
w
.
conf
.
g
enesis
==
nil
{
if
w
.
conf
.
G
enesis
==
nil
{
log
.
Error
(
"No genesis block configured"
)
return
}
...
...
@@ -47,8 +47,8 @@ func (w *wizard) deployWallet() {
if
err
!=
nil
{
infos
=
&
walletInfos
{
nodePort
:
30303
,
rpcPort
:
8545
,
webPort
:
80
,
webHost
:
client
.
server
}
}
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
g
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
g
enesis
.
Config
.
ChainId
.
Int64
()
infos
.
genesis
,
_
=
json
.
MarshalIndent
(
w
.
conf
.
G
enesis
,
""
,
" "
)
infos
.
network
=
w
.
conf
.
G
enesis
.
Config
.
ChainId
.
Int64
()
// Figure out which port to listen on
fmt
.
Println
()
...
...
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