Installing and Testing PBFT
This procedure describes how to install PBFT, start a four-node network in Docker containers, and run a basic liveness test.
Prerequisites: Docker and Docker Compose must be installed.
-
Clone the PBFT repository.
$ git clone https://github.com/splintercommunity/sawtooth-pbft.git -
Run the following commands to install the dependencies for PBFT and connect to the interactive shell container,
sawtooth-dev-pbft.$ cd sawtooth-pbft $ docker build . -f Dockerfile -t sawtooth-dev-pbft $ docker run -v $(pwd):/project/sawtooth-pbft -it sawtooth-dev-pbft bashTip
If you have already configured a
cargo-registryDocker volume, use the followingdocker runcommand to speed up the build time in the next step.$ docker run -v $(pwd):/project/sawtooth-pbft \ -v cargo-registry:/root/.cargo/registry \ -it sawtooth-dev-pbft bash -
Build the PBFT project.
$ cargo build -
After the project has finished building, exit the
sawtooth-dev-pbftshell container. -
Run the PBFT test script on your host system from the
sawtooth-pbftdirectory.% bin/run_docker_test tests/test_liveness.yamlThis command builds several Docker images, starts up a network of four Sawtooth nodes with PBFT consensus, then goes through a liveness test of 55 blocks, as defined in the Docker Compose file
test_liveness.yaml. The default log level isINFO, so the test script displays a large amount of information as it executes.Tips:
- This script has several options, such as
--clean,--no-build, and--timeout. For more information, executerun_docker_test --help. - To run a different test, specify a different Compose file for
run_docker_test. Thesawtooth-pbft/tests/directory includes several Docker Compose files for testing, such asgrafana.yaml,client.yaml, andpbft_unit_tests.yaml. - To adjust the on chain settings, edit the
testing Compose file and change the
sawset proposal createparameter for the genesis validator container (validator-0). This example shows the settings intest_liveness.yaml:
validator-0 ... sawset proposal create \ ... sawtooth.consensus.algorithm.name=pbft \ sawtooth.consensus.algorithm.version=1.0 \ sawtooth.consensus.pbft.members=\\['\\\"'$$(cat /etc/sawtooth/keys/validator.pub)'\\\"','\\\"'$$(cat /etc/sawtooth/keys/validator-1.pub)'\\\"','\\\"'$$(cat /etc/sawtooth/keys/validator-2.pub)'\\\"','\\\"'$$(cat /etc/sawtooth/keys/validator-3.pub)'\\\"'\\] \ ...-
To adjust the CLI options, edit the testing Compose file and change the options used with the
pbft-enginecommand for each PBFT container. This example shows the options intest_liveness.yamlfor thepbft-0container:pbft-0 ... command: ./target/debug/pbft-engine --connect tcp://validator-0:5050 -vv ...
- This script has several options, such as