From c6af384f714fbfad04e7853a877f67c1f5bc84f3 Mon Sep 17 00:00:00 2001 From: Mark Logan <103447440+mystenmark@users.noreply.github.com> Date: Fri, 23 Sep 2022 10:34:32 -0700 Subject: [PATCH] Support for patching blst with a mocked version that bypasses crypto ops. (#4748) Massively speeds up the simulator in cases where all the verifications would succeed anyway. --- scripts/simtest/cargo-simtest | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/simtest/cargo-simtest b/scripts/simtest/cargo-simtest index abccbbc65b543..6c318b8bf3f63 100755 --- a/scripts/simtest/cargo-simtest +++ b/scripts/simtest/cargo-simtest @@ -43,6 +43,8 @@ else echo "Using MSIM_TEST_SEED=$MSIM_TEST_SEED from the environment" fi +RUST_FLAGS=('"--cfg"' '"msim"') + cargo_patch_args=( --config 'patch.crates-io.hyper.git = "https://github.com/mystenmark/hyper-madsim-fork.git"' --config 'patch.crates-io.hyper.rev = "2b2eca1e983376294c84c93385ebe848ccf9a99f"' @@ -60,6 +62,23 @@ else ) fi +# Mock out the blst crate to massively speed up the simulation. +# You should not assume that test runs will be repeatable with and without blst mocking, +# as blst samples from the PRNG when not mocked. +if [ -n "$USE_MOCK_CRYPTO" ]; then + echo "Using mocked crypto crates - no cryptographic verification will occur" + RUST_FLAGS+=( + '"--cfg"' + '"use_mock_crypto"' + ) + cargo_patch_args+=( + --config 'patch.crates-io.blst.git = "https://github.com/MystenLabs/mock-blst.git"' + --config 'patch.crates-io.blst.rev = "630ca4d55de8e199e62c5b6a695c702d95fe6498"' + ) +fi + +RUST_FLAGS=$(IFS=, ; echo "${RUST_FLAGS[*]}") + CARGO_COMMAND=(nextest run --cargo-profile simulator) if [ "$1" = "build" ]; then shift @@ -67,7 +86,7 @@ if [ "$1" = "build" ]; then fi cargo ${CARGO_COMMAND[@]} \ - --config 'build.rustflags = ["--cfg", "msim"]' \ + --config "build.rustflags = [$RUST_FLAGS]" \ "${cargo_patch_args[@]}" \ --config 'patch.crates-io.hyper.git = "https://github.com/mystenmark/hyper-madsim-fork.git"' \ --config 'patch.crates-io.hyper.rev = "2b2eca1e983376294c84c93385ebe848ccf9a99f"' \