diff --git a/conductor-config-ci.yaml b/conductor-config-ci.yaml index bdf2e045..d4d5a908 100644 --- a/conductor-config-ci.yaml +++ b/conductor-config-ci.yaml @@ -1,9 +1,17 @@ +danger_generate_throwaway_device_seed: true dpki: dna_path: ~ - no_dpki: true + network_seed: wind-tunnel-test + allow_throwaway_random_dpki_agent_key: true + no_dpki: false 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..d973c1da 100644 --- a/conductor-config.yaml +++ b/conductor-config.yaml @@ -1,6 +1,17 @@ +danger_generate_throwaway_device_seed: true +dpki: + dna_path: ~ + network_seed: wind-tunnel-test + allow_throwaway_random_dpki_agent_key: true + no_dpki: false 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 b4f95860..a94026a4 100644 --- a/scenarios/two_party_countersigning/src/main.rs +++ b/scenarios/two_party_countersigning/src/main.rs @@ -1,8 +1,6 @@ use anyhow::Context; -use countersigning_integrity::Signals; -use holochain_types::prelude::{ - AgentPubKey, CellId, EntryHash, PreflightRequest, PreflightResponse, -}; +use countersigning_integrity::{AcceptedRequest, Signals}; +use holochain_types::prelude::{AgentPubKey, CellId, EntryHash, PreflightResponse}; use holochain_types::signal::{Signal, SystemSignal}; use rand::seq::SliceRandom; use rand::thread_rng; @@ -21,6 +19,7 @@ pub struct ScenarioValues { initiate_with_peers: Vec, session_attempts: Arc, session_successes: Arc, + session_failures: Arc, } impl UserValuesConstraint for ScenarioValues {} @@ -115,6 +114,7 @@ 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() @@ -193,27 +193,57 @@ fn agent_behaviour_initiate( client.clone(), my_preflight_response, session_timeout, - agent_pub_key, - agent_name.clone(), + agent_pub_key.clone(), cell_id.clone(), app_port, - start, - initiated_success.clone(), - reporter, ) .await { - Ok(_) => { - // Completed successfully + 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::Acquire); + 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 to run initiated session, waiting for it to time out: {:?}", + "Failed countersigning session with agent {:?}: {:?}", + agent_pub_key, e ); - // TODO this can be replaced with listening for the abandoned signal - tokio::time::sleep_until(session_timeout).await; + let initiated_failure = initiated_failure + .fetch_add(1, std::sync::atomic::Ordering::Acquire); + 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()), + ); } } @@ -231,19 +261,14 @@ fn agent_behaviour_initiate( Ok(()) } -#[allow(clippy::too_many_arguments)] async fn run_initiated_session( client: TryCPClient, my_preflight_response: PreflightResponse, session_timeout: Instant, agent_pub_key: AgentPubKey, - agent_name: String, cell_id: CellId, app_port: u16, - start: Instant, - initiated_success: Arc, - reporter: Arc, -) -> anyhow::Result<()> { +) -> 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"))?; @@ -262,8 +287,8 @@ async fn run_initiated_session( let other_response = match signal.clone().into_inner().decode::() { Ok(Signals::Response(response)) - if session_fingerprint(response.request())? - == session_fingerprint(my_preflight_response.request())? => + if response.request().fingerprint()? + == my_preflight_response.request().fingerprint()? => { response } @@ -272,8 +297,8 @@ async fn run_initiated_session( continue; } Err(_) => { - // Must be resilient to unexpected signals, somebody else might try to initiate with us while we're already - // working with another peer. + // 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; } @@ -284,7 +309,7 @@ async fn run_initiated_session( agent_pub_key ); - let retry_count = complete_session( + return complete_session( client.clone(), app_port, cell_id.clone(), @@ -292,39 +317,13 @@ async fn run_initiated_session( 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; + .await; } None => { log::warn!("No signal received, problem with the remote? Will try again."); } } } - - Ok(()) } fn agent_behaviour_participate( @@ -339,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 { @@ -390,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::Acquire); + 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::Acquire); + 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; } @@ -445,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. @@ -495,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| { @@ -527,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", @@ -555,7 +586,7 @@ async fn complete_session( } } - log::info!( + log::debug!( "Completed countersigning session with retry count: {}", retry_count ); @@ -563,22 +594,14 @@ async fn complete_session( Ok(retry_count) } -fn session_fingerprint(preflight_request: &PreflightRequest) -> anyhow::Result> { - let hash = holo_hash::encode::blake2b_256( - &holochain_serialized_bytes::encode(preflight_request) - .context("Failed to serialize preflight request")?, - ); - - Ok(hash) -} - 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| { @@ -591,10 +614,20 @@ 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. + // 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::warn!("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::warn!("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. signal => { log::debug!("Received a signal that is not a successful countersigning signal, listening for other signals. {:?}", signal);