From 7ef56d6f35f2a6bd38e3bec55dc2f1131da79424 Mon Sep 17 00:00:00 2001 From: Aditya Shastri Date: Wed, 24 Aug 2022 12:27:04 -0700 Subject: [PATCH] Bubble up CertificateRequest to utils.py (#1496) Summary: Pull Request resolved: https://github.com/facebookresearch/fbpcs/pull/1496 `create_and_start_mpc_instance` is the main interface used by mpc games (ex. https://fburl.com/code/cmfkxuzv). in this diff, we add the change to fbpcs and update the changelog Reviewed By: gorel Differential Revision: D38666369 fbshipit-source-id: 42f2703a6372b1662033bfbecbe3dfdf424672cc --- fbpcs/CHANGELOG.md | 2 +- fbpcs/private_computation/service/utils.py | 5 +++++ .../test/service/test_private_computation.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fbpcs/CHANGELOG.md b/fbpcs/CHANGELOG.md index ff037c45f..cadf2b794 100644 --- a/fbpcs/CHANGELOG.md +++ b/fbpcs/CHANGELOG.md @@ -15,7 +15,7 @@ Types of changes ## [Unreleased] ### Added - + - Added an option to specify a CertificateRequest when creating an mpc game instance ### Changed - Mark validate_container_definition as deprecated in PCSContainerService since it is no longer a public method in ContainerService in fbpcp ### Removed diff --git a/fbpcs/private_computation/service/utils.py b/fbpcs/private_computation/service/utils.py index 9d3b4a2b9..96632be4c 100644 --- a/fbpcs/private_computation/service/utils.py +++ b/fbpcs/private_computation/service/utils.py @@ -15,6 +15,8 @@ import warnings from typing import Any, DefaultDict, Dict, List, Optional +from fbpcp.entity.certificate_request import CertificateRequest + from fbpcp.entity.container_instance import ContainerInstance from fbpcp.entity.mpc_instance import MPCInstance, MPCInstanceStatus, MPCParty from fbpcp.service.mpc import MPCService @@ -62,6 +64,7 @@ async def create_and_start_mpc_instance( game_args: Optional[List[Dict[str, Any]]] = None, container_timeout: Optional[int] = None, repository_path: Optional[str] = None, + certificate_request: Optional[CertificateRequest] = None, ) -> MPCInstance: """Creates an MPC instance and runs MPC service with it @@ -76,6 +79,7 @@ async def create_and_start_mpc_instance( game_args: arguments that are passed to game binaries by onedocker container_timeout: optional duration in seconds before cloud containers timeout repository_path: Path from where we can download the required executable. + certificate_request: Arguments to create a TLS certificate/key pair Returns: return: an mpc instance started by mpc service @@ -97,6 +101,7 @@ async def create_and_start_mpc_instance( timeout=container_timeout or DEFAULT_CONTAINER_TIMEOUT_IN_SEC, version=binary_version, env_vars=env_vars, + certificate_request=certificate_request, ) diff --git a/fbpcs/private_computation/test/service/test_private_computation.py b/fbpcs/private_computation/test/service/test_private_computation.py index af8d5d54e..829005845 100644 --- a/fbpcs/private_computation/test/service/test_private_computation.py +++ b/fbpcs/private_computation/test/service/test_private_computation.py @@ -782,6 +782,7 @@ async def test_create_and_start_mpc_instance(self, mock_mpc_svc) -> None: timeout=DEFAULT_CONTAINER_TIMEOUT_IN_SEC, version=binary_version, env_vars=env_vars, + certificate_request=None, ), mock_mpc_svc.start_instance_async.call_args, )