diff --git a/bindings/trycp_runner/src/common.rs b/bindings/trycp_runner/src/common.rs index 4bdd8102..682f87b4 100644 --- a/bindings/trycp_runner/src/common.rs +++ b/bindings/trycp_runner/src/common.rs @@ -315,7 +315,7 @@ where let agent_name = agent_name.clone(); async move { let logs = client - .download_logs(agent_name, Some(Duration::from_secs(180))) + .download_logs(agent_name, Some(Duration::from_secs(10 * 60))) .await .context("Failed to download logs")?; Ok(logs) diff --git a/conductor-config-ci.yaml b/conductor-config-ci.yaml index 213fd207..b6e2335f 100644 --- a/conductor-config-ci.yaml +++ b/conductor-config-ci.yaml @@ -1,6 +1,21 @@ +#danger_generate_throwaway_device_seed: true +#dpki: +# dna_path: ~ +# network_seed: wind-tunnel-test +# allow_throwaway_random_dpki_agent_key: true +# no_dpki: false +dpki: + dna_path: ~ + network_seed: wind-tunnel-test + no_dpki: true network: network_type: quic_bootstrap transport_pool: - type: webrtc signal_url: "ws://localhost:4423" bootstrap_service: "http://localhost:4422" +tuning_params: + countersigning_resolution_retry_delay: + secs: 10 + nanos: 0 + countersigning_resolution_retry_limit: 5 diff --git a/conductor-config.yaml b/conductor-config.yaml index 7f5576d3..66bd3e34 100644 --- a/conductor-config.yaml +++ b/conductor-config.yaml @@ -1,6 +1,21 @@ +#danger_generate_throwaway_device_seed: true +#dpki: +# dna_path: ~ +# network_seed: wind-tunnel-test +# allow_throwaway_random_dpki_agent_key: true +# no_dpki: false +dpki: + dna_path: ~ + network_seed: wind-tunnel-test + no_dpki: true network: network_type: quic_bootstrap transport_pool: - type: webrtc signal_url: "wss://sbd.holo.host" bootstrap_service: "https://bootstrap.holo.host" +tuning_params: + countersigning_resolution_retry_delay: + secs: 10 + nanos: 0 + countersigning_resolution_retry_limit: 5 diff --git a/influx/templates/dashboards/countersigning.json b/influx/templates/dashboards/countersigning.json index eb53d33a..4e6e0f85 100644 --- a/influx/templates/dashboards/countersigning.json +++ b/influx/templates/dashboards/countersigning.json @@ -1 +1 @@ -[{"apiVersion":"influxdata.com/v2alpha1","kind":"Dashboard","metadata":{"name":"dreamy-cray-276001"},"spec":{"charts":[{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Initiated sessions","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","yCol":"_value"},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","label":"Duration","name":"y","scale":"linear","suffix":"s"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Successful initiated session duration","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated_duration\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":12,"widthRatio":1,"xCol":"_time","yCol":"_value","yPos":4},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Accepted sessions","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","yCol":"_value","yPos":8},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","label":"Duration","name":"y","scale":"linear","suffix":"s"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Successful accepted session duration","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted_duration\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":12,"widthRatio":1,"xCol":"_time","yCol":"_value","yPos":12},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Successful initiated sessions","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated_success\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\") \n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","xPos":4,"yCol":"_value"},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Successful accepted sessions","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted_success\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","xPos":4,"yCol":"_value","yPos":8},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Failed initiated sessions","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"Initiated = from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n\nSucceeded = from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated_success\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n\nunion(tables: [Initiated, Succeeded])\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> difference()\n |> yield(name: \"difference\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","xPos":8,"yCol":"_value"},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Failed accepted sessions","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"accepted = from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n\nsucceeded = from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted_success\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n\nunion(tables: [accepted, succeeded])\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> difference()\n |> yield(name: \"difference\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","xPos":8,"yCol":"_value","yPos":8}],"description":"Generic charts for countersigning scenarios","name":"Countersigning"}}] \ No newline at end of file +[{"apiVersion":"influxdata.com/v2alpha1","kind":"Dashboard","metadata":{"name":"sharp-einstein-dda001"},"spec":{"charts":[{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Initiated: session count","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> yield(name: \"value\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","yCol":"_value"},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","label":"Duration","name":"y","scale":"linear","suffix":"s"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Initiated: success duration","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated_duration\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> filter(fn: (r) => r[\"failed\"] == \"false\")\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":6,"widthRatio":1,"xCol":"_time","yCol":"_value","yPos":4},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Accepted: session count","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> yield(name: \"value\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","yCol":"_value","yPos":8},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","label":"Duration","name":"y","scale":"linear","suffix":"s"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Accepted: Success duration","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted_duration\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> filter(fn: (r) => r[\"failed\"] == \"false\")\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":6,"widthRatio":1,"xCol":"_time","yCol":"_value","yPos":12},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Initiated: Success count","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated_success\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\") \n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> yield(name: \"value\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","xPos":4,"yCol":"_value"},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Accepted: success count","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted_success\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> yield(name: \"value\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","xPos":4,"yCol":"_value","yPos":8},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","label":"Duration","name":"y","scale":"linear","suffix":"s"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Initiated: failure duration","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated_duration\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> filter(fn: (r) => r[\"failed\"] == \"true\")\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":6,"widthRatio":1,"xCol":"_time","xPos":6,"yCol":"_value","yPos":4},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","label":"Duration","name":"y","scale":"linear","suffix":"s"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Accepted: Failed duration","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted_duration\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> filter(fn: (r) => r[\"failed\"] == \"true\")\n |> group(columns: [\"agent\"], mode:\"by\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":6,"widthRatio":1,"xCol":"_time","xPos":6,"yCol":"_value","yPos":12},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Initated: Failure count","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_initiated_failure\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> yield(name: \"value\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xCol":"_time","xPos":8,"yCol":"_value"},{"axes":[{"base":"10","name":"x","scale":"linear"},{"base":"10","name":"y","scale":"linear"}],"colorizeRows":true,"colors":[{"id":"KUTtqo_3thkHsXMmw8AAx","name":"Color Blind Friendly - Light","type":"scale","hex":"#FFFFFF"},{"id":"746gR03rdZ6XitWhLnBQ0","name":"Color Blind Friendly - Light","type":"scale","hex":"#E69F00"},{"id":"d51OBsEuj4XCsSSy4IXGi","name":"Color Blind Friendly - Light","type":"scale","hex":"#56B4E9"},{"id":"tmIUeSU3NKTKKhnQBhAqk","name":"Color Blind Friendly - Light","type":"scale","hex":"#009E73"},{"id":"s7VBZJDbJbHxPVJZ48XHd","name":"Color Blind Friendly - Light","type":"scale","hex":"#F0E442"},{"id":"P72-bQCsx8W1i6Z1miSWn","name":"Color Blind Friendly - Light","type":"scale","hex":"#0072B2"},{"id":"EZdhHDCFyiqI8aqjRRAaa","name":"Color Blind Friendly - Light","type":"scale","hex":"#D55E00"},{"id":"TBqjw60qQwNkbVslVTBy0","name":"Color Blind Friendly - Light","type":"scale","hex":"#CC79A7"}],"geom":"line","height":4,"hoverDimension":"auto","kind":"Xy","legendColorizeRows":true,"legendOpacity":1,"legendOrientationThreshold":100000000,"name":"Accepted: failed count","opacity":1,"orientationThreshold":100000000,"position":"overlaid","queries":[{"query":"from(bucket: \"windtunnel\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"wt.custom.countersigning_session_accepted_failure\")\n |> filter(fn: (r) => r[\"run_id\"] == v.RunId)\n |> group(columns: [\"agent\"], mode:\"by\")\n |> filter(fn: (r) => r[\"_field\"] == \"value\")\n |> yield(name: \"value\")"}],"staticLegend":{"colorizeRows":true,"opacity":1,"orientationThreshold":100000000,"widthRatio":1},"width":4,"widthRatio":1,"xPos":8,"yPos":8}],"description":"Generic charts for countersigning scenarios","name":"Countersigning"}}] \ No newline at end of file diff --git a/scenarios/two_party_countersigning/src/main.rs b/scenarios/two_party_countersigning/src/main.rs index 2d83884a..530fe74a 100644 --- a/scenarios/two_party_countersigning/src/main.rs +++ b/scenarios/two_party_countersigning/src/main.rs @@ -1,5 +1,5 @@ use anyhow::Context; -use countersigning_integrity::Signals; +use countersigning_integrity::{AcceptedRequest, Signals}; use holochain_types::prelude::{AgentPubKey, CellId, EntryHash, PreflightResponse}; use holochain_types::signal::{Signal, SystemSignal}; use rand::seq::SliceRandom; @@ -19,6 +19,7 @@ pub struct ScenarioValues { initiate_with_peers: Vec, session_attempts: Arc, session_successes: Arc, + session_failures: Arc, } impl UserValuesConstraint for ScenarioValues {} @@ -113,136 +114,144 @@ fn agent_behaviour_initiate( let agent_name = ctx.agent_name().to_string(); let initiated = ctx.get().scenario_values.session_attempts.clone(); let initiated_success = ctx.get().scenario_values.session_successes.clone(); + let initiated_failure = ctx.get().scenario_values.session_failures.clone(); let new_peers = ctx .runner_context() .executor() - .execute_in_place( - async move { - match initiate_with_peers { - None => { - // No more agents available to call, get a new list. - // This is also the initial condition. - let response = client - .call_zome( - app_port, - cell_id.clone(), - "countersigning", - "list_participants", - (), - None, - ) - .await - .context("Failed to list participants")?; - let mut new_peer_list = response.decode::>().map_err(|e| anyhow::anyhow!("Decoding failure: {:?}", e))?; - new_peer_list.shuffle(&mut thread_rng()); - - // Pause to let Holochain receive more agent links if none are found yet. - if new_peer_list.is_empty() { - tokio::time::sleep(Duration::from_millis(100)).await; - } - - Ok(new_peer_list) + .execute_in_place(async move { + match initiate_with_peers { + None => { + // No more agents available to call, get a new list. + // This is also the initial condition. + let response = client + .call_zome( + app_port, + cell_id.clone(), + "countersigning", + "list_participants", + (), + None, + ) + .await + .context("Failed to list participants")?; + let mut new_peer_list = response + .decode::>() + .map_err(|e| anyhow::anyhow!("Decoding failure: {:?}", e))?; + new_peer_list.shuffle(&mut thread_rng()); + + // Pause to let Holochain receive more agent links if none are found yet. + if new_peer_list.is_empty() { + tokio::time::sleep(Duration::from_millis(100)).await; } - Some(agent_pub_key) => { - log::debug!("Initiating a countersigning session with agent {:?}", agent_pub_key); - let start = Instant::now(); - let initiated = initiated.fetch_add(1, std::sync::atomic::Ordering::Acquire); - reporter.add_custom( - ReportMetric::new("countersigning_session_initiated") - .with_tag("agent", agent_name.clone()) - .with_field("value", initiated as u64), - ); + Ok(new_peer_list) + } + Some(agent_pub_key) => { + log::debug!( + "Initiating a countersigning session with agent {:?}", + agent_pub_key + ); + + let start = Instant::now(); + let initiated = initiated.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + reporter.add_custom( + ReportMetric::new("countersigning_session_initiated") + .with_tag("agent", agent_name.clone()) + .with_field("value", initiated as u64), + ); - // Start a countersigning session with the next agent in the list. - let response = client - .call_zome( - app_port, - cell_id.clone(), - "countersigning", - "start_two_party", - agent_pub_key.clone(), - // This should be fairly quick, can increase this if it causes problems - None, + // Start a countersigning session with the next agent in the list. + let response = client + .call_zome( + app_port, + cell_id.clone(), + "countersigning", + "start_two_party", + agent_pub_key.clone(), + // This should be fairly quick, can increase this if it causes problems + None, + ) + .await + .with_context(|| { + format!( + "Failed to start a new countersigning session: {:?}", + agent_pub_key ) - .await - .with_context(|| { - format!("Failed to start a new countersigning session: {:?}", agent_pub_key) - })?; + })?; - let my_preflight_response: PreflightResponse = response.decode().map_err(|e| anyhow::anyhow!("Decoding failure: {:?}", e))?; + let my_preflight_response: PreflightResponse = response + .decode() + .map_err(|e| anyhow::anyhow!("Decoding failure: {:?}", e))?; - let session_times = my_preflight_response.request.session_times.clone(); - let session_timeout = Instant::now().add(Duration::from_millis( - (session_times.end.as_millis() - session_times.start.as_millis()) as u64, - )); - loop { - // Now listen for a signal from the remote with their acceptance - let signal = tokio::time::timeout_at(session_timeout, client.recv_signal()).await.with_context(|| format!("Agent [{agent_pub_key:?}] did not respond to the countersigning request in time, abandoning"))?; - - match signal { - Some(signal) => { - let signal = match rmp_serde::decode::from_slice::(&signal.data).map_err(|e| anyhow::anyhow!("Decoding failure, appears to not be a signal: {:?}", e))? { - Signal::App { - signal, - .. - } => signal, - _ => { - log::debug!("Received a signal that is not an app signal, listening for other signals."); - continue; - } - }; - - let other_response = match signal.clone().into_inner().decode::() { - Ok(Signals::Response(response)) if response.request.app_entry_hash == my_preflight_response.request.app_entry_hash => response, - Ok(_) => { - log::debug!("Received a signal that is not a response for this countersigning session, listening for other signals."); - continue; - } - Err(_) => { - // Must be resilient to unexpected signals, somebody else might try to initiate with us while we're already - // working with another peer. - log::debug!("Got an unexpected signal, will try again. {:?}", signal); - continue; - } - }; - - log::debug!("The other party [{:?}] has accepted the countersigning session.", agent_pub_key); - - let retry_count = complete_session(client.clone(), app_port, cell_id.clone(), my_preflight_response, other_response, session_timeout).await.context("Initiator failed to complete session")?; - - let elapsed = start.elapsed(); - - log::debug!("Completed the countersigning session with agent {:?}", agent_pub_key); - - let initiated_success = initiated_success.fetch_add(1, std::sync::atomic::Ordering::Acquire); - reporter.add_custom( - ReportMetric::new("countersigning_session_initiated_success") - .with_tag("agent", agent_name.clone()) - .with_field("retries", retry_count as u64) - .with_field("value", initiated_success as u64), - ); - reporter.add_custom( - ReportMetric::new("countersigning_session_initiated_duration") - .with_tag("agent", agent_name) - .with_field("value", elapsed.as_secs_f64()), - ); - - break; - } - None => { - log::warn!("No signal received, problem with the remote? Will try again."); - } - } - } + let session_times = my_preflight_response.request.session_times.clone(); + let session_timeout = Instant::now().add(Duration::from_millis( + (session_times.end.as_millis() - session_times.start.as_millis()) as u64, + )); - // Add no new agents, that should only happen when we exhaust the list. - Ok(Vec::with_capacity(0)) + match run_initiated_session( + client.clone(), + my_preflight_response, + session_timeout, + agent_pub_key.clone(), + cell_id.clone(), + app_port, + ) + .await + { + Ok(retry_count) => { + let elapsed = start.elapsed(); + + log::debug!( + "Completed countersigning session with agent {:?}", + agent_pub_key + ); + + let initiated_success = initiated_success + .fetch_add(1, std::sync::atomic::Ordering::Relaxed); + reporter.add_custom( + ReportMetric::new("countersigning_session_initiated_success") + .with_tag("agent", agent_name.clone()) + .with_tag("retries", retry_count as u64) + .with_field("value", (initiated_success + 1) as u64), + ); + reporter.add_custom( + ReportMetric::new("countersigning_session_initiated_duration") + .with_tag("agent", agent_name) + .with_tag("failed", false) + .with_field("value", elapsed.as_secs_f64()), + ); + } + Err(e) => { + let elapsed = start.elapsed(); + + log::warn!( + "Failed countersigning session with agent {:?}: {:?}", + agent_pub_key, + e + ); + + let initiated_failure = initiated_failure + .fetch_add(1, std::sync::atomic::Ordering::Relaxed); + reporter.add_custom( + ReportMetric::new("countersigning_session_initiated_failure") + .with_tag("agent", agent_name.clone()) + .with_field("value", (initiated_failure + 1) as u64), + ); + reporter.add_custom( + ReportMetric::new("countersigning_session_initiated_duration") + .with_tag("agent", agent_name) + .with_tag("failed", true) + .with_field("value", elapsed.as_secs_f64()), + ); + } } + + // Add no new agents, that should only happen when we exhaust the list. + Ok(Vec::with_capacity(0)) } } - )?; + })?; ctx.get_mut() .scenario_values @@ -252,6 +261,71 @@ fn agent_behaviour_initiate( Ok(()) } +async fn run_initiated_session( + client: TryCPClient, + my_preflight_response: PreflightResponse, + session_timeout: Instant, + agent_pub_key: AgentPubKey, + cell_id: CellId, + app_port: u16, +) -> anyhow::Result { + loop { + // Now listen for a signal from the remote with their acceptance + let signal = tokio::time::timeout_at(session_timeout, client.recv_signal()).await.with_context(|| format!("Agent [{agent_pub_key:?}] did not respond to the countersigning request in time, abandoning"))?; + + match signal { + Some(signal) => { + let signal = match rmp_serde::decode::from_slice::(&signal.data).map_err( + |e| anyhow::anyhow!("Decoding failure, appears to not be a signal: {:?}", e), + )? { + Signal::App { signal, .. } => signal, + _ => { + log::debug!("Received a signal that is not an app signal, listening for other signals."); + continue; + } + }; + + let other_response = match signal.clone().into_inner().decode::() { + Ok(Signals::Response(response)) + if response.request().fingerprint()? + == my_preflight_response.request().fingerprint()? => + { + response + } + Ok(_) => { + log::debug!("Received a signal that is not a response for this countersigning session, listening for other signals."); + continue; + } + Err(_) => { + // We shouldn't really be getting signals that don't decode but choosing to + // filter them out here. + log::debug!("Got an unexpected signal, will try again. {:?}", signal); + continue; + } + }; + + log::debug!( + "The other party [{:?}] has accepted the countersigning session.", + agent_pub_key + ); + + return complete_session( + client.clone(), + app_port, + cell_id.clone(), + my_preflight_response, + other_response, + session_timeout, + ) + .await; + } + None => { + log::warn!("No signal received, problem with the remote? Will try again."); + } + } + } +} + fn agent_behaviour_participate( ctx: &mut AgentContext>, ) -> HookResult { @@ -264,6 +338,7 @@ fn agent_behaviour_participate( let agent_name = ctx.agent_name().to_string(); let accepted = ctx.get().scenario_values.session_attempts.clone(); let accepted_success = ctx.get().scenario_values.session_successes.clone(); + let accepted_failure = ctx.get().scenario_values.session_failures.clone(); ctx.runner_context().executor().execute_in_place( async move { @@ -301,7 +376,7 @@ fn agent_behaviour_participate( }; let start = Instant::now(); - let accepted = accepted.fetch_add(1, std::sync::atomic::Ordering::Acquire); + let accepted = accepted.fetch_add(1, std::sync::atomic::Ordering::Relaxed); reporter.add_custom( ReportMetric::new("countersigning_session_accepted") .with_tag("agent", agent_name.clone()) @@ -315,45 +390,48 @@ fn agent_behaviour_participate( (session_times.end.as_millis() - session_times.start.as_millis()) as u64, )); - log::debug!("Another party has initiated a countersigning session."); - - let response = client.call_zome( - app_port, - cell_id.clone(), - "countersigning", - "accept_two_party", - request.preflight_request, - None, - ).await?; - - log::debug!("Accepted the incoming session, proceeding to commit."); + match run_accepted_session(client, request, session_timeout, cell_id, app_port).await { + Ok(retry_count) => { + let elapsed = start.elapsed(); + + log::debug!("Completed countersigning session with the initiating party."); + + let accepted_success = accepted_success.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + reporter.add_custom( + ReportMetric::new("countersigning_session_accepted_success") + .with_tag("agent", agent_name.clone()) + .with_tag("retries", retry_count as u64) + .with_field("value", (accepted_success + 1) as u64), + ); + reporter.add_custom( + ReportMetric::new("countersigning_session_accepted_duration") + .with_tag("agent", agent_name) + .with_tag("failed", false) + .with_field("value", elapsed.as_secs_f64()), + ); + }, + Err(e) => { + let elapsed = start.elapsed(); - let my_accept_response: PreflightResponse = response.decode().map_err(|e| anyhow::anyhow!("Decoding failure: {:?}", e))?; + log::warn!("Failed countersigning session with the initiating party: {:?}", e); - let retry_count = match complete_session(client.clone(), app_port, cell_id.clone(), request.preflight_response, my_accept_response, session_timeout).await { - Ok(retry_count) => retry_count, - Err(e) => { // If we got a fatal error rather than a successful session, wait for the session to expire before trying again tokio::time::sleep_until(session_timeout).await; - return Err(e).context("Acceptor failed to complete session"); + + let accepted_failure = accepted_failure.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + reporter.add_custom( + ReportMetric::new("countersigning_session_accepted_failure") + .with_tag("agent", agent_name.clone()) + .with_field("value", (accepted_failure + 1) as u64), + ); + reporter.add_custom( + ReportMetric::new("countersigning_session_accepted_duration") + .with_tag("agent", agent_name) + .with_tag("failed", true) + .with_field("value", elapsed.as_secs_f64()), + ); } }; - let elapsed = start.elapsed(); - - log::debug!("Completed the countersigning session with the initiating party."); - - let accepted_success = accepted_success.fetch_add(1, std::sync::atomic::Ordering::Acquire); - reporter.add_custom( - ReportMetric::new("countersigning_session_accepted_success") - .with_tag("agent", agent_name.clone()) - .with_field("retries", retry_count as u64) - .with_field("value", accepted_success as u64), - ); - reporter.add_custom( - ReportMetric::new("countersigning_session_accepted_duration") - .with_tag("agent", agent_name) - .with_field("value", elapsed.as_secs_f64()), - ); break; } @@ -370,15 +448,54 @@ fn agent_behaviour_participate( Ok(()) } +async fn run_accepted_session( + client: TryCPClient, + request: AcceptedRequest, + session_timeout: Instant, + cell_id: CellId, + app_port: u16, +) -> anyhow::Result { + log::debug!("Another party has initiated a countersigning session."); + + let response = client + .call_zome( + app_port, + cell_id.clone(), + "countersigning", + "accept_two_party", + request.preflight_request, + None, + ) + .await?; + + log::debug!("Accepted the incoming session, proceeding to commit."); + + let my_accept_response: PreflightResponse = response + .decode() + .map_err(|e| anyhow::anyhow!("Decoding failure: {:?}", e))?; + + complete_session( + client.clone(), + app_port, + cell_id.clone(), + request.preflight_response, + my_accept_response, + session_timeout, + ) + .await +} + fn agent_teardown( ctx: &mut AgentContext>, ) -> HookResult { + log::debug!("Downloading logs for agent {}", ctx.agent_name()); if let Err(e) = dump_logs(ctx) { log::warn!("Failed to dump logs: {:?}", e); } // Best effort to remove data and cleanup. // You should comment out this line if you want to examine the result of the scenario run! + log::debug!("Resetting TryCP remote from agent {}", ctx.agent_name()); let _ = reset_trycp_remote(ctx); // Alternatively, you can just shut down the remote conductor instead of shutting it down and removing data. @@ -420,13 +537,16 @@ async fn complete_session( } Err(e) => { if Instant::now() > session_timeout { + // We haven't been able to commit our entry by the end of the countersigning + // session time, so we should abandon the attempt. This is safe because we + // haven't published a signature. return Err(e).context(format!( "Abandoning commit attempt because the session timed out on attempt {}", i )); } else if e .chain() - .any(|e| e.to_string().contains("was not found on the DHT")) + .any(|e| e.to_string().contains("DepMissingFromDht")) { // Skip logging this message, it's what we're expecting to take some time in this retry loop } else if e.chain().any(|e| { @@ -452,25 +572,11 @@ async fn complete_session( match await_countersigning_success( client.clone(), initiate_preflight_response.request.app_entry_hash, - session_timeout, ) .await { Ok(_) => {} Err(e) => { - // Try to force unlock the chain - client - .call_zome( - app_port, - cell_id.clone(), - "countersigning", - "create_anything", - (), - None, - ) - .await - .ok(); - return Err(e).with_context(|| { format!( "Session between [{:?}] did not complete within the session time", @@ -480,7 +586,7 @@ async fn complete_session( } } - log::info!( + log::debug!( "Completed countersigning session with retry count: {}", retry_count ); @@ -491,10 +597,11 @@ async fn complete_session( async fn await_countersigning_success( client: TryCPClient, session_entry_hash: EntryHash, - session_timeout: Instant, ) -> HookResult { loop { - let signal = tokio::time::timeout_at(session_timeout, client.recv_signal()).await?; + // Note that we don't expect the session timeout here. We will wait for Holochain to + // make a decision and not assume that the session is resolved at the end time. + let signal = client.recv_signal().await; match signal { Some(signal) => { match rmp_serde::decode::from_slice::(&signal.data).map_err(|e| { @@ -507,8 +614,18 @@ async fn await_countersigning_success( break; } Signal::System(SystemSignal::SuccessfulCountersigning(_)) => { - // This shouldn't happen because the scenario should only be running one at a time. There's a bug if this log message shows up. - log::warn!("Received a successful countersigning signal for a different session, listening for other signals."); + // This shouldn't happen because only one countersigning session can be active at a time. There's a bug if this log message shows up. + log::error!("Received a successful countersigning signal for a different session, listening for other signals."); + continue; + } + Signal::System(SystemSignal::AbandonedCountersigning(eh)) + if eh == session_entry_hash => + { + return Err(anyhow::anyhow!("Countersigning session was abandoned")); + } + Signal::System(SystemSignal::AbandonedCountersigning(_)) => { + // This shouldn't happen because only one countersigning session can be active at a time. There's a bug if this log message shows up. + log::error!("Received an abandoned countersigning signal for a different session, listening for other signals."); continue; } // Note that this might include other initiations. Since we will ignore the signal here, the initiator will have to wait for the timeout.