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

Add support for BFT and improve Fabric v3 support #501

Merged
merged 47 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
15f7ec6
version 3 changes initiated
Sanket-0510 Oct 25, 2024
5758c56
added the tests
Sanket-0510 Oct 25, 2024
a99c65e
added the samples
Sanket-0510 Oct 25, 2024
bb1d407
updated some conditions
Sanket-0510 Oct 25, 2024
c399ca8
updated the templates, now version 3 is supported
Sanket-0510 Nov 6, 2024
16c2f02
Successfully pass the tests
Sanket-0510 Nov 13, 2024
7db1c55
updated testCases.md
Sanket-0510 Nov 13, 2024
e98306f
done with initial configuration for BFT, updated the templates for th…
Sanket-0510 Nov 13, 2024
4b3e785
updated the permission
Sanket-0510 Nov 22, 2024
a711deb
version 3 completed heading towards adding BFT support
Sanket-0510 Nov 22, 2024
e0aefc2
Use proper createChannelAndJoinTls with certs
dzikowski Nov 30, 2024
cdb3203
Enable TLS for admin endpoints
dzikowski Nov 30, 2024
d788ef8
Reorder and fix docker compose variable for orderer
dzikowski Nov 30, 2024
f2add14
Fix identity which remove NOT_FOUND error while fetching the channel
dzikowski Nov 30, 2024
5c8f780
Remove unnecessary sleep
dzikowski Nov 30, 2024
a7315ce
Fix docker compose variables for RAFT
dzikowski Nov 30, 2024
0b3828c
Some polishing and cleanup
dzikowski Nov 30, 2024
b57deb6
increased the number of instances for the orderers
Sanket-0510 Dec 1, 2024
b46833b
minor changes
Sanket-0510 Dec 2, 2024
6cfdd01
Update src/setup-docker/templates/fabric-docker/docker-compose.yaml
Sanket-0510 Dec 3, 2024
f953b52
Merge pull request #1 from dzikowski/fix-bft
Sanket-0510 Dec 3, 2024
658e041
merged BFT support with version 3
Sanket-0510 Dec 3, 2024
e4062c3
updated the snapshots
Sanket-0510 Dec 3, 2024
c313bf2
changed the log check message in BFT test file
Sanket-0510 Dec 3, 2024
93a3a75
Update src/setup-docker/index.ts
Sanket-0510 Dec 3, 2024
dda9873
minor changes
Sanket-0510 Dec 3, 2024
a5ac2b3
Update e2e-network/docker/test-05-version3-BFT.sh
Sanket-0510 Dec 3, 2024
da49380
Update e2e-network/docker/test-05-version3.sh
Sanket-0510 Dec 3, 2024
cbf301f
minor fixes after the review
Sanket-0510 Dec 3, 2024
711f7f0
updated the snapshots
Sanket-0510 Dec 3, 2024
439c5a7
added the tests in the CI pipeline of fablo
Sanket-0510 Dec 4, 2024
8586cc7
updated testCases.md
Sanket-0510 Dec 4, 2024
bee292a
fixes in docker-compose
Sanket-0510 Dec 5, 2024
d0b6a9f
some linting and other fixes
Sanket-0510 Dec 5, 2024
9530918
updated the workflow file
Sanket-0510 Dec 5, 2024
16ee7b0
final fixes
Sanket-0510 Dec 5, 2024
d3af059
Update snapshot
dzikowski Dec 6, 2024
589f423
Adjust versions
dzikowski Dec 6, 2024
c9fc458
Update snapshots
dzikowski Dec 6, 2024
acc7a88
Add explicit fabricToolsVetsion
dzikowski Dec 6, 2024
89e0a59
Update Docker commands to use FABRIC_TOOLS_VERSION instead of FABRIC_…
dzikowski Dec 6, 2024
e248186
Update fabricToolsVersion to 3.0.0-beta in configuration snapshots an…
dzikowski Dec 6, 2024
fce9648
Update snapshots
dzikowski Dec 6, 2024
357d0d7
Validation changes to make explicit Fablo supports Fabric up to 3.0.0…
dzikowski Dec 7, 2024
867b326
Update CHANGELOG
dzikowski Dec 7, 2024
c430c74
Update snapshots
dzikowski Dec 7, 2024
12bac57
Create directory to avoid permission errors
dzikowski Dec 7, 2024
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
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
Loading