Skip to content

Commit

Permalink
feat!: TXE (#6985)
Browse files Browse the repository at this point in the history
This PR adds the TXE (Testing eXecution Environment, or Tricky PXE) as a
minimalistic oracle resolver that mimics the behavior of the Aztec
protocol in order to write smart contract tests, much like Foundry for
Solidity contracts.

Together with a `TestEnvironment` added to `aztec-nr`, its aim is to
make possible writing Aztec tests in pure noir resulting in much faster
tests times than running e2e tests.

TXE does NOT test the protocol itself and might let you do very illegal
stuff ATM, but its intent is to provide a faster way to test contract
logic and contract logic only.

A 38 second Token Transfer test:

![Screenshot 2024-06-14 at 13 38
08](https://github.com/AztecProtocol/aztec-packages/assets/5404052/93c38be5-b2fd-4507-9894-e3c93e9bb913)

WARNING: TXE is under heavy development and we are learning how and what
we want to test as we go. It's also in need of a heavy refactor, but we
need this base code in order to get it in the hands of more people and
understand its scope and required capabilities.

---------

Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
  • Loading branch information
Thunkar and nventuro authored Jun 18, 2024
1 parent 59df722 commit 109624f
Show file tree
Hide file tree
Showing 53 changed files with 2,949 additions and 570 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ jobs:
run: earthly-ci --no-output ./noir+packages-test

noir-projects:
needs: [setup, changes]
needs: [setup, changes, build]
runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86
if: ${{ needs.changes.outputs.barretenberg == 'true' || needs.changes.outputs.noir == 'true' || needs.changes.outputs.noir-projects == 'true' }}
steps:
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,4 @@
"**/noir/noir-repo/docs/versioned_docs/**": true
},
"cmake.sourceDirectory": "${workspaceFolder}/barretenberg/cpp",
"noir.nargoPath": "./noir/noir-repo/target/release/nargo"
}
25 changes: 19 additions & 6 deletions noir-projects/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM aztecprotocol/noir as noir
FROM aztecprotocol/avm-transpiler as transpiler
FROM aztecprotocol/yarn-project AS yarn-project

FROM ubuntu:lunar AS builder
RUN apt-get update && apt-get install -y parallel nodejs npm
Expand All @@ -13,13 +14,25 @@ ENV PATH="/usr/src/avm-transpiler/target/release:${PATH}"
# Copy in noir projects
WORKDIR /usr/src/noir-projects
COPY . .


# Build
WORKDIR /usr/src/noir-projects/noir-contracts
RUN ./bootstrap.sh && nargo test --silence-warnings
WORKDIR /usr/src/noir-projects/noir-protocol-circuits
RUN ./bootstrap.sh && nargo test --silence-warnings
WORKDIR /usr/src/noir-projects/aztec-nr
RUN nargo test --silence-warnings
WORKDIR /usr/src/noir-projects
RUN cd noir-protocol-circuits && ./bootstrap.sh && nargo test --silence-warnings

RUN cd /usr/src/yarn-project/txe && yarn start & echo $! > /tmp/txe.pid && \
# Wait for TXE to initialize
sleep 5 && \
cd /usr/src/noir-projects/noir-contracts && \
./bootstrap.sh && nargo test --silence-warnings --oracle-resolver http://localhost:8080 ; \
kill $(cat /tmp/txe.pid)

RUN cd /usr/src/yarn-project/txe && yarn start & echo $! > /tmp/txe.pid && \
# Wait for TXE to initialize
sleep 5 && \
cd /usr/src/noir-projects/aztec-nr && \
nargo test --silence-warnings --oracle-resolver http://localhost:8080


FROM scratch
COPY --from=builder /usr/src/noir-projects /usr/src/noir-projects
23 changes: 19 additions & 4 deletions noir-projects/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,25 @@ build:
SAVE ARTIFACT noir-protocol-circuits

test:
FROM +build
RUN cd noir-protocol-circuits && nargo test --silence-warnings
RUN cd aztec-nr && nargo test --silence-warnings
RUN cd noir-contracts && nargo test --silence-warnings
FROM ../yarn-project/+txe

# Install nargo
COPY ../noir/+nargo/nargo /usr/bin/nargo

COPY +build/. /usr/src/noir-projects

RUN cd /usr/src/noir-projects/noir-protocol-circuits && nargo test --silence-warnings
RUN cd /usr/src/yarn-project/txe && yarn start & echo $! > /tmp/txe.pid && \
# Wait for TXE to initialize
sleep 5 && \
cd /usr/src/noir-projects/aztec-nr && nargo test --silence-warnings --oracle-resolver http://localhost:8080 ; \
kill $(cat /tmp/txe.pid)

RUN cd /usr/src/yarn-project/txe && yarn start & echo $! > /tmp/txe.pid && \
# Wait for TXE to initialize
sleep 5 && \
cd /usr/src/noir-projects/noir-contracts && nargo test --silence-warnings --oracle-resolver http://localhost:8080 ; \
kill $(cat /tmp/txe.pid)

format:
FROM +build
Expand Down
Loading

0 comments on commit 109624f

Please sign in to comment.