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
8698fbab
Unverified
Commit
8698fbab
authored
Nov 24, 2018
by
Martin Holst Swende
Committed by
Péter Szilágyi
Dec 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/puppeth: implement chainspec converters
parent
a3fd415c
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
779 additions
and
161 deletions
+779
-161
genesis.go
cmd/puppeth/genesis.go
+241
-145
module_dashboard.go
cmd/puppeth/module_dashboard.go
+1
-1
puppeth.go
cmd/puppeth/puppeth.go
+32
-0
puppeth_test.go
cmd/puppeth/puppeth_test.go
+91
-0
stureby_aleth.json
cmd/puppeth/testdata/stureby_aleth.json
+112
-0
stureby_geth.json
cmd/puppeth/testdata/stureby_geth.json
+47
-0
stureby_parity.json
cmd/puppeth/testdata/stureby_parity.json
+181
-0
wizard.go
cmd/puppeth/wizard.go
+22
-0
wizard_genesis.go
cmd/puppeth/wizard_genesis.go
+52
-15
No files found.
cmd/puppeth/genesis.go
View file @
8698fbab
This diff is collapsed.
Click to expand it.
cmd/puppeth/module_dashboard.go
View file @
8698fbab
...
...
@@ -640,7 +640,7 @@ func deployDashboard(client *sshClient, network string, conf *config, config *da
files
[
filepath
.
Join
(
workdir
,
network
+
".json"
)]
=
genesis
if
conf
.
Genesis
.
Config
.
Ethash
!=
nil
{
cppSpec
,
err
:=
new
CppEthereum
GenesisSpec
(
network
,
conf
.
Genesis
)
cppSpec
,
err
:=
new
Aleth
GenesisSpec
(
network
,
conf
.
Genesis
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
cmd/puppeth/puppeth.go
View file @
8698fbab
...
...
@@ -18,11 +18,15 @@
package
main
import
(
"encoding/json"
"io/ioutil"
"math/rand"
"os"
"strings"
"time"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
)
...
...
@@ -43,6 +47,14 @@ func main() {
Usage
:
"log level to emit to the screen"
,
},
}
app
.
Commands
=
[]
cli
.
Command
{
cli
.
Command
{
Action
:
utils
.
MigrateFlags
(
convert
),
Name
:
"convert"
,
Usage
:
"Convert from geth genesis into chainspecs for other nodes."
,
ArgsUsage
:
"<geth-genesis.json>"
,
},
}
app
.
Action
=
func
(
c
*
cli
.
Context
)
error
{
// Set up the logger to print everything and the random generator
log
.
Root
()
.
SetHandler
(
log
.
LvlFilterHandler
(
log
.
Lvl
(
c
.
Int
(
"loglevel"
)),
log
.
StreamHandler
(
os
.
Stdout
,
log
.
TerminalFormat
(
true
))))
...
...
@@ -58,3 +70,23 @@ func main() {
}
app
.
Run
(
os
.
Args
)
}
func
convert
(
ctx
*
cli
.
Context
)
error
{
// Ensure we have a source genesis
log
.
Root
()
.
SetHandler
(
log
.
LvlFilterHandler
(
log
.
LvlInfo
,
log
.
StreamHandler
(
os
.
Stdout
,
log
.
TerminalFormat
(
true
))))
if
len
(
ctx
.
Args
())
!=
1
{
utils
.
Fatalf
(
"No geth genesis provided"
)
}
blob
,
err
:=
ioutil
.
ReadFile
(
ctx
.
Args
()
.
First
())
if
err
!=
nil
{
utils
.
Fatalf
(
"Could not read file: %v"
,
err
)
}
var
genesis
core
.
Genesis
if
err
:=
json
.
Unmarshal
(
blob
,
&
genesis
);
err
!=
nil
{
utils
.
Fatalf
(
"Failed parsing genesis: %v"
,
err
)
}
basename
:=
strings
.
TrimRight
(
ctx
.
Args
()
.
First
(),
".json"
)
convertGenesis
(
&
genesis
,
basename
,
basename
,
[]
string
{})
return
nil
}
cmd/puppeth/puppeth_test.go
0 → 100644
View file @
8698fbab
package
main
import
(
"encoding/json"
"fmt"
"io/ioutil"
"reflect"
"strings"
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/core"
)
func
TestConverter_AlethStureby
(
t
*
testing
.
T
)
{
blob
,
err
:=
ioutil
.
ReadFile
(
"testdata/stureby_geth.json"
)
if
err
!=
nil
{
t
.
Fatalf
(
"could not read file: %v"
,
err
)
}
var
genesis
core
.
Genesis
if
err
:=
json
.
Unmarshal
(
blob
,
&
genesis
);
err
!=
nil
{
t
.
Fatalf
(
"failed parsing genesis: %v"
,
err
)
}
spec
,
err
:=
newAlethGenesisSpec
(
"stureby"
,
&
genesis
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed creating chainspec: %v"
,
err
)
}
expBlob
,
err
:=
ioutil
.
ReadFile
(
"testdata/stureby_aleth.json"
)
if
err
!=
nil
{
t
.
Fatalf
(
"could not read file: %v"
,
err
)
}
expspec
:=
&
alethGenesisSpec
{}
if
err
:=
json
.
Unmarshal
(
expBlob
,
expspec
);
err
!=
nil
{
t
.
Fatalf
(
"failed parsing genesis: %v"
,
err
)
}
if
!
reflect
.
DeepEqual
(
expspec
,
spec
)
{
t
.
Errorf
(
"chainspec mismatch"
)
c
:=
spew
.
ConfigState
{
DisablePointerAddresses
:
true
,
SortKeys
:
true
,
}
exp
:=
strings
.
Split
(
c
.
Sdump
(
expspec
),
"
\n
"
)
got
:=
strings
.
Split
(
c
.
Sdump
(
spec
),
"
\n
"
)
for
i
:=
0
;
i
<
len
(
exp
)
&&
i
<
len
(
got
);
i
++
{
if
exp
[
i
]
!=
got
[
i
]
{
fmt
.
Printf
(
"got: %v
\n
exp: %v
\n
"
,
exp
[
i
],
got
[
i
])
}
}
}
}
func
TestConverter_ParityStureby
(
t
*
testing
.
T
)
{
blob
,
err
:=
ioutil
.
ReadFile
(
"testdata/stureby_geth.json"
)
if
err
!=
nil
{
t
.
Fatalf
(
"could not read file: %v"
,
err
)
}
var
genesis
core
.
Genesis
if
err
:=
json
.
Unmarshal
(
blob
,
&
genesis
);
err
!=
nil
{
t
.
Fatalf
(
"failed parsing genesis: %v"
,
err
)
}
spec
,
err
:=
newParityChainSpec
(
"Stureby"
,
&
genesis
,
[]
string
{})
if
err
!=
nil
{
t
.
Fatalf
(
"failed creating chainspec: %v"
,
err
)
}
expBlob
,
err
:=
ioutil
.
ReadFile
(
"testdata/stureby_parity.json"
)
if
err
!=
nil
{
t
.
Fatalf
(
"could not read file: %v"
,
err
)
}
expspec
:=
&
parityChainSpec
{}
if
err
:=
json
.
Unmarshal
(
expBlob
,
expspec
);
err
!=
nil
{
t
.
Fatalf
(
"failed parsing genesis: %v"
,
err
)
}
expspec
.
Nodes
=
[]
string
{}
if
!
reflect
.
DeepEqual
(
expspec
,
spec
)
{
t
.
Errorf
(
"chainspec mismatch"
)
c
:=
spew
.
ConfigState
{
DisablePointerAddresses
:
true
,
SortKeys
:
true
,
}
exp
:=
strings
.
Split
(
c
.
Sdump
(
expspec
),
"
\n
"
)
got
:=
strings
.
Split
(
c
.
Sdump
(
spec
),
"
\n
"
)
for
i
:=
0
;
i
<
len
(
exp
)
&&
i
<
len
(
got
);
i
++
{
if
exp
[
i
]
!=
got
[
i
]
{
fmt
.
Printf
(
"got: %v
\n
exp: %v
\n
"
,
exp
[
i
],
got
[
i
])
}
}
}
}
cmd/puppeth/testdata/stureby_aleth.json
0 → 100644
View file @
8698fbab
{
"sealEngine"
:
"Ethash"
,
"params"
:{
"accountStartNonce"
:
"0x00"
,
"maximumExtraDataSize"
:
"0x20"
,
"homesteadForkBlock"
:
"0x2710"
,
"daoHardforkBlock"
:
"0x00"
,
"EIP150ForkBlock"
:
"0x3a98"
,
"EIP158ForkBlock"
:
"0x59d8"
,
"byzantiumForkBlock"
:
"0x7530"
,
"constantinopleForkBlock"
:
"0x9c40"
,
"minGasLimit"
:
"0x1388"
,
"maxGasLimit"
:
"0x7fffffffffffffff"
,
"tieBreakingGas"
:
false
,
"gasLimitBoundDivisor"
:
"0x0400"
,
"minimumDifficulty"
:
"0x20000"
,
"difficultyBoundDivisor"
:
"0x0800"
,
"durationLimit"
:
"0x0d"
,
"blockReward"
:
"0x4563918244F40000"
,
"networkID"
:
"0x4cb2e"
,
"chainID"
:
"0x4cb2e"
,
"allowFutureBlocks"
:
false
},
"genesis"
:{
"nonce"
:
"0x0000000000000000"
,
"difficulty"
:
"0x20000"
,
"mixHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"author"
:
"0x0000000000000000000000000000000000000000"
,
"timestamp"
:
"0x59a4e76d"
,
"parentHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"extraData"
:
"0x0000000000000000000000000000000000000000000000000000000b4dc0ffee"
,
"gasLimit"
:
"0x47b760"
},
"accounts"
:{
"0000000000000000000000000000000000000001"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"ecrecover"
,
"linear"
:{
"base"
:
3000
,
"word"
:
0
}
}
},
"0000000000000000000000000000000000000002"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"sha256"
,
"linear"
:{
"base"
:
60
,
"word"
:
12
}
}
},
"0000000000000000000000000000000000000003"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"ripemd160"
,
"linear"
:{
"base"
:
600
,
"word"
:
120
}
}
},
"0000000000000000000000000000000000000004"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"identity"
,
"linear"
:{
"base"
:
15
,
"word"
:
3
}
}
},
"0000000000000000000000000000000000000005"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"modexp"
,
"startingBlock"
:
"0x7530"
}
},
"0000000000000000000000000000000000000006"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"alt_bn128_G1_add"
,
"startingBlock"
:
"0x7530"
,
"linear"
:{
"base"
:
500
,
"word"
:
0
}
}
},
"0000000000000000000000000000000000000007"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"alt_bn128_G1_mul"
,
"startingBlock"
:
"0x7530"
,
"linear"
:{
"base"
:
40000
,
"word"
:
0
}
}
},
"0000000000000000000000000000000000000008"
:{
"balance"
:
"1"
,
"precompiled"
:{
"name"
:
"alt_bn128_pairing_product"
,
"startingBlock"
:
"0x7530"
}
}
}
}
cmd/puppeth/testdata/stureby_geth.json
0 → 100644
View file @
8698fbab
{
"config"
:
{
"ethash"
:{},
"chainId"
:
314158
,
"homesteadBlock"
:
10000
,
"eip150Block"
:
15000
,
"eip150Hash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"eip155Block"
:
23000
,
"eip158Block"
:
23000
,
"byzantiumBlock"
:
30000
,
"constantinopleBlock"
:
40000
},
"nonce"
:
"0x0"
,
"timestamp"
:
"0x59a4e76d"
,
"parentHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"extraData"
:
"0x0000000000000000000000000000000000000000000000000000000b4dc0ffee"
,
"gasLimit"
:
"0x47b760"
,
"difficulty"
:
"0x20000"
,
"mixHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"coinbase"
:
"0x0000000000000000000000000000000000000000"
,
"alloc"
:
{
"0000000000000000000000000000000000000001"
:
{
"balance"
:
"0x01"
},
"0000000000000000000000000000000000000002"
:
{
"balance"
:
"0x01"
},
"0000000000000000000000000000000000000003"
:
{
"balance"
:
"0x01"
},
"0000000000000000000000000000000000000004"
:
{
"balance"
:
"0x01"
},
"0000000000000000000000000000000000000005"
:
{
"balance"
:
"0x01"
},
"0000000000000000000000000000000000000006"
:
{
"balance"
:
"0x01"
},
"0000000000000000000000000000000000000007"
:
{
"balance"
:
"0x01"
},
"0000000000000000000000000000000000000008"
:
{
"balance"
:
"0x01"
}
}
}
cmd/puppeth/testdata/stureby_parity.json
0 → 100644
View file @
8698fbab
{
"name"
:
"Stureby"
,
"dataDir"
:
"stureby"
,
"engine"
:{
"Ethash"
:{
"params"
:{
"minimumDifficulty"
:
"0x20000"
,
"difficultyBoundDivisor"
:
"0x800"
,
"durationLimit"
:
"0xd"
,
"blockReward"
:{
"0x0"
:
"0x4563918244f40000"
,
"0x7530"
:
"0x29a2241af62c0000"
,
"0x9c40"
:
"0x1bc16d674ec80000"
},
"homesteadTransition"
:
"0x2710"
,
"eip100bTransition"
:
"0x7530"
,
"difficultyBombDelays"
:{
"0x7530"
:
"0x2dc6c0"
,
"0x9c40"
:
"0x1e8480"
}
}
}
},
"params"
:{
"accountStartNonce"
:
"0x0"
,
"maximumExtraDataSize"
:
"0x20"
,
"gasLimitBoundDivisor"
:
"0x400"
,
"minGasLimit"
:
"0x1388"
,
"networkID"
:
"0x4cb2e"
,
"chainID"
:
"0x4cb2e"
,
"maxCodeSize"
:
"0x6000"
,
"maxCodeSizeTransition"
:
"0x0"
,
"eip98Transition"
:
"0x7fffffffffffffff"
,
"eip150Transition"
:
"0x3a98"
,
"eip160Transition"
:
"0x59d8"
,
"eip161abcTransition"
:
"0x59d8"
,
"eip161dTransition"
:
"0x59d8"
,
"eip155Transition"
:
"0x59d8"
,
"eip140Transition"
:
"0x7530"
,
"eip211Transition"
:
"0x7530"
,
"eip214Transition"
:
"0x7530"
,
"eip658Transition"
:
"0x7530"
,
"eip145Transition"
:
"0x9c40"
,
"eip1014Transition"
:
"0x9c40"
,
"eip1052Transition"
:
"0x9c40"
,
"eip1283Transition"
:
"0x9c40"
},
"genesis"
:{
"seal"
:{
"ethereum"
:{
"nonce"
:
"0x0000000000000000"
,
"mixHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"difficulty"
:
"0x20000"
,
"author"
:
"0x0000000000000000000000000000000000000000"
,
"timestamp"
:
"0x59a4e76d"
,
"parentHash"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"extraData"
:
"0x0000000000000000000000000000000000000000000000000000000b4dc0ffee"
,
"gasLimit"
:
"0x47b760"
},
"nodes"
:[
"enode://dfa7aca3f5b635fbfe7d0b20575f25e40d9e27b4bfbb3cf74364a42023ad9f25c1a4383bcc8cced86ee511a7d03415345a4df05be37f1dff040e4c780699f1c0@168.61.153.255:31303"
,
"enode://ef441b20dd70aeabf0eac35c3b8a2854e5ce04db0e30be9152ea9fd129359dcbb3f803993303ff5781c755dfd7223f3fe43505f583cccb740949407677412ba9@40.74.91.252:31303"
,
"enode://953b5ea1c8987cf46008232a0160324fd00d41320ecf00e23af86ec8f5396b19eb57ddab37c78141be56f62e9077de4f4dfa0747fa768ed8c8531bbfb1046237@40.70.214.166:31303"
,
"enode://276e613dd4b277a66591e565711e6c8bb107f0905248a9f8f8228c1a87992e156e5114bb9937c02824a9d9d25f76340442cf86e2028bf5293cae19904fb2b98e@35.178.251.52:30303"
,
"enode://064c820d41e52ed7d426ac64b60506c2998235bedc7e67cb497c6faf7bb4fc54fe56fc82d0add3180b747c0c4f40a1108a6f84d7d0629ed606d504528e61cc57@3.8.5.3:30303"
,
"enode://90069fdabcc5e684fa5d59430bebbb12755d9362dfe5006a1485b13d71a78a3812d36e74dd7d88e50b51add01e097ea80f16263aeaa4f0230db6c79e2a97e7ca@217.29.191.142:30303"
,
"enode://0aac74b7fd28726275e466acb5e03bc88a95927e9951eb66b5efb239b2f798ada0690853b2f2823fe4efa408f0f3d4dd258430bc952a5ff70677b8625b3e3b14@40.115.33.57:40404"
,
"enode://0b96415a10f835106d83e090a0528eed5e7887e5c802a6d084e9f1993a9d0fc713781e6e4101f6365e9b91259712f291acc0a9e6e667e22023050d602c36fbe2@40.115.33.57:40414"
],
"accounts"
:{
"0000000000000000000000000000000000000001"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"ecrecover"
,
"pricing"
:{
"linear"
:{
"base"
:
3000
,
"word"
:
0
}
}
}
},
"0000000000000000000000000000000000000002"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"sha256"
,
"pricing"
:{
"linear"
:{
"base"
:
60
,
"word"
:
12
}
}
}
},
"0000000000000000000000000000000000000003"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"ripemd160"
,
"pricing"
:{
"linear"
:{
"base"
:
600
,
"word"
:
120
}
}
}
},
"0000000000000000000000000000000000000004"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"identity"
,
"pricing"
:{
"linear"
:{
"base"
:
15
,
"word"
:
3
}
}
}
},
"0000000000000000000000000000000000000005"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"modexp"
,
"activate_at"
:
"0x7530"
,
"pricing"
:{
"modexp"
:{
"divisor"
:
20
}
}
}
},
"0000000000000000000000000000000000000006"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"alt_bn128_add"
,
"activate_at"
:
"0x7530"
,
"pricing"
:{
"linear"
:{
"base"
:
500
,
"word"
:
0
}
}
}
},
"0000000000000000000000000000000000000007"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"alt_bn128_mul"
,
"activate_at"
:
"0x7530"
,
"pricing"
:{
"linear"
:{
"base"
:
40000
,
"word"
:
0
}
}
}
},
"0000000000000000000000000000000000000008"
:{
"balance"
:
"1"
,
"nonce"
:
"0"
,
"builtin"
:{
"name"
:
"alt_bn128_pairing"
,
"activate_at"
:
"0x7530"
,
"pricing"
:{
"alt_bn128_pairing"
:{
"base"
:
100000
,
"pair"
:
80000
}
}
}
}
}
}
cmd/puppeth/wizard.go
View file @
8698fbab
...
...
@@ -104,6 +104,28 @@ func (w *wizard) readString() string {
}
}
// readYesNo reads a yes or no from stdin, returning boolean true for yes
func
(
w
*
wizard
)
readYesNo
(
def
bool
)
bool
{
for
{
fmt
.
Printf
(
"> "
)
text
,
err
:=
w
.
in
.
ReadString
(
'\n'
)
if
err
!=
nil
{
log
.
Crit
(
"Failed to read user input"
,
"err"
,
err
)
}
text
=
strings
.
ToLower
(
strings
.
TrimSpace
(
text
))
if
text
==
"y"
||
text
==
"yes"
{
return
true
}
if
text
==
"n"
||
text
==
"no"
{
return
false
}
if
len
(
text
)
==
0
{
return
def
}
fmt
.
Println
(
"Valid answers: y, yes, n, no or leave empty for default"
)
}
}
// readDefaultString reads a single line from stdin, trimming if from spaces. If
// an empty line is entered, the default value is returned.
func
(
w
*
wizard
)
readDefaultString
(
def
string
)
string
{
...
...
cmd/puppeth/wizard_genesis.go
View file @
8698fbab
...
...
@@ -114,9 +114,13 @@ func (w *wizard) makeGenesis() {
}
break
}
// Add a batch of precompile balances to avoid them getting deleted
for
i
:=
int64
(
0
);
i
<
256
;
i
++
{
genesis
.
Alloc
[
common
.
BigToAddress
(
big
.
NewInt
(
i
))]
=
core
.
GenesisAccount
{
Balance
:
big
.
NewInt
(
1
)}
fmt
.
Println
()
fmt
.
Println
(
"Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei? (advisable yes)"
)
if
w
.
readYesNo
(
true
)
{
// Add a batch of precompile balances to avoid them getting deleted
for
i
:=
int64
(
0
);
i
<
256
;
i
++
{
genesis
.
Alloc
[
common
.
BigToAddress
(
big
.
NewInt
(
i
))]
=
core
.
GenesisAccount
{
Balance
:
big
.
NewInt
(
1
)}
}
}
// Query the user for some custom extras
fmt
.
Println
()
...
...
@@ -136,47 +140,57 @@ 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"
)
fmt
.
Println
(
" 2. Export genesis configuration
s
"
)
fmt
.
Println
(
" 3. Remove genesis configuration"
)
choice
:=
w
.
read
()
switch
{
case
choice
==
"1"
:
switch
choice
{
case
"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
)
fmt
.
Printf
(
"Which block should EIP150
(Tangerine Whistle)
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
)
fmt
.
Printf
(
"Which block should EIP155
(Spurious Dragon)
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
)
fmt
.
Printf
(
"Which block should EIP158
/161 (also Spurious Dragon)
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
)
fmt
.
Println
()
fmt
.
Printf
(
"Which block should Constantinople come into effect? (default = %v)
\n
"
,
w
.
conf
.
Genesis
.
Config
.
ByzantiumBlock
)
w
.
conf
.
Genesis
.
Config
.
ConstantinopleBlock
=
w
.
readDefaultBigInt
(
w
.
conf
.
Genesis
.
Config
.
ConstantinopleBlock
)
out
,
_
:=
json
.
MarshalIndent
(
w
.
conf
.
Genesis
.
Config
,
""
,
" "
)
fmt
.
Printf
(
"Chain configuration updated:
\n\n
%s
\n
"
,
out
)
case
choice
==
"2"
:
case
"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
)
fmt
.
Printf
(
"Which
base filename to save the genesis specifications into? (default = %s
)
\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
{
basename
:=
w
.
readDefaultString
(
fmt
.
Sprintf
(
"%s.json"
,
w
.
network
))
gethJson
:=
fmt
.
Sprintf
(
"%s.json"
,
basename
)
if
err
:=
ioutil
.
WriteFile
((
gethJson
),
out
,
0644
);
err
!=
nil
{
log
.
Error
(
"Failed to save genesis file"
,
"err"
,
err
)
}
log
.
Info
(
"Exported existing genesis block"
)
log
.
Info
(
"Saved geth genesis as %v"
,
gethJson
)
if
err
:=
convertGenesis
(
w
.
conf
.
Genesis
,
basename
,
w
.
network
,
w
.
conf
.
bootnodes
);
err
!=
nil
{
log
.
Error
(
"Conversion failed"
,
"err"
,
err
)
}
case
choice
==
"3"
:
case
"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"
)
...
...
@@ -186,8 +200,31 @@ func (w *wizard) manageGenesis() {
w
.
conf
.
Genesis
=
nil
w
.
conf
.
flush
()
default
:
log
.
Error
(
"That's not something I can do"
)
}
}
func
saveGenesis
(
basename
,
client
string
,
spec
interface
{})
{
filename
:=
fmt
.
Sprintf
(
"%s-%s.json"
,
basename
,
client
)
out
,
_
:=
json
.
Marshal
(
spec
)
if
err
:=
ioutil
.
WriteFile
(
filename
,
out
,
0644
);
err
!=
nil
{
log
.
Error
(
"failed to save genesis file"
,
"client"
,
client
,
"err"
,
err
)
}
log
.
Info
(
"saved chainspec"
,
"client"
,
client
,
"filename"
,
filename
)
}
func
convertGenesis
(
genesis
*
core
.
Genesis
,
basename
string
,
network
string
,
bootnodes
[]
string
)
error
{
if
spec
,
err
:=
newAlethGenesisSpec
(
network
,
genesis
);
err
==
nil
{
saveGenesis
(
basename
,
"aleth"
,
spec
)
}
else
{
log
.
Error
(
"failed to create chain spec"
,
"client"
,
"aleth"
,
"err"
,
err
)
}
if
spec
,
err
:=
newParityChainSpec
(
network
,
genesis
,
[]
string
{});
err
==
nil
{
saveGenesis
(
basename
,
"parity"
,
spec
)
}
else
{
log
.
Error
(
"failed to create chain spec"
,
"client"
,
"parity"
,
"err"
,
err
)
}
saveGenesis
(
basename
,
"harmony"
,
genesis
)
return
nil
}
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