Skip to content

Commit

Permalink
Merge pull request #501 from dzikowski/upgrade_to_version3
Browse files Browse the repository at this point in the history
Add support for BFT and improve Fabric v3 support
  • Loading branch information
dzikowski authored Dec 7, 2024
2 parents 9713fec + 12bac57 commit 6b05c12
Show file tree
Hide file tree
Showing 37 changed files with 10,294 additions and 318 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/test-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,55 @@ jobs:
path: |
e2e-network/docker/test-04-snapshot.sh.logs/*
e2e-network/docker/test-04-snapshot.sh.tmpdir/fablo-target/**/*
test-05-v3:
needs: test-main
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Build Fablo
run: |
shellcheck --version && \
yamllint -v && \
npm install && \
./fablo-build.sh
- name: Test version 3
run: e2e-network/docker/test-05-version3.sh

- uses: actions/upload-artifact@v4
if: always()
with:
name: test-05-version3
path: |
e2e-network/docker/test-05-version3-snapshot.sh.logs/*
e2e-network/docker/test-05-version3-snapshot.sh.tmpdir/fablo-target/**/*
test-05-v3-BFT:
needs: test-main
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Build Fablo
run: |
shellcheck --version && \
yamllint -v && \
npm install && \
./fablo-build.sh
- name: Test version 3 with BFT
run: e2e-network/docker/test-05-version3-BFT.sh

- uses: actions/upload-artifact@v4
if: always()
with:
name: test-05-version3-BFT-snapshot
path: |
e2e-network/docker/test-05-version3-BFT-snapshot.sh.logs/*
e2e-network/docker/test-05-version3-BFT-snapshot.sh.tmpdir/fablo-target/**/*

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ fablo-target
generators
node_modules
.idea
samples/invalid-fablo-config.json
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.1.0

### Features
* Support Fabric 3.0.0-beta, along with BFT consensus
[#501](https://github.com/hyperledger-labs/fablo/pull/501)

## 2.0.0

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

set -eu

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-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" "Channel created"
waitForContainer "orderer1.group1.orderer.example.com" "Channel created"
waitForContainer "orderer2.group1.orderer.example.com" "Channel created"
waitForContainer "orderer3.group1.orderer.example.com" "Channel created"
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 -eu

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! 🎉"
Loading

0 comments on commit 6b05c12

Please sign in to comment.