Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c28d680
Bump stwo-cairo dependency
m-kus Oct 3, 2025
108967f
Fix ts compilation issues
maciejka Oct 6, 2025
6e5daef
Format
maciejka Oct 6, 2025
1f5a0a6
backend: remove file sink (#375)
m-kus Oct 6, 2025
797d76b
Single writer/multiple reader MMR store (#376)
m-kus Oct 6, 2025
877271c
Expose endpoint to fetch multiple block headers (#377)
m-kus Oct 6, 2025
208850f
Thread safe MMR (#379)
m-kus Oct 6, 2025
27946f6
Bump stwo-cairo
m-kus Oct 8, 2025
24acc65
Assumevalid args serialization draft
maciejka Oct 7, 2025
3ebc458
Break into several files, add tests
maciejka Oct 7, 2025
ba97b74
Use cairo-serialize instead of serde
maciejka Oct 9, 2025
b0b1530
Drive proving with rust, WIP
maciejka Oct 9, 2025
934af25
Cleanup generate_args, still missing some deps
maciejka Oct 10, 2025
d3861d3
Use deserialize_proof_from_file
maciejka Oct 10, 2025
9177a7b
Update stwo-cairo dep
maciejka Oct 12, 2025
2b871ce
Add serialization of U256StringLittleEndian and other fixes
maciejka Oct 14, 2025
8ffa3e0
Run proving in ephemeral spot instance
maciejka Oct 14, 2025
49f2b8c
Add stable log labels
maciejka Oct 14, 2025
9165e95
Fix startup process
maciejka Oct 15, 2025
f655156
WIP
maciejka Oct 15, 2025
ba792a3
Use stwo_run_and_prove
maciejka Oct 17, 2025
bd3a630
Fixes
maciejka Oct 17, 2025
4727f1a
Add loading/saving proofs from/to gcs
maciejka Oct 20, 2025
994fc19
Update dependencies
maciejka Oct 21, 2025
9ddadde
Fmt
maciejka Oct 21, 2025
84bfe4c
Save only last proof
maciejka Oct 21, 2025
ceba3a0
Get max memory
maciejka Oct 21, 2025
7ef9887
Limit usage on info log level
maciejka Oct 21, 2025
480f0a8
Simplify gcs.rs
maciejka Oct 22, 2025
3e7c803
Params handling cleanup
maciejka Oct 22, 2025
844c71f
Run proving in ephemeral spot instance
maciejka Oct 14, 2025
f27822b
Add stable log labels
maciejka Oct 14, 2025
67fc275
Fix startup process
maciejka Oct 15, 2025
36ca067
Add bootloader-hints to the image
maciejka Oct 23, 2025
97bc802
Merge branch '10-14-run_proving_in_ephemeral_spot_instance' of github…
maciejka Oct 23, 2025
9bb8a8a
Merge branch '10-14-run_proving_in_ephemeral_spot_instance' of github…
maciejka Oct 23, 2025
bd69c95
Use Docker Buildkit
maciejka Oct 23, 2025
660ab3a
Add .dockerignore
maciejka Oct 23, 2025
109755f
Image works
maciejka Oct 23, 2025
0e842a5
Simplify proving scripts
maciejka Oct 23, 2025
0703968
Delete instances on termination
maciejka Oct 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
target/
!target/proving/
!target/proving/assumevalid-syscalls.executable.json
.proofs
**/*.rlib
**/*.rmeta

.git
.gitignore

**/.vscode

**/node_modules
**/dist
**/build

*.log
tmp/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ client.errors.log
cairo_project.toml
*.bin
*.bz2
*.gz
*.gz
scripts/prove/.last_instance
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
scarb 2.12.0
scarb 2.12.2
scarb
14 changes: 11 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
resolver = "2"
members = ["crates/*"]

[patch."https://github.com/m-kus/cairo-vm"]
cairo-vm = { git = "https://github.com/maciejka/cairo-vm", rev = "19d8a07ce9799a8af9db6f8a14a8accaad900214" }

[workspace.dependencies]
# Accumulators
accumulators = { version = "0.5.1", features = ["blake", "memory", "mmr"]}
Expand Down Expand Up @@ -37,6 +34,8 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
hex = "0.4"
bincode = "1.3"
starknet-ff = "0.3.7"
bytes = "1.0"

# BigInt
num-bigint = { version = "0.4", features = ["serde"] }
Expand All @@ -54,3 +53,12 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
mockall = "0.12"
wiremock = "0.5"
tempfile = "3.10"

# Stwo-cairo
stwo = { git = "https://github.com/starkware-libs/stwo", rev = "d9176e6e22319370a8501f799829b920c0db2eac", default-features = false }
cairo-air = { git = "https://github.com/maciejka/stwo-cairo", rev = "d2793e9f19f575c13f6bc37c36f9b229797456e1", default-features = false }
stwo-cairo-serialize = { git = "https://github.com/maciejka/stwo-cairo", rev = "d2793e9f19f575c13f6bc37c36f9b229797456e1" }
stwo-prover = { git = "https://github.com/starkware-libs/stwo", rev = "d9176e6e22319370a8501f799829b920c0db2eac", features = [], default-features = false }
stwo_cairo_prover = { git = "https://github.com/maciejka/stwo-cairo", rev = "d2793e9f19f575c13f6bc37c36f9b229797456e1" }
stwo_cairo_utils = { git = "https://github.com/maciejka/stwo-cairo", rev = "d2793e9f19f575c13f6bc37c36f9b229797456e1" }

45 changes: 34 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Git revisions for external dependencies
BOOTLOADER_HINTS_REV ?= 5648cf0a5a2574c2870151cd178ff3ae4b141824
STWO_REV ?= e5981958234c4b28fa2b4c3368a0290ec3fc57c2
CAIRO_EXECUTE_REV ?= 7fbbd0112b5a926403c17fa95ad831c1715fd1b1
BOOTLOADER_HINTS_REV ?= cec3b568447a2ebc7f1cdee8c1001b5af11ba34b
STWO_REV ?= d2793e9f19f575c13f6bc37c36f9b229797456e1
CAIRO_EXECUTE_REV ?= e209f4557c535ddb4d2c76b2c6b14d004af99467
################################## CLIENT ##################################

client-build:
Expand All @@ -16,7 +16,7 @@ install-bootloader-hints:
cargo install \
--git ssh://git@github.com/starkware-libs/bootloader-hints.git \
--rev $(BOOTLOADER_HINTS_REV) \
cairo-program-runner
cairo-program-runner stwo_run_and_prove

install-stwo:
RUSTFLAGS="-C target-cpu=native -C opt-level=3" \
Expand All @@ -31,7 +31,8 @@ install-cairo-execute:

install-scarb-eject:
cargo install --git \
https://github.com/software-mansion-labs/scarb-eject
https://github.com/m-kus/scarb-eject \
--rev 9c9b35870ac35af46e62b725219a8ac925281fe5

install-convert-proof-format:
RUSTFLAGS="-C target-cpu=native -C opt-level=3" \
Expand All @@ -42,36 +43,44 @@ install-convert-proof-format:
install-corelib:
mkdir -p vendor
rm -rf vendor/cairo
git clone --single-branch --branch m-kus/system-builtin \
git clone --single-branch --branch raito \
https://github.com/m-kus/cairo vendor/cairo
(cd vendor/cairo && git checkout $(CAIRO_EXECUTE_REV))

(cd vendor/cairo && git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" && git fetch origin --prune && git checkout $(CAIRO_EXECUTE_REV))
ln -s "$(CURDIR)/vendor/cairo/corelib" \
packages/assumevalid/corelib

install: install-bootloader-hints install-stwo install-cairo-execute \
install-convert-proof-format install-scarb-eject install-corelib
install: install-bootloader-hints install-cairo-execute \
install-scarb-eject install-corelib

################################## ASSUMEVALID ##################################

assumevalid-build:
scarb --profile proving build --package assumevalid \
--no-default-features


assumevalid-eject:
scarb-eject --package assumevalid \
--output packages/assumevalid/cairo_project.toml

assumevalid-build-with-syscalls:
mkdir -p target/proving
cd packages/assumevalid && \
cairo-execute \
--build-only \
--output-path \
../../target/proving/assumevalid.executable.json \
../../target/proving/assumevalid-syscalls.executable.json \
--executable assumevalid::main \
--ignore-warnings \
--allow-syscalls .

assumevalid-execute:
@[ -n "$(ARGS_FILE)" ] || (echo "ERROR: ARGS_FILE is required. Usage: make assumevalid-execute ARGS_FILE=path/to/args.json" >&2; exit 1)
scarb --profile proving execute \
--no-build \
--package assumevalid \
--arguments-file $(ARGS_FILE) \
--print-resource-usage

################################## PIPELINE ##################################

Expand Down Expand Up @@ -125,6 +134,20 @@ prove-pow:
$(if $(SLOW),--slow) \
$(if $(VERBOSE),--verbose)

# Run the raito-assumevalid CLI Prove subcommand
assumevalid-prove:
cargo run -p raito-assumevalid -- \
$(if $(LOG_LEVEL),--log-level $(LOG_LEVEL)) \
$(if $(BRIDGE_URL),--bridge-url $(BRIDGE_URL)) \
prove \
$(if $(KEEP_TEMP_FILES),--keep-temp-files) \
$(if $(OUTPUT_DIR),--output-dir $(OUTPUT_DIR)) \
$(if $(TOTAL_BLOCKS),--total-blocks $(TOTAL_BLOCKS)) \
$(if $(STEP_SIZE),--step-size $(STEP_SIZE)) \
$(if $(LOAD_FROM_GCS),--load-from-gcs) \
$(if $(SAVE_TO_GCS),--save-to-gcs) \
$(if $(GCS_BUCKET),--gcs-bucket $(GCS_BUCKET))

build-recent-proof:
@echo ">>> Building recent proof..."
. .venv/bin/activate && cd scripts/data && \
Expand Down
16 changes: 12 additions & 4 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
[[package]]
name = "bounded_int"
version = "0.1.0"
source = "git+https://github.com/starkware-libs/stwo-cairo?rev=bbe3e469bc636b89c37cb385854447bd46277b3b#bbe3e469bc636b89c37cb385854447bd46277b3b"
source = "git+https://github.com/maciejka/stwo-cairo?rev=d2793e9f19f575c13f6bc37c36f9b229797456e1#d2793e9f19f575c13f6bc37c36f9b229797456e1"

[[package]]
name = "client"
Expand Down Expand Up @@ -59,28 +59,36 @@ source = "git+https://github.com/keep-starknet-strange/shinigami.git?rev=1963116
[[package]]
name = "stwo_cairo_air"
version = "0.1.0"
source = "git+https://github.com/starkware-libs/stwo-cairo?rev=bbe3e469bc636b89c37cb385854447bd46277b3b#bbe3e469bc636b89c37cb385854447bd46277b3b"
source = "git+https://github.com/maciejka/stwo-cairo?rev=d2793e9f19f575c13f6bc37c36f9b229797456e1#d2793e9f19f575c13f6bc37c36f9b229797456e1"
dependencies = [
"bounded_int",
"stwo_constraint_framework",
"stwo_verifier_core",
"stwo_verifier_utils",
]

[[package]]
name = "stwo_constraint_framework"
version = "0.1.0"
source = "git+https://github.com/starkware-libs/stwo-cairo?rev=bbe3e469bc636b89c37cb385854447bd46277b3b#bbe3e469bc636b89c37cb385854447bd46277b3b"
source = "git+https://github.com/maciejka/stwo-cairo?rev=d2793e9f19f575c13f6bc37c36f9b229797456e1#d2793e9f19f575c13f6bc37c36f9b229797456e1"
dependencies = [
"stwo_verifier_core",
]

[[package]]
name = "stwo_verifier_core"
version = "0.1.0"
source = "git+https://github.com/starkware-libs/stwo-cairo?rev=bbe3e469bc636b89c37cb385854447bd46277b3b#bbe3e469bc636b89c37cb385854447bd46277b3b"
source = "git+https://github.com/maciejka/stwo-cairo?rev=d2793e9f19f575c13f6bc37c36f9b229797456e1#d2793e9f19f575c13f6bc37c36f9b229797456e1"
dependencies = [
"bounded_int",
"stwo_verifier_utils",
]

[[package]]
name = "stwo_verifier_utils"
version = "0.1.0"
source = "git+https://github.com/maciejka/stwo-cairo?rev=d2793e9f19f575c13f6bc37c36f9b229797456e1#d2793e9f19f575c13f6bc37c36f9b229797456e1"

[[package]]
name = "utils"
version = "0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ members = ["packages/*"]

[workspace.package]
description = "Bitcoin ZK client."
cairo-version = "2.12.0"
cairo-version = "2.12.2"
version = "0.1.0"
readme = "README.md"
repository = "https://github.com/keep-starknet-strange/raito"
license-file = "LICENSE"

[workspace.dependencies]
cairo_test = "2.12.0"
cairo_test = "2.12.2"
shinigami_engine = { git = "https://github.com/keep-starknet-strange/shinigami.git", rev = "1963116" }

[profile.proving]
Expand All @@ -21,7 +21,7 @@ enable-gas = false
sierra-replace-ids = true
# NOTE: this flag set causes build errors in Cairo 2.12.0 (because of use of print right before a panic).
# Use only for assumevalid package.
unsafe-panic = true
# unsafe-panic = true

[profile.release.cairo]
enable-gas = false
48 changes: 48 additions & 0 deletions crates/raito-assumevalid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[package]
name = "raito-assumevalid"
version = "0.1.0"
edition = "2021"

[lib]
name = "raito_assumevalid"
path = "src/lib.rs"

[[bin]]
name = "raito-assumevalid"
path = "src/main.rs"

[dependencies]
anyhow = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
tokio = { workspace = true }
reqwest = { workspace = true }
clap = { workspace = true }
hex = { workspace = true }
tracing-subscriber = { workspace = true }
bytes = { workspace = true }
regex = "1.0"
starknet-ff = { workspace = true }
num-bigint = { workspace = true }
chrono = { version = "0.4", features = ["clock"] }

# Raito dependencies
raito-cairo-serialize = { path = "../raito-cairo-serialize"}
stwo-cairo-serialize = { workspace = true }
raito-spv-verify = { path = "../raito-spv-verify" }
raito-spv-mmr = { path = "../raito-spv-mmr" }

# Bitcoin
bitcoin = { workspace = true }

cairo-air = { workspace = true }
stwo = { workspace = true}
stwo_cairo_prover = { workspace = true }
stwo_cairo_utils = { workspace = true }

# Compression
flate2 = "1.0"
percent-encoding = "2"
google-cloud-storage = "1.1.0"
gcp_auth = "0.11"
Loading
Loading