Skip to content

Commit ea99baf

Browse files
authored
Merge branch 'merge-train/fairies' into nico/f-260-warn-on-packable-with-small-types
2 parents f77eacb + 43b7f8d commit ea99baf

234 files changed

Lines changed: 3381 additions & 1992 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Network Healthcheck
2+
3+
on:
4+
schedule:
5+
- cron: '0 8 * * *'
6+
workflow_dispatch:
7+
inputs:
8+
networks:
9+
description: 'Comma-separated list of networks to check (default: all)'
10+
required: false
11+
type: string
12+
default: 'v4-devnet-2,testnet,mainnet,staging-public,next-net'
13+
14+
jobs:
15+
healthcheck:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Run healthcheck
22+
env:
23+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
24+
GH_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
25+
run: ./ci3/network_healthcheck "${{ inputs.networks || 'v4-devnet-2,testnet,mainnet,staging-public,next-net' }}"

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ avm-transpiler-cross-arm64-macos:
8686
avm-transpiler-cross-arm64-linux:
8787
$(call build,$@,avm-transpiler,build_cross arm64-linux)
8888

89-
avm-transpiler-cross: avm-transpiler-cross-amd64-macos avm-transpiler-cross-arm64-macos avm-transpiler-cross-arm64-linux
89+
avm-transpiler-cross-amd64-windows:
90+
$(call build,$@,avm-transpiler,build_cross amd64-windows)
91+
92+
avm-transpiler-cross: avm-transpiler-cross-amd64-macos avm-transpiler-cross-arm64-macos avm-transpiler-cross-arm64-linux avm-transpiler-cross-amd64-windows
9093

9194
#==============================================================================
9295
# Barretenberg
@@ -148,7 +151,14 @@ bb-cpp-cross-amd64-macos: bb-cpp-cross-amd64-macos-objects avm-transpiler-cross-
148151
bb-cpp-cross-arm64-macos: bb-cpp-cross-arm64-macos-objects avm-transpiler-cross-arm64-macos
149152
$(call build,$@,barretenberg/cpp,build_cross arm64-macos)
150153

151-
bb-cpp-cross: bb-cpp-cross-arm64-linux bb-cpp-cross-amd64-macos bb-cpp-cross-arm64-macos bb-cpp-cross-arm64-ios bb-cpp-cross-arm64-ios-sim bb-cpp-cross-arm64-android bb-cpp-cross-x86_64-android
154+
bb-cpp-cross-amd64-windows-objects:
155+
$(call build,$@,barretenberg/cpp,build_cross_objects amd64-windows)
156+
157+
# Cross-compile for AMD64 Windows (release only)
158+
bb-cpp-cross-amd64-windows: bb-cpp-cross-amd64-windows-objects avm-transpiler-cross-amd64-windows
159+
$(call build,$@,barretenberg/cpp,build_cross_windows amd64-windows)
160+
161+
bb-cpp-cross: bb-cpp-cross-arm64-linux bb-cpp-cross-amd64-macos bb-cpp-cross-arm64-macos bb-cpp-cross-amd64-windows bb-cpp-cross-arm64-ios bb-cpp-cross-arm64-ios-sim bb-cpp-cross-arm64-android bb-cpp-cross-x86_64-android
152162

153163
# iOS SDK download (shared by all iOS cross-compile targets)
154164
bb-cpp-ios-sdk:

avm-transpiler/bootstrap.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ function build_cross {
4848
arm64-macos)
4949
rust_target=aarch64-apple-darwin
5050
;;
51+
amd64-windows)
52+
rust_target=x86_64-pc-windows-gnu
53+
;;
5154
*)
5255
echo_stderr "Unknown target: $target"
5356
exit 1

barretenberg/cpp/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "wasm32")
108108
endif()
109109
endif()
110110

111+
if(WIN32)
112+
message(STATUS "Cross-compiling for Windows (MinGW)")
113+
link_libraries(ws2_32 bcrypt psapi)
114+
endif()
115+
111116
set(CMAKE_C_STANDARD 11)
112117
set(CMAKE_C_EXTENSIONS ON)
113118
set(CMAKE_CXX_STANDARD 20)

barretenberg/cpp/CMakePresets.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,24 @@
538538
"HAVE_STD_REGEX": "ON"
539539
}
540540
},
541+
{
542+
"name": "zig-amd64-windows",
543+
"displayName": "Build for Windows amd64 with Zig",
544+
"description": "Cross-compile for Windows x86_64 using Zig (MinGW). Excludes ipc/lmdb/world_state/nodejs_module (no Windows support).",
545+
"inherits": "zig-base",
546+
"environment": {
547+
"CC": "zig cc -target x86_64-windows-gnu",
548+
"CXX": "zig c++ -target x86_64-windows-gnu",
549+
"LDFLAGS": "-s"
550+
},
551+
"cacheVariables": {
552+
"CMAKE_SYSTEM_NAME": "Windows",
553+
"CMAKE_SYSTEM_PROCESSOR": "x86_64",
554+
"TARGET_ARCH": "skylake",
555+
"MOBILE": "ON",
556+
"AVM_TRANSPILER_LIB": "${sourceDir}/../../avm-transpiler/target/x86_64-pc-windows-gnu/release/libavm_transpiler.a"
557+
}
558+
},
541559
{
542560
"name": "zig-arm64-ios",
543561
"displayName": "iOS arm64 static library (Zig)",
@@ -789,6 +807,11 @@
789807
"configurePreset": "zig-arm64-macos",
790808
"inheritConfigureEnvironment": true
791809
},
810+
{
811+
"name": "zig-amd64-windows",
812+
"configurePreset": "zig-amd64-windows",
813+
"inheritConfigureEnvironment": true
814+
},
792815
{
793816
"name": "zig-arm64-ios",
794817
"configurePreset": "zig-arm64-ios",

barretenberg/cpp/bootstrap.sh

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ function build_cross_objects {
9595
set -eu
9696
target=$1
9797
if ! cache_exists barretenberg-$target-$hash.zst; then
98-
(flock -x 200 && cd src/barretenberg/nodejs_module && yarn --immutable) 200>/tmp/bb-yarn.lock
99-
build_preset zig-$target --target barretenberg nodejs_module vm2_stub circuit_checker honk
98+
if [[ "$target" == *-windows ]]; then
99+
# Windows builds exclude nodejs_module (N-API requires MSVC, not MinGW)
100+
AVM_TRANSPILER=0 build_preset zig-$target --target barretenberg vm2_stub circuit_checker honk
101+
else
102+
(flock -x 200 && cd src/barretenberg/nodejs_module && yarn --immutable) 200>/tmp/bb-yarn.lock
103+
build_preset zig-$target --target barretenberg nodejs_module vm2_stub circuit_checker honk
104+
fi
100105
fi
101106
}
102107

@@ -114,6 +119,19 @@ function build_cross {
114119
inject_version build-zig-$target/bin/bb
115120
}
116121

122+
# Cross compile Windows binary (bb.exe only, no nodejs_module).
123+
# Arg is target arch-os e.g. amd64-windows.
124+
function build_cross_windows {
125+
set -eu
126+
target=$1
127+
if ! cache_download barretenberg-$target-$hash.zst; then
128+
AVM_TRANSPILER=0 build_preset zig-$target --target bb --target bb-external
129+
cache_upload barretenberg-$target-$hash.zst build-zig-$target/{bin,lib}
130+
fi
131+
# Always inject version (even for cached binaries) to ensure correct version on release
132+
inject_version build-zig-$target/bin/bb.exe
133+
}
134+
117135
# Build static library (.a) for iOS using Zig cross-compilation from Linux.
118136
# Only produces static libraries (bb-external) — Zig cannot link iOS executables
119137
# due to lack of TBD/dylib support. Requires iOS SDK headers (downloaded automatically).
@@ -258,6 +276,11 @@ function build_release_dir {
258276
# Package amd64-macos
259277
tar -czf build-release/barretenberg-amd64-darwin.tar.gz -C build-zig-amd64-macos/bin bb
260278

279+
# Package amd64-windows
280+
if [ -f build-zig-amd64-windows/bin/bb.exe ]; then
281+
tar -czf build-release/barretenberg-amd64-windows.tar.gz -C build-zig-amd64-windows/bin bb.exe
282+
fi
283+
261284
# Package static libraries for FFI bindings
262285
if [ -f $native_build_dir/lib/libbb-external.a ]; then
263286
tar -czf build-release/barretenberg-static-amd64-linux.tar.gz -C $native_build_dir/lib libbb-external.a
@@ -271,6 +294,9 @@ function build_release_dir {
271294
if [ -f build-zig-arm64-macos/lib/libbb-external.a ]; then
272295
tar -czf build-release/barretenberg-static-arm64-darwin.tar.gz -C build-zig-arm64-macos/lib libbb-external.a
273296
fi
297+
if [ -f build-zig-amd64-windows/lib/libbb-external.a ]; then
298+
tar -czf build-release/barretenberg-static-amd64-windows.tar.gz -C build-zig-amd64-windows/lib libbb-external.a
299+
fi
274300

275301
# Package iOS static libraries (cross-compiled with Zig from Linux)
276302
if [ -f build-zig-arm64-ios/lib/libbb-external.a ]; then
@@ -289,7 +315,7 @@ function build_release_dir {
289315
fi
290316
}
291317

292-
export -f build_preset build_native_objects build_cross_objects build_native build_cross build_ios build_android build_asan_fast build_wasm build_wasm_threads build_gcc_syntax_check_only build_fuzzing_syntax_check_only build_smt_verification inject_version
318+
export -f build_preset build_native_objects build_cross_objects build_native build_cross build_cross_windows build_ios build_android build_asan_fast build_wasm build_wasm_threads build_gcc_syntax_check_only build_fuzzing_syntax_check_only build_smt_verification inject_version
293319

294320
function build {
295321
echo_header "bb cpp build"
@@ -311,6 +337,7 @@ function build {
311337
"build_cross arm64-linux" \
312338
"build_cross amd64-macos" \
313339
"build_cross arm64-macos" \
340+
"build_cross_windows amd64-windows" \
314341
"build_ios zig-arm64-ios" \
315342
"build_ios zig-arm64-ios-sim" \
316343
"build_android zig-arm64-android" \

barretenberg/cpp/pil/vm2/bitwise.pil

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,16 @@ start_sha256 * (1 - start_sha256) = 0;
142142
// Crucial constraint to prevent the vulnerability described in PR #19875 consisting
143143
// of maliciously setting start_keccak/start_sha256=1 on error rows (sel=1, err=1)
144144
// and forging arbitrary bitwise operation results.
145-
// keccak and sh256 only enforce that tag_a = U64/U32 respectively. An attacker is free to
145+
// keccak and sha256 only enforce that tag_a = U64/U32 respectively. An attacker is free to
146146
// set tag_b to any tag value and use the resulting tag mismatch error to return an invalid result
147-
// Since error rows have sel=1, we gate by err instead of (1 - sel).
148147
#[BITW_NO_EXTERNAL_START_ON_ERROR]
149148
(start_keccak + start_sha256) * err = 0;
150149

151150
// To support dynamically sized memory operands we use a counter against a lookup
152151
// This decrementing counter goes from [TAG_LEN, 0] where TAG_LEN is the number of bytes in the
153152
// corresponding integer. i.e. TAG_LEN is between 1 (U1/U8) and 16 (U128).
154153
// Consistency can be achieved with a lookup table between the tag and precomputed.tag_byte_length
155-
pol commit ctr; // when err=1, last=1 forces ctr in {0,1} via BITW_LAST_FOR_CTR_ONE; 0 is optimal
154+
pol commit ctr;
156155

157156
// The error flags for this subtrace
158157
pol commit sel_tag_ff_err; // @boolean
@@ -163,7 +162,7 @@ sel_tag_mismatch_err * (1 - sel_tag_mismatch_err) = 0;
163162
// Consolidated error flag
164163
pol commit err; // @boolean (by definition)
165164
err = 1 - (1 - sel_tag_mismatch_err) * (1 - sel_tag_ff_err);
166-
#[LAST_ON_ERROR] // end = 1 if err = 1
165+
#[END_ON_ERROR] // end = 1 if err = 1
167166
err * (end - 1) = 0;
168167

169168
// Error can only manifest on start rows (where tag checks are evaluated).

0 commit comments

Comments
 (0)