Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "slot" and "nick" to "app role" #1045

Merged
merged 13 commits into from Oct 28, 2021
6 changes: 3 additions & 3 deletions crates/hc_bundle/src/init.rs
Expand Up @@ -2,7 +2,7 @@ use std::io::Write;
use std::{io, path::PathBuf};

use holochain_types::prelude::{
AppBundle, AppManifest, AppManifestCurrentBuilder, AppSlotManifest, DnaBundle, DnaManifest,
AppBundle, AppManifest, AppManifestCurrentBuilder, AppRoleManifest, DnaBundle, DnaManifest,
};
use holochain_types::web_app::{WebAppBundle, WebAppManifest};

Expand Down Expand Up @@ -52,11 +52,11 @@ fn prompt_dna_init(root_dir: PathBuf) -> anyhow::Result<DnaBundle> {
fn prompt_app_init(root_dir: PathBuf) -> anyhow::Result<AppBundle> {
let name = prompt_required("name:")?;
let description = prompt_optional("description:")?;
let slot = AppSlotManifest::sample("sample-slot".into());
let role = AppRoleManifest::sample("sample-role".into());
let manifest: AppManifest = AppManifestCurrentBuilder::default()
.name(name)
.description(description)
.slots(vec![slot])
.roles(vec![role])
.build()
.unwrap()
.into();
Expand Down
6 changes: 3 additions & 3 deletions crates/hc_bundle/tests/fixtures/my-app/happ.yaml
Expand Up @@ -4,8 +4,8 @@ manifest_version: "1"
name: fixture-app
description: it's an app

slots:
- id: slot-1
roles:
- id: role-1
provisioning:
strategy: create
deferred: false
Expand All @@ -14,7 +14,7 @@ slots:
uid: 0123456
properties: ~
clone_limit: 0
- id: slot-2
- id: role-2
provisioning:
strategy: create
deferred: true
Expand Down
4 changes: 2 additions & 2 deletions crates/hc_sandbox/src/calls.rs
Expand Up @@ -122,7 +122,7 @@ pub struct RegisterDna {
///
/// Setting properties and membrane proofs is not
/// yet supported.
/// CellNicks are set to `my-app-0`, `my-app-1` etc.
/// AppRoleIds are set to `my-app-0`, `my-app-1` etc.
pub struct InstallApp {
#[structopt(short, long, default_value = "test-app")]
/// Sets the InstalledAppId.
Expand All @@ -143,7 +143,7 @@ pub struct InstallApp {
///
/// Setting properties and membrane proofs is not
/// yet supported.
/// CellNicks are set to `my-app-0`, `my-app-1` etc.
/// AppRoleIds are set to `my-app-0`, `my-app-1` etc.
pub struct InstallAppBundle {
#[structopt(short, long)]
/// Sets the InstalledAppId.
Expand Down
6 changes: 5 additions & 1 deletion crates/holochain/CHANGELOG.md
Expand Up @@ -4,6 +4,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

- **BREAKING CHANGE**: The notion of "cell nicknames" ("nicks") and "app slots" has been unified into the notion of "app roles". This introduces several breaking changes. In general, you will need to rebuild any app bundles you are using, and potentially update some usages of the admin interface. In particular:
- The `slots` field in App manifests is now called `roles`
- The `InstallApp` admin method now takes a `role_id` field instead of a `nick` field
thedavidmeister marked this conversation as resolved.
Show resolved Hide resolved
- In the return value for any admin method which lists installed apps, e.g. `ListEnabledApps`, any reference to `"slots"` is now named `"roles"`
- See [\#1045](https://github.com/holochain/holochain/pull/1045)
- Adds test utils for creating simulated networks. [#1037](https://github.com/holochain/holochain/pull/1037).
- Conductor can take a mocked network for testing simulated networks. [#1036](https://github.com/holochain/holochain/pull/1036)
- Batch peer store write so we use less transactions. [#1007](https://github.com/holochain/holochain/pull/1007/).
Expand All @@ -20,7 +25,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 0.0.111

- `call_info` is now implemented [1047](https://github.com/holochain/holochain/pull/1047)

- `dna_info` now returns `DnaInfo` correctly [\#1044](https://github.com/holochain/holochain/pull/1044)

- `ZomeInfo` no longer includes what is now on `DnaInfo`
Expand Down
10 changes: 5 additions & 5 deletions crates/holochain/benches/websocket.rs
Expand Up @@ -76,10 +76,10 @@ pub fn websocket_concurrent_install(c: &mut Criterion) {
debug!("[{}] Agent pub key generated: {}", g, agent_key);

// Install Dna
let nick = format!("fake_dna_{}", g);
let name = format!("fake_dna_{}", g);
let dna = fake_dna_zomes_named(
&uuid::Uuid::new_v4().to_string(),
&nick,
&name,
zomes,
);

Expand All @@ -92,15 +92,15 @@ pub fn websocket_concurrent_install(c: &mut Criterion) {
agent_key,
fake_dna_path.clone(),
None,
nick.clone(),
nick.clone(),
name.clone(),
name.clone(),
REQ_TIMEOUT_MS,
)
.await;

debug!(
"[{}] installed dna with hash {} and name {}",
g, dna_hash, nick
g, dna_hash, name
);
})
}))
Expand Down
10 changes: 5 additions & 5 deletions crates/holochain/examples/websocket_install_dna.rs
Expand Up @@ -32,8 +32,8 @@ pub async fn main() {
println!("[{}] Agent pub key generated: {}", i, agent_key);

// Install Dna
let nick = format!("fake_dna_{}", i);
let dna = fake_dna_zomes_named(&uuid::Uuid::new_v4().to_string(), &nick, zomes);
let name = format!("fake_dna_{}", i);
let dna = fake_dna_zomes_named(&uuid::Uuid::new_v4().to_string(), &name, zomes);

let original_dna_hash = dna.dna_hash().clone();
let (fake_dna_path, _tmpdir) = write_fake_dna_file(dna.clone()).await.unwrap();
Expand All @@ -43,15 +43,15 @@ pub async fn main() {
agent_key,
fake_dna_path.clone(),
None,
nick.clone(),
nick.clone(),
name.clone(),
name.clone(),
REQ_TIMEOUT_MS,
)
.await;

println!(
"[{}] installed dna with hash {} and name {}",
i, dna_hash, nick
i, dna_hash, name
);
})
}))
Expand Down
Expand Up @@ -149,7 +149,7 @@ impl AdminInterfaceApi for RealAdminInterfaceApi {
let InstallAppDnaPayload {
hash,
membrane_proof,
nick,
role_id,
} = dna_payload;

// confirm that hash has been installed
Expand All @@ -161,7 +161,7 @@ impl AdminInterfaceApi for RealAdminInterfaceApi {
)));
}
let cell_id = CellId::from((hash, agent_key.clone()));
ConductorApiResult::Ok((InstalledCell::new(cell_id, nick), membrane_proof))
ConductorApiResult::Ok((InstalledCell::new(cell_id, role_id), membrane_proof))
});

// Join all the install tasks
Expand Down
18 changes: 9 additions & 9 deletions crates/holochain/src/conductor/conductor.rs
Expand Up @@ -777,21 +777,21 @@ where
pub(super) async fn add_clone_cell_to_app(
&self,
app_id: InstalledAppId,
slot_id: SlotId,
role_id: AppRoleId,
properties: YamlProperties,
) -> ConductorResult<CellId> {
let dna_store = &self.dna_store;
let (_, parent_dna_hash) = self
.update_state_prime({
let app_id = app_id.clone();
let slot_id = slot_id.clone();
let role_id = role_id.clone();
move |mut state| {
if let Some(app) = state.installed_apps_mut().get_mut(&app_id) {
let slot = app
.slots()
.get(&slot_id)
.ok_or_else(|| AppError::SlotIdMissing(slot_id.to_owned()))?;
let parent_dna_hash = slot.dna_hash().clone();
let role = app
.roles()
.get(&role_id)
.ok_or_else(|| AppError::AppRoleIdMissing(role_id.to_owned()))?;
let parent_dna_hash = role.dna_hash().clone();
Ok((state, parent_dna_hash))
} else {
Err(ConductorError::AppNotRunning(app_id.clone()))
Expand All @@ -809,9 +809,9 @@ where
let (_, cell_id) = self
.update_state_prime(move |mut state| {
if let Some(app) = state.installed_apps_mut().get_mut(&app_id) {
let agent_key = app.slot(&slot_id)?.agent_key().to_owned();
let agent_key = app.role(&role_id)?.agent_key().to_owned();
let cell_id = CellId::new(child_dna_hash, agent_key);
app.add_clone(&slot_id, cell_id.clone())?;
app.add_clone(&role_id, cell_id.clone())?;
Ok((state, cell_id))
} else {
Err(ConductorError::AppNotRunning(app_id.clone()))
Expand Down
28 changes: 14 additions & 14 deletions crates/holochain/src/conductor/conductor/tests.rs
Expand Up @@ -47,7 +47,7 @@ async fn can_update_state() {
assert_eq!(state, ConductorState::default());

let cell_id = fake_cell_id(1);
let installed_cell = InstalledCell::new(cell_id.clone(), "nick".to_string());
let installed_cell = InstalledCell::new(cell_id.clone(), "role_id".to_string());
let app = InstalledAppCommon::new_legacy("fake app", vec![installed_cell]).unwrap();

conductor
Expand Down Expand Up @@ -93,17 +93,17 @@ async fn can_add_clone_cell_to_app() {
.await
.unwrap();

let installed_cell = InstalledCell::new(cell_id.clone(), "nick".to_string());
let slot = AppSlot::new(cell_id.clone(), true, 1);
let installed_cell = InstalledCell::new(cell_id.clone(), "role_id".to_string());
let role = AppRoleAssignment::new(cell_id.clone(), true, 1);
let app1 = InstalledAppCommon::new_legacy("no clone", vec![installed_cell.clone()]).unwrap();
let app2 = InstalledAppCommon::new("yes clone", agent, vec![("nick".into(), slot.clone())]);
let app2 = InstalledAppCommon::new("yes clone", agent, vec![("role_id".into(), role.clone())]);
assert_eq!(
app1.slots().keys().collect::<Vec<_>>(),
vec![&"nick".to_string()]
app1.roles().keys().collect::<Vec<_>>(),
vec![&"role_id".to_string()]
);
assert_eq!(
app2.slots().keys().collect::<Vec<_>>(),
vec![&"nick".to_string()]
app2.roles().keys().collect::<Vec<_>>(),
vec![&"role_id".to_string()]
);

conductor.register_phenotype(dna);
Expand All @@ -122,13 +122,13 @@ async fn can_add_clone_cell_to_app() {

matches::assert_matches!(
conductor
.add_clone_cell_to_app("no clone".to_string(), "nick".to_string(), ().into())
.add_clone_cell_to_app("no clone".to_string(), "role_id".to_string(), ().into())
.await,
Err(ConductorError::AppError(AppError::CloneLimitExceeded(0, _)))
);

let cloned_cell_id = conductor
.add_clone_cell_to_app("yes clone".to_string(), "nick".to_string(), ().into())
.add_clone_cell_to_app("yes clone".to_string(), "role_id".to_string(), ().into())
.await
.unwrap();

Expand Down Expand Up @@ -197,9 +197,9 @@ async fn app_ids_are_unique() {
);
}

/// App can't be installed if it contains duplicate CellNicks
/// App can't be installed if it contains duplicate AppRoleIds
#[tokio::test(flavor = "multi_thread")]
async fn cell_nicks_are_unique() {
async fn app_role_ids_are_unique() {
let cells = vec![
InstalledCell::new(fixt!(CellId), "1".into()),
InstalledCell::new(fixt!(CellId), "1".into()),
Expand All @@ -208,7 +208,7 @@ async fn cell_nicks_are_unique() {
let result = InstalledAppCommon::new_legacy("id", cells.into_iter());
matches::assert_matches!(
result,
Err(AppError::DuplicateSlotIds(_, nicks)) if nicks == vec!["1".to_string()]
Err(AppError::DuplicateAppRoleIds(_, role_ids)) if role_ids == vec!["1".to_string()]
);
}

Expand Down Expand Up @@ -573,7 +573,7 @@ async fn test_signing_error_during_genesis_doesnt_bork_interfaces() {
installed_app_id: "app3".into(),
agent_key: agent3.clone(),
dnas: vec![InstallAppDnaPayload {
nick: "whatever".into(),
role_id: "whatever".into(),
hash: dna.dna_hash().clone(),
membrane_proof: None,
}],
Expand Down
8 changes: 4 additions & 4 deletions crates/holochain/src/conductor/handle.rs
Expand Up @@ -767,7 +767,7 @@ impl<DS: DnaStore + 'static> ConductorHandleT for ConductorHandleImpl<DS> {
dna_hash,
installed_app_id,
agent_key,
slot_id,
role_id,
membrane_proof,
} = payload;
let cell_id = CellId::new(dna_hash, agent_key);
Expand All @@ -789,7 +789,7 @@ impl<DS: DnaStore + 'static> ConductorHandleT for ConductorHandleImpl<DS> {
let properties = properties.unwrap_or_else(|| ().into());
let cell_id = self
.conductor
.add_clone_cell_to_app(installed_app_id, slot_id, properties)
.add_clone_cell_to_app(installed_app_id, role_id, properties)
.await?;
Ok(cell_id)
}
Expand Down Expand Up @@ -876,8 +876,8 @@ impl<DS: DnaStore + 'static> ConductorHandleT for ConductorHandleImpl<DS> {
)
.await?;

let slots = ops.slots;
let app = InstalledAppCommon::new(installed_app_id, agent_key, slots);
let roles = ops.role_assignments;
let app = InstalledAppCommon::new(installed_app_id, agent_key, roles);

// Update the db
let stopped_app = self.conductor.add_disabled_app_to_db(app).await?;
Expand Down
4 changes: 2 additions & 2 deletions crates/holochain/src/sweettest/sweet_conductor.rs
Expand Up @@ -263,11 +263,11 @@ impl SweetConductor {

/// Opinionated app setup. Creates one app per agent, using the given DnaFiles.
///
/// All InstalledAppIds and CellNicks are auto-generated. In tests driven directly
/// All InstalledAppIds and AppRoleIds are auto-generated. In tests driven directly
/// by Rust, you typically won't care what these values are set to, but in case you
/// do, they are set as so:
/// - InstalledAppId: {app_id_prefix}-{agent_pub_key}
/// - CellNick: {dna_hash}
/// - AppRoleId: {dna_hash}
///
/// Returns a batch of SweetApps, sorted in the same order as Agents passed in.
pub async fn setup_app_for_agents<'a, A, D>(
Expand Down
4 changes: 2 additions & 2 deletions crates/holochain/src/test_utils/test_conductor/test_handle.rs
Expand Up @@ -16,11 +16,11 @@ pub struct TestConductorHandle(pub(crate) ConductorHandle);
impl TestConductorHandle {
/// Opinionated app setup. Creates one app per agent, using the given DnaFiles.
///
/// All InstalledAppIds and CellNicks are auto-generated. In tests driven directly
/// All InstalledAppIds and AppRoleIds are auto-generated. In tests driven directly
/// by Rust, you typically won't care what these values are set to, but in case you
/// do, they are set as so:
/// - InstalledAppId: {app_id_prefix}-{agent_pub_key}
/// - CellNick: {dna_hash}
/// - AppRoleId: {dna_hash}
///
/// Returns the list of generated InstalledAppIds, in the same order as Agents passed in.
pub async fn setup_app_for_agents_with_no_membrane_proof(
Expand Down
8 changes: 4 additions & 4 deletions crates/holochain/tests/test_utils.rs
Expand Up @@ -159,7 +159,7 @@ pub async fn register_and_install_dna(
agent_key: AgentPubKey,
dna_path: PathBuf,
properties: Option<YamlProperties>,
nick: String,
role_id: AppRoleId,
timeout: u64,
) -> DnaHash {
register_and_install_dna_named(
Expand All @@ -168,7 +168,7 @@ pub async fn register_and_install_dna(
agent_key,
dna_path,
properties,
nick,
role_id,
"test".to_string(),
timeout,
)
Expand All @@ -181,7 +181,7 @@ pub async fn register_and_install_dna_named(
agent_key: AgentPubKey,
dna_path: PathBuf,
properties: Option<YamlProperties>,
nick: String,
role_id: AppRoleId,
name: String,
timeout: u64,
) -> DnaHash {
Expand All @@ -202,7 +202,7 @@ pub async fn register_and_install_dna_named(

let dna_payload = InstallAppDnaPayload {
hash: dna_hash.clone(),
nick,
role_id,
membrane_proof: None,
};
let payload = InstallAppPayload {
Expand Down