Merge pull request #269 from jpmorganchase/is-quorum-fix

Make `IsQuorum: true` default but not forced.
This commit is contained in:
Patrick Mylund Nielsen 2018-01-30 22:59:02 -05:00 committed by GitHub
commit b8d00f9253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 3 deletions

View File

@ -19,6 +19,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"os" "os"
"runtime" "runtime"
"strconv" "strconv"
@ -140,6 +141,24 @@ Use "ethereum dump 0" to dump the genesis block.`,
} }
) )
// In the regular Genesis / ChainConfig struct, due to the way go deserializes
// json, IsQuorum defaults to false (when not specified). Here we specify it as
// a pointer so we can make the distinction and default unspecified to true.
func getIsQuorum(file io.Reader) bool {
altGenesis := new(struct {
Config *struct {
IsQuorum *bool `json:"isQuorum"`
} `json:"config"`
})
if err := json.NewDecoder(file).Decode(altGenesis); err != nil {
utils.Fatalf("invalid genesis file: %v", err)
}
// unspecified defaults to true
return altGenesis.Config.IsQuorum == nil || *altGenesis.Config.IsQuorum
}
// initGenesis will initialise the given JSON format genesis file and writes it as // initGenesis will initialise the given JSON format genesis file and writes it as
// the zero'd block (i.e. genesis) or will fail hard if it can't succeed. // the zero'd block (i.e. genesis) or will fail hard if it can't succeed.
func initGenesis(ctx *cli.Context) error { func initGenesis(ctx *cli.Context) error {
@ -158,6 +177,10 @@ func initGenesis(ctx *cli.Context) error {
if err := json.NewDecoder(file).Decode(genesis); err != nil { if err := json.NewDecoder(file).Decode(genesis); err != nil {
utils.Fatalf("invalid genesis file: %v", err) utils.Fatalf("invalid genesis file: %v", err)
} }
file.Seek(0, 0)
genesis.Config.IsQuorum = getIsQuorum(file)
// Open an initialise both full and light databases // Open an initialise both full and light databases
stack := makeFullNode(ctx) stack := makeFullNode(ctx)
for _, name := range []string{"chaindata", "lightchaindata"} { for _, name := range []string{"chaindata", "lightchaindata"} {

View File

@ -191,8 +191,6 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
// config is supplied. These chains would get AllProtocolChanges (and a compat error) // config is supplied. These chains would get AllProtocolChanges (and a compat error)
// if we just continued here. // if we just continued here.
if genesis == nil && stored != params.MainnetGenesisHash { if genesis == nil && stored != params.MainnetGenesisHash {
log.Info("Reconfiguring old genesis as Quorum")
storedcfg.IsQuorum = true
return storedcfg, stored, nil return storedcfg, stored, nil
} }

View File

@ -143,7 +143,7 @@ type ChainConfig struct {
Clique *CliqueConfig `json:"clique,omitempty"` Clique *CliqueConfig `json:"clique,omitempty"`
Istanbul *IstanbulConfig `json:"istanbul,omitempty"` Istanbul *IstanbulConfig `json:"istanbul,omitempty"`
IsQuorum bool `json:"isQuorum,omitempty"` IsQuorum bool `json:"isQuorum"`
} }
// EthashConfig is the consensus engine configs for proof-of-work based sealing. // EthashConfig is the consensus engine configs for proof-of-work based sealing.