Skip to content

Commit

Permalink
Create workflow for full AVM tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Jun 17, 2024
1 parent a23fd0b commit b2b5fe6
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 8 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/vm_full_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: AVM Full Tests

on:
push: #TODO: REMOVE BEFOre MERGING
schedule:
- cron: "15 4 * * 1-5" # Monday to Friday at 4:15 AM UTC
workflow_dispatch:
inputs:
username:
description: 'Username (optional)'
required: false
action:
description: "Default to 'start'"
required: false
default: 'start'
inputs: {}

concurrency:
# force parallelism in master
group: avm-full-tests-${{ github.ref }}
cancel-in-progress: true

env:
DOCKERHUB_PASSWORD: "${{ secrets.DOCKERHUB_PASSWORD }}"
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
USERNAME: ${{ github.event.pull_request.user.login || github.actor }}
GITHUB_TOKEN: ${{ github.token }}
GH_SELF_HOSTED_RUNNER_TOKEN: ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BUILD_INSTANCE_SSH_KEY: ${{ secrets.BUILD_INSTANCE_SSH_KEY }}
GIT_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
# kludge until we move away from runners
WAIT_FOR_RUNNERS: false

jobs:
setup:
uses: ./.github/workflows/setup-runner.yml
with:
username: ${{ github.event.pull_request.user.login || github.actor }}
runner_type: builder-x86
secrets: inherit

# barretenberg (prover) native and AVM (public VM) tests
# only ran on x86 for resource reasons (memory intensive)
avm-full-tests:
needs: [setup]
runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86
#if: ${{ needs.changes.outputs.barretenberg-cpp == 'true' }}
steps:
- uses: actions/checkout@v4
with: { ref: "${{ env.GIT_COMMIT }}" }
# Only allow one memory-hunger prover test to use this runner
- uses: ./.github/ci-setup-action
with:
# must be globally unique for build x runner
concurrency_key: avm-full-tests-x86
- name: "AVM Full Tests"
working-directory: ./barretenberg/cpp/
timeout-minutes: 60
# limit our parallelism to half our cores
run: earthly-ci --no-output +vm-full-test --hardware_concurrency=64
17 changes: 17 additions & 0 deletions barretenberg/cpp/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,23 @@ test:
END
RUN cd build && GTEST_COLOR=1 ctest -j$(nproc) --output-on-failure

vm-full-test:
ARG hardware_concurrency=""
# prefetch
BUILD +test-binaries
BUILD +preset-release-assert-test
BUILD +test-clang-format
BUILD ./srs_db/+build # prefetch
FROM +source
COPY --dir +test-binaries/build build
FROM +preset-release-assert-test
COPY --dir ./srs_db/+build/. srs_db
# limit hardware concurrency, if provided
IF [ "$HARDWARE_CONCURRENCY" != "" ]
ENV HARDWARE_CONCURRENCY=$hardware_concurrency
END
RUN cd build && GTEST_COLOR=1 AVM_TESTS_ENABLE_PROVING=1 ctest -j4 --test-dir src/barretenberg/vm --output-on-failure

build:
BUILD +preset-wasm
BUILD +preset-wasm-threads
Expand Down
5 changes: 2 additions & 3 deletions barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ namespace bb::avm_trace {
using Flavor = bb::AvmFlavor;
using FF = Flavor::FF;

} // namespace bb::avm_trace

namespace bb::avm_trace {
// To toggle all relevant unit tests with proving, set the env variable "AVM_TESTS_ENABLE_PROVING".
static const bool ENABLE_PROVING = std::getenv("AVM_TESTS_ENABLE_PROVING") != nullptr;

// There are 4 public input columns, 1 for context inputs, and 3 for emitting side effects
using VmPublicInputs = std::tuple<std::array<FF, KERNEL_INPUTS_LENGTH>, // Input: Kernel context inputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AvmTraceBuilder {
ExecutionHints execution_hints = {},
uint32_t side_effect_counter = 0);

std::vector<Row> finalize(uint32_t min_trace_size = 0, bool range_check_required = false);
std::vector<Row> finalize(uint32_t min_trace_size = 0, bool range_check_required = ENABLE_PROVING);
void reset();

uint32_t getPc() const { return pc; }
Expand Down
5 changes: 1 addition & 4 deletions barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ using ThreeOpParam = std::array<FF, 3>;
using ThreeOpParamRow = std::tuple<ThreeOpParam, bb::avm_trace::AvmMemoryTag>;
using VmPublicInputs = bb::avm_trace::VmPublicInputs;

// To toggle all relevant unit tests with proving, set the env variable "AVM_TESTS_ENABLE_PROVING".
static const bool ENABLE_PROVING = std::getenv("AVM_TESTS_ENABLE_PROVING") != nullptr;

// If the test is expecting a relation to fail, then use validate_trace_check_circuit.
// Otherwise, use validate_trace with a single argument. If the proving needs to be
// enabled all the time in a given test, use validate_trace with setting with_proof = true.
void validate_trace_check_circuit(std::vector<Row>&& trace, VmPublicInputs public_inputs = {});
void validate_trace(std::vector<Row>&& trace,
VmPublicInputs const& public_inputs = {},
bool with_proof = ENABLE_PROVING);
bool with_proof = bb::avm_trace::ENABLE_PROVING);
void mutate_ic_in_trace(std::vector<Row>& trace,
std::function<bool(Row)>&& selectRow,
FF const& newValue,
Expand Down

0 comments on commit b2b5fe6

Please sign in to comment.