Skip to content

Commit 0e0e34f

Browse files
committed
[FAB-3358] Remove testchainid from peer startup
There is currently a --peer-defaultchain option which can be passed to peer node start which will setup a testchain. This was used in the past while work was underway to support creating channels but at this point it is no longer needed and we should not have test code in the production path. This is Part 1 of 2 to fix this. First, we remove the actual code for creating testchainid but we leave the CLI flag because the SDK e2e's have it in their compose cmd. Change-Id: I7229d647976a5d927dc0c53cfaeebd7f5fa9c811 Signed-off-by: Gari Singh <[email protected]>
1 parent 010dcf6 commit 0e0e34f

File tree

6 files changed

+12
-80
lines changed

6 files changed

+12
-80
lines changed

bddtests/dc-peer-base.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
# $$GOPATH (double dollar) required to prevent docker-compose doing its own
3131
# substitution before the value gets to the container
3232
#command: sh -c "exec $$GOPATH/src/github.com/hyperledger/fabric/bddtests/scripts/start-peer.sh"
33-
command: peer node start --peer-defaultchain=false
33+
command: peer node start
3434

3535
# Use these options if coverage desired for peers
3636
#image: hyperledger/fabric-peer-coverage

docs/source/chaincode.rst

+5-30
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Command
215215

216216
<th width="371" bgcolor="#ffffff" style="border-top: none; border-bottom: 1.50pt solid #e1e4e5; border-left: none; border-right: none; padding-top: 0in; padding-bottom: 0.08in; padding-left: 0in; padding-right: 0in">
217217

218-
stdout result in the event of success
218+
stdout result in the event of success
219219

220220
.. raw:: html
221221

@@ -251,7 +251,7 @@ version
251251

252252
<td width="371" bgcolor="#f3f6f6" style="border-top: 1px solid #e1e4e5; border-bottom: 1px solid #e1e4e5; border-left: 1px solid #e1e4e5; border-right: none; padding-top: 0in; padding-bottom: 0.08in; padding-left: 0.16in; padding-right: 0in">
253253

254-
String form of peer.version defined in core.yaml
254+
String form of peer.version defined in core.yaml
255255

256256
.. raw:: html
257257

@@ -307,7 +307,7 @@ node status
307307

308308
<td width="371" bgcolor="#f3f6f6" style="border-top: 1px solid #e1e4e5; border-bottom: 1px solid #e1e4e5; border-left: 1px solid #e1e4e5; border-right: none; padding-top: 0in; padding-bottom: 0.08in; padding-left: 0.16in; padding-right: 0in">
309309

310-
String form of StatusCode
310+
String form of StatusCode
311311

312312
.. raw:: html
313313

@@ -335,7 +335,7 @@ node stop
335335

336336
<td width="371" bgcolor="#ffffff" style="border-top: 1px solid #e1e4e5; border-bottom: 1px solid #e1e4e5; border-left: 1px solid #e1e4e5; border-right: none; padding-top: 0in; padding-bottom: 0.08in; padding-left: 0.16in; padding-right: 0in">
337337

338-
String form of StatusCode
338+
String form of StatusCode
339339

340340
.. raw:: html
341341

@@ -364,7 +364,7 @@ chaincode deploy
364364
<td width="371" bgcolor="#f3f6f6" style="border-top: 1px solid #e1e4e5; border-bottom: 1px solid #e1e4e5; border-left: 1px solid #e1e4e5; border-right: none; padding-top: 0in; padding-bottom: 0.08in; padding-left: 0.16in; padding-right: 0in">
365365

366366
The chaincode container name (hash) required for subsequent chaincode
367-
invoke and chaincode query commands
367+
invoke and chaincode query commands
368368

369369
.. raw:: html
370370

@@ -490,31 +490,6 @@ Adds a peer to the chain
490490

491491
<tr>
492492

493-
.. raw:: html
494-
495-
<td width="262" bgcolor="#f3f6f6" style="border-top: 1px solid #e1e4e5; border-bottom: 1px solid #e1e4e5; border-left: 1px solid #e1e4e5; border-right: none; padding-top: 0in; padding-bottom: 0.08in; padding-left: 0.16in; padding-right: 0in">
496-
497-
.. raw:: html
498-
499-
<pre class="western" style="orphans: 2; widows: 2"><span style="display: inline-block; border: 1px solid #e1e4e5; padding: 0.01in"><span style="font-variant: normal"><font color="#e74c3c"><font face="Consolas, Andale Mono WT, Andale Mono, Lucida Console, Lucida Sans Typewriter, DejaVu Sans Mono, Bitstream Vera Sans Mono, Liberation Mono, Nimbus Mono L, Monaco, Courier New, Courier, monospace"><font size="1" style="font-size: 7pt"><span style="letter-spacing: normal"><span lang="en-US"><span style="font-style: normal"><span style="font-weight: normal">--peer-defaultchain=true</span></span></span></span></font></font></font></span></span></pre>
500-
501-
.. raw:: html
502-
503-
</td>
504-
505-
.. raw:: html
506-
507-
<td width="371" bgcolor="#f3f6f6" style="border-top: 1px solid #e1e4e5; border-bottom: 1px solid #e1e4e5; border-left: 1px solid #e1e4e5; border-right: none; padding-top: 0in; padding-bottom: 0.08in; padding-left: 0.16in; padding-right: 0in">
508-
509-
Allows users to continue to work with the default TEST\_CHAINID string.
510-
Command line options support writing this value as raw bytes (-r, –raw)
511-
or formatted as the hexadecimal representation of the raw bytes (-x,
512-
–hex). If the query response is empty then nothing is output.
513-
514-
.. raw:: html
515-
516-
</td>
517-
518493
.. raw:: html
519494

520495
</tbody>

docs/source/peer-chaincode-devmode.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Start the peer in dev mode
2828

2929
::
3030

31-
peer node start --peer-defaultchain=false --peer-chaincodedev=true
31+
peer node start --peer-chaincodedev=true
3232

3333
The above command starts the peer using the default ``sampleconfig/msp``
3434
MSP. The ``--peer-chaincodedev=true`` puts it in “dev” mode.
@@ -77,13 +77,13 @@ Use the chaincode
7777

7878
Even though you are in ``--peer-chaincodedev`` mode, you still have to install the chaincode so the life-cycle system
7979
chaincode can go through its checks normally. This requirement may be removed in future when in ``--peer-chaincodedev``
80-
mode.
80+
mode.
8181

8282
::
8383

8484
peer chaincode install -n mycc -v 0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
8585

86-
Once installed, the chaincode is ready to be instantiated.
86+
Once installed, the chaincode is ready to be instantiated.
8787

8888
::
8989

examples/cluster/compose/peer-base/peer-base.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ services:
1717
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=compose_default
1818
volumes:
1919
- /var/run/docker.sock:/var/run/docker.sock
20-
command: peer node start --peer-defaultchain=false
20+
command: peer node start

examples/e2e_cli/base/peer-base.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ services:
2727
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
2828
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
2929
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
30-
command: peer node start --peer-defaultchain=false
30+
command: peer node start

peer/node/start.go

+1-44
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ import (
2323
"os"
2424
"os/signal"
2525
"path/filepath"
26-
"strings"
2726
"syscall"
2827
"time"
2928

30-
genesisconfig "github.com/hyperledger/fabric/common/configtx/tool/localconfig"
31-
"github.com/hyperledger/fabric/common/configtx/tool/provisional"
3229
"github.com/hyperledger/fabric/common/flogging"
3330
"github.com/hyperledger/fabric/common/localmsp"
34-
"github.com/hyperledger/fabric/common/util"
3531
"github.com/hyperledger/fabric/core"
3632
"github.com/hyperledger/fabric/core/chaincode"
3733
"github.com/hyperledger/fabric/core/comm"
@@ -46,7 +42,6 @@ import (
4642
"github.com/hyperledger/fabric/msp/mgmt"
4743
"github.com/hyperledger/fabric/peer/common"
4844
peergossip "github.com/hyperledger/fabric/peer/gossip"
49-
cb "github.com/hyperledger/fabric/protos/common"
5045
pb "github.com/hyperledger/fabric/protos/peer"
5146
"github.com/spf13/cobra"
5247
"github.com/spf13/viper"
@@ -69,7 +64,7 @@ func startCmd() *cobra.Command {
6964
flags := nodeStartCmd.Flags()
7065
flags.BoolVarP(&chaincodeDevMode, "peer-chaincodedev", "", false,
7166
"Whether peer in chaincode development mode")
72-
flags.BoolVarP(&peerDefaultChain, "peer-defaultchain", "", true,
67+
flags.BoolVarP(&peerDefaultChain, "peer-defaultchain", "", false,
7368
"Whether to start peer with chain testchainid")
7469
flags.StringVarP(&orderingEndpoint, "orderer", "o", "orderer:7050", "Ordering service endpoint")
7570

@@ -183,44 +178,6 @@ func serve(args []string) error {
183178
//initialize system chaincodes
184179
initSysCCs()
185180

186-
// Begin startup of default chain
187-
if peerDefaultChain {
188-
if orderingEndpoint == "" {
189-
logger.Panic("No ordering service endpoint provided, please use -o option.")
190-
}
191-
192-
if len(strings.Split(orderingEndpoint, ":")) != 2 {
193-
logger.Panicf("Invalid format of ordering service endpoint, %s.", orderingEndpoint)
194-
}
195-
196-
chainID := util.GetTestChainID()
197-
198-
var block *cb.Block
199-
200-
func() {
201-
defer func() {
202-
if err := recover(); err != nil {
203-
logger.Fatalf("Peer configured to start with the default test chain, but supporting configuration files did not match. Please ensure that configtx.yaml contains the unmodified SampleSingleMSPSolo profile and that sampleconfig/msp is present.\n%s", err)
204-
}
205-
}()
206-
207-
genConf := genesisconfig.Load(genesisconfig.SampleSingleMSPSoloProfile)
208-
genConf.Orderer.Addresses = []string{orderingEndpoint}
209-
genConf.Application.Organizations[0].Name = XXXDefaultChannelMSPID
210-
genConf.Application.Organizations[0].ID = XXXDefaultChannelMSPID
211-
block = provisional.New(genConf).GenesisBlockForChannel(chainID)
212-
}()
213-
214-
//this creates testchainid and sets up gossip
215-
if err = peer.CreateChainFromBlock(block); err == nil {
216-
logger.Infof("create chain [%s]", chainID)
217-
scc.DeploySysCCs(chainID)
218-
logger.Infof("Deployed system chaincodes on %s", chainID)
219-
} else {
220-
logger.Errorf("create default chain [%s] failed with %s", chainID, err)
221-
}
222-
}
223-
224181
//this brings up all the chains (including testchainid)
225182
peer.Initialize(func(cid string) {
226183
logger.Debugf("Deploying system CC, for chain <%s>", cid)

0 commit comments

Comments
 (0)