Skip to content

Commit 8f317f7

Browse files
chore: Add scripts for easy local rebuilds (#94)
## What ❔ When working on Era locally, there is often a need to build `app.bin` and `app_logging_enabled.bin` to be copied to the server ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [ ] Yes - [ ] No ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted.
1 parent 04b23b0 commit 8f317f7

File tree

3 files changed

+128
-13
lines changed

3 files changed

+128
-13
lines changed

zksync_os/.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
os.elf
2-
app.elf
3-
app.text
1+
*.elf
2+
*.text
3+
server_app.bin
4+
server_app_logging_enabled.bin
45
/target

zksync_os/dump_bin.sh

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,67 @@
11
#!/bin/sh
2-
rm app.bin
3-
rm app.elf
4-
rm app.text
5-
6-
cargo build --features proving --release # easier errors
7-
# cargo build -Z build-std=core,panic_abort,alloc -Z build-std-features=panic_immediate_abort --release
8-
cargo objcopy --features proving --release -- -O binary app.bin
9-
cargo objcopy --features proving --release -- -R .text app.elf
10-
cargo objcopy --features proving --release -- -O binary --only-section=.text app.text
11-
# cargo objcopy -- -O binary app.bin
2+
set -e
3+
4+
# Default mode
5+
TYPE="default"
6+
7+
# Parse --type argument
8+
while [ "$#" -gt 0 ]; do
9+
case "$1" in
10+
--type)
11+
TYPE="$2"
12+
shift 2
13+
;;
14+
*)
15+
echo "Unknown argument: $1"
16+
echo "Usage: $0 [--type default|server|server-logging-enabled]"
17+
exit 1
18+
;;
19+
esac
20+
done
21+
22+
# Base features and output names
23+
FEATURES="proving"
24+
BIN_NAME="app.bin"
25+
ELF_NAME="app.elf"
26+
TEXT_NAME="app.text"
27+
28+
# Adjust for server modes
29+
case "$TYPE" in
30+
server)
31+
FEATURES="$FEATURES,proof_running_system/unlimited_native,proof_running_system/wrap-in-batch"
32+
BIN_NAME="server_app.bin"
33+
ELF_NAME="server_app.elf"
34+
TEXT_NAME="server_app.text"
35+
;;
36+
server-logging-enabled)
37+
FEATURES="$FEATURES,proof_running_system/unlimited_native,proof_running_system/wrap-in-batch,print_debug_info"
38+
BIN_NAME="server_app_logging_enabled.bin"
39+
ELF_NAME="server_app_logging_enabled.elf"
40+
TEXT_NAME="server_app_logging_enabled.text"
41+
;;
42+
default)
43+
# leave defaults
44+
;;
45+
*)
46+
echo "Invalid --type: $TYPE"
47+
echo "Valid types are: default, server, server-logging-enabled"
48+
exit 1
49+
;;
50+
esac
51+
52+
# Clean up only the artifacts for this mode
53+
rm -f "$BIN_NAME" "$ELF_NAME" "$TEXT_NAME"
54+
55+
# Build
56+
cargo build --features "$FEATURES" --release
57+
58+
# Produce and rename outputs
59+
cargo objcopy --features "$FEATURES" --release -- -O binary "$BIN_NAME"
60+
cargo objcopy --features "$FEATURES" --release -- -R .text "$ELF_NAME"
61+
cargo objcopy --features "$FEATURES" --release -- -O binary --only-section=.text "$TEXT_NAME"
62+
63+
# Summary
64+
echo "Built [$TYPE] with features: $FEATURES"
65+
echo "$BIN_NAME"
66+
echo "$ELF_NAME"
67+
echo "$TEXT_NAME"

zksync_os/upd_local_era.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Default: do recompile/dump
5+
RECOMPILE=true
6+
7+
# Parse flags
8+
while [ "$#" -gt 0 ]; do
9+
case "$1" in
10+
--no-recompile)
11+
RECOMPILE=false
12+
shift
13+
;;
14+
*)
15+
echo "Unknown argument: $1"
16+
echo "Usage: $0 [--no-recompile]"
17+
exit 1
18+
;;
19+
esac
20+
done
21+
22+
TARGET_DIR="../../zksync-era"
23+
24+
# 1. Optionally regenerate the server binaries
25+
if [ "$RECOMPILE" = "true" ]; then
26+
echo "Regenerating server binaries…"
27+
28+
echo " → ./dump_bin.sh --type server"
29+
./dump_bin.sh --type server
30+
31+
echo " → ./dump_bin.sh --type server-logging-enabled"
32+
./dump_bin.sh --type server-logging-enabled
33+
fi
34+
35+
# 2. Verify target directory exists
36+
if [ ! -d "$TARGET_DIR" ]; then
37+
echo "Error: target directory '$TARGET_DIR' does not exist."
38+
exit 1
39+
fi
40+
41+
# 3. Copy server_app.bin → app.bin
42+
if [ ! -f server_app.bin ]; then
43+
echo "Error: source file 'server_app.bin' not found."
44+
exit 1
45+
fi
46+
cp -f server_app.bin "$TARGET_DIR/app.bin"
47+
echo "Copied server_app.bin → $TARGET_DIR/app.bin"
48+
49+
# 4. Copy server_app_logging_enabled.bin → app_logging_enabled.bin
50+
if [ ! -f server_app_logging_enabled.bin ]; then
51+
echo "Error: source file 'server_app_logging_enabled.bin' not found."
52+
exit 1
53+
fi
54+
cp -f server_app_logging_enabled.bin "$TARGET_DIR/app_logging_enabled.bin"
55+
echo "Copied server_app_logging_enabled.bin → $TARGET_DIR/app_logging_enabled.bin"
56+
57+
# 5. Done
58+
echo "All specified binaries have been replaced in '$TARGET_DIR'."

0 commit comments

Comments
 (0)