Skip to content

Commit

Permalink
refactor: reorganize folders (#540)
Browse files Browse the repository at this point in the history
* refactor: move compiler, riscv into toolchain

* refactor: create circuits folder

* refactor: create lib folder

* chore: update workflows

* fix: ecc workflow

* refactor: update vm folder structure

* fix: toolchain imports

* fix: toolchain imports

* chore: fix lint

* fix: update import
  • Loading branch information
yi-sun authored Oct 14, 2024
1 parent 8edcd1b commit 32b50d4
Show file tree
Hide file tree
Showing 539 changed files with 517 additions and 426 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/ecc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ on:
branches: ["main"]
paths:
- "stark-backend/**"
- "primitives/**"
- "circuits/primitives/**"
- "vm/**"
- "compiler/**"
- "ecc/**"
- "toolchain/compiler/**"
- "circuits/ecc/**"
- "lib/ecc/**"
- "lib/ecc-execution/**"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -33,6 +35,16 @@ jobs:
- uses: taiki-e/install-action@nextest

- name: Run ecc-lib crate tests
working-directory: ecc/lib
working-directory: lib/ecc
run: |
cargo nextest run --cargo-profile=fast --features parallel
- name: Run ecc-execution crate tests
working-directory: lib/ecc-execution
run: |
cargo nextest run --cargo-profile=fast
- name: Run ecc-circuits crate tests
working-directory: circuits/ecc
run: |
cargo nextest run --cargo-profile=fast --features parallel
8 changes: 4 additions & 4 deletions .github/workflows/primitives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches: ["main"]
paths:
- "stark-backend/**"
- "primitives/**"
- "poseidon2-air/**"
- "circuits/primitives/**"
- "circuits/hashes/poseidon2-air/**"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -31,11 +31,11 @@ jobs:
- uses: taiki-e/install-action@nextest

- name: Run tests for primitives
working-directory: primitives
working-directory: circuits/primitives
run: |
cargo nextest run --cargo-profile fast --features parallel
- name: Run tests for poseidon2-air
working-directory: poseidon2-air
working-directory: circuits/hashes/poseidon2-air
run: |
cargo nextest run --cargo-profile fast --features parallel
6 changes: 3 additions & 3 deletions .github/workflows/recursion-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ on:
branches: ["main"]
paths:
- "stark-backend/**"
- "primitives/**"
- "circuits/primitives/**"
- "vm/**"
- "compiler/**"
- "recursion/**"
- "toolchain/compiler/**"
- "lib/recursion/**"
- ".github/workflows/benchmark-call.yml"
label:
types: [created]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/recursion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ on:
branches: ["main"]
paths:
- "stark-backend/**"
- "primitives/**"
- "circuits/primitives/**"
- "vm/**"
- "compiler/**"
- "recursion/**"
- "toolchain/compiler/**"
- "lib/recursion/**"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -37,7 +37,7 @@ jobs:
version: v0.8.19

- name: Run recursion crate tests
working-directory: recursion
working-directory: lib/recursion
run: |
cargo nextest run --cargo-profile=fast --features parallel
cargo nextest run --cargo-profile=fast --features parallel,static-verifier -- halo2::tests
6 changes: 3 additions & 3 deletions .github/workflows/vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
branches: ["main"]
paths:
- "stark-backend/**"
- "primitives/**"
- "circuits/primitives/**"
- "vm/**"
- "compiler/**"
- "toolchain/compiler/**"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand Down Expand Up @@ -37,6 +37,6 @@ jobs:
cargo nextest run --cargo-profile=fast --features parallel
- name: Run compiler crate tests
working-directory: compiler
working-directory: toolchain/compiler
run: |
cargo nextest run --cargo-profile=fast --features parallel
34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
[workspace]
members = [
"primitives",
"compiler",
"derive",
"poseidon2-air",
"recursion",
"ecc/lib",
"ecc/execution",
"ecc/primitives",
"stark-backend",
"circuits/ecc",
"circuits/hashes/poseidon2-air",
"circuits/primitives",
"lib/ecc",
"lib/ecc-execution",
"lib/recursion",
"sdk",
"vm",
"riscv/zkvm/lib",
"riscv/zkvm/platform",
"riscv/transpiler",
"stark-backend",
"toolchain/compiler",
"toolchain/riscv/zkvm/lib",
"toolchain/riscv/zkvm/platform",
"toolchain/riscv/transpiler",
"vm"
]
resolver = "2"

Expand Down Expand Up @@ -58,15 +58,15 @@ incremental = true
lto = "thin"

[workspace.dependencies]
axvm-platform = { path = "riscv/zkvm/platform", default-features = false }
axvm = { path = "riscv/zkvm/lib", default-features = false }
afs-compiler = { path = "compiler", default-features = false }
axvm-platform = { path = "toolchain/riscv/zkvm/platform", default-features = false }
axvm = { path = "toolchain/riscv/zkvm/lib", default-features = false }
afs-compiler = { path = "toolchain/compiler", default-features = false }
stark-vm = { path = "vm", default-features = false }
afs-primitives = { path = "primitives", default-features = false }
afs-primitives = { path = "circuits/primitives", default-features = false }
afs-stark-backend = { path = "stark-backend", default-features = false }
afs-derive = { path = "derive", default-features = false }
ax-sdk = { path = "sdk", default-features = false }
afs-transpiler = { path = "riscv/transpiler", default-features = false }
afs-transpiler = { path = "toolchain/riscv/transpiler", default-features = false }

p3-air = { git = "https://github.com/Plonky3/Plonky3.git", rev = "95e56fa" }
p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "95e56fa" }
Expand Down
4 changes: 2 additions & 2 deletions ecc/primitives/Cargo.toml → circuits/ecc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Elliptic curve cryptography building blocks."

[dependencies]
afs-stark-backend = { path = "../../stark-backend" }
afs-primitives = { path = "../../primitives" }
afs-primitives = { path = "../primitives" }
ax-sdk = { path = "../../sdk" }
p3-air = { workspace = true }
p3-field = { workspace = true }
Expand Down Expand Up @@ -37,7 +37,7 @@ k256 = { workspace = true }
elliptic-curve = { workspace = true, features = ["std"] }

[dev-dependencies]
afs-primitives = { path = "../../primitives" }
afs-primitives = { path = "../primitives" }
hex-literal = { workspace = true }
sha3 = "0.10.8"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ p3-util = { workspace = true }
zkhash = { workspace = true }
rand = "0.8"

afs-primitives = { path = "../primitives" }
afs-stark-backend = { path = "../stark-backend", default-features = false }
afs-derive = { path = "../derive" }
ax-sdk = { path = "../sdk" }
afs-primitives = { path = "../../primitives" }
afs-stark-backend = { path = "../../../stark-backend", default-features = false }
afs-derive = { path = "../../../derive" }
ax-sdk = { path = "../../../sdk" }
lazy_static = "1.5.0"
itertools.workspace = true

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions primitives/Cargo.toml → circuits/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ p3-util = { workspace = true }
rand = "0.8"
derive-new = "0.6.0"

afs-stark-backend = { path = "../stark-backend", default-features = false }
afs-derive = { path = "../derive" }
afs-stark-backend = { path = "../../stark-backend", default-features = false }
afs-derive = { path = "../../derive" }
parking_lot = "0.12.2"
itertools.workspace = true
getset = "0.1.2"
Expand All @@ -41,7 +41,7 @@ p3-merkle-tree = { workspace = true }
p3-poseidon2 = { workspace = true }
p3-symmetric = { workspace = true }
test-case = "3.3.1"
ax-sdk = { path = "../sdk" }
ax-sdk = { path = "../../sdk" }

[features]
default = []
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions ecc/lib/Cargo.toml → lib/ecc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Elliptic curve cryptography library written in Axiom's eDSL."

[dependencies]
afs-stark-backend = { path = "../../stark-backend" }
afs-compiler = { path = "../../compiler" }
afs-compiler = { path = "../../toolchain/compiler" }
ax-sdk = { path = "../../sdk" }
stark-vm = { path = "../../vm" }
p3-air = { workspace = true }
Expand Down Expand Up @@ -38,7 +38,7 @@ k256 = { workspace = true }
elliptic-curve = { workspace = true, features = ["std"] }

[dev-dependencies]
afs-primitives = { path = "../../primitives" }
afs-primitives = { path = "../../circuits/primitives" }
hex-literal = { workspace = true }
sha3 = "0.10.8"
test-log.workspace = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ecc/lib/src/types.rs → lib/ecc/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use k256::{
};
use num_bigint_dig::BigUint;
use p3_field::{AbstractField, PrimeField64};
use stark_vm::modular_addsub::big_uint_to_num_limbs;
use stark_vm::intrinsics::modular_addsub::big_uint_to_num_limbs;
use zkhash::ark_ff::Zero;

/// EC point in Rust. **Unsafe** to assume (x, y) is a point on the curve.
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions recursion/Cargo.toml → lib/recursion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ version = "0.1.0"
edition = "2021"

[dependencies]
afs-stark-backend = { path = "../stark-backend" }
afs-compiler = { path = "../compiler", features = ["sdk"] }
ax-sdk = { path = "../sdk" } # TODO: feature-gate sdk
afs-derive = { path = "../derive" }
stark-vm = { path = "../vm", features = ["sdk"] }
ax-ecc-lib = { path = "../ecc/lib" }
afs-stark-backend = { path = "../../stark-backend" }
afs-compiler = { path = "../../toolchain/compiler", features = ["sdk"] }
ax-sdk = { path = "../../sdk" } # TODO: feature-gate sdk
afs-derive = { path = "../../derive" }
stark-vm = { path = "../../vm", features = ["sdk"] }
ax-ecc-lib = { path = "../ecc" }

p3-air = { workspace = true }
p3-field = { workspace = true }
Expand Down Expand Up @@ -44,7 +44,7 @@ metrics = { workspace = true, optional = true }
cfg-if = { workspace = true }

[dev-dependencies]
afs-primitives = { path = "../primitives" }
afs-primitives = { path = "../../circuits/primitives" }

[[bin]]
name = "verify_fibair"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ pub mod tests {
use p3_matrix::dense::RowMajorMatrix;
use p3_uni_stark::{StarkGenericConfig, Val};
use rand::rngs::OsRng;
use stark_vm::program::Program;
use stark_vm::system::program::Program;

use crate::{
challenger::{duplex::DuplexChallengerVariable, CanObserveDigest, FeltChallenger},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion recursion/src/hints.rs → lib/recursion/src/hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use p3_merkle_tree::FieldMerkleTreeMmcs;
use p3_poseidon2::{Poseidon2, Poseidon2ExternalMatrixGeneral};
use p3_symmetric::{PaddingFreeSponge, TruncatedPermutation};
use p3_util::log2_strict_usize;
use stark_vm::modular_addsub::big_uint_to_num_limbs;
use stark_vm::intrinsics::modular_addsub::big_uint_to_num_limbs;

use crate::{
types::{InnerConfig, VerifierInput},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use p3_baby_bear::BabyBear;
use p3_commit::LagrangeSelectors;
use p3_field::{AbstractExtensionField, AbstractField, TwoAdicField};
use p3_matrix::{dense::RowMajorMatrixView, stack::VerticalPair};
use stark_vm::program::Program;
use stark_vm::system::program::Program;

use crate::{
challenger::{duplex::DuplexChallengerVariable, ChallengerVariable},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use inner::build_verification_program;
use p3_baby_bear::BabyBear;
use p3_commit::PolynomialSpace;
use p3_uni_stark::{Domain, StarkGenericConfig, Val};
use stark_vm::{program::Program, vm::config::VmConfig};
use stark_vm::system::{program::Program, vm::config::VmConfig};

use crate::hints::InnerVal;

Expand All @@ -27,7 +27,7 @@ pub mod inner {
},
engine::{StarkFriEngine, VerificationDataWithFriParams},
};
use stark_vm::vm::config::VmConfig;
use stark_vm::system::vm::config::VmConfig;

use super::*;
use crate::{hints::Hintable, stark::VerifierProgram, types::new_from_inner_multi_vk};
Expand Down
2 changes: 1 addition & 1 deletion recursion/src/tests.rs → lib/recursion/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use ax_sdk::{
use p3_field::{AbstractField, PrimeField32};
use p3_matrix::{dense::RowMajorMatrix, Matrix};
use p3_uni_stark::{StarkGenericConfig, Val};
use stark_vm::{sdk::gen_vm_program_stark_for_test, vm::config::VmConfig};
use stark_vm::{sdk::gen_vm_program_stark_for_test, system::vm::config::VmConfig};

use crate::{
hints::Hintable, stark::VerifierProgram, testing_utils::inner::run_recursive_test,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use p3_baby_bear::BabyBear;
use p3_commit::PolynomialSpace;
use p3_field::{extension::BinomialExtensionField, AbstractField};
use p3_uni_stark::{Domain, StarkGenericConfig};
use stark_vm::{
use stark_vm::system::{
program::Program,
vm::{config::VmConfig, VirtualMachine},
};
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions compiler/Cargo.toml → toolchain/compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ edition = "2021"
p3-field = { workspace = true }
p3-baby-bear = { workspace = true }
p3-bn254-fr = { workspace = true }
afs-derive = { path = "../derive" }
ax-sdk = { path = "../sdk" }
stark-vm = { path = "../vm" }
afs-derive = { path = "../../derive" }
ax-sdk = { path = "../../sdk" }
stark-vm = { path = "../../vm" }
tracing.workspace = true
itertools.workspace = true
serde.workspace = true
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use p3_field::{ExtensionField, PrimeField32, TwoAdicField};
use stark_vm::program::Program;
use stark_vm::system::program::Program;

use super::{config::AsmConfig, AsmCompiler};
use crate::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use alloc::{collections::BTreeMap, format};
use core::{fmt, fmt::Display};

use p3_field::{ExtensionField, PrimeField32};
use stark_vm::program::DebugInfo;
use stark_vm::system::program::DebugInfo;

use super::AsmInstruction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use alloc::{collections::BTreeMap, vec};
use std::collections::BTreeSet;

use p3_field::{ExtensionField, Field, PrimeField32, TwoAdicField};
use stark_vm::program::DebugInfo;
use stark_vm::system::program::DebugInfo;

use super::{config::AsmConfig, AssemblyCode, BasicBlock, IndexTriple, ValueOrConst};
use crate::{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use snark_verifier_sdk::snark_verifier::{
},
util::arithmetic::PrimeField as _,
};
use stark_vm::vm::cycle_tracker::CycleTracker;
use stark_vm::system::vm::cycle_tracker::CycleTracker;

use super::stats::Halo2Stats;
use crate::{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use num_bigint_dig::BigUint;
use p3_field::{ExtensionField, PrimeField32, PrimeField64};
use stark_vm::{
arch::instructions::*,
program::{DebugInfo, Instruction, Program},
vm::config::Modulus,
system::{
program::{DebugInfo, Instruction, Program},
vm::config::Modulus,
},
};
use strum::EnumCount;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 32b50d4

Please sign in to comment.