Skip to content

Latest commit

 

History

History
147 lines (112 loc) · 7.13 KB

README.md

File metadata and controls

147 lines (112 loc) · 7.13 KB

Overview

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 and zombienet pre-compiled binaries taken from offical releases
  • moonbeam 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 to smart-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:

  1. use smart-bench:latest image as is, composed of specific versions of nodes and contracts
  2. use smart-bench:latest for what it consists of but provide custom set of pre-compiled contracts
  3. use smart-bench:latest but provide custom set of node binaries (polkadot, zombienet polkadot-parachain, moonbeam)
  4. 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.

Usage

Step 1. Build image

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

Step 2. Run image

run.sh help screen:

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

run examples

Following are examples of running smart-bench:latest image using either run.sh wrapper script or raw docker run commands equivalents (see expandable sections)


Scenario 1. Running smart-bench without overriding any binaries or configurations:

./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

Scenario 2. Override binaries:

./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

Scenario 3. Override contracts

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

Scenario 4. Override configs

./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

Miscellaneous

Moonbeam with Dev RPC module enabled build recipe

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