Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,9 @@ fn add_main_fingerprint(cf: &mut CompileForm, forms: &[Rc<SExp>]) {
nl: cf.loc(),
name: b"main".to_vec(),
kind: Some(IncludeProcessType::Compiled),
fingerprint: sha256tree(form_list),
fingerprint: sha256tree(form_list)
.try_into()
.expect("sha256tree digest is 32 bytes"),
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/comptypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,8 @@ pub struct IncludeDesc {
/// Kind of inclusion. Determines whether dependencies are recursed and
/// what operation is performed on the retrieved clvm form.
pub kind: Option<IncludeProcessType>,
/// Fingerprint of input
pub fingerprint: Vec<u8>,
/// Fingerprint of input (SHA-256 tree hash of file bytes when known; otherwise zero).
pub fingerprint: [u8; 32],
}

impl IncludeDesc {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/diskcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::compiler::sexp::decode_string;
fn cache_key(cf: &CompileForm) -> String {
let mut include_fingerprints = Vec::new();
for include in cf.include_forms.iter() {
include_fingerprints.append(&mut include.fingerprint.clone());
include_fingerprints.extend_from_slice(&include.fingerprint);
}
hex::encode(sha256tree_from_atom(&include_fingerprints))
}
Expand Down
24 changes: 15 additions & 9 deletions src/compiler/preprocessor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,9 @@ impl Preprocessor {
self.opts.read_new_file(self.opts.filename(), filename_clsp)
{
// Hash newly read input.
let content_hash = sha256tree_from_atom(&content);
let content_hash: [u8; 32] = sha256tree_from_atom(&content)
.try_into()
.expect("sha256tree_from_atom digest is 32 bytes");
includes.push(IncludeDesc {
kw: kw.clone(),
nl: nl.clone(),
Expand Down Expand Up @@ -668,7 +670,9 @@ impl Preprocessor {
nl: nl.clone(),
name: full_name.as_bytes().to_vec(),
kind: Some(IncludeProcessType::Module(Box::new(kind.clone()))),
fingerprint: sha256tree_from_atom(&content),
fingerprint: sha256tree_from_atom(&content)
.try_into()
.expect("sha256tree_from_atom digest is 32 bytes"),
});

Ok(res)
Expand Down Expand Up @@ -805,7 +809,9 @@ impl Preprocessor {
let (full_name, content) = self.opts.read_new_file(self.opts.filename(), name_string)?;

// Hash newly read input.
let content_hash = sha256tree_from_atom(&content);
let content_hash: [u8; 32] = sha256tree_from_atom(&content)
.try_into()
.expect("sha256tree_from_atom digest is 32 bytes");
includes.push(IncludeDesc {
name: full_name.as_bytes().to_vec(),
fingerprint: content_hash,
Expand Down Expand Up @@ -1116,7 +1122,7 @@ impl Preprocessor {
nl: import.nl.clone(),
name: fname.clone(),
kind: Some(mod_kind.clone()),
fingerprint: Vec::new(),
fingerprint: [0u8; 32],
}),
mod_kind,
fname.clone(),
Expand Down Expand Up @@ -1180,7 +1186,7 @@ impl Preprocessor {
nl: nl.clone(),
name: fname.clone(),
kind: None,
fingerprint: Vec::new(),
fingerprint: [0u8; 32],
})));
}

Expand Down Expand Up @@ -1217,7 +1223,7 @@ impl Preprocessor {
nl: nl.clone(),
kind: Some(IncludeProcessType::Hex),
name: fname.clone(),
fingerprint: Vec::new(),
fingerprint: [0u8; 32],
}),
IncludeProcessType::Hex,
name.clone(),
Expand All @@ -1229,7 +1235,7 @@ impl Preprocessor {
nl: nl.clone(),
kind: Some(IncludeProcessType::Bin),
name: fname.clone(),
fingerprint: Vec::new(),
fingerprint: [0u8; 32],
}),
IncludeProcessType::Bin,
name.clone(),
Expand All @@ -1241,7 +1247,7 @@ impl Preprocessor {
nl: nl.clone(),
kind: Some(IncludeProcessType::SExpression),
name: fname.clone(),
fingerprint: Vec::new(),
fingerprint: [0u8; 32],
}),
IncludeProcessType::SExpression,
name.clone(),
Expand Down Expand Up @@ -1274,7 +1280,7 @@ impl Preprocessor {
nl: nl.clone(),
kind: Some(IncludeProcessType::Compiled),
name: fname.clone(),
fingerprint: Vec::new(),
fingerprint: [0u8; 32],
}),
IncludeProcessType::Compiled,
name.clone(),
Expand Down
Loading