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
edba5e98
Unverified
Commit
edba5e98
authored
Oct 04, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/puppeth: support managing fork block in the chain config
parent
c0a1f1c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
11 deletions
+77
-11
wizard.go
cmd/puppeth/wizard.go
+22
-0
wizard_genesis.go
cmd/puppeth/wizard_genesis.go
+52
-0
wizard_intro.go
cmd/puppeth/wizard_intro.go
+2
-10
wizard_netstats.go
cmd/puppeth/wizard_netstats.go
+1
-1
No files found.
cmd/puppeth/wizard.go
View file @
edba5e98
...
@@ -161,6 +161,28 @@ func (w *wizard) readDefaultInt(def int) int {
...
@@ -161,6 +161,28 @@ func (w *wizard) readDefaultInt(def int) int {
}
}
}
}
// readDefaultBigInt reads a single line from stdin, trimming if from spaces,
// enforcing it to parse into a big integer. If an empty line is entered, the
// default value is returned.
func
(
w
*
wizard
)
readDefaultBigInt
(
def
*
big
.
Int
)
*
big
.
Int
{
for
{
fmt
.
Printf
(
"> "
)
text
,
err
:=
w
.
in
.
ReadString
(
'\n'
)
if
err
!=
nil
{
log
.
Crit
(
"Failed to read user input"
,
"err"
,
err
)
}
if
text
=
strings
.
TrimSpace
(
text
);
text
==
""
{
return
def
}
val
,
ok
:=
new
(
big
.
Int
)
.
SetString
(
text
,
0
)
if
!
ok
{
log
.
Error
(
"Invalid input, expected big integer"
)
continue
}
return
val
}
}
/*
/*
// readFloat reads a single line from stdin, trimming if from spaces, enforcing it
// readFloat reads a single line from stdin, trimming if from spaces, enforcing it
// to parse into a float.
// to parse into a float.
...
...
cmd/puppeth/wizard_genesis.go
View file @
edba5e98
...
@@ -18,7 +18,9 @@ package main
...
@@ -18,7 +18,9 @@ package main
import
(
import
(
"bytes"
"bytes"
"encoding/json"
"fmt"
"fmt"
"io/ioutil"
"math/big"
"math/big"
"math/rand"
"math/rand"
"time"
"time"
...
@@ -135,3 +137,53 @@ func (w *wizard) makeGenesis() {
...
@@ -135,3 +137,53 @@ func (w *wizard) makeGenesis() {
// All done, store the genesis and flush to disk
// All done, store the genesis and flush to disk
w
.
conf
.
genesis
=
genesis
w
.
conf
.
genesis
=
genesis
}
}
// manageGenesis permits the modification of chain configuration parameters in
// a genesis config and the export of the entire genesis spec.
func
(
w
*
wizard
)
manageGenesis
()
{
// Figure out whether to modify or export the genesis
fmt
.
Println
()
fmt
.
Println
(
" 1. Modify existing fork rules"
)
fmt
.
Println
(
" 2. Export 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
.
genesis
.
Config
.
HomesteadBlock
)
w
.
conf
.
genesis
.
Config
.
HomesteadBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
genesis
.
Config
.
HomesteadBlock
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP150 come into effect? (default = %v)
\n
"
,
w
.
conf
.
genesis
.
Config
.
EIP150Block
)
w
.
conf
.
genesis
.
Config
.
EIP150Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
genesis
.
Config
.
EIP150Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP155 come into effect? (default = %v)
\n
"
,
w
.
conf
.
genesis
.
Config
.
EIP155Block
)
w
.
conf
.
genesis
.
Config
.
EIP155Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
genesis
.
Config
.
EIP155Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should EIP158 come into effect? (default = %v)
\n
"
,
w
.
conf
.
genesis
.
Config
.
EIP158Block
)
w
.
conf
.
genesis
.
Config
.
EIP158Block
=
w
.
readDefaultBigInt
(
w
.
conf
.
genesis
.
Config
.
EIP158Block
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should Byzantium come into effect? (default = %v)
\n
"
,
w
.
conf
.
genesis
.
Config
.
ByzantiumBlock
)
w
.
conf
.
genesis
.
Config
.
ByzantiumBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
genesis
.
Config
.
ByzantiumBlock
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
genesis
.
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
.
genesis
,
""
,
" "
)
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"
)
default
:
log
.
Error
(
"That's not something I can do"
)
}
}
cmd/puppeth/wizard_intro.go
View file @
edba5e98
...
@@ -98,7 +98,7 @@ func (w *wizard) run() {
...
@@ -98,7 +98,7 @@ func (w *wizard) run() {
if
w
.
conf
.
genesis
==
nil
{
if
w
.
conf
.
genesis
==
nil
{
fmt
.
Println
(
" 2. Configure new genesis"
)
fmt
.
Println
(
" 2. Configure new genesis"
)
}
else
{
}
else
{
fmt
.
Println
(
" 2.
Sav
e existing genesis"
)
fmt
.
Println
(
" 2.
Manag
e existing genesis"
)
}
}
if
len
(
w
.
servers
)
==
0
{
if
len
(
w
.
servers
)
==
0
{
fmt
.
Println
(
" 3. Track new remote server"
)
fmt
.
Println
(
" 3. Track new remote server"
)
...
@@ -118,18 +118,10 @@ func (w *wizard) run() {
...
@@ -118,18 +118,10 @@ func (w *wizard) run() {
w
.
networkStats
(
false
)
w
.
networkStats
(
false
)
case
choice
==
"2"
:
case
choice
==
"2"
:
// If we don't have a genesis, make one
if
w
.
conf
.
genesis
==
nil
{
if
w
.
conf
.
genesis
==
nil
{
w
.
makeGenesis
()
w
.
makeGenesis
()
}
else
{
}
else
{
// Otherwise just save whatever we currently have
w
.
manageGenesis
()
fmt
.
Println
()
fmt
.
Printf
(
"Which file to save the genesis into? (default = %s.json)
\n
"
,
w
.
network
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
genesis
,
""
,
" "
)
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"
:
case
choice
==
"3"
:
if
len
(
w
.
servers
)
==
0
{
if
len
(
w
.
servers
)
==
0
{
...
...
cmd/puppeth/wizard_netstats.go
View file @
edba5e98
...
@@ -129,7 +129,7 @@ func (w *wizard) networkStats(tips bool) {
...
@@ -129,7 +129,7 @@ func (w *wizard) networkStats(tips bool) {
}
}
}
}
// If a genesis block was found, load it into our configs
// If a genesis block was found, load it into our configs
if
protips
.
genesis
!=
""
{
if
protips
.
genesis
!=
""
&&
w
.
conf
.
genesis
==
nil
{
genesis
:=
new
(
core
.
Genesis
)
genesis
:=
new
(
core
.
Genesis
)
if
err
:=
json
.
Unmarshal
([]
byte
(
protips
.
genesis
),
genesis
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
protips
.
genesis
),
genesis
);
err
!=
nil
{
log
.
Error
(
"Failed to parse remote genesis"
,
"err"
,
err
)
log
.
Error
(
"Failed to parse remote genesis"
,
"err"
,
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