Skip to content

Commit

Permalink
Remove unstable dpki and countersigning for 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
c12i committed Nov 28, 2024
1 parent 0089629 commit 124caa8
Show file tree
Hide file tree
Showing 9 changed files with 408 additions and 454 deletions.
10 changes: 4 additions & 6 deletions crates/trycp_server/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ async fn multiple_conductors_on_same_machine_are_assigned_different_admin_ports(
id: id_player_1.to_string(),
partial_config: "dpki:
dna_path: ~
network_seed: test
allow_throwaway_random_dpki_agent_key: true
no_dpki: false"
network_seed: ~
no_dpki: true"
.to_string(),
},
ONE_MIN,
Expand Down Expand Up @@ -87,9 +86,8 @@ async fn multiple_conductors_on_same_machine_are_assigned_different_admin_ports(
id: id_player_2.to_string(),
partial_config: "dpki:
dna_path: ~
network_seed: test
allow_throwaway_random_dpki_agent_key: true
no_dpki: false"
network_seed: ~
no_dpki: true"
.to_string(),
},
ONE_MIN,
Expand Down
26 changes: 7 additions & 19 deletions ts/src/local/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,19 @@ export interface ConductorOptions {

/**
* Disable DPKI in the conductor instance.
*
* unstable
*/
noDpki?: boolean;
// noDpki?: boolean;

/**
* Set a DPKI network seed in the conductor instance.
*
* Defaults to "deepkey-test".
*
* unstable
*/
dpkiNetworkSeed?: NetworkSeed;
// dpkiNetworkSeed?: NetworkSeed;

/**
* Timeout for requests to Admin and App API.
Expand All @@ -85,11 +89,7 @@ export interface ConductorOptions {
*/
export type CreateConductorOptions = Pick<
ConductorOptions,
| "bootstrapServerUrl"
| "networkType"
| "noDpki"
| "dpkiNetworkSeed"
| "timeout"
"bootstrapServerUrl" | "networkType" | "timeout"
>;

/**
Expand Down Expand Up @@ -152,12 +152,6 @@ export class Conductor implements IConductor {
signalingServerUrl: URL,
options?: CreateConductorOptions
) {
if (options?.noDpki && options?.dpkiNetworkSeed) {
throw new Error(
"DPKI network seed can not be set when DPKI is disabled. Enable DPKI or do not provide a DPKI network seed."
);
}

const networkType = options?.networkType ?? NetworkType.WebRtc;
if (options?.bootstrapServerUrl && networkType !== NetworkType.WebRtc) {
throw new Error(
Expand All @@ -166,12 +160,6 @@ export class Conductor implements IConductor {
}

const args = ["sandbox", "--piped", "create", "--in-process-lair"];
if (options?.noDpki) {
args.push("--no-dpki");
}
if (options?.dpkiNetworkSeed) {
args.push("--dpki-network-seed", options.dpkiNetworkSeed);
}
args.push("network");
if (options?.bootstrapServerUrl) {
args.push("--bootstrap", options.bootstrapServerUrl.href);
Expand Down
16 changes: 8 additions & 8 deletions ts/src/trycp/conductor/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,17 @@ export interface TryCpConductorOptions {
* Disable DPKI in the conductor instance.
*
* default: false // defaults to using DPKI
*
* unstable
*/
noDpki?: boolean;
// noDpki?: boolean;

/**
* Set a DPKI network seed.
*
* unstable
*/
dpkiNetworkSeed?: string;
// dpkiNetworkSeed?: string;

/**
* Start up conductor after creation.
Expand Down Expand Up @@ -185,11 +189,7 @@ export const createTryCpConductor = async (
const conductor = new TryCpConductor(tryCpClient, options?.id);
if (options?.startup !== false) {
// configure and startup conductor by default
await conductor.configure(
options?.partialConfig,
options?.noDpki,
options?.dpkiNetworkSeed
);
await conductor.configure(options?.partialConfig, true, undefined);
await conductor.startUp({ logLevel: options?.logLevel });
}
return conductor;
Expand All @@ -210,7 +210,7 @@ export class TryCpConductor implements IConductor {
}

static defaultPartialConfig() {
return getPartialConfig();
return getPartialConfig(true);
}

/**
Expand Down
14 changes: 7 additions & 7 deletions ts/src/trycp/conductor/scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ export interface ClientPlayers {
* @public
*/
export class TryCpScenario {
noDpki: boolean;
dpkiNetworkSeed: string;
private noDpki: boolean;
private dpkiNetworkSeed: string;
network_seed: string;
servicesProcess: ChildProcessWithoutNullStreams | undefined;
bootstrapServerUrl: URL | undefined;
signalingServerUrl: URL | undefined;
clients: TryCpClient[];

constructor() {
this.noDpki = false;
this.noDpki = true;
this.dpkiNetworkSeed = uuidv4();
this.network_seed = uuidv4();
this.clients = [];
Expand Down Expand Up @@ -144,9 +144,9 @@ export class TryCpScenario {
// Conductors must be created in sequence to avoid identical admin ports being assigned multiple times.
const conductor = await client.addConductor({
partialConfig: options?.partialConfig,
noDpki: this.noDpki,
// noDpki: this.noDpki,
// Set a common unique DPKI network seed.
dpkiNetworkSeed: this.noDpki ? "" : this.dpkiNetworkSeed,
// dpkiNetworkSeed: this.noDpki ? "" : this.dpkiNetworkSeed,
});
const app = options.app;
let appOptions;
Expand Down Expand Up @@ -217,8 +217,8 @@ export class TryCpScenario {
) {
const conductor = await tryCpClient.addConductor({
logLevel: options?.logLevel,
noDpki: this.noDpki,
dpkiNetworkSeed: this.dpkiNetworkSeed,
// noDpki: this.noDpki,
// dpkiNetworkSeed: this.dpkiNetworkSeed,
});
options = {
...options,
Expand Down
178 changes: 89 additions & 89 deletions ts/test/fixture/zomes/coordinator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hdk::prelude::*;
use integrity::{Content, EntryTypes, EntryTypesUnit, UpdateInput};
use integrity::{Content, EntryTypes, UpdateInput};

#[hdk_extern]
pub fn create(input: Content) -> ExternResult<ActionHash> {
Expand Down Expand Up @@ -43,91 +43,91 @@ fn signal_loopback(value: LoopBack) -> ExternResult<()> {
Ok(())
}

#[hdk_extern]
fn create_two_party_countersigning_session(
with_other: AgentPubKey,
) -> ExternResult<PreflightResponse> {
let my_agent_info = agent_info()?;

let entry = Content("hello".to_string());

let entry_hash = hash_entry(EntryTypes::Content(entry.clone()))?;

let session_times = session_times_from_millis(10_000)?;
let request = PreflightRequest::try_new(
entry_hash,
vec![
(my_agent_info.agent_initial_pubkey, vec![]),
(with_other.clone(), vec![]),
],
Vec::with_capacity(0),
0,
true,
session_times,
ActionBase::Create(CreateBase::new(EntryTypesUnit::Content.try_into()?)),
PreflightBytes(vec![]),
)
.map_err(|e| {
wasm_error!(WasmErrorInner::Guest(format!(
"Failed to create countersigning request: {:?}",
e
)))
})?;

// Accept ours now and then Holochain should wait for the other party to join the session
let my_acceptance = accept_countersigning_preflight_request(request.clone())?;

let response = match &my_acceptance {
PreflightRequestAcceptance::Accepted(response) => response.clone(),
e => {
return Err(wasm_error!(WasmErrorInner::Guest(format!(
"Unexpected response: {:?}",
e
))))
}
};

Ok(response)
}

#[hdk_extern]
fn accept_two_party(request: PreflightRequest) -> ExternResult<PreflightResponse> {
let my_accept = accept_countersigning_preflight_request(request)?;
match my_accept {
PreflightRequestAcceptance::Accepted(response) => Ok(response),
e => Err(wasm_error!(WasmErrorInner::Guest(format!(
"Unexpected response: {:?}",
e
)))),
}
}

#[hdk_extern]
fn commit_two_party(responses: Vec<PreflightResponse>) -> ExternResult<()> {
let inner = Content("hello".to_string());

let entry = Entry::CounterSign(
Box::new(
CounterSigningSessionData::try_from_responses(responses, vec![]).map_err(
|countersigning_error| {
wasm_error!(WasmErrorInner::Guest(countersigning_error.to_string()))
},
)?,
),
inner.clone().try_into()?,
);

let agreement = EntryTypes::Content(inner);
let entry_def_index = ScopedEntryDefIndex::try_from(&agreement)?;
let visibility = EntryVisibility::from(&agreement);

hdk::prelude::create(CreateInput::new(
entry_def_index,
visibility,
entry,
// Countersigned entries MUST have strict ordering.
ChainTopOrdering::Strict,
))?;

Ok(())
}
// #[hdk_extern]
// fn create_two_party_countersigning_session(
// with_other: AgentPubKey,
// ) -> ExternResult<PreflightResponse> {
// let my_agent_info = agent_info()?;

// let entry = Content("hello".to_string());

// let entry_hash = hash_entry(EntryTypes::Content(entry.clone()))?;

// let session_times = session_times_from_millis(10_000)?;
// let request = PreflightRequest::try_new(
// entry_hash,
// vec![
// (my_agent_info.agent_initial_pubkey, vec![]),
// (with_other.clone(), vec![]),
// ],
// Vec::with_capacity(0),
// 0,
// true,
// session_times,
// ActionBase::Create(CreateBase::new(EntryTypesUnit::Content.try_into()?)),
// PreflightBytes(vec![]),
// )
// .map_err(|e| {
// wasm_error!(WasmErrorInner::Guest(format!(
// "Failed to create countersigning request: {:?}",
// e
// )))
// })?;

// // Accept ours now and then Holochain should wait for the other party to join the session
// let my_acceptance = accept_countersigning_preflight_request(request.clone())?;

// let response = match &my_acceptance {
// PreflightRequestAcceptance::Accepted(response) => response.clone(),
// e => {
// return Err(wasm_error!(WasmErrorInner::Guest(format!(
// "Unexpected response: {:?}",
// e
// ))))
// }
// };

// Ok(response)
// }

// #[hdk_extern]
// fn accept_two_party(request: PreflightRequest) -> ExternResult<PreflightResponse> {
// let my_accept = accept_countersigning_preflight_request(request)?;
// match my_accept {
// PreflightRequestAcceptance::Accepted(response) => Ok(response),
// e => Err(wasm_error!(WasmErrorInner::Guest(format!(
// "Unexpected response: {:?}",
// e
// )))),
// }
// }

// #[hdk_extern]
// fn commit_two_party(responses: Vec<PreflightResponse>) -> ExternResult<()> {
// let inner = Content("hello".to_string());

// let entry = Entry::CounterSign(
// Box::new(
// CounterSigningSessionData::try_from_responses(responses, vec![]).map_err(
// |countersigning_error| {
// wasm_error!(WasmErrorInner::Guest(countersigning_error.to_string()))
// },
// )?,
// ),
// inner.clone().try_into()?,
// );

// let agreement = EntryTypes::Content(inner);
// let entry_def_index = ScopedEntryDefIndex::try_from(&agreement)?;
// let visibility = EntryVisibility::from(&agreement);

// hdk::prelude::create(CreateInput::new(
// entry_def_index,
// visibility,
// entry,
// // Countersigned entries MUST have strict ordering.
// ChainTopOrdering::Strict,
// ))?;

// Ok(())
// }
Loading

0 comments on commit 124caa8

Please sign in to comment.