Skip to content

Commit f6527ae

Browse files
authored
feat: include anvil-zksync in foundryup install script (#765)
* feat: adds anvil-zksync to installation script * fix: address target issue * chore: lint * fix: revert unneeded changes * fix: linux install * chore: update workflow action * chore: make requested changes * chore: resolve conflicts * chore: update action
1 parent 85f68fd commit f6527ae

File tree

2 files changed

+184
-118
lines changed

2 files changed

+184
-118
lines changed

.github/workflows/test.yml

Lines changed: 128 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
11
name: test
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- "*upstream*"
8-
pull_request:
9-
branches:
10-
- main
11-
- "*upstream*"
4+
push:
5+
branches:
6+
- main
7+
- "*upstream*"
8+
pull_request:
9+
branches:
10+
- main
11+
- "*upstream*"
1212

1313
concurrency:
14-
cancel-in-progress: true
15-
group: ${{github.workflow}}-${{github.ref}}
14+
cancel-in-progress: true
15+
group: ${{github.workflow}}-${{github.ref}}
1616

1717
env:
18-
CARGO_TERM_COLOR: always
19-
TARGET_RUST_VERSION: "nightly-2024-09-01"
18+
CARGO_TERM_COLOR: always
19+
TARGET_RUST_VERSION: "nightly-2024-09-01"
2020

2121
jobs:
22-
nextest:
23-
uses: ./.github/workflows/nextest.yml
24-
with:
25-
profile: default
26-
secrets: inherit
22+
nextest:
23+
uses: ./.github/workflows/nextest.yml
24+
with:
25+
profile: default
26+
secrets: inherit
2727

2828
doctest:
29-
runs-on: ubuntu-22.04
30-
timeout-minutes: 60
31-
steps:
32-
- uses: actions/checkout@v4
33-
- uses: dtolnay/rust-toolchain@nightly
34-
with:
35-
toolchain: ${{ env.TARGET_RUST_VERSION }}
36-
- uses: Swatinem/rust-cache@v2
37-
with:
38-
cache-on-failure: true
39-
- name: cargo test
40-
run: cargo test --doc -p forge
29+
runs-on: ubuntu-22.04
30+
timeout-minutes: 60
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: dtolnay/rust-toolchain@nightly
34+
with:
35+
toolchain: ${{ env.TARGET_RUST_VERSION }}
36+
- uses: Swatinem/rust-cache@v2
37+
with:
38+
cache-on-failure: true
39+
- name: cargo test
40+
run: cargo test --doc -p forge
4141

4242
clippy:
43-
name: clippy
44-
runs-on: ubuntu-22.04
45-
timeout-minutes: 60
46-
steps:
47-
- uses: actions/checkout@v4
48-
- uses: dtolnay/rust-toolchain@clippy
49-
- uses: Swatinem/rust-cache@v2
50-
with:
51-
cache-on-failure: true
52-
- run: cargo clippy --workspace --all-targets --all-features
53-
env:
54-
RUSTFLAGS: -Dwarnings
43+
name: clippy
44+
runs-on: ubuntu-22.04
45+
timeout-minutes: 60
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: dtolnay/rust-toolchain@clippy
49+
- uses: Swatinem/rust-cache@v2
50+
with:
51+
cache-on-failure: true
52+
- run: cargo clippy --workspace --all-targets --all-features
53+
env:
54+
RUSTFLAGS: -Dwarnings
5555

5656
rustfmt:
57-
runs-on: ubuntu-22.04
58-
timeout-minutes: 60
59-
steps:
60-
- uses: actions/checkout@v4
61-
- uses: dtolnay/rust-toolchain@nightly
62-
with:
63-
toolchain: ${{ env.TARGET_RUST_VERSION }}
64-
components: rustfmt
65-
- run: cargo fmt --all --check
57+
runs-on: ubuntu-22.04
58+
timeout-minutes: 60
59+
steps:
60+
- uses: actions/checkout@v4
61+
- uses: dtolnay/rust-toolchain@nightly
62+
with:
63+
toolchain: ${{ env.TARGET_RUST_VERSION }}
64+
components: rustfmt
65+
- run: cargo fmt --all --check
6666

6767
forge-fmt:
68-
runs-on: ubuntu-22.04
69-
timeout-minutes: 60
70-
steps:
71-
- uses: actions/checkout@v4
72-
- uses: dtolnay/rust-toolchain@nightly
73-
with:
74-
toolchain: ${{ env.TARGET_RUST_VERSION }}
75-
- uses: Swatinem/rust-cache@v2
76-
with:
77-
cache-on-failure: true
78-
- name: forge fmt
79-
shell: bash
80-
run: ./.github/scripts/format.sh --check
68+
runs-on: ubuntu-22.04
69+
timeout-minutes: 60
70+
steps:
71+
- uses: actions/checkout@v4
72+
- uses: dtolnay/rust-toolchain@nightly
73+
with:
74+
toolchain: ${{ env.TARGET_RUST_VERSION }}
75+
- uses: Swatinem/rust-cache@v2
76+
with:
77+
cache-on-failure: true
78+
- name: forge fmt
79+
shell: bash
80+
run: ./.github/scripts/format.sh --check
8181

8282
codespell:
8383
runs-on: ubuntu-22.04
@@ -89,66 +89,81 @@ jobs:
8989
skip: "*.json"
9090

9191
crate-checks:
92-
# ubuntu-22.04 runs out of disk space
93-
runs-on: ubuntu-22.04-github-hosted-16core
94-
timeout-minutes: 60
95-
steps:
96-
- uses: actions/checkout@v4
97-
- uses: dtolnay/rust-toolchain@nightly
98-
with:
99-
toolchain: ${{ env.TARGET_RUST_VERSION }}
100-
- uses: taiki-e/install-action@cargo-hack
101-
- uses: Swatinem/rust-cache@v2
102-
with:
103-
cache-on-failure: true
104-
- name: cargo hack
105-
run: cargo hack check
106-
92+
# ubuntu-22.04 runs out of disk space
93+
runs-on: ubuntu-22.04-github-hosted-16core
94+
timeout-minutes: 60
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: dtolnay/rust-toolchain@nightly
98+
with:
99+
toolchain: ${{ env.TARGET_RUST_VERSION }}
100+
- uses: taiki-e/install-action@cargo-hack
101+
- uses: Swatinem/rust-cache@v2
102+
with:
103+
cache-on-failure: true
104+
- name: cargo hack
105+
run: cargo hack check
106+
107107
zk-cargo-test:
108-
runs-on: ubuntu-22.04
109-
110-
steps:
108+
runs-on: ubuntu-22.04
109+
110+
steps:
111111
- name: Checkout code
112112
uses: actions/checkout@v4
113113
with:
114114
submodules: recursive
115115
ref: ${{ github.event.pull_request.head.sha }}
116-
116+
117117
- name: Install Rust
118118
uses: actions-rust-lang/setup-rust-toolchain@v1
119119
with:
120120
toolchain: ${{ env.TARGET_RUST_VERSION }}
121121

122-
- name: Install cargo-nextest
123-
uses: taiki-e/install-action@nextest
122+
zk-cargo-test:
123+
runs-on: ubuntu-22.04
124124

125-
- name: Run era-test-node
126-
uses: dutterbutter/era-test-node-action@v1
127-
with:
128-
mode: fork
129-
network: mainnet
130-
log: info
131-
logFilePath: era_test_node.log
132-
target: x86_64-unknown-linux-gnu
133-
releaseTag: v0.1.0-alpha.29
134-
- name: Setup Git config
135-
run: |
136-
git config --global user.name "GitHub Actions Bot"
137-
git config --global user.email "<>"
138-
git config --global url."https://github.com/".insteadOf "[email protected]:"
139-
- name: Run zk tests
140-
env:
141-
RUST_BACKTRACE: full
142-
TEST_MAINNET_URL: http://localhost:8011
143-
run: |
144-
ZK_DEBUG_HISTORICAL_BLOCK_HASHES=5 cargo nextest run --package '*' --lib --test '*' --filter-expr 'test(~zk)'
125+
steps:
126+
- name: Checkout code
127+
uses: actions/checkout@v4
128+
with:
129+
submodules: recursive
130+
ref: ${{ github.event.pull_request.head.sha }}
145131

146-
check-ci-install:
147-
name: CI install
148-
runs-on: ubuntu-22.04
149-
steps:
150-
- uses: actions/checkout@v4
151-
- name: Install foundry-zksync
152-
run: cp ./install-foundry-zksync ./foundryup-zksync/* /tmp/ && cd /tmp && ./install-foundry-zksync
153-
- name: Verify installation
154-
run: forge --version
132+
- name: Install Rust
133+
uses: actions-rust-lang/setup-rust-toolchain@v1
134+
with:
135+
toolchain: ${{ env.TARGET_RUST_VERSION }}
136+
137+
- name: Install cargo-nextest
138+
uses: taiki-e/install-action@nextest
139+
140+
- name: Run anvil-zksync
141+
uses: dutterbutter/[email protected]
142+
with:
143+
mode: fork
144+
forkUrl: mainnet
145+
log: info
146+
logFilePath: anvil_zksync.log
147+
target: x86_64-unknown-linux-gnu
148+
releaseTag: v0.2.1
149+
- name: Setup Git config
150+
run: |
151+
git config --global user.name "GitHub Actions Bot"
152+
git config --global user.email "<>"
153+
git config --global url."https://github.com/".insteadOf "[email protected]:"
154+
- name: Run zk tests
155+
env:
156+
RUST_BACKTRACE: full
157+
TEST_MAINNET_URL: http://localhost:8011
158+
run: |
159+
ZK_DEBUG_HISTORICAL_BLOCK_HASHES=5 cargo nextest run --package '*' --lib --test '*' --filter-expr 'test(~zk)'
160+
161+
check-ci-install:
162+
name: CI install
163+
runs-on: ubuntu-22.04
164+
steps:
165+
- uses: actions/checkout@v4
166+
- name: Install foundry-zksync
167+
run: cp ./install-foundry-zksync ./foundryup-zksync/* /tmp/ && cd /tmp && ./install-foundry-zksync
168+
- name: Verify installation
169+
run: forge --version

foundryup-zksync/foundryup-zksync

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,59 @@ EOF
178178
fi
179179
done
180180

181+
# Begin anvil-zksync installation
182+
say "downloading anvil-zksync"
183+
184+
# Supported targets for anvil-zksync
185+
SUPPORTED_TARGETS=(
186+
"x86_64-apple-darwin"
187+
"aarch64-apple-darwin"
188+
"x86_64-unknown-linux-gnu"
189+
"aarch64-unknown-linux-gnu"
190+
)
191+
192+
if [ "$ARCHITECTURE" = "arm64" ]; then
193+
ARCHITECTURE="aarch64"
194+
fi
195+
196+
if [ "$PLATFORM" = "darwin" ]; then
197+
TARGET="${ARCHITECTURE}-apple-${PLATFORM}"
198+
elif [ "$PLATFORM" = "linux" ]; then
199+
TARGET="${ARCHITECTURE}-unknown-${PLATFORM}-gnu"
200+
else
201+
TARGET="${ARCHITECTURE}-${PLATFORM}"
202+
fi
203+
204+
if [[ " ${SUPPORTED_TARGETS[*]} " == *" $TARGET "* ]]; then
205+
ANVIL_REPO="matter-labs/anvil-zksync"
206+
207+
say "getting latest tag for anvil-zksync"
208+
209+
ANVIL_TAG=$(curl -s https://api.github.com/repos/$ANVIL_REPO/releases/latest | sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p')
210+
211+
if [ -z "$ANVIL_TAG" ]; then
212+
err "failed to get latest tag for anvil-zksync"
213+
fi
214+
215+
ANVIL_BIN_NAME="anvil-zksync-${ANVIL_TAG}-${TARGET}.${EXT}"
216+
217+
ANVIL_BIN_URL="https://github.com/$ANVIL_REPO/releases/download/$ANVIL_TAG/$ANVIL_BIN_NAME"
218+
219+
ANVIL_BIN_PATH="$FOUNDRY_BIN_DIR/anvil-zksync"
220+
221+
say "downloading anvil-zksync from $ANVIL_BIN_URL"
222+
223+
ensure download "$ANVIL_BIN_URL" | ensure tar -xzC "$FOUNDRY_BIN_DIR"
224+
225+
mv "$FOUNDRY_BIN_DIR/anvil-zksync" "$ANVIL_BIN_PATH"
226+
227+
chmod +x "$ANVIL_BIN_PATH"
228+
229+
say "installed - $(ensure "$ANVIL_BIN_PATH" --version)"
230+
else
231+
warn "anvil-zksync is not supported on your platform ($TARGET). Skipping anvil-zksync installation."
232+
fi
233+
181234
say "done!"
182235

183236
# Install by cloning the repo with the provided branch/tag
@@ -235,8 +288,6 @@ Update or revert to a specific Foundry-zksync version with ease.
235288
236289
By default, the latest nightly version is installed from built binaries.
237290
238-
By default, the latest nightly version is installed from built binaries.
239-
240291
USAGE:
241292
foundryup-zksync <OPTIONS>
242293
@@ -313,19 +364,19 @@ banner() {
313364
.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx
314365
315366
╔═╗ ╔═╗ ╦ ╦ ╔╗╔ ╔╦╗ ╦═╗ ╦ ╦ Portable and modular toolkit
316-
╠╣ ║ ║ ║ ║ ║║║ ║║ ╠╦╝ ╚╦╝ for Ethereum Application Development
367+
╠╣ ║ ║ ║ ║ ║║║ ║║ ╠╦╝ ╚╦╝ for ZKsync Application Development
317368
╚ ╚═╝ ╚═╝ ╝╚╝ ═╩╝ ╩╚═ ╩ written in Rust.
318369
319370
.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx
320371
321372
Fork of : https://github.com/foundry-rs/
322373
Repo : https://github.com/matter-labs/foundry-zksync/
323-
Book : https://book.getfoundry.sh/
374+
Book : https://foundry-book.zksync.io/
324375
325376
.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx
326377
327378
'
328-
}
329379

380+
}
330381

331382
main "$@"

0 commit comments

Comments
 (0)