Skip to content

Commit 511e0f9

Browse files
committed
fix: handled additional merge conflicts
1 parent b4d6597 commit 511e0f9

File tree

8 files changed

+27
-28
lines changed

8 files changed

+27
-28
lines changed

core/grpc/src/rpc_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ impl TryFrom<BackupRecoveryRequest> for InternalBackupRecoveryRequest {
10401040
.ok_or_else(|| {
10411041
anyhow::anyhow!("Missing custodian context ID in BackupRestoreRequest")
10421042
})?
1043-
.into(),
1043+
.try_into()?,
10441044
threshold: value.threshold,
10451045
custodian_recovery_outputs: value
10461046
.custodian_recovery_outputs

core/service/src/client/test_tools.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub async fn setup_threshold_no_client<
181181
service_listener,
182182
cur_arc_server,
183183
Arc::new(crate::grpc::MetaStoreStatusServiceImpl::new(
184-
None, None, None, None, None,
184+
None, None, None, None, None, None,
185185
)),
186186
cur_health_service,
187187
server_shutdown_rx.map(drop),
@@ -429,7 +429,7 @@ pub async fn setup_centralized_no_client<
429429
listener,
430430
arc_kms,
431431
Arc::new(crate::grpc::MetaStoreStatusServiceImpl::new(
432-
None, None, None, None, None,
432+
None, None, None, None, None, None,
433433
)),
434434
health_service,
435435
rx.map(drop),

core/service/src/client/tests/threshold/misc_tests.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,7 @@ async fn default_insecure_dkg_backup() {
418418
resp_tasks.spawn(async move {
419419
let req = Empty {};
420420
// send query
421-
cur_client
422-
.custodian_backup_restore(tonic::Request::new(req))
423-
.await
421+
cur_client.backup_restore(tonic::Request::new(req)).await
424422
});
425423
}
426424
while let Some(res) = resp_tasks.join_next().await {
@@ -591,9 +589,7 @@ async fn default_insecure_crs_backup() {
591589
resp_tasks.spawn(async move {
592590
let req = Empty {};
593591
// send query
594-
cur_client
595-
.custodian_backup_restore(tonic::Request::new(req))
596-
.await
592+
cur_client.backup_restore(tonic::Request::new(req)).await
597593
});
598594
}
599595
while let Some(res) = resp_tasks.join_next().await {

core/service/src/engine/centralized/endpoint.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use observability::{
1919
metrics::METRICS,
2020
metrics_names::{
2121
map_tonic_code_to_metric_tag, ERR_INVALID_REQUEST, OP_CRS_GEN_REQUEST, OP_CRS_GEN_RESULT,
22-
OP_CUSTODIAN_CONTEXT_RESTORE, OP_DESTROY_CUSTODIAN_CONTEXT, OP_DESTROY_KMS_CONTEXT,
22+
OP_CUSTODIAN_BACKUP_RECOVERY, OP_DESTROY_CUSTODIAN_CONTEXT, OP_DESTROY_KMS_CONTEXT,
2323
OP_FETCH_PK, OP_INIT, OP_KEYGEN_PREPROC_REQUEST, OP_KEYGEN_PREPROC_RESULT,
2424
OP_KEYGEN_REQUEST, OP_KEYGEN_RESULT, OP_NEW_CUSTODIAN_CONTEXT, OP_NEW_KMS_CONTEXT,
2525
OP_PUBLIC_DECRYPT_REQUEST, OP_PUBLIC_DECRYPT_RESULT, OP_USER_DECRYPT_REQUEST,
@@ -307,8 +307,8 @@ impl<PubS: Storage + Sync + Send + 'static, PrivS: Storage + Sync + Send + 'stat
307307
&self,
308308
_request: Request<BackupRecoveryRequest>,
309309
) -> Result<Response<Empty>, Status> {
310-
METRICS.increment_request_counter(OP_CUSTODIAN_CONTEXT_RESTORE);
311-
METRICS.increment_error_counter(OP_CUSTODIAN_CONTEXT_RESTORE, ERR_INVALID_REQUEST);
310+
METRICS.increment_request_counter(OP_CUSTODIAN_BACKUP_RECOVERY);
311+
METRICS.increment_error_counter(OP_CUSTODIAN_BACKUP_RECOVERY, ERR_INVALID_REQUEST);
312312
Err(Status::unimplemented(
313313
"custodian_backup_recovery is not implemented",
314314
))

core/service/src/engine/context_manager.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ use crate::cryptography::backup_pke::{self, BackupCiphertext};
55
use crate::cryptography::internal_crypto_types::PrivateSigKey;
66
use crate::engine::context::ContextInfo;
77
use crate::engine::threshold::service::ThresholdFheKeys;
8+
use crate::engine::validation::{parse_optional_proto_request_id, RequestIdParsingErr};
89
use crate::vault::Vault;
910
use crate::{
10-
engine::{
11-
base::BaseKmsStruct, threshold::traits::ContextManager, validation::validate_request_id,
12-
},
11+
engine::{base::BaseKmsStruct, threshold::traits::ContextManager},
1312
grpc::metastore_status_service::CustodianMetaStore,
1413
vault::storage::{crypto_material::ThresholdCryptoMaterialStorage, Storage},
1514
};
@@ -147,15 +146,10 @@ where
147146
PrivS: Storage + Sync + Send + 'static,
148147
{
149148
async fn inner_new_custodian_context(&self, context: CustodianContext) -> anyhow::Result<()> {
150-
let context_id: RequestId = match context.context_id {
151-
Some(id) => id.into(),
152-
None => {
153-
return Err(anyhow::anyhow!(
154-
"Context ID is required in NewCustodianContextRequest"
155-
))
156-
}
157-
};
158-
validate_request_id(&context_id)?;
149+
let context_id: RequestId = parse_optional_proto_request_id(
150+
&context.context_id,
151+
RequestIdParsingErr::CustodianContext,
152+
)?;
159153
let backup_vault = match self.crypto_storage.inner.backup_vault {
160154
Some(ref backup_vault) => backup_vault,
161155
None => return Err(anyhow::anyhow!("Backup vault is not configured")),
@@ -177,7 +171,10 @@ where
177171
let custodian_context = InternalCustodianContext {
178172
context_id,
179173
threshold: context.threshold,
180-
previous_context_id: context.previous_context_id.map(Into::into),
174+
previous_context_id: Some(parse_optional_proto_request_id(
175+
&context.previous_context_id,
176+
RequestIdParsingErr::CustodianContext,
177+
)?),
181178
custodian_nodes: node_map,
182179
backup_enc_key: backup_enc_key.clone(),
183180
};

core/service/src/engine/threshold/endpoint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use kms_grpc::kms_service::v1::core_service_endpoint_server::CoreServiceEndpoint
1010
use observability::{
1111
metrics::METRICS,
1212
metrics_names::{
13-
map_tonic_code_to_metric_tag, OP_CRS_GEN_REQUEST, OP_CRS_GEN_RESULT,
13+
map_tonic_code_to_metric_tag, OP_BACKUP_RESTORE, OP_CRS_GEN_REQUEST, OP_CRS_GEN_RESULT,
1414
OP_CUSTODIAN_BACKUP_RECOVERY, OP_DESTROY_CUSTODIAN_CONTEXT, OP_DESTROY_KMS_CONTEXT,
1515
OP_FETCH_PK, OP_INIT, OP_KEYGEN_PREPROC_REQUEST, OP_KEYGEN_PREPROC_RESULT,
1616
OP_KEYGEN_REQUEST, OP_KEYGEN_RESULT, OP_NEW_CUSTODIAN_CONTEXT, OP_NEW_KMS_CONTEXT,
@@ -332,7 +332,7 @@ impl_endpoint! {
332332
request: Request<kms_grpc::kms::v1::BackupRecoveryRequest>,
333333
) -> Result<Response<kms_grpc::kms::v1::Empty>, Status> {
334334
METRICS.increment_request_counter(OP_CUSTODIAN_BACKUP_RECOVERY);
335-
self.backup_operator.custodian_backup_restore(request).await.inspect_err(|err| {
335+
self.backup_operator.custodian_backup_recovery(request).await.inspect_err(|err| {
336336
let tag = map_tonic_code_to_metric_tag(err.code());
337337
let _ = METRICS
338338
.increment_error_counter(OP_CUSTODIAN_BACKUP_RECOVERY, tag);

core/service/src/engine/validation_non_wasm.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ pub(crate) enum RequestIdParsingErr {
6262
KeyGenResponse,
6363
UserDecResponse,
6464
PublicDecResponse,
65+
66+
CustodianContext,
6567
}
6668

6769
impl std::fmt::Display for RequestIdParsingErr {
@@ -100,6 +102,9 @@ impl std::fmt::Display for RequestIdParsingErr {
100102
RequestIdParsingErr::PublicDecResponse => {
101103
write!(f, "Invalid get public decryption result response ID")
102104
}
105+
RequestIdParsingErr::CustodianContext => {
106+
write!(f, "Invalid new custodian context result response ID")
107+
}
103108
}
104109
}
105110
}

observability/src/metrics_names.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ pub const OP_NEW_KMS_CONTEXT: &str = "new_kms_context";
4040
pub const OP_DESTROY_KMS_CONTEXT: &str = "destroy_kms_context";
4141
pub const OP_NEW_CUSTODIAN_CONTEXT: &str = "new_custodian_context";
4242
pub const OP_DESTROY_CUSTODIAN_CONTEXT: &str = "destroy_custodian_context";
43-
pub const OP_CUSTODIAN_CONTEXT_RESTORE: &str = "custodian_context_restore";
43+
pub const OP_CUSTODIAN_BACKUP_RECOVERY: &str = "custodian_backup_recovery";
44+
pub const OP_BACKUP_RESTORE: &str = "backup_restore";
4445

4546
// PK fetch
4647
pub const OP_FETCH_PK: &str = "fetch_pk";

0 commit comments

Comments
 (0)