-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: /foundry is canoncial build of foundry. e2e tests can start own…
… anvil. (#5522) We want e2e tests to be able to launch their own anvil. This will enable deterministic L1 states for the test. * We use viems anvil package and get-port to find a random port to run anvil on, and launch it and use it if no `ETHEREUM_HOST` env var is set. * Anvil is wrapped in wrapper script to ensure it's process is killed when the parent dies, no matter what. * This is as close as we can get to what looks like an "in-memory" blockchain for testing with no side-effects. * Anvil needs to be present *within* the e2e image to achieve this. This means we need an x86 and arm build of anvil in our image, and we want it to be whatever our chosen version of foundry is (which is often some random pinned nightly that only has x86 builds). * Solution, foundry build in monorepo! `/foundry` now contains an Earthly ubuntu build of foundry using their `local` build target which keeps builds at about 1m on a decent core machine. * L1 contracts, yarn-project, and any other code that uses foundry, should take foundry from the foundry image we build. * We also do some cleanup in `yarn-project/Earthfile`, and leverage layer caching to only reinstall dependencies if bb.js, noir-packages, or package.json files change. --------- Co-authored-by: ludamad <[email protected]> Co-authored-by: ludamad <[email protected]>
- Loading branch information
1 parent
eb66fc6
commit 510daa0
Showing
21 changed files
with
245 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
foundry-repo |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
VERSION 0.8 | ||
|
||
builder: | ||
FROM rust:bookworm | ||
ARG TARGETARCH | ||
WORKDIR /usr/src/foundry | ||
COPY bootstrap.sh bootstrap.sh | ||
RUN ./bootstrap.sh && rm -rf foundry-repo | ||
SAVE ARTIFACT bin /usr/src/foundry/bin | ||
|
||
build: | ||
FROM ubuntu:lunar | ||
ARG TARGETARCH | ||
FROM DOCKERFILE . | ||
COPY --dir +builder/usr/src/foundry/bin /usr/src/foundry/bin | ||
SAVE ARTIFACT /usr/src/foundry/bin /usr/src/foundry/bin | ||
SAVE IMAGE --push aztecprotocol/foundry-nightly-de33b6af53005037b463318d2628b5cfcaf3991-$TARGETARCH:latest | ||
|
||
# Relies on both steps being published | ||
build-multiplatform: | ||
FROM --platform=linux/amd64 aztecprotocol/foundry-nightly-de33b6af53005037b463318d2628b5cfcaf3991-amd64:latest | ||
SAVE IMAGE --push aztecprotocol/foundry-nightly-de33b6af53005037b463318d2628b5cfcaf3991:latest | ||
FROM --platform=linux/arm64 aztecprotocol/foundry-nightly-de33b6af53005037b463318d2628b5cfcaf3991-arm64:latest | ||
SAVE IMAGE --push aztecprotocol/foundry-nightly-de33b6af53005037b463318d2628b5cfcaf3991:latest | ||
|
||
get: | ||
ARG TARGETARCH | ||
# If this is failing, we need to run earthly --push +build on both archs then earthly --push +build-multiplatform on any runner | ||
FROM aztecprotocol/foundry-nightly-de33b6af53005037b463318d2628b5cfcaf3991:latest | ||
build-save-local: | ||
# for renaming the image as a local image, used with e2e runners | ||
ARG image | ||
FROM +build | ||
SAVE IMAGE $image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
cd $(dirname $0) | ||
|
||
rm -rf bin share | ||
|
||
[ "${TARGETARCH:-$(uname -m)}" = "arm64" ] && echo "export CFLAGS=-mno-outline-atomics" >> $HOME/.profile || true | ||
|
||
if [ ! -d './foundry-repo' ]; then | ||
git clone --depth 1 --branch nightly-de33b6af53005037b463318d2628b5cfcaf39916 \ | ||
https://github.com/foundry-rs/foundry.git foundry-repo | ||
fi | ||
|
||
(cd foundry-repo && cargo build --profile local) | ||
|
||
mkdir bin \ | ||
&& mv foundry-repo/target/local/forge bin/forge \ | ||
&& mv foundry-repo/target/local/cast bin/cast \ | ||
&& mv foundry-repo/target/local/anvil bin/anvil \ | ||
&& mv foundry-repo/target/local/chisel bin/chisel \ | ||
&& strip bin/forge \ | ||
&& strip bin/cast \ | ||
&& strip bin/chisel \ | ||
&& strip bin/anvil; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
VERSION 0.8 | ||
FROM ubuntu:lunar | ||
RUN apt update && apt install curl git jq bash nodejs npm python3.11-full python3-pip -y | ||
|
||
# Use virtualenv, do not try to use pipx, it's not working. | ||
RUN python3 -m venv /root/.venv | ||
RUN /root/.venv/bin/pip3 install slither-analyzer==0.10.0 slitherin==0.5.0 | ||
RUN curl -L https://foundry.paradigm.xyz | bash | ||
build: | ||
FROM ubuntu:lunar | ||
RUN apt update && apt install curl git jq bash nodejs npm python3.11-full python3-pip -y | ||
|
||
# Set env variables for foundry and venv | ||
ENV PATH="${PATH}:/root/.foundry/bin:/root/.venv/bin" | ||
RUN foundryup --version nightly-de33b6af53005037b463318d2628b5cfcaf39916 | ||
# Use virtualenv, do not try to use pipx, it's not working. | ||
RUN python3 -m venv /root/.venv | ||
RUN /root/.venv/bin/pip3 install slither-analyzer==0.10.0 slitherin==0.5.0 | ||
ENV PATH="${PATH}:/root/.venv/bin" | ||
|
||
# Install yarn and solhint. | ||
RUN npm install --global yarn solhint | ||
# Install yarn and solhint. | ||
RUN npm install --global yarn solhint | ||
|
||
WORKDIR /usr/src | ||
COPY --dir lib scripts src terraform test *.json *.toml *.sh . | ||
# Install our build of foundry. | ||
COPY --dir ../foundry/+build/usr/src/foundry/bin /usr/src/foundry/bin | ||
ENV PATH="${PATH}:/usr/src/foundry/bin" | ||
|
||
build: | ||
WORKDIR /usr/src/l1-contracts | ||
COPY --dir lib scripts src terraform test *.json *.toml *.sh . | ||
RUN git init && git add . && yarn lint && yarn slither && yarn slither-has-diff | ||
RUN forge clean && forge fmt --check && forge build && forge test --no-match-contract UniswapPortalTest | ||
SAVE ARTIFACT out | ||
SAVE ARTIFACT /usr/src/l1-contracts /usr/src/l1-contracts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.