Skip to content

Commit

Permalink
Support for patching blst with a mocked version that bypasses crypto …
Browse files Browse the repository at this point in the history
…ops. (#4748)

Massively speeds up the simulator in cases where all the verifications
would succeed anyway.
  • Loading branch information
mystenmark committed Sep 23, 2022
1 parent e5beaa6 commit c6af384
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion scripts/simtest/cargo-simtest
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand All @@ -60,14 +62,31 @@ 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
CARGO_COMMAND=(build --profile simulator)
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"' \
Expand Down

0 comments on commit c6af384

Please sign in to comment.