Skip to content

Commit

Permalink
refactor: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
polydez committed Sep 19, 2024
1 parent d6f3f32 commit 119f0b0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ miden-stdlib = { version = "0.10", default-features = false }
miden-tx = { path = "miden-tx", version = "0.6" }
miden-verifier = { version = "0.10", default-features = false }
rand = { version = "0.8", default-features = false }
regex = { version = "1.10.6", default-features = false }
vm-core = { package = "miden-core", version = "0.10", default-features = false }
vm-processor = { package = "miden-processor", version = "0.10", default-features = false }
2 changes: 1 addition & 1 deletion miden-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ vm-processor = { workspace = true, features = ["testing"] }
[build-dependencies]
assembly = { workspace = true }
miden-stdlib = { workspace = true }
regex = { workspace = true }
regex = { version = "1.10" }
16 changes: 8 additions & 8 deletions miden-lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ASM_DIR: &str = "asm";
const ASM_MIDEN_DIR: &str = "miden";
const ASM_NOTE_SCRIPTS_DIR: &str = "note_scripts";
const ASM_TX_KERNEL_DIR: &str = "kernels/transaction";
const PROCEDURES_V0_RS_FILE: &str = "src/transaction/procedures_v0.rs";
const KERNEL_V0_RS_FILE: &str = "src/transaction/procedures/kernel_v0.rs";

// PRE-PROCESSING
// ================================================================================================
Expand All @@ -34,7 +34,7 @@ const PROCEDURES_V0_RS_FILE: &str = "src/transaction/procedures_v0.rs";
fn main() -> Result<()> {
// re-build when the MASM code changes
println!("cargo:rerun-if-changed=asm");
println!("cargo:rerun-if-changed={PROCEDURES_V0_RS_FILE}");
println!("cargo:rerun-if-changed={KERNEL_V0_RS_FILE}");

// Copies the MASM code to the build directory
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
Expand Down Expand Up @@ -81,9 +81,9 @@ fn main() -> Result<()> {
///
/// The complied files are written as follows:
///
/// - {target_dir}/tx_kernel.masl -> contains kernel library compiled from api.masm.
/// - {target_dir}/tx_kernel.masb -> contains the executable compiled from main.masm.
/// - src/transaction/procedures_v0.rs -> contains the kernel procedures table.
/// - {target_dir}/tx_kernel.masl -> contains kernel library compiled from api.masm.
/// - {target_dir}/tx_kernel.masb -> contains the executable compiled from main.masm.
/// - src/transaction/procedures/kernel_v0.rs -> contains the kernel procedures table.
///
/// When the `testing` feature is enabled, the POW requirements for account ID generation are
/// adjusted by modifying the corresponding constants in {source_dir}/lib/constants.masm file.
Expand Down Expand Up @@ -122,7 +122,7 @@ fn compile_tx_kernel(source_dir: &Path, target_dir: &Path) -> Result<Assembler>
assembler,
)?;

// generate `procedures_v0.rs` file
// generate `kernel_v0.rs` file
generate_kernel_proc_hash_file(kernel_lib.clone())?;

let output_file = target_dir.join("tx_kernel").with_extension(Library::LIBRARY_EXTENSION);
Expand Down Expand Up @@ -172,7 +172,7 @@ fn decrease_pow(line: io::Result<String>) -> io::Result<String> {
Ok(line)
}

/// Generates `procedures_v0.rs` file based on the kernel library
/// Generates `kernel_v0.rs` file based on the kernel library
fn generate_kernel_proc_hash_file(kernel: KernelLibrary) -> Result<()> {
let (_, module_info, _) = kernel.into_parts();

Expand Down Expand Up @@ -215,7 +215,7 @@ fn generate_kernel_proc_hash_file(kernel: KernelLibrary) -> Result<()> {
}).collect::<Vec<_>>().join("\n");

fs::write(
PROCEDURES_V0_RS_FILE,
KERNEL_V0_RS_FILE,
format!(
r#"/// This file is generated by build.rs, do not modify
Expand Down
4 changes: 0 additions & 4 deletions miden-lib/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ pub use errors::{

mod procedures;

// Include procedure hashes generated in build.rs
#[rustfmt::skip]
mod procedures_v0;

// CONSTANTS
// ================================================================================================

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use alloc::vec::Vec;

use kernel_v0::KERNEL0_PROCEDURES;
use miden_objects::{Digest, Felt, Hasher};

use super::TransactionKernel;

// Include procedure hashes generated in build.rs
#[rustfmt::skip]
mod kernel_v0;

// TRANSACTION KERNEL
// ================================================================================================

Expand All @@ -15,8 +20,7 @@ impl TransactionKernel {
pub const NUM_VERSIONS: usize = 1;

/// Array of all available kernels.
pub const PROCEDURES: [&'static [Digest]; Self::NUM_VERSIONS] =
[&super::procedures_v0::KERNEL0_PROCEDURES];
pub const PROCEDURES: [&'static [Digest]; Self::NUM_VERSIONS] = [&KERNEL0_PROCEDURES];

// PUBLIC ACCESSORS
// --------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 119f0b0

Please sign in to comment.