Skip to content

Commit

Permalink
added initial local instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
dshuffma-ibm committed Apr 5, 2017
1 parent 5245d27 commit 54cce2f
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 93 deletions.
113 changes: 113 additions & 0 deletions docs/config_file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Configuration

Configuration of marbles happens with two files.
These files can be found in the folder `<marbles directory>/config`.

1. Config File
- This is the file that has settings for the marble company you are pretending to be.
- Such as a the name of your marbles company, list of marble owners, what port this marbles app should use, etc..
- It can be found in `<marbles directory>/config/marbles1.json`.
- You only need to edit/create 1 file.
- Create a new file for each Marble company you want to pretend to be.

1. Credential File
- This file has settings for your network.
- This can be found in `<marbles>/config/blockchain_creds1.json`.
- You only need to edit/create 1 file.
- Use seperate files for seperate blockchain networks.



### Config File Example:

```json
{
"cred_filename": "blockchain_creds4.json",
"use_events": true,
"keep_alive_secs": 120,
"company": "United Marbles",
"usernames": [
"amy",
"alice",
"ava"
],
"port": 3001,
"last_startup_hash": "db9c62e3b6a3dabfd1d108a99342185f1cac92c7"
}

```

- cred_filename - The name of the `Credential File` to use for your network. See the `Credential File` section for details.
- use_events - When `true` it will use EventHub.js in the SDK to be notified when tx are committed to the ledger. When `false` it will wait/sleep for a block to be created
- keep_alive_secs - How often to periodically re-enroll in seconds. This keeps the gRPC connections alive.
- company - The name of your marbles company
- usernames - The list of marbles owners that should be created on initial startup
- port - The port to use when hosting the marbles application
- last_start_hash - You do not need to modify/create this field. Its created internally when marbles runs successfull. Its a hash of the network credentials file. Its used to detect when you are trying to re-run marbles with a new network and we should go through the full initial startup.



### Creds File Example:

```json
{
"credentials": {
"network_id": "FakeNetworkId",
"orderers": [
{
"discovery": "grpc://localhost:7050",
"msp_id": "Org1MSP"
}
],
"cas": [
{
"api": "http://localhost:7054",
"msp_id": "Org1MSP",
"users": [
{
"enrollId": "admin",
"enrollSecret": "adminpw"
}
]
}
],
"peers": [
{
"discovery": "grpc://localhost:7051",
"events": "grpc://localhost:7053",
"msp_id": "Org1MSP"
}
],
"app": {
"channel_id": "mychannel",
"chaincode_id": "marbles",
"chaincode_version": "v0",
"block_delay": 1000
},
"tls_common_name": null,
"tls_certificate": "-----BEGIN CERTIFICATE----- <removed> -----END CERTIFICATE-----\r\n"
}
}
```

- network_id - The main purpose of this is to detect when people try to use the default file w/o any editing! Set it to anything other than `FakeNetworkId`.
- orderers - An Array. Must have at least 1 entry. You can add more, but currently only the first one will be used.
- discovery - The gRPC url to reach the orderer. It must include the port.
- msp_id - The ID associated with the orderer. See fabric documentation for MSP information.
- cas - An Array. Must have at least 1 entry. You can add more, but currently only the first one will be used.
- api - The gRPC url to reach the ca. It must include the port.
- msp_id - The ID associated with the ca.
- users - An array of object containing the `enrollId` and `enrollSecret`.
- enrollId - A registered user's id on the CA. Can be found in the CA's yaml file.
- enrollSecret - A registered user's secret on the CA. Can be found in the CA's yaml file.
- peers - An array. Must have at least 1 entry. You can add more, but currently only the first one will be used.
- discovery - The gRPC url to reach the peer. It must include the port.
- events - The gRPC url to reach event endpoint of the peer. It must include the port and it is different than the discovery port!
- msp_id - The ID associated with the peer.
- app - This is an object
- channel_id - Name of the channel where marbles chaincode has been instantiated.
- chaincode_id - Name of the chaincode installed.
- chaincode_version - Version of the chaincode installed.
- block_delay - Time in ms for a block to be created by the orderer. This is a setting in the orderer's yaml.
- tls_common_name - Only needed when using self signed certs. It will override the common name.
- tls_certificate - Can be either the complete PEM file that has line breaks encoded as `\r\n` **OR** a relative file path to a PEM file inside the `config` folder.
6 changes: 2 additions & 4 deletions docs/tutorial_start_here.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ Now we need a blockchain network.

- **Option 1:** Create a network with the Bluemix IBM Blockchain Service - [instructions](./use_bluemix_hyperledger.md)

<strike>
- **Option 2:** Use a locally hosted Hyperledger Network - instructions
</strike>
- **Option 2:** Use a locally hosted Hyperledger Network - [instructions](./use_local_hyperleder.md)

*^ instructions coming soon*
**Update:** *local instructions are a work in progress*

<a name="installchaincode"></a>

Expand Down
98 changes: 9 additions & 89 deletions docs/use_local_hyperledger.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,103 +2,23 @@

### Creating a Local Hyperledger Fabric Network
Use the published fabric docker images and docker-compose script to get a local network quickly.
<strike>
1. Follow the Fabric v1.0 [Hackfest setup instructions](http://hyperledger-fabric.readthedocs.io/en/latest/asset_setup/).
</strike>

^ New instructions coming soon...
1. Follow the Fabric v1 [Getting Started instructions](http://fabric-rtd.readthedocs.io/en/latest/getting_started.html).

### Finished
The network is all setup, right?
So if you followed the Hackfest instructions exactly then your orderer will be batching new blocks every 10 seconds.
So if you followed the instructions then your orderer will be batching new blocks every 10 seconds.
This is a litttttle long for our application, and may give you unexpected behavior.
Basicaly if you move a marble the trade will take 10 seconds to settle.
The **UI may redraw the marble back in its original position**, and then jump to a correct position after some time.
This is normal and is because of a the long batch time.
The **UI may redraw the marble back in its original position**, and then jump to a correct position after some time.
This is *normal* and is because of a the long batch time.
If you use the Bluemix service, the batch time is only 1 second.

Next we need to **pass the location of our peer to our marbles application**.
This is done by editing the `/config/blockchain_creds1.json` file.
Next we need to **pass the location of our peer to our marbles application**.
This is done by editing the creds file.

There are multiple credential files to show different setups.
Marbles will open the file found in the environmental variable `creds_filename`.
Gulp will set this for us based on what gulp task we tell it to do.

This initial file (`marbles1.json`) points to our blockchain credentials file with the field "cred_filename". Thats the file that holds our network ips/hostnames/ports and other similar data.

Next we must edit `blockchain_creds1.json` with information about your network.
Below is a sample showing the information that must be in the JSON file.

__sample blockchain_creds1.json__

```js
{
"credentials": {
"network_id": "asdf", //not important atm
"peers": [
{
"discovery": "grpc://192.168.99.100:8051", //must match the ip or hostname of your peer
"events": "grpc://192.168.99.100:8053", //must match the ip or hostname of your peer
"msp_id": "Org1MSP"
}
],
"cas": [
{
"api": "http://192.168.99.100:8054", //must match the ip or hostname of your ca
"msp_id": "Org1MSP",
"users": [
{
"enrollId": "admin",
"enrollSecret": "adminpw"
}
]
}
],
"orderers": [
{
"discovery": "grpc://192.168.99.100", //must match the ip or hostname of your peer
"msp_id": "Org1MSP"
}
],
"app": {
"channel_id": "mychannel", //name of the blockchain channel
"chaincode_id": "marbles", //name of instantiated chaincode
"chaincode_version": "v0"
}
}
}
```

Remove any comments in your json file

**Do you see the "credentials" field in your json file?**
It should be the outer most field like in the sample above.
If its not there you need to add it such that `peers`, `cas` and etc are inside `credentials`.

Marbles only talks to 1 peer.
Therefore, you should have 1 entry in the `peers` array and 1 entry in the `users` array.
You will need to look up the default CA enroll ID/users for your Hyperledger Fabric version to populate the `users` array.
Fabric version 0.7.0 enroll Ids can be found in the [cop.json](https://github.com/hyperledger/fabric-cop/blob/master/docker/fabric-cop/cop.json) file.

Example cop.json section:

```json
"alice": {
"pass": "alicepw",
"type": "client",
"group": "bank_a",
"attrs": [{"name":"hf.Registrar.Roles","value":"client,peer,validator,auditor"}, {"name":"hf.Registrar.DelegateRoles", "value": "client"}]
}
```

Maps to:

```json
{
"enrollId": "alice",
"enrollSecret": "alicepw"
}
```
1. Follow the [config instructions](./config_file.md). Then come back here.

Once you have edited `blockchain_creds1.json` you are ready to run Marbles.

1. Continue where you left off in [tutorial 1](./tutorial_start_here.md#hostmarbles).
1. Continue where you left off in [tutorial 1](./tutorial_start_here.md#hostmarbles).

0 comments on commit 54cce2f

Please sign in to comment.