Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Add UUID to DnaConfig and disable integrity check if UUID is specified #1724

Closed
wants to merge 6 commits into from

Conversation

maackle
Copy link
Collaborator

@maackle maackle commented Sep 27, 2019

PR summary

Allow dna.uuid to be specified as config. Previously the only way to set a UUID on a dna was by installing through the admin interface.

changelog

Please check one of the following, relating to the CHANGELOG-UNRELEASED.md

  • this is a code change that effects some consumer (e.g. zome developers) of holochain core so it is added to the CHANGELOG-UNRELEASED.md (linked above), with the format - summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)
  • this is not a code change, or doesn't effect anyone outside holochain core development

@maackle maackle requested review from dymayday, lucksus and zippy and removed request for dymayday September 27, 2019 16:21
Copy link
Collaborator

@timotree3 timotree3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! I'm trying out reviewing PRs so I can get more familiar with the code. I hope you take a look at these suggestions :)

// self.config.dnas.iter_mut().fing(|dna_config| dna_config.id == instance_config.dna)
// .map(|dna_config| {

// })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to leave this comment here?

@@ -750,7 +750,11 @@ impl Conductor {

// Get DNA

let mut dna_config = self.config.dna_by_id(&instance_config.dna).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a latent bug before? dna_by_id clones its result so I doubt that mutating it has the desired effect. If so, it might be good to add a regression test.

@@ -478,6 +478,15 @@ impl Configuration {
self.dnas.iter().find(|dc| &dc.id == id).cloned()
}

/// Returns the DNA configuration with the given ID if present
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment got copy-pasted unchanged :)

Suggested change
/// Returns the DNA configuration with the given ID if present
/// Updates the hash of the DNA with the given ID, returns true if it was present.

Comment on lines +794 to +795
let msg = format!("Conductor: Could not load DNA file {:?}.", &dna_file);
log_error!(context, "{}", msg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use format! and allocate a String just to pass it as a format-arg. Just format it in the log macro

Suggested change
let msg = format!("Conductor: Could not load DNA file {:?}.", &dna_file);
log_error!(context, "{}", msg);
log_error!(context, "Conductor: Could not load DNA file {:?}.", &dna_file);

Comment on lines +804 to +809
let msg = format!("\
Conductor: DNA hashes mismatch: 'Conductor config' != 'Conductor instance': \
'{}' != '{}'",
&dna_hash_from_conductor_config,
&dna_hash_computed);
log_error!(context, "{}", msg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use format! and allocate a String just to pass it as a format-arg. Just format it in the log macro

Suggested change
let msg = format!("\
Conductor: DNA hashes mismatch: 'Conductor config' != 'Conductor instance': \
'{}' != '{}'",
&dna_hash_from_conductor_config,
&dna_hash_computed);
log_error!(context, "{}", msg);
log_error!(
context,
"Conductor: DNA hashes mismatch: \
'Conductor config' != 'Conductor instance': \
'{}' != '{}'",
&dna_hash_from_conductor_config,
&dna_hash_computed
);

Comment on lines +212 to 217
self.config.instances.push(new_instance_config);
self.config.check_consistency(&mut self.dna_loader)?;
let instance = self.instantiate_from_config(id)?;
self.instances
.insert(id.clone(), Arc::new(RwLock::new(instance)));
self.config = new_config;
self.save_config()?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this change seems problematic to me. The old code would jump out in line 213 if the new config is bogus and not change self at all. Now the new instance will always get added to self.config.instances.

I don't understand why we need to change these lines at all. What is wrong with the old code?

new_config.instances.push(new_instance_config);
new_config.check_consistency(&mut self.dna_loader)?;
let instance = self.instantiate_from_config(id, Some(&mut new_config))?;
self.config.instances.push(new_instance_config);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.config.instances.push(new_instance_config);
// TODO: use cloned config to check consistency first, before setting self.confg
self.config.instances.push(new_instance_config);

@lucksus
Copy link
Collaborator

lucksus commented Oct 4, 2019

This got merged with #1725

@lucksus lucksus closed this Oct 4, 2019
@zippy zippy deleted the add-uuid-to-config branch October 4, 2019 18:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants