Skip to content

Commit 5a64e65

Browse files
authored
Merge pull request #242 from HerodotusDev/docs_codebase_refactor
Docs codebase refactor
2 parents 35df812 + e901409 commit 5a64e65

File tree

330 files changed

+6255
-3287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

330 files changed

+6255
-3287
lines changed

.github/workflows/build-cli.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: Checkout Code
36-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3737
with:
3838
submodules: true
3939

@@ -92,7 +92,7 @@ jobs:
9292

9393
steps:
9494
- name: Checkout Code
95-
uses: actions/checkout@v3
95+
uses: actions/checkout@v4
9696
with:
9797
submodules: true
9898

@@ -103,9 +103,11 @@ jobs:
103103

104104
- name: Set up Rust
105105
uses: actions-rust-lang/setup-rust-toolchain@v1
106+
with:
107+
toolchain: nightly-2025-04-06
106108

107109
- name: Cargo Cache
108-
uses: actions/cache@v3
110+
uses: actions/cache@v4
109111
with:
110112
path: |
111113
~/.cargo/bin/
@@ -146,7 +148,7 @@ jobs:
146148
runs-on: ubuntu-latest
147149
steps:
148150
- name: Checkout Code
149-
uses: actions/checkout@v3
151+
uses: actions/checkout@v4
150152
with:
151153
submodules: true
152154

@@ -157,9 +159,11 @@ jobs:
157159

158160
- name: Set up Rust
159161
uses: actions-rust-lang/setup-rust-toolchain@v1
162+
with:
163+
toolchain: nightly-2025-04-06
160164

161165
- name: Cargo Cache
162-
uses: actions/cache@v3
166+
uses: actions/cache@v4
163167
with:
164168
path: |
165169
~/.cargo/bin

.github/workflows/mdbook.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout Code
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323
with:
2424
submodules: true
2525

@@ -30,9 +30,11 @@ jobs:
3030

3131
- name: Set up Rust
3232
uses: actions-rust-lang/setup-rust-toolchain@v1
33+
with:
34+
toolchain: nightly-2025-04-06
3335

3436
- name: Cargo Cache
35-
uses: actions/cache@v3
37+
uses: actions/cache@v4
3638
with:
3739
path: |
3840
~/.cargo/bin

.github/workflows/rust-vm.yaml

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
name: rust-vm-CI
22

33
on:
4+
workflow_dispatch:
5+
pull_request:
46
push:
57
branches:
68
- "**"
79

10+
env:
11+
RUST_BACKTRACE: 1
12+
CARGO_TERM_COLOR: always
13+
14+
concurrency:
15+
group: "${{ github.workflow }}-${{ github.ref }}"
16+
cancel-in-progress: true
17+
818
jobs:
919
check:
1020
name: Format and Lint
@@ -16,7 +26,7 @@ jobs:
1626

1727
steps:
1828
- name: Checkout Code
19-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
2030
with:
2131
submodules: true
2232

@@ -27,6 +37,8 @@ jobs:
2737

2838
- name: Set up Rust
2939
uses: actions-rust-lang/setup-rust-toolchain@v1
40+
with:
41+
toolchain: nightly-2025-04-06
3042

3143
- name: Cargo cache
3244
uses: actions/cache@v4
@@ -57,10 +69,13 @@ jobs:
5769
run: .venv/bin/cairo-format -c src/*.cairo
5870

5971
- name: Run clippy check
60-
run: cargo clippy
72+
run: cargo clippy --workspace --all-targets -- -D warnings
73+
74+
- name: Future incompatibility report
75+
run: cargo report future-incompatibilities
6176

6277
test:
63-
name: Run Tests
78+
name: Run Tests (stable / offline)
6479
strategy:
6580
fail-fast: false
6681
matrix:
@@ -69,7 +84,7 @@ jobs:
6984

7085
steps:
7186
- name: Checkout Code
72-
uses: actions/checkout@v3
87+
uses: actions/checkout@v4
7388
with:
7489
submodules: true
7590

@@ -80,10 +95,65 @@ jobs:
8095

8196
- name: Set up Rust
8297
uses: actions-rust-lang/setup-rust-toolchain@v1
98+
with:
99+
toolchain: nightly-2025-04-06
100+
101+
- name: Set up Scarb
102+
uses: software-mansion/setup-scarb@v1
103+
104+
- name: Cargo cache
105+
uses: actions/cache@v4
106+
with:
107+
path: |
108+
~/.cargo/bin/
109+
~/.cargo/registry/index/
110+
~/.cargo/registry/cache/
111+
~/.cargo/git/db/
112+
target/
113+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
114+
115+
- name: Set up Cairo (Linux)
116+
if: runner.os == 'Linux'
117+
run: uv sync
118+
119+
- name: Set up Cairo (macOS)
120+
if: runner.os == 'macOS'
121+
run: CFLAGS=-I/opt/homebrew/opt/gmp/include LDFLAGS=-L/opt/homebrew/opt/gmp/lib uv sync
122+
123+
- name: Build Test Contracts
124+
run: scarb build
125+
126+
- name: Run cargo tests (stable)
127+
run: cargo test --workspace --all-targets
128+
129+
integration:
130+
name: Run Integration Tests (optional / requires secrets)
131+
if: ${{ secrets.RPC_URL_HERODOTUS_INDEXER != '' }}
132+
strategy:
133+
fail-fast: false
134+
matrix:
135+
os: [ubuntu-latest, macos-latest]
136+
runs-on: ${{ matrix.os }}
137+
138+
steps:
139+
- name: Checkout Code
140+
uses: actions/checkout@v4
141+
with:
142+
submodules: true
143+
144+
- name: Install uv
145+
uses: astral-sh/setup-uv@v6
146+
with:
147+
enable-cache: true
148+
149+
- name: Set up Rust
150+
uses: actions-rust-lang/setup-rust-toolchain@v1
151+
with:
152+
toolchain: nightly-2025-04-06
83153

84154
- name: Install Nextest
85155
uses: taiki-e/install-action@nextest
86-
156+
87157
- name: Set up Scarb
88158
uses: software-mansion/setup-scarb@v1
89159

@@ -109,13 +179,14 @@ jobs:
109179
- name: Build Test Contracts
110180
run: scarb build
111181

112-
- name: Run Nextest Tests
182+
- name: Run Nextest Tests (integration)
113183
env:
184+
HDP_INTEGRATION_TESTS: "1"
114185
RPC_URL_ETHEREUM_MAINNET: ${{ secrets.RPC_URL_ETHEREUM_MAINNET }}
115186
RPC_URL_ETHEREUM_TESTNET: ${{ secrets.RPC_URL_ETHEREUM_TESTNET }}
116187
RPC_URL_HERODOTUS_INDEXER: ${{ secrets.RPC_URL_HERODOTUS_INDEXER }}
117188
RPC_URL_STARKNET_MAINNET: ${{ secrets.RPC_URL_STARKNET_MAINNET }}
118189
RPC_URL_STARKNET_TESTNET: ${{ secrets.RPC_URL_STARKNET_TESTNET }}
119190
RPC_URL_OPTIMISM_MAINNET: ${{ secrets.RPC_URL_OPTIMISM_MAINNET }}
120-
RPC_URL_OPTIMISM_SEPOLIA: ${{ secrets.RPC_URL_OPTIMISM_SEPOLIA }}
191+
RPC_URL_OPTIMISM_TESTNET: ${{ secrets.RPC_URL_OPTIMISM_TESTNET }}
121192
run: cargo nextest run --profile ci

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ dist/
3333
# --- IDEs ---
3434
.idea/
3535
.vscode/
36+
.cursor/
3637

3738
# --- Whitelist ---
3839
# Keep specific files that would otherwise be ignored
3940
!example.env
4041
!packages/cairo-lang-0.13.3.zip
4142
!examples/**/*.json
42-
!crates/server/tests/*.json
43+
!crates/state_server/tests/*.json
4344

4445
# State server db folder
4546
crates/state_server/db

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ alloy = { version = "1.0", features = ["full"] }
2222
alloy-rlp = { version = "0.3", features = ["derive"] }
2323
alloy-trie = { version = "0.9", features = ["ethereum", "serde"] }
2424
anyhow = "1.0.100"
25-
api = { path = "src/crates/api" }
2625
axum = { version = "0.8", features = ["tracing"] }
2726
bincode = "2.0.1"
2827
bitvec = "1.0.1"
2928
bytemuck = { version = "1.20", features = ["derive"] }
30-
cairo_runner = { path = "src/crates/cairo-runner" }
3129
cairo_type_derive = { path = "crates/cairo_type_derive" }
3230
cairo-lang-casm = "2.12.3"
3331
cairo-lang-starknet-classes = "2.12.3"
@@ -88,3 +86,16 @@ utoipa = { version = "5.3.1", features = ["axum_extras"] }
8886
utoipa-swagger-ui = { version = "9", features = ["axum"] }
8987
uuid = { version = "1.18.1", features = ["v4"] }
9088
version-compare = "0.2.0"
89+
90+
[workspace.lints.rust]
91+
unsafe_code = "forbid"
92+
93+
[workspace.lints.clippy]
94+
unwrap_used = "warn"
95+
expect_used = "warn"
96+
panic = "warn"
97+
redundant_closure_for_method_calls = "warn"
98+
cloned_instead_of_copied = "warn"
99+
too_many_arguments = "warn"
100+
type_complexity = "warn"
101+
large_enum_variant = "warn"

Dockerfile

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,76 @@
1-
FROM rust:1.89.0
1+
# syntax=docker/dockerfile:1.7
2+
FROM rust:1.89.0 AS builder
3+
4+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
25

36
# Install uv, the Python package manager.
47
COPY --from=ghcr.io/astral-sh/uv:0.8.13 /uv /uvx /bin/
58

69
# Set the working directory for all subsequent commands.
710
WORKDIR /hdp-cairo
811

12+
# Install the pinned nightly toolchain.
13+
ARG RUST_TOOLCHAIN=nightly-2025-04-06
14+
RUN rustup toolchain install "${RUST_TOOLCHAIN}" && rustup default "${RUST_TOOLCHAIN}"
15+
916
# Copy dependency files FIRST to leverage Docker's layer caching.
1017
# If these files don't change, Docker won't re-run the `uv sync` step.
18+
ENV PROJECT_ROOT=/hdp-cairo
1119
COPY pyproject.toml uv.lock ./
1220
COPY packages/cairo-lang-0.13.3.zip ./packages/cairo-lang-0.13.3.zip
1321

1422
# Synchronize and install project dependencies using uv.
15-
RUN uv sync
23+
RUN --mount=type=cache,target=/root/.cache/uv \
24+
uv sync --frozen
25+
26+
# Pre-fetch Rust dependencies using workspace sources.
27+
COPY Cargo.toml Cargo.lock ./
28+
COPY crates/ ./crates/
29+
COPY tests/ ./tests/
30+
COPY packages/eth_essentials/cairo_vm_hints/ ./packages/eth_essentials/cairo_vm_hints/
31+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
32+
--mount=type=cache,target=/usr/local/cargo/git \
33+
cargo fetch
1634

1735
# Copy the rest of the application source code into the container.
1836
COPY . .
1937

38+
# Precompile Cairo artifacts and set stable paths for the binary.
39+
ENV HDP_COMPILED_JSON=/opt/hdp/compiled.json
40+
ENV DRY_RUN_COMPILED_JSON=/opt/hdp/dry_run_compiled.json
41+
RUN mkdir -p /opt/hdp && \
42+
.venv/bin/cairo-compile --cairo_path=/hdp-cairo:/hdp-cairo/packages/eth_essentials /hdp-cairo/src/hdp.cairo \
43+
--output "$HDP_COMPILED_JSON" --proof_mode && \
44+
.venv/bin/cairo-compile --cairo_path=/hdp-cairo:/hdp-cairo/packages/eth_essentials \
45+
/hdp-cairo/src/contract_bootloader/contract_dry_run.cairo --output "$DRY_RUN_COMPILED_JSON"
46+
2047
# Install the specific Rust binary from the local crate.
2148
# We use the `--locked` flag to ensure the build uses the exact versions
2249
# specified in Cargo.lock, for reproducibility.
23-
RUN cargo install --path ./crates/cli --locked
50+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
51+
--mount=type=cache,target=/usr/local/cargo/git \
52+
cargo install --path ./crates/cli --locked
53+
54+
FROM debian:trixie-slim
55+
56+
RUN useradd --create-home --uid 10001 hdp && \
57+
apt-get update && \
58+
apt-get install -y --no-install-recommends ca-certificates && \
59+
rm -rf /var/lib/apt/lists/*
60+
61+
COPY --from=builder /usr/local/cargo/bin/hdp-cli /usr/local/bin/hdp-cli
62+
COPY --from=builder --chown=hdp:hdp /opt/hdp /opt/hdp
63+
64+
ENV HDP_COMPILED_JSON=/opt/hdp/compiled.json
65+
ENV DRY_RUN_COMPILED_JSON=/opt/hdp/dry_run_compiled.json
66+
67+
USER hdp
2468

2569
# Set the default executable for the container.
26-
ENTRYPOINT ["/hdp-cairo/target/release/hdp-cli"]
70+
ENTRYPOINT ["hdp-cli"]
2771

2872
# Set the default command when the container is run without any arguments.
2973
# This provides a default action for the entrypoint.
30-
CMD ["program-hash"]
74+
CMD ["program-hash"]
75+
76+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD ["hdp-cli", "--version"]

0 commit comments

Comments
 (0)