This directory contains docker related scripts and configurations to compile and run smart-bench as Docker Image. Resulting image and toolings available here are meant to be used in scenarios where consistent results are required such as CI/CD systems, but also for rapid testing on environments where there is no interest of setting up rust or any other compile prerequisites. Clients of the image will also benefit from not being required to track current recommendations for toolchain configurations or version changes and any compatibility issues that can arise from that, it can be expected that project will compile and run out of the box.
The environment is created as Docker Image (by default named and tagged as smart-bench:latest
) which leverages multi-stage Docker builds. Helper scripts available in this directory streamline operations to build (build.sh) and run (run.sh) of the image.
At the first stage of docker build, based upon docker.io/paritytech/ci-unified:bullseye-1.74.0
as rust enabled compilation env, smart-bench software is being compiled from current sources (this git repository). Resulting binary is copied into second stage / final docker image based on ubuntu:20.04
image where also other dependencies are configured and installed.
Final image consists of few pieces that are integrated into it:
polkadot
,polkadot-parachain
andzombienet
pre-compiled binaries taken from offical releasesmoonbeam
binary provided by custom release created on this fork (custom fork was required to enable dev rpc module which is not supported by offical releases)- pre-compiled smart contracts available within this repository at contracts dir
- entrypoint.sh script that orchestrates running of the above to eventually receive benchmarking results from
smart-bench
itself. The script accepts set of parameters to be passed as-is tosmart-bench
app. It runs zombienet as a background job and starts smart-bench while providing it with correct parameters to reach to zombienet nodes.
Please refer to the download-bin.sh script for detailed info about source of download for binary components
It is possible to run smart-bench:latest
using raw docker run
command with options (see examples below) but usage of run.sh
can abstract away some of the internals of the image and also result in better compatibility with future image versions. The run.sh
currently helps with following usage scenarios:
- use
smart-bench:latest
image as is, composed of specific versions of nodes and contracts - use
smart-bench:latest
for what it consists of but provide custom set of pre-compiled contracts - use
smart-bench:latest
but provide custom set of node binaries (polkadot
,zombienet
polkadot-parachain
,moonbeam
) - use
smart-bench:latest
but provide custom zombienet config
Usage scenarios above are possible by providing volume mounts arguments to docker run
, to override specific locations within the resulting container filesystem. And this is exactly what run.sh
is doing under the hood for you when providing optional parameters (see usage below) to the script.
a) downloads dependencies
./download-bins.sh
b) build smart-bench:latest image
./build.sh
or build using manual VERSION, eg. smart-bench:1.0 image
VERSION=1.0 ./build.sh
Usage: ./run.sh OPTION -- ARGUMENTS_TO_SMART_BENCH
OPTION
-b, --binaries-dir (Optional) Path to directory that contains binaries to mount into the container (eg. polkadot, zombienet, moonbeam)
List of binaries being used depends on config provided. Default set of binaries is available within the image
-t, --contracts-dir (Optional) Path to directory that contains compiled smart contracts. Default set of compiled smart contracts is available within the image
-u, --configs-dir (Optional) Path to directory that contains zombienet config files. Default set of configs files is available within the image
-h, --help Print this help message
ARGUMENTS_TO_SMART_BENCH
smart-bench specific parameters (NOTE: do not provide --url param as it is managed by this tool)
EXAMPLES
./run.sh -- evm erc20 --instance-count 1 --call-count 10
./run.sh -- ink-wasm erc20 --instance-count 1 --call-count 10
./run.sh -- sol-wasm erc20 --instance-count 1 --call-count 10
./run.sh --binaries-dir=./bin -- sol-wasm erc20 --instance-count 1 --call-count 10
./run.sh --contracts-dir=../contracts -- sol-wasm erc20 --instance-count 1 --call-count 10
./run.sh --configs-dir=./configs -- sol-wasm erc20 --instance-count 1 --call-count 10
Following are examples of running smart-bench:latest
image using either run.sh
wrapper script or raw docker run
commands equivalents (see expandable sections)
./run.sh -- evm erc20 --instance-count 1 --call-count 10
expand
docker run --rm -it --init smart-bench:latest evm erc20 --instance-count 1 --call-count 10
./run.sh --binaries-dir=./bin -- sol-wasm erc20 --instance-count 1 --call-count 10
expand
docker run --rm -it --init -v $PWD/bin:/usr/local/smart-bench/bin smart-bench:latest sol-wasm erc20 --instance-count 1 --call-count 10
NOTE: please note that smart-bench application expects some particular hierarchy of files in context of contracts directory and it must be preserved when creating other one to override. Please consult hierarchy available at contracts which is also part of this git repository. It might be easier to create copy of the one mentioned and modify only the parts of interest / to override.
./run.sh --contracts-dir=../contracts -- sol-wasm erc20 --instance-count 1 --call-count 10
expand
docker run --rm -it --init -v $PWD/../contracts:/usr/local/smart-bench/contracts smart-bench:latest sol-wasm erc20 --instance-count 1 --call-count 10
./run.sh --configs-dir=./configs -- sol-wasm erc20 --instance-count 1 --call-count 10
expand
docker run --rm -it --init -v $PWD/configs:/usr/local/smart-bench/config smart-bench:latest sol-wasm erc20 --instance-count 1 --call-count 10
Following is an example recipe how to build moonbeam binary with Dev RPC module enabled
git clone https://github.com/PureStake/moonbeam.git
cd moonbeam && git fetch https://github.com/karolk91/moonbeam master && git cherry-pick decd877
docker run -it --rm -v $PWD:/moonbeam docker.io/paritytech/ci-unified:bullseye-1.74.0 /bin/bash
cd /moonbeam
rustup toolchain install 1.74
rustup default 1.74
rustup override set 1.74
rustup target add wasm32-unknown-unknown --toolchain 1.74
cargo build --release