Skip to content

Commit 5868d83

Browse files
authored
fix: use absolute paths in VmConfig derive macro (#1550)
- use absolute paths for structs used only in the derive macro
1 parent 17cefbc commit 5868d83

File tree

15 files changed

+36
-56
lines changed

15 files changed

+36
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ rustc-*
2222
# Bench metrics
2323
.bench_metrics/
2424
__pycache__/
25+
metrics.json
2526

2627
# KZG trusted setup
2728
**/params

Cargo.lock

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

benchmarks/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ harness = false
6666

6767
[[bin]]
6868
name = "fib_e2e"
69+
70+
[package.metadata.cargo-shear]
71+
ignored = ["derive_more"]

benchmarks/src/bin/ecrecover.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clap::Parser;
2-
use derive_more::derive::From;
32
use eyre::Result;
43
use k256::ecdsa::{SigningKey, VerifyingKey};
54
use num_bigint::BigUint;
@@ -9,12 +8,8 @@ use openvm_algebra_circuit::{
98
use openvm_algebra_transpiler::ModularTranspilerExtension;
109
use openvm_benchmarks::utils::BenchmarkCli;
1110
use openvm_circuit::{
12-
arch::{
13-
instructions::exe::VmExe, SystemConfig, SystemExecutor, SystemPeriphery, VmChipComplex,
14-
VmConfig, VmInventoryError,
15-
},
16-
circuit_derive::{Chip, ChipUsageGetter},
17-
derive::{AnyEnum, InstructionExecutor, VmConfig},
11+
arch::{instructions::exe::VmExe, SystemConfig},
12+
derive::VmConfig,
1813
};
1914
use openvm_ecc_circuit::{
2015
CurveConfig, WeierstrassExtension, WeierstrassExtensionExecutor, WeierstrassExtensionPeriphery,

crates/toolchain/tests/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ homepage.workspace = true
88
repository.workspace = true
99

1010
[dependencies]
11-
openvm-circuit-primitives-derive.workspace = true
1211
openvm-stark-backend.workspace = true
1312
openvm-stark-sdk.workspace = true
1413
openvm-circuit = { workspace = true, features = ["test-utils"] }
@@ -35,3 +34,6 @@ num-bigint.workspace = true
3534
[features]
3635
default = ["parallel"]
3736
parallel = ["openvm-circuit/parallel"]
37+
38+
[package.metadata.cargo-shear]
39+
ignored = ["derive_more", "openvm-stark-backend"]

crates/toolchain/tests/tests/transpiler_tests.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::{
33
path::{Path, PathBuf},
44
};
55

6-
use derive_more::derive::From;
76
use eyre::Result;
87
use num_bigint::BigUint;
98
use openvm_algebra_circuit::{
@@ -13,14 +12,10 @@ use openvm_algebra_circuit::{
1312
use openvm_algebra_transpiler::{Fp2TranspilerExtension, ModularTranspilerExtension};
1413
use openvm_bigint_circuit::{Int256, Int256Executor, Int256Periphery};
1514
use openvm_circuit::{
16-
arch::{
17-
SystemConfig, SystemExecutor, SystemPeriphery, VmChipComplex, VmConfig, VmExecutor,
18-
VmInventoryError,
19-
},
20-
derive::{AnyEnum, InstructionExecutor, VmConfig},
15+
arch::{SystemConfig, VmExecutor},
16+
derive::VmConfig,
2117
utils::air_test,
2218
};
23-
use openvm_circuit_primitives_derive::{Chip, ChipUsageGetter};
2419
use openvm_ecc_guest::k256::{SECP256K1_MODULUS, SECP256K1_ORDER};
2520
use openvm_instructions::exe::VmExe;
2621
use openvm_platform::memory::MEM_SIZE;

crates/vm/derive/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,15 @@ pub fn vm_generic_config_derive(input: proc_macro::TokenStream) -> proc_macro::T
317317
#field_name_upper(#periphery_name<F>),
318318
});
319319
create_chip_complex.push(quote! {
320-
let complex: VmChipComplex<F, Self::Executor, Self::Periphery> = complex.extend(&self.#field_name)?;
320+
let complex: ::openvm_circuit::arch::VmChipComplex<F, Self::Executor, Self::Periphery> = complex.extend(&self.#field_name)?;
321321
});
322322
}
323323

324324
let (source_executor_type, source_periphery_type) = match &source {
325-
Source::System(_) => (quote! { SystemExecutor }, quote! { SystemPeriphery }),
325+
Source::System(_) => (
326+
quote! { ::openvm_circuit::arch::SystemExecutor },
327+
quote! { ::openvm_circuit::arch::SystemPeriphery },
328+
),
326329
Source::Config(field_ident) => {
327330
let field_type = fields
328331
.iter()
@@ -344,34 +347,34 @@ pub fn vm_generic_config_derive(input: proc_macro::TokenStream) -> proc_macro::T
344347
let periphery_type = Ident::new(&format!("{}Periphery", name), name.span());
345348

346349
TokenStream::from(quote! {
347-
#[derive(ChipUsageGetter, Chip, InstructionExecutor, From, AnyEnum)]
350+
#[derive(::openvm_circuit::circuit_derive::ChipUsageGetter, ::openvm_circuit::circuit_derive::Chip, ::openvm_circuit::derive::InstructionExecutor, ::derive_more::derive::From, ::openvm_circuit::derive::AnyEnum)]
348351
pub enum #executor_type<F: PrimeField32> {
349352
#[any_enum]
350353
#source_name_upper(#source_executor_type<F>),
351354
#(#executor_enum_fields)*
352355
}
353356

354-
#[derive(ChipUsageGetter, Chip, From, AnyEnum)]
357+
#[derive(::openvm_circuit::circuit_derive::ChipUsageGetter, ::openvm_circuit::circuit_derive::Chip, ::derive_more::derive::From, ::openvm_circuit::derive::AnyEnum)]
355358
pub enum #periphery_type<F: PrimeField32> {
356359
#[any_enum]
357360
#source_name_upper(#source_periphery_type<F>),
358361
#(#periphery_enum_fields)*
359362
}
360363

361-
impl<F: PrimeField32> VmConfig<F> for #name {
364+
impl<F: PrimeField32> ::openvm_circuit::arch::VmConfig<F> for #name {
362365
type Executor = #executor_type<F>;
363366
type Periphery = #periphery_type<F>;
364367

365-
fn system(&self) -> &SystemConfig {
366-
VmConfig::<F>::system(&self.#source_name)
368+
fn system(&self) -> &::openvm_circuit::arch::SystemConfig {
369+
::openvm_circuit::arch::VmConfig::<F>::system(&self.#source_name)
367370
}
368-
fn system_mut(&mut self) -> &mut SystemConfig {
369-
VmConfig::<F>::system_mut(&mut self.#source_name)
371+
fn system_mut(&mut self) -> &mut ::openvm_circuit::arch::SystemConfig {
372+
::openvm_circuit::arch::VmConfig::<F>::system_mut(&mut self.#source_name)
370373
}
371374

372375
fn create_chip_complex(
373376
&self,
374-
) -> Result<VmChipComplex<F, Self::Executor, Self::Periphery>, VmInventoryError> {
377+
) -> Result<::openvm_circuit::arch::VmChipComplex<F, Self::Executor, Self::Periphery>, ::openvm_circuit::arch::VmInventoryError> {
375378
let complex = self.#source_name.create_chip_complex()?;
376379
#(#create_chip_complex)*
377380
Ok(complex)

extensions/algebra/circuit/src/config.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
use derive_more::derive::From;
21
use num_bigint::BigUint;
3-
use openvm_circuit::arch::{
4-
SystemConfig, SystemExecutor, SystemPeriphery, VmChipComplex, VmConfig, VmInventoryError,
5-
};
6-
use openvm_circuit_derive::{AnyEnum, InstructionExecutor, VmConfig};
7-
use openvm_circuit_primitives_derive::{Chip, ChipUsageGetter};
2+
use openvm_circuit::arch::SystemConfig;
3+
use openvm_circuit_derive::VmConfig;
84
use openvm_rv32im_circuit::*;
95
use openvm_stark_backend::p3_field::PrimeField32;
106
use serde::{Deserialize, Serialize};

extensions/bigint/circuit/src/extension.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use openvm_bigint_transpiler::{
55
};
66
use openvm_circuit::{
77
arch::{
8-
SystemConfig, SystemExecutor, SystemPeriphery, SystemPort, VmChipComplex, VmConfig,
9-
VmExtension, VmInventory, VmInventoryBuilder, VmInventoryError,
8+
SystemConfig, SystemPort, VmExtension, VmInventory, VmInventoryBuilder, VmInventoryError,
109
},
1110
system::phantom::PhantomChip,
1211
};

extensions/ecc/circuit/src/config.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
use derive_more::derive::From;
21
use openvm_algebra_circuit::*;
3-
use openvm_circuit::arch::{
4-
SystemConfig, SystemExecutor, SystemPeriphery, VmChipComplex, VmConfig, VmInventoryError,
5-
};
6-
use openvm_circuit_derive::{AnyEnum, InstructionExecutor, VmConfig};
7-
use openvm_circuit_primitives_derive::{Chip, ChipUsageGetter};
2+
use openvm_circuit::arch::SystemConfig;
3+
use openvm_circuit_derive::VmConfig;
84
use openvm_rv32im_circuit::*;
95
use openvm_stark_backend::p3_field::PrimeField32;
106
use serde::{Deserialize, Serialize};

0 commit comments

Comments
 (0)