Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bft support #499

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@
"description": "The 'solo' consensus type may be used in development environment only. Use 'raft' in production.",
"enum": [
"solo",
"raft"
"raft",
"BFT"
]
},
"instances": {
Expand Down
40 changes: 20 additions & 20 deletions e2e-network/TEST_CASES.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Test cases

| Test case | 01-simple | 02-raft | 03-private | 04-snapshot |
| ------------------------- |:---------------:|:-----------:|:----------:|:------------------------:|
| Fabric versions | 2.4.7 | 2.3.2 | 2.4.7 | 2.3.3/2.4.2 |
| TLS | no | yes | no | yes |
| Channel capabilities | v2 | v2 | v2_5 | v2 |
| Consensus | solo | RAFT | solo | RAFT |
| Orderer nodes | 1 | 3 | 1 | 1 |
| Organizations | 1 | 2 | 2 | 1 |
| CA database | SQLite | SQLite | SQLite | Postgres |
| Peer database | LevelDB | LevelDB | LevelDB | CouchDB |
| Peer count | 2 | 2, 2 | 2, 1 | 2 |
| Channels | 1 | 2 | 1 | 1 |
| Node chaincode | yes | yes | yes | yes |
| Node chaincode upgrade | no | yes | no | no |
| Node chaincode endorsement| OR | OR | OR, AND | default |
| Private data | no | no | yes | yes |
| Java chaincode | no | yes | no | no |
| Go chaincode | no | no | no | no |
| Tools | channel scripts | Fablo REST | - | Fablo REST, Explorer |
| Other Fablo commands | init, reset | stop, start | - | snapshot, prune, restore |
| Test case | 01-simple | 02-raft | 03-private | 04-snapshot | test-05-version3 |
| ------------------------- |:---------------:|:-----------:|:----------:|:------------------------:|:------------------:|
| Fabric versions | 2.4.7 | 2.3.2 | 2.4.7 | 2.3.3/2.4.2 | 3.0.0-beta |
| TLS | no | yes | no | yes | yes |
| Channel capabilities | v2 | v2 | v2_5 | v2 | v3_0 |
| Consensus | solo | RAFT | solo | RAFT | RAFT |
| Orderer nodes | 1 | 3 | 1 | 1 | 1 |
| Organizations | 1 | 2 | 2 | 1 | 1 |
| CA database | SQLite | SQLite | SQLite | Postgres | Postgres |
| Peer database | LevelDB | LevelDB | LevelDB | CouchDB | CouchDB |
| Peer count | 2 | 2, 2 | 2, 1 | 2 | 2 |
| Channels | 1 | 2 | 1 | 1 | 1 |
| Node chaincode | yes | yes | yes | yes | yes |
| Node chaincode upgrade | no | yes | no | no | no |
| Node chaincode endorsement| OR | OR | OR, AND | default | OR |
| Private data | no | no | yes | yes | no |
| Java chaincode | no | yes | no | no | no |
| Go chaincode | no | no | no | no | no |
| Tools | channel scripts | Fablo REST | - | Fablo REST, Explorer | channel scripts |
| Other Fablo commands | init, reset | stop, start | - | snapshot, prune, restore | init, reset |
84 changes: 84 additions & 0 deletions e2e-network/docker/test-05-version3-BFT.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

set -eux

TEST_TMP="$(rm -rf "$0.tmpdir" && mkdir -p "$0.tmpdir" && (cd "$0.tmpdir" && pwd))"
TEST_LOGS="$(mkdir -p "$0.logs" && (cd "$0.logs" && pwd))"
FABLO_HOME="$TEST_TMP/../../.."

export FABLO_HOME

CONFIG="$FABLO_HOME/fablo-config-hlf3-bft-1orgs-1chaincode.json"

networkUp() {
"$FABLO_HOME/fablo-build.sh"
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" generate "$CONFIG")
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" up)
}

dumpLogs() {
echo "Saving logs of $1 to $TEST_LOGS/$1.log"
mkdir -p "$TEST_LOGS"
docker logs "$1" >"$TEST_LOGS/$1.log" 2>&1
}

networkDown() {
rm -rf "$TEST_LOGS"
(for name in $(docker ps --format '{{.Names}}'); do dumpLogs "$name"; done)
dumpLogs orderer0.group1.orderer.example.com
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" down)
}

waitForContainer() {
sh "$TEST_TMP/../wait-for-container.sh" "$1" "$2"
}

waitForChaincode() {
(cd "$TEST_TMP" && sh ../wait-for-chaincode.sh "$1" "$2" "$3" "$4")
}

expectInvoke() {
(cd "$TEST_TMP" && sh ../expect-invoke-cli.sh "$1" "$2" "$3" "$4" "$5" "")
}

expectCommand() {
sh "$TEST_TMP/../expect-command.sh" "$1" "$2"
}

trap networkDown EXIT
trap 'networkDown ; echo "Test failed" ; exit 1' ERR SIGINT

# start the network
networkUp

waitForContainer "orderer0.group1.orderer.example.com" "Starting raft node as part of a new channel channel=my-channel1"
waitForContainer "ca.org1.example.com" "Listening on https://0.0.0.0:7054"
waitForContainer "peer0.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
waitForContainer "peer1.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
waitForContainer "peer0.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
waitForContainer "peer0.org1.example.com" "Anchor peer.*with same endpoint, skipping connecting to myself"
waitForContainer "peer0.org1.example.com" "Membership view has changed. peers went online:.*peer1.org1.example.com:7042"
waitForContainer "peer1.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
waitForContainer "peer1.org1.example.com" "Membership view has changed. peers went online:.*peer0.org1.example.com:7041"

# Test simple chaincode
expectInvoke "peer0.org1.example.com" "my-channel1" "chaincode1" \
'{"Args":["KVContract:put", "name", "Willy Wonka"]}' \
'{\"success\":\"OK\"}'
expectInvoke "peer1.org1.example.com" "my-channel1" "chaincode1" \
'{"Args":["KVContract:get", "name"]}' \
'{\"success\":\"Willy Wonka\"}'

# Verify channel query scripts
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch newest my-channel1 org1 peer1)
expectCommand "cat \"$TEST_TMP/newest.block\"" "KVContract:get"

(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch 3 my-channel1 org1 peer1 "another.block")
expectCommand "cat \"$TEST_TMP/another.block\"" "KVContract:put"

(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch config my-channel1 org1 peer1 "channel-config.json")
expectCommand "cat \"$TEST_TMP/channel-config.json\"" "\"mod_policy\": \"Admins\","

expectCommand "(cd \"$TEST_TMP\" && \"$FABLO_HOME/fablo.sh\" channel getinfo my-channel1 org1 peer1)" "\"height\":5"

echo "🎉 Test passed! 🎉"
84 changes: 84 additions & 0 deletions e2e-network/docker/test-05-version3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

set -eux

TEST_TMP="$(rm -rf "$0.tmpdir" && mkdir -p "$0.tmpdir" && (cd "$0.tmpdir" && pwd))"
TEST_LOGS="$(mkdir -p "$0.logs" && (cd "$0.logs" && pwd))"
FABLO_HOME="$TEST_TMP/../../.."

export FABLO_HOME

CONFIG="$FABLO_HOME/samples/fablo-config-hlf3-1orgs-1chaincode.json"

networkUp() {
"$FABLO_HOME/fablo-build.sh"
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" generate "$CONFIG")
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" up)
}

dumpLogs() {
echo "Saving logs of $1 to $TEST_LOGS/$1.log"
mkdir -p "$TEST_LOGS"
docker logs "$1" >"$TEST_LOGS/$1.log" 2>&1
}

networkDown() {
rm -rf "$TEST_LOGS"
(for name in $(docker ps --format '{{.Names}}'); do dumpLogs "$name"; done)
dumpLogs orderer0.group1.orderer.example.com
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" down)
}

waitForContainer() {
sh "$TEST_TMP/../wait-for-container.sh" "$1" "$2"
}

waitForChaincode() {
(cd "$TEST_TMP" && sh ../wait-for-chaincode.sh "$1" "$2" "$3" "$4")
}

expectInvoke() {
(cd "$TEST_TMP" && sh ../expect-invoke-cli.sh "$1" "$2" "$3" "$4" "$5" "")
}

expectCommand() {
sh "$TEST_TMP/../expect-command.sh" "$1" "$2"
}

trap networkDown EXIT
trap 'networkDown ; echo "Test failed" ; exit 1' ERR SIGINT

# start the network
networkUp

waitForContainer "orderer0.group1.orderer.example.com" "Starting raft node as part of a new channel channel=my-channel1"
waitForContainer "ca.org1.example.com" "Listening on https://0.0.0.0:7054"
waitForContainer "peer0.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
waitForContainer "peer1.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations"
waitForContainer "peer0.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
waitForContainer "peer0.org1.example.com" "Anchor peer.*with same endpoint, skipping connecting to myself"
waitForContainer "peer0.org1.example.com" "Membership view has changed. peers went online:.*peer1.org1.example.com:7042"
waitForContainer "peer1.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1"
waitForContainer "peer1.org1.example.com" "Membership view has changed. peers went online:.*peer0.org1.example.com:7041"

# Test simple chaincode
expectInvoke "peer0.org1.example.com" "my-channel1" "chaincode1" \
'{"Args":["KVContract:put", "name", "Willy Wonka"]}' \
'{\"success\":\"OK\"}'
expectInvoke "peer1.org1.example.com" "my-channel1" "chaincode1" \
'{"Args":["KVContract:get", "name"]}' \
'{\"success\":\"Willy Wonka\"}'

# Verify channel query scripts
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch newest my-channel1 org1 peer1)
expectCommand "cat \"$TEST_TMP/newest.block\"" "KVContract:get"

(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch 3 my-channel1 org1 peer1 "another.block")
expectCommand "cat \"$TEST_TMP/another.block\"" "KVContract:put"

(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch config my-channel1 org1 peer1 "channel-config.json")
expectCommand "cat \"$TEST_TMP/channel-config.json\"" "\"mod_policy\": \"Admins\","

expectCommand "(cd \"$TEST_TMP\" && \"$FABLO_HOME/fablo.sh\" channel getinfo my-channel1 org1 peer1)" "\"height\":5"

echo "🎉 Test passed! 🎉"
59 changes: 59 additions & 0 deletions samples/fablo-config-hlf3-1orgs-1chaincode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.0.0/schema.json",
"global": {
"fabricVersion": "3.0.0-beta",
"tls": true,
"monitoring": {
"loglevel": "debug"
}
},
"orgs": [
{
"organization": {
"name": "Orderer",
"domain": "orderer.example.com"
},
"orderers": [
{
"groupName": "group1",
"type": "BFT",
"instances": 4
}
]
},
{
"organization": {
"name": "Org1",
"domain": "org1.example.com"
},
"peer": {
"instances": 2,
"db": "LevelDb"
}
}
],
"channels": [
{
"name": "my-channel1",
"orgs": [
{
"name": "Org1",
"peers": [
"peer0",
"peer1"
]
}
]
}
],
"chaincodes": [
{
"name": "chaincode1",
"version": "0.0.1",
"lang": "node",
"channel": "my-channel1",
"directory": "./chaincodes/chaincode-kv-node"
}
]
}

60 changes: 60 additions & 0 deletions samples/fablo-config-hlf3-bft-1orgs-1chaincode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.0.0/schema.json",
"global": {
"fabricVersion": "3.0.0-beta",
"tls": true,
"monitoring": {
"loglevel": "debug"
}
},
"orgs": [
{
"organization": {
"name": "Orderer",
"domain": "orderer.example.com"
},
"orderers": [
{
"groupName": "group1",
"type": "BFT",
"instances": 4
}

]
},
{
"organization": {
"name": "Org1",
"domain": "org1.example.com"
},
"peer": {
"instances": 2,
"db": "LevelDb"
}
}
],
"channels": [
{
"name": "my-channel1",
"orgs": [
{
"name": "Org1",
"peers": [
"peer0",
"peer1"
]
}
]
}
],
"chaincodes": [
{
"name": "chaincode1",
"version": "0.0.1",
"lang": "node",
"channel": "my-channel1",
"directory": "./chaincodes/chaincode-kv-node"
}
]
}

1 change: 1 addition & 0 deletions src/extend-config/extendOrgsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const extendOrderersConfig = (
orgMspName,
domain: ordererOrgDomainJson,
consensus,
adminPort: 7053,
port,
fullAddress: `${address}:${port}`,
};
Expand Down
13 changes: 4 additions & 9 deletions src/setup-docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,20 +213,15 @@ export default class SetupDockerGenerator extends Generator {
}

_copyUtilityScripts(capabilities: Capabilities): void {
this.fs.copyTpl(this.templatePath("fabric-docker.sh"), this.destinationPath("fabric-docker.sh"));
this.fs.copyTpl(this.templatePath(`fabric-docker.sh`), this.destinationPath("fabric-docker.sh"));

this.fs.copyTpl(
this.templatePath("fabric-docker/scripts/cli/channel_fns.sh"),
this.templatePath(`fabric-docker/scripts/cli/channel_fns-${capabilities.isV3? "v3": "v2"}.sh`),
this.destinationPath("fabric-docker/scripts/cli/channel_fns.sh"),
);

this.fs.copyTpl(
this.templatePath("fabric-docker/scripts/cli/channel_fns.sh"),
this.destinationPath("fabric-docker/scripts/cli/channel_fns.sh"),
);

this.fs.copyTpl(
this.templatePath("fabric-docker/scripts/base-functions.sh"),
this.templatePath(`fabric-docker/scripts/base-functions-${capabilities.isV3? "v3": "v2"}.sh`),
this.destinationPath("fabric-docker/scripts/base-functions.sh"),
);

Expand All @@ -241,7 +236,7 @@ export default class SetupDockerGenerator extends Generator {
);

this.fs.copyTpl(
this.templatePath(`fabric-docker/scripts/chaincode-functions-${capabilities.isV2 ? "v2" : "v1.4"}.sh`),
this.templatePath(`fabric-docker/scripts/chaincode-functions-${capabilities.isV2 ? "v2" : "v2"}.sh`),
this.destinationPath("fabric-docker/scripts/chaincode-functions.sh"),
);
}
Expand Down
Loading
Loading