Skip to content

Commit

Permalink
Merge "[FAB-16477] Use bootstrap file for raft consensus"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Yellick authored and Gerrit Code Review committed Nov 20, 2019
2 parents b77fbe6 + d919905 commit 102ea3c
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/source/kafka.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Then proceed as follows:
of this writing, so there's no need to set it explicitly.)

7. Orderers: **Point each OSN to the genesis block.** Edit
``General.GenesisFile`` in ``orderer.yaml`` so that it points to the genesis
``General.BootstrapFile`` in ``orderer.yaml`` so that it points to the genesis
block created in Step 5 above. While at it, ensure all other keys in that YAML
file are set appropriately.

Expand Down
6 changes: 3 additions & 3 deletions docs/source/orderer_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ to [enable TLS](enable_tls.html). If you set this value to `true`, you will have
to specify the locations of the relevant TLS certificates. Note that this is
mandatory for Raft nodes.

* `GenesisFile` --- this is the name of the genesis block you will generate for
* `BootstrapFile` --- this is the name of the genesis block you will generate for
this ordering service.

* `GenesisMethod` --- the method by which the genesis block is created. For now,
this can only be `file`, in which the file in the `GenesisFile` is specified.
* `GenesisMethod` --- the method by which the bootstrap block is given. For now,
this can only be `file`, in which the file in the `BootstrapFile` is specified.

If you are deploying this node as part of a cluster (for example, as part of a
cluster of Raft nodes), make note of the `Cluster` and `Consensus` sections.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/raft_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Adding a new node to a Raft cluster is done by:
by checking that the config block that was fetched includes the certificate of
(soon to be) added node.
4. **Starting the new Raft node** with the path to the config block in the
`General.GenesisFile` configuration parameter.
`General.BootstrapFile` configuration parameter.
5. **Waiting for the Raft node to replicate the blocks** from existing nodes for
all channels its certificates have been added to. After this step has been
completed, the node begins servicing the channel.
Expand Down
3 changes: 2 additions & 1 deletion integration/nwo/fabricconfig/orderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type General struct {
Keepalive *OrdererKeepalive `yaml:"Keepalive,omitempty"`
GenesisMethod string `yaml:"GenesisMethod,omitempty"`
GenesisProfile string `yaml:"GenesisProfile,omitempty"`
GenesisFile string `yaml:"GenesisFile,omitempty"`
GenesisFile string `yaml:"GenesisFile,omitempty"` // will be replaced by the BootstrapFile
BootstrapFile string `yaml:"BootstrapFile,omitempty"`
LocalMSPDir string `yaml:"LocalMSPDir,omitempty"`
LocalMSPID string `yaml:"LocalMSPID,omitempty"`
Profile *OrdererProfile `yaml:"Profile,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion integration/nwo/orderer_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ General:
ServerInterval: 7200s
ServerTimeout: 20s
GenesisMethod: file
GenesisFile: {{ .RootDir }}/{{ .SystemChannel.Name }}_block.pb
BootstrapFile: {{ .RootDir }}/{{ .SystemChannel.Name }}_block.pb
LocalMSPDir: {{ $w.OrdererLocalMSPDir Orderer }}
LocalMSPID: {{ ($w.Organization Orderer.Organization).MSPID }}
Profile:
Expand Down
2 changes: 1 addition & 1 deletion orderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For details on the configuration structure of channels, refer to the [Channel Co

`configtxgen` is a tool that allows for the creation of a genesis block using profiles, or grouped configuration parameters — refer to the [Configuring using the connfigtxgen tool](../docs/source/configtxgen.rst) guide for more.

The location of this block can be set using the `ORDERER_GENERAL_GENESISFILE` environment variable. As is the case with all the configuration paths for Fabric binaries, this location is relative to the path set via the `FABRIC_CFG_PATH` environment variable.
The location of this block can be set using the `ORDERER_GENERAL_BOOTSTRAPFILE` environment variable. As is the case with all the configuration paths for Fabric binaries, this location is relative to the path set via the `FABRIC_CFG_PATH` environment variable.

## Ledger

Expand Down
17 changes: 12 additions & 5 deletions orderer/common/localconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ type General struct {
Keepalive Keepalive
ConnectionTimeout time.Duration
GenesisMethod string
GenesisFile string
GenesisFile string // For compatibility only, will be replaced by BootstrapFile
BootstrapFile string
Profile Profile
LocalMSPDir string
LocalMSPID string
Expand Down Expand Up @@ -207,7 +208,7 @@ var Defaults = TopLevel{
ListenAddress: "127.0.0.1",
ListenPort: 7050,
GenesisMethod: "file",
GenesisFile: "genesisblock",
BootstrapFile: "genesisblock",
Profile: Profile{
Enabled: false,
Address: "0.0.0.0:6060",
Expand Down Expand Up @@ -316,7 +317,7 @@ func (c *TopLevel) completeInitialization(configDir string) {
c.General.TLS.ClientRootCAs = translateCAs(configDir, c.General.TLS.ClientRootCAs)
coreconfig.TranslatePathInPlace(configDir, &c.General.TLS.PrivateKey)
coreconfig.TranslatePathInPlace(configDir, &c.General.TLS.Certificate)
coreconfig.TranslatePathInPlace(configDir, &c.General.GenesisFile)
coreconfig.TranslatePathInPlace(configDir, &c.General.BootstrapFile)
coreconfig.TranslatePathInPlace(configDir, &c.General.LocalMSPDir)
// Translate file ledger location
coreconfig.TranslatePathInPlace(configDir, &c.FileLedger.Location)
Expand All @@ -332,8 +333,14 @@ func (c *TopLevel) completeInitialization(configDir string) {
c.General.ListenPort = Defaults.General.ListenPort
case c.General.GenesisMethod == "":
c.General.GenesisMethod = Defaults.General.GenesisMethod
case c.General.GenesisFile == "":
c.General.GenesisFile = Defaults.General.GenesisFile
case c.General.BootstrapFile == "":
if c.General.GenesisFile != "" {
// This is to keep the compatibility with old config file that uses genesisfile
logger.Warn("General.GenesisFile should be replaced by General.BootstrapFile")
c.General.BootstrapFile = c.General.GenesisFile
} else {
c.General.BootstrapFile = Defaults.General.BootstrapFile
}
case c.General.Cluster.RPCTimeout == 0:
c.General.Cluster.RPCTimeout = Defaults.General.Cluster.RPCTimeout
case c.General.Cluster.DialTimeout == 0:
Expand Down
6 changes: 3 additions & 3 deletions orderer/common/server/etcdraft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func testEtcdRaftOSNNoTLSSingleListener(gt *GomegaWithT, tempDir, orderer, fabri
"ORDERER_GENERAL_GENESISMETHOD=file",
"ORDERER_GENERAL_SYSTEMCHANNEL=system",
fmt.Sprintf("ORDERER_FILELEDGER_LOCATION=%s", filepath.Join(tempDir, "ledger")),
fmt.Sprintf("ORDERER_GENERAL_GENESISFILE=%s", genesisBlockPath),
fmt.Sprintf("ORDERER_GENERAL_BOOTSTRAPFILE=%s", genesisBlockPath),
fmt.Sprintf("FABRIC_CFG_PATH=%s", filepath.Join(fabricRootDir, "sampleconfig")),
}
ordererProcess, err := gexec.Start(cmd, nil, nil)
Expand All @@ -175,7 +175,7 @@ func testEtcdRaftOSNNoTLSDualListener(gt *GomegaWithT, tempDir, orderer, fabricR
"ORDERER_GENERAL_TLS_ENABLED=false",
"ORDERER_OPERATIONS_TLS_ENABLED=false",
fmt.Sprintf("ORDERER_FILELEDGER_LOCATION=%s", filepath.Join(tempDir, "ledger")),
fmt.Sprintf("ORDERER_GENERAL_GENESISFILE=%s", genesisBlockPath),
fmt.Sprintf("ORDERER_GENERAL_BOOTSTRAPFILE=%s", genesisBlockPath),
fmt.Sprintf("ORDERER_GENERAL_CLUSTER_LISTENPORT=%d", nextPort()),
"ORDERER_GENERAL_CLUSTER_LISTENADDRESS=127.0.0.1",
fmt.Sprintf("ORDERER_GENERAL_CLUSTER_SERVERCERTIFICATE=%s", filepath.Join(cwd, "testdata", "example.com", "tls", "server.crt")),
Expand Down Expand Up @@ -210,7 +210,7 @@ func launchOrderer(gt *GomegaWithT, orderer, tempDir, genesisBlockPath, fabricRo
"ORDERER_GENERAL_TLS_ENABLED=true",
"ORDERER_OPERATIONS_TLS_ENABLED=false",
fmt.Sprintf("ORDERER_FILELEDGER_LOCATION=%s", filepath.Join(tempDir, "ledger")),
fmt.Sprintf("ORDERER_GENERAL_GENESISFILE=%s", genesisBlockPath),
fmt.Sprintf("ORDERER_GENERAL_BOOTSTRAPFILE=%s", genesisBlockPath),
fmt.Sprintf("ORDERER_GENERAL_CLUSTER_LISTENPORT=%d", nextPort()),
"ORDERER_GENERAL_CLUSTER_LISTENADDRESS=127.0.0.1",
fmt.Sprintf("ORDERER_GENERAL_CLUSTER_SERVERCERTIFICATE=%s", filepath.Join(cwd, "testdata", "example.com", "tls", "server.crt")),
Expand Down
2 changes: 1 addition & 1 deletion orderer/common/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func extractBootstrapBlock(conf *localconfig.TopLevel) *cb.Block {
// Select the bootstrapping mechanism
switch conf.General.GenesisMethod {
case "file": // For now, "file" is the only supported genesis method
bootstrapBlock = file.New(conf.General.GenesisFile).GenesisBlock()
bootstrapBlock = file.New(conf.General.BootstrapFile).GenesisBlock()
case "none": // simply honor the configuration value
return nil
default:
Expand Down
12 changes: 6 additions & 6 deletions orderer/common/server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ func TestInitializeBootstrapChannel(t *testing.T) {
bootstrapConfig := &localconfig.TopLevel{
General: localconfig.General{
GenesisMethod: "file",
GenesisFile: genesisFile,
BootstrapFile: genesisFile,
},
}

genesisBlock := extractBootstrapBlock(bootstrapConfig)
initializeBootstrapChannel(genesisBlock, ledgerFactory)
bootstrapBlock := extractBootstrapBlock(bootstrapConfig)
initializeBootstrapChannel(bootstrapBlock, ledgerFactory)

ledger, err := ledgerFactory.GetOrCreate("testchannelid")
assert.NoError(t, err)
Expand All @@ -241,7 +241,7 @@ func TestExtractBootstrapBlock(t *testing.T) {
}{
{
config: &localconfig.TopLevel{
General: localconfig.General{GenesisMethod: "file", GenesisFile: genesisFile},
General: localconfig.General{GenesisMethod: "file", BootstrapFile: genesisFile},
},
block: file.New(genesisFile).GenesisBlock(),
},
Expand Down Expand Up @@ -470,7 +470,7 @@ func TestUpdateTrustedRoots(t *testing.T) {
conf := &localconfig.TopLevel{
General: localconfig.General{
GenesisMethod: "file",
GenesisFile: genesisFile,
BootstrapFile: genesisFile,
ListenAddress: "localhost",
ListenPort: uint16(port),
TLS: localconfig.TLS{
Expand Down Expand Up @@ -838,7 +838,7 @@ func genesisConfig(t *testing.T, genesisFile string) *localconfig.TopLevel {
return &localconfig.TopLevel{
General: localconfig.General{
GenesisMethod: "file",
GenesisFile: genesisFile,
BootstrapFile: genesisFile,
LocalMSPDir: localMSPDir,
LocalMSPID: "SampleOrg",
BCCSP: &factory.FactoryOpts{
Expand Down
7 changes: 7 additions & 0 deletions sampleconfig/orderer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ General:
# The file containing the genesis block to use when initializing the orderer system channel
GenesisFile: genesisblock

# Bootstrap file: The file containing the bootstrap block to use when
# initializing the orderer system channel and GenesisMethod is set to
# "file". Ignored if GenesisMethod is set to "provisional".
# The bootstrap file can be the genesis block, and it can also be a config block that expands the
# network to add orderer.
BootstrapFile: genesisblock

# LocalMSPDir is where to find the private crypto material needed by the
# orderer. It is set relative here as a default for dev environments but
# should be changed to the real location in production.
Expand Down

0 comments on commit 102ea3c

Please sign in to comment.