Skip to content

Commit

Permalink
Enable reach-only LLv2 protocol in local and dev configurations.
Browse files Browse the repository at this point in the history
This also removes the flag from the Kingdom internal API server since it is not read there.
  • Loading branch information
SanjayVas committed Sep 12, 2023
1 parent ba974fe commit e1cb27d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/main/k8s/kingdom.cue
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ import ("strings")
_debug_verbose_grpc_server_logging_flag,
_llv2_protocol_config_config,
_ro_llv2_protocol_config_config,
_ro_llv2_enable_flag,
_kingdom_tls_cert_file_flag,
_kingdom_tls_key_file_flag,
_kingdom_cert_collection_file_flag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class InProcessCmmsComponents(
RO_LLV2_PROTOCOL_CONFIG_CONFIG.duchyProtocolConfig,
setOf("aggregator"),
2,
false
)
DuchyInfo.initializeFromConfig(
loadTextProto("duchy_cert_config.textproto", DuchyCertConfig.getDefaultInstance())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import org.wfanet.measurement.internal.kingdom.ProtocolConfig
import picocli.CommandLine

object RoLlv2ProtocolConfig {
var enabled: Boolean by Delegates.notNull()
private set

const val name = "rollv2"
lateinit var protocolConfig: ProtocolConfig.LiquidLegionsV2
private set
Expand All @@ -49,18 +46,14 @@ object RoLlv2ProtocolConfig {
duchyProtocolConfig = configMessage.duchyProtocolConfig
requiredExternalDuchyIds = configMessage.requiredExternalDuchyIdsList.toSet()
minimumNumberOfRequiredDuchies = configMessage.minimumDuchyParticipantCount
enabled = flags.enableRoLlv2Protocol
}

fun setForTest(
protocolConfig: ProtocolConfig.LiquidLegionsV2,
duchyProtocolConfig: DuchyProtocolConfig.LiquidLegionsV2,
requiredExternalDuchyIds: Set<String>,
minimumNumberOfRequiredDuchies: Int,
enabled: Boolean,
) {
RoLlv2ProtocolConfig.enabled = enabled

require(!RoLlv2ProtocolConfig::protocolConfig.isInitialized)
require(!RoLlv2ProtocolConfig::duchyProtocolConfig.isInitialized)
require(!RoLlv2ProtocolConfig::requiredExternalDuchyIds.isInitialized)
Expand All @@ -79,12 +72,4 @@ class RoLlv2ProtocolConfigFlags {
)
lateinit var config: File
private set

@CommandLine.Option(
names = ["--enable-ro-llv2-protocol"],
description = ["Determine whether enable reach-only liquid legions v2 protocol."],
required = false
)
var enableRoLlv2Protocol: Boolean = false
private set
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package org.wfanet.measurement.kingdom.deploy.common.server

import io.grpc.ServerServiceDefinition
import java.io.File
import kotlin.properties.Delegates
import org.wfanet.measurement.api.v2alpha.AkidPrincipalLookup
import org.wfanet.measurement.api.v2alpha.ProtocolConfig.NoiseMechanism
import org.wfanet.measurement.api.v2alpha.withPrincipalsFromX509AuthorityKeyIdentifiers
Expand Down Expand Up @@ -144,7 +145,8 @@ private fun run(
.withApiKeyAuthenticationServerInterceptor(internalApiKeysCoroutineStub),
MeasurementsService(
InternalMeasurementsCoroutineStub(channel),
v2alphaFlags.directNoiseMechanisms
v2alphaFlags.directNoiseMechanisms,
v2alphaFlags.reachOnlyLlV2Enabled
)
.withPrincipalsFromX509AuthorityKeyIdentifiers(principalLookup)
.withApiKeyAuthenticationServerInterceptor(internalApiKeysCoroutineStub),
Expand Down Expand Up @@ -218,6 +220,16 @@ private class V2alphaFlags {
lateinit var spec: CommandLine.Model.CommandSpec // injected by picocli
private set

@set:CommandLine.Option(
names = ["--enable-ro-llv2-protocol"],
description = ["Whether to enable the Reach-Only Liquid Legions v2 protocol"],
negatable = true,
required = false,
defaultValue = "false",
)
var reachOnlyLlV2Enabled by Delegates.notNull<Boolean>()
private set

@CommandLine.Option(
names = ["--direct-noise-mechanism"],
description =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private const val MISSING_RESOURCE_NAME_ERROR = "Resource name is either unspeci

class MeasurementsService(
private val internalMeasurementsStub: MeasurementsCoroutineStub,
private val noiseMechanisms: List<NoiseMechanism>
private val noiseMechanisms: List<NoiseMechanism>,
private val reachOnlyLlV2Enabled: Boolean,
) : MeasurementsCoroutineImplBase() {

override suspend fun getMeasurement(request: GetMeasurementRequest): Measurement {
Expand Down Expand Up @@ -167,7 +168,8 @@ class MeasurementsService(
measurementConsumerCertificateKey,
dataProvidersMap,
parsedMeasurementSpec,
noiseMechanisms.map { it.toInternal() }
noiseMechanisms.map { it.toInternal() },
reachOnlyLlV2Enabled
)
requestId = request.requestId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ fun Measurement.toInternal(
measurementConsumerCertificateKey: MeasurementConsumerCertificateKey,
dataProvidersMap: Map<Long, DataProviderValue>,
measurementSpecProto: MeasurementSpec,
internalNoiseMechanisms: List<InternalProtocolConfig.NoiseMechanism>
internalNoiseMechanisms: List<InternalProtocolConfig.NoiseMechanism>,
reachOnlyLlV2Enabled: Boolean,
): InternalMeasurement {
val publicMeasurement = this

Expand All @@ -927,7 +928,7 @@ fun Measurement.toInternal(
when (measurementSpecProto.measurementTypeCase) {
MeasurementSpec.MeasurementTypeCase.REACH -> {
if (dataProvidersCount > 1) {
if (RoLlv2ProtocolConfig.enabled) {
if (reachOnlyLlV2Enabled) {
protocolConfig = internalProtocolConfig {
externalProtocolConfigId = RoLlv2ProtocolConfig.name
reachOnlyLiquidLegionsV2 = RoLlv2ProtocolConfig.protocolConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2227,8 +2227,7 @@ abstract class MeasurementsServiceTest<T : MeasurementsCoroutineImplBase> {
Population.AGGREGATOR_DUCHY.externalDuchyId,
Population.WORKER1_DUCHY.externalDuchyId
),
2,
true
2
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class MeasurementsServiceTest {
service =
MeasurementsService(
MeasurementsGrpcKt.MeasurementsCoroutineStub(grpcTestServerRule.channel),
NOISE_MECHANISMS
NOISE_MECHANISMS,
reachOnlyLlV2Enabled = true
)
}

Expand Down Expand Up @@ -1765,8 +1766,7 @@ class MeasurementsServiceTest {
RO_LLV2_INTERNAL_PROTOCOL_CONFIG.reachOnlyLiquidLegionsV2,
RO_LLV2_DUCHY_PROTOCOL_CONFIG.reachOnlyLiquidLegionsV2,
setOf("aggregator"),
2,
true
2
)
}

Expand Down

0 comments on commit e1cb27d

Please sign in to comment.