Skip to content

Commit

Permalink
refactor: remove Package::rodata, swap Package::digest with `dige…
Browse files Browse the repository at this point in the history
…st()`
  • Loading branch information
greenhat committed Nov 19, 2024
1 parent 2fe5cc2 commit 7898968
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 100 deletions.
2 changes: 0 additions & 2 deletions package/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ extern crate alloc;
mod de;
mod dep;
mod package;
mod rodata;
mod se;

#[cfg(test)]
Expand All @@ -28,7 +27,6 @@ pub use self::{
Dependency, DependencyName, SystemLibraryId,
},
package::{MastArtifact, Package, PackageExport, PackageManifest},
rodata::{PtrDesc, Rodata},
};

type Digest = vm_core::chiplets::hasher::Digest;
38 changes: 7 additions & 31 deletions package/src/package.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
use alloc::{
collections::{BTreeMap, BTreeSet},
format,
string::String,
sync::Arc,
vec::Vec,
};
use alloc::{collections::BTreeSet, format, string::String, sync::Arc, vec::Vec};
use core::fmt;

use assembly::{ast::QualifiedProcedureName, Library, Report};
use serde::{Deserialize, Serialize};
use vm_core::{mast::MastForest, utils::DisplayHex, Felt, Program};
use vm_core::{mast::MastForest, utils::DisplayHex, Program};

use super::{de, se};
use crate::{Dependency, Digest, Rodata};
use crate::{Dependency, Digest};

// MAST ARTIFACT
// ================================================================================================
Expand Down Expand Up @@ -113,18 +107,9 @@ impl fmt::Debug for PackageExport {
pub struct Package {
/// Name of the package
pub name: String,
/// Content digest of the package
#[serde(
serialize_with = "se::serialize_digest",
deserialize_with = "de::deserialize_digest"
)]
pub digest: Digest,
/// The MAST artifact ([Program] or [Library]) of the package
#[serde(serialize_with = "se::serialize_mast", deserialize_with = "de::deserialize_mast")]
pub mast: MastArtifact,
/// The rodata segments required to be loaded in the advice provider before executing the code
/// in this package
pub rodata: Vec<Rodata>,
/// The package manifest, containing the set of exported procedures and their signatures,
/// if known.
pub manifest: PackageManifest,
Expand Down Expand Up @@ -166,6 +151,10 @@ impl Package {
Ok(bytes)
}

pub fn digest(&self) -> Digest {
self.mast.digest()
}

/// Checks if the package's MAST artifact is a [Program]
pub fn is_program(&self) -> bool {
matches!(self.mast, MastArtifact::Executable(_))
Expand Down Expand Up @@ -226,12 +215,10 @@ impl Package {

Ok(Self {
name: self.name.clone(),
digest,
mast: MastArtifact::Executable(Arc::new(Program::new(
library.mast_forest().clone(),
node_id,
))),
rodata: self.rodata.clone(),
manifest: PackageManifest {
exports,
dependencies: self.manifest.dependencies.clone(),
Expand All @@ -244,15 +231,4 @@ impl Package {
)))
}
}

/// The advice map that is expected to be loaded into the advice provider so that the
/// program's compiler-generated prologue will load the rodata from the advice provider into
/// memory before the program is executed
pub fn advice_map(&self) -> BTreeMap<Digest, Vec<Felt>> {
let mut advice_inputs = BTreeMap::default();
for rodata in self.rodata.iter() {
advice_inputs.extend([(rodata.digest, rodata.to_elements())]);
}
advice_inputs
}
}
67 changes: 0 additions & 67 deletions package/src/rodata.rs

This file was deleted.

0 comments on commit 7898968

Please sign in to comment.